@Test public void testRemoveConnection() { String namespace = "test-namespace-remove"; String address1 = "12.23.34.45:1997"; String address2 = "12.23.34.46:1998"; String address3 = "12.23.34.47:1999"; ConnectionManager.addConnection(namespace, address1); ConnectionManager.addConnection(namespace, address2); ConnectionManager.addConnection(namespace, address3); assertEquals(3, ConnectionManager.getConnectedCount(namespace)); ConnectionManager.removeConnection(namespace, address3); assertEquals(2, ConnectionManager.getConnectedCount(namespace)); assertFalse(ConnectionManager.getOrCreateConnectionGroup(namespace).getConnectionSet().contains( new ConnectionDescriptor().setAddress(address3) )); }
public static void removeConnection(String address) { AssertUtil.assertNotBlank(address, "address should not be empty"); String namespace = NAMESPACE_MAP.get(address); if (namespace != null) { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { return; } group.removeConnection(address); RecordLog.info("[ConnectionManager] Client <{0}> disconnected and removed from namespace <{1}>", address, namespace); } NAMESPACE_MAP.remove(address); }
ConnectionManager { public static void removeConnection(String address) { AssertUtil.assertNotBlank(address, "address should not be empty"); String namespace = NAMESPACE_MAP.get(address); if (namespace != null) { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { return; } group.removeConnection(address); RecordLog.info("[ConnectionManager] Client <{0}> disconnected and removed from namespace <{1}>", address, namespace); } NAMESPACE_MAP.remove(address); } }
ConnectionManager { public static void removeConnection(String address) { AssertUtil.assertNotBlank(address, "address should not be empty"); String namespace = NAMESPACE_MAP.get(address); if (namespace != null) { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { return; } group.removeConnection(address); RecordLog.info("[ConnectionManager] Client <{0}> disconnected and removed from namespace <{1}>", address, namespace); } NAMESPACE_MAP.remove(address); } private  ConnectionManager(); }
ConnectionManager { public static void removeConnection(String address) { AssertUtil.assertNotBlank(address, "address should not be empty"); String namespace = NAMESPACE_MAP.get(address); if (namespace != null) { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { return; } group.removeConnection(address); RecordLog.info("[ConnectionManager] Client <{0}> disconnected and removed from namespace <{1}>", address, namespace); } NAMESPACE_MAP.remove(address); } private  ConnectionManager(); static int getConnectedCount(String namespace); static ConnectionGroup getOrCreateGroup(String namespace); static void removeConnection(String address); static void removeConnection(String namespace, String address); static ConnectionGroup addConnection(String namespace, String address); static ConnectionGroup getOrCreateConnectionGroup(String namespace); static ConnectionGroup getConnectionGroup(String namespace); }
ConnectionManager { public static void removeConnection(String address) { AssertUtil.assertNotBlank(address, "address should not be empty"); String namespace = NAMESPACE_MAP.get(address); if (namespace != null) { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { return; } group.removeConnection(address); RecordLog.info("[ConnectionManager] Client <{0}> disconnected and removed from namespace <{1}>", address, namespace); } NAMESPACE_MAP.remove(address); } private  ConnectionManager(); static int getConnectedCount(String namespace); static ConnectionGroup getOrCreateGroup(String namespace); static void removeConnection(String address); static void removeConnection(String namespace, String address); static ConnectionGroup addConnection(String namespace, String address); static ConnectionGroup getOrCreateConnectionGroup(String namespace); static ConnectionGroup getConnectionGroup(String namespace);  }