use of com.alibaba.nacos.naming.core.v2.client.manager.ClientManager in project nacos by alibaba.
the class EphemeralClientOperationServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
when(instance.getIp()).thenReturn(ip);
when(instance.getPort()).thenReturn(port);
when(service.getNamespace()).thenReturn("public");
when(service.getGroupedServiceName()).thenReturn("G@@S");
when(service.isEphemeral()).thenReturn(true);
ephemeralClientOperationServiceImpl = new EphemeralClientOperationServiceImpl(clientManager);
client = new IpPortBasedClient(clientId, true);
when(clientManager.getClient(clientId)).thenReturn(client);
}
use of com.alibaba.nacos.naming.core.v2.client.manager.ClientManager in project nacos by alibaba.
the class PushExecuteTask method run.
@Override
public void run() {
try {
PushDataWrapper wrapper = generatePushData();
ClientManager clientManager = delayTaskEngine.getClientManager();
for (String each : getTargetClientIds()) {
Client client = clientManager.getClient(each);
if (null == client) {
// means this client has disconnect
continue;
}
Subscriber subscriber = clientManager.getClient(each).getSubscriber(service);
delayTaskEngine.getPushExecutor().doPushWithCallback(each, subscriber, wrapper, new NamingPushCallback(each, subscriber, wrapper.getOriginalData(), delayTask.isPushToAll()));
}
} catch (Exception e) {
Loggers.PUSH.error("Push task for service" + service.getGroupedServiceName() + " execute failed ", e);
delayTaskEngine.addTask(service, new PushDelayTask(service, 1000L));
}
}
use of com.alibaba.nacos.naming.core.v2.client.manager.ClientManager in project nacos by alibaba.
the class NamingSubscriberServiceV2ImplTest method setUp.
@Before
public void setUp() throws Exception {
subscriberService = new NamingSubscriberServiceV2Impl(clientManager, indexesManager, null, null, null, upgradeJudgement, switchDomain);
ReflectionTestUtils.setField(subscriberService, "delayTaskEngine", delayTaskEngine);
when(indexesManager.getAllClientsSubscribeService(service)).thenReturn(Collections.singletonList(testClientId));
when(indexesManager.getAllClientsSubscribeService(service1)).thenReturn(Collections.singletonList(testClientId));
Collection<Service> services = new LinkedList<>();
services.add(service);
services.add(service1);
when(indexesManager.getSubscribedService()).thenReturn(services);
when(clientManager.getClient(testClientId)).thenReturn(client);
when(client.getSubscriber(service)).thenReturn(new Subscriber("1.1.1.1:1111", "Test", "unknown", "1.1.1.1", "N", service.getGroupedServiceName(), 0));
when(client.getSubscriber(service1)).thenReturn(new Subscriber("1.1.1.1:1111", "Test", "unknown", "1.1.1.1", "N", service1.getGroupedServiceName(), 0));
when(upgradeJudgement.isUseGrpcFeatures()).thenReturn(true);
}
Aggregations