ZKLogSegmentMetadataStore implements LogSegmentMetadataStore, Watcher, Children2Callback { @Override public Future<List<String>> getLogSegmentNames(String logSegmentsPath) { return getLogSegmentNames(logSegmentsPath, null); } ZKLogSegmentMetadataStore(DistributedLogConfiguration conf,
                                     ZooKeeperClient zkc,
                                     OrderedScheduler scheduler); @Override void storeMaxLogSegmentSequenceNumber(Transaction<Object> txn,
                                                 String path,
                                                 Versioned<Long> lssn,
                                                 Transaction.OpListener<Version> listener); @Override void storeMaxTxnId(Transaction<Object> txn,
                              String path,
                              Versioned<Long> transactionId,
                              Transaction.OpListener<Version> listener); @Override Transaction<Object> transaction(); @Override void createLogSegment(Transaction<Object> txn, LogSegmentMetadata segment); @Override void deleteLogSegment(Transaction<Object> txn, LogSegmentMetadata segment); @Override void updateLogSegment(Transaction<Object> txn, LogSegmentMetadata segment); @Override void process(WatchedEvent event); @Override Future<LogSegmentMetadata> getLogSegment(String logSegmentPath); @Override Future<List<String>> getLogSegmentNames(String logSegmentsPath); @Override @SuppressWarnings("unchecked") void processResult(int rc, String path, Object ctx, List<String> children, Stat stat); @Override void registerLogSegmentListener(String logSegmentsPath,
                                           LogSegmentNamesListener listener); @Override void unregisterLogSegmentListener(String logSegmentsPath,
                                             LogSegmentNamesListener listener); @Override void close();  }
@Test(timeout = 60000) public void testGetLogSegmentNames() throws Exception { Transaction<Object> createTxn = lsmStore.transaction(); List<LogSegmentMetadata> createdSegments = Lists.newArrayListWithExpectedSize(10); for (int i = 0; i < 10; i++) { LogSegmentMetadata segment = createLogSegment(i); createdSegments.add(segment); lsmStore.createLogSegment(createTxn, segment); } FutureUtils.result(createTxn.execute()); String rootPath = "/" + runtime.getMethodName(); List<String> children = zkc.get().getChildren(rootPath, false); Collections.sort(children); assertEquals("Should find 10 log segments", 10, children.size()); List<String> logSegmentNames = FutureUtils.result(lsmStore.getLogSegmentNames(rootPath)); Collections.sort(logSegmentNames); assertEquals("Should find 10 log segments", 10, logSegmentNames.size()); assertEquals(children, logSegmentNames); List<Future<LogSegmentMetadata>> getFutures = Lists.newArrayListWithExpectedSize(10); for (int i = 0; i < 10; i++) { getFutures.add(lsmStore.getLogSegment(rootPath + "/" + logSegmentNames.get(i))); } List<LogSegmentMetadata> segments = FutureUtils.result(Future.collect(getFutures)); for (int i = 0; i < 10; i++) { assertEquals(createdSegments.get(i), segments.get(i)); } }