@Test public void testUnregisterWithoutFirstRegistering() throws Exception { _registry.unregister(FOO); verify(_nodeFactory, never()).create(eq(FOO_PATH), any(byte[].class)); }
@Override public void unregister(ServiceEndPoint endPoint) { checkState(!_closed); checkNotNull(endPoint); String path = makeEndPointPath(endPoint); PersistentEphemeralNode node = _nodes.remove(path); if (node != null) { closeNode(node); String serviceName = endPoint.getServiceName(); _numRegisteredEndpoints.getUnchecked(serviceName).dec(); } }
ZooKeeperServiceRegistry implements ServiceRegistry { @Override public void unregister(ServiceEndPoint endPoint) { checkState(!_closed); checkNotNull(endPoint); String path = makeEndPointPath(endPoint); PersistentEphemeralNode node = _nodes.remove(path); if (node != null) { closeNode(node); String serviceName = endPoint.getServiceName(); _numRegisteredEndpoints.getUnchecked(serviceName).dec(); } } }
ZooKeeperServiceRegistry implements ServiceRegistry { @Override public void unregister(ServiceEndPoint endPoint) { checkState(!_closed); checkNotNull(endPoint); String path = makeEndPointPath(endPoint); PersistentEphemeralNode node = _nodes.remove(path); if (node != null) { closeNode(node); String serviceName = endPoint.getServiceName(); _numRegisteredEndpoints.getUnchecked(serviceName).dec(); } } ZooKeeperServiceRegistry(CuratorFramework curator, MetricRegistry metrics); @VisibleForTesting  ZooKeeperServiceRegistry(NodeFactory nodeFactory, MetricRegistry metrics); }
ZooKeeperServiceRegistry implements ServiceRegistry { @Override public void unregister(ServiceEndPoint endPoint) { checkState(!_closed); checkNotNull(endPoint); String path = makeEndPointPath(endPoint); PersistentEphemeralNode node = _nodes.remove(path); if (node != null) { closeNode(node); String serviceName = endPoint.getServiceName(); _numRegisteredEndpoints.getUnchecked(serviceName).dec(); } } ZooKeeperServiceRegistry(CuratorFramework curator, MetricRegistry metrics); @VisibleForTesting  ZooKeeperServiceRegistry(NodeFactory nodeFactory, MetricRegistry metrics); @Override void register(ServiceEndPoint endPoint); @Override void unregister(ServiceEndPoint endPoint); @Override synchronized void close(); static String makeServicePath(String serviceName); }
ZooKeeperServiceRegistry implements ServiceRegistry { @Override public void unregister(ServiceEndPoint endPoint) { checkState(!_closed); checkNotNull(endPoint); String path = makeEndPointPath(endPoint); PersistentEphemeralNode node = _nodes.remove(path); if (node != null) { closeNode(node); String serviceName = endPoint.getServiceName(); _numRegisteredEndpoints.getUnchecked(serviceName).dec(); } } ZooKeeperServiceRegistry(CuratorFramework curator, MetricRegistry metrics); @VisibleForTesting  ZooKeeperServiceRegistry(NodeFactory nodeFactory, MetricRegistry metrics); @Override void register(ServiceEndPoint endPoint); @Override void unregister(ServiceEndPoint endPoint); @Override synchronized void close(); static String makeServicePath(String serviceName);  }