FederatedZKLogMetadataStore extends NamespaceWatcher implements LogMetadataStore, Watcher, Runnable,
        FutureEventListener<Set<URI>> { @Override public void registerNamespaceListener(NamespaceListener listener) { registerListener(listener); } FederatedZKLogMetadataStore(
            DistributedLogConfiguration conf,
            URI namespace,
            ZooKeeperClient zkc,
            OrderedScheduler scheduler); static void createFederatedNamespace(URI namespace, ZooKeeperClient zkc); @Override void run(); @Override void onSuccess(Set<URI> uris); @Override void onFailure(Throwable cause); @Override void process(WatchedEvent watchedEvent); @Override Future<URI> createLog(final String logName); @Override Future<Optional<URI>> getLogLocation(final String logName); @Override Future<Iterator<String>> getLogs(); @Override void registerNamespaceListener(NamespaceListener listener);  }
@Test(timeout = 60000) public void testNamespaceListener() throws Exception { int numLogs = 3 * maxLogsPerSubnamespace; TestNamespaceListenerWithExpectedSize listener = new TestNamespaceListenerWithExpectedSize(numLogs); metadataStore.registerNamespaceListener(listener); Set<String> expectedLogs = createLogs(numLogs, "test-namespace-listener"); listener.waitForDone(); Set<String> receivedLogs = listener.getResult(); assertEquals(numLogs, receivedLogs.size()); assertTrue(Sets.difference(expectedLogs, receivedLogs).isEmpty()); Random r = new Random(System.currentTimeMillis()); int logId = r.nextInt(numLogs); String logName = "test-namespace-listener" + logId; TestNamespaceListener deleteListener = new TestNamespaceListener(); metadataStore.registerNamespaceListener(deleteListener); deleteLog(logName); deleteListener.waitForDone(); Set<String> logsAfterDeleted = Sets.newTreeSet(Lists.newArrayList(deleteListener.getResult())); assertEquals(numLogs - 1, logsAfterDeleted.size()); expectedLogs.remove(logName); assertTrue(Sets.difference(expectedLogs, receivedLogs).isEmpty()); }