### Question:
ZkLedgerIdGenerator implements LedgerIdGenerator { @Override public void generateLedgerId(final GenericCallback<Long> cb) { generateLedgerIdImpl(cb, zk, ledgerPrefix, zkAcls); } ZkLedgerIdGenerator(ZooKeeper zk,
                               String ledgersPath,
                               String idGenZnodeName,
                               List<ACL> zkAcls); static String createLedgerPrefix(String ledgersPath, String idGenZnodeName); @Override void generateLedgerId(final GenericCallback<Long> cb); static void generateLedgerIdImpl(final GenericCallback<Long> cb, ZooKeeper zk, String ledgerPrefix,
            List<ACL> zkAcls); @Override void close();  }### Answer:
@Test public void testGenerateLedgerId() throws Exception { final int nThread = 2; final int nLedgers = 2000; final CountDownLatch countDownLatch = new CountDownLatch(nThread * nLedgers); final AtomicInteger errCount = new AtomicInteger(0); final ConcurrentLinkedQueue<Long> ledgerIds = new ConcurrentLinkedQueue<Long>(); final GenericCallback<Long> cb = new GenericCallback<Long>() { @Override public void operationComplete(int rc, Long result) { if (Code.OK.intValue() == rc) { ledgerIds.add(result); } else { errCount.incrementAndGet(); } countDownLatch.countDown(); } }; long start = System.currentTimeMillis(); for (int i = 0; i < nThread; i++) { new Thread() { @Override public void run() { for (int j = 0; j < nLedgers; j++) { ledgerIdGenerator.generateLedgerId(cb); } } }.start(); } assertTrue("Wait ledger id generation threads to stop timeout : ", countDownLatch.await(30, TimeUnit.SECONDS)); LOG.info("Number of generated ledger id: {}, time used: {}", ledgerIds.size(), System.currentTimeMillis() - start); assertEquals("Error occur during ledger id generation : ", 0, errCount.get()); Set<Long> ledgers = new HashSet<Long>(); while (!ledgerIds.isEmpty()) { Long ledger = ledgerIds.poll(); assertNotNull("Generated ledger id is null : ", ledger); assertFalse("Ledger id [" + ledger + "] conflict : ", ledgers.contains(ledger)); ledgers.add(ledger); } }