use of com.alibaba.nacos.naming.core.v2.client.impl.ConnectionBasedClient in project nacos by alibaba.
the class HealthOperatorV2ImplTest method testUpdateHealthStatusForPersistentInstance.
@Test
public void testUpdateHealthStatusForPersistentInstance() {
try {
ServiceMetadata metadata = new ServiceMetadata();
Map<String, ClusterMetadata> clusterMap = new HashMap<>(2);
ClusterMetadata cluster = Mockito.mock(ClusterMetadata.class);
clusterMap.put("C", cluster);
metadata.setClusters(clusterMap);
Instance instance = new Instance();
instance.setIp("1.1.1.1");
instance.setPort(8080);
Mockito.when(cluster.getHealthyCheckType()).thenReturn(HealthCheckType.NONE.name());
Mockito.when(metadataManager.getServiceMetadata(Mockito.any())).thenReturn(Optional.of(metadata));
ConnectionBasedClient client = Mockito.mock(ConnectionBasedClient.class);
Mockito.when(clientManager.getClient(Mockito.anyString())).thenReturn(client);
InstancePublishInfo instancePublishInfo = new InstancePublishInfo();
instancePublishInfo.setExtendDatum(new HashMap<>(2));
Mockito.when(client.getInstancePublishInfo(Mockito.any())).thenReturn(instancePublishInfo);
healthOperatorV2.updateHealthStatusForPersistentInstance("A", "B", "C", "1.1.1.1", 8080, true);
} catch (NacosException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.alibaba.nacos.naming.core.v2.client.impl.ConnectionBasedClient in project nacos by alibaba.
the class ConnectionBasedClientManager method clientDisconnected.
@Override
public boolean clientDisconnected(String clientId) {
Loggers.SRV_LOG.info("Client connection {} disconnect, remove instances and subscribers", clientId);
ConnectionBasedClient client = clients.remove(clientId);
if (null == client) {
return true;
}
client.release();
NotifyCenter.publishEvent(new ClientEvent.ClientDisconnectEvent(client));
return true;
}
Aggregations