@Test public void testAdd() { DirectoryAgentInfoCache cache = new DirectoryAgentInfoCache(); Long bootTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()); DirectoryAgentInfo info = DirectoryAgentInfo.from("1.2.3.4", Scopes.from("test"), Attributes.from("(a=1)"), "en", bootTime.intValue()); DirectoryAgentInfo existing = cache.add(info); assert existing == null; List<DirectoryAgentInfo> infos = cache.match(null, null); assert infos.size() == 1; DirectoryAgentInfo testInfo = infos.get(0); assert testInfo == info; }
public DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent) { lock.lock(); try { return cache.put(directoryAgent.getKey(), directoryAgent); } finally { lock.unlock(); } }
DirectoryAgentInfoCache { public DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent) { lock.lock(); try { return cache.put(directoryAgent.getKey(), directoryAgent); } finally { lock.unlock(); } } }
DirectoryAgentInfoCache { public DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent) { lock.lock(); try { return cache.put(directoryAgent.getKey(), directoryAgent); } finally { lock.unlock(); } }  }
DirectoryAgentInfoCache { public DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent) { lock.lock(); try { return cache.put(directoryAgent.getKey(), directoryAgent); } finally { lock.unlock(); } }  DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent); void addAll(List<DirectoryAgentInfo> directoryAgents); DirectoryAgentInfo remove(DirectoryAgentInfo.Key key); void removeAll(); List<DirectoryAgentInfo> match(Scopes scopes, Filter filter); void addDirectoryAgentListener(DirectoryAgentListener listener); void removeDirectoryAgentListener(DirectoryAgentListener listener); void handle(DirectoryAgentInfo directoryAgent); }
DirectoryAgentInfoCache { public DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent) { lock.lock(); try { return cache.put(directoryAgent.getKey(), directoryAgent); } finally { lock.unlock(); } }  DirectoryAgentInfo add(DirectoryAgentInfo directoryAgent); void addAll(List<DirectoryAgentInfo> directoryAgents); DirectoryAgentInfo remove(DirectoryAgentInfo.Key key); void removeAll(); List<DirectoryAgentInfo> match(Scopes scopes, Filter filter); void addDirectoryAgentListener(DirectoryAgentListener listener); void removeDirectoryAgentListener(DirectoryAgentListener listener); void handle(DirectoryAgentInfo directoryAgent);  }