Search in sources :

Example 1 with ClientManager

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);
}
Also used : IpPortBasedClient(com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient) Before(org.junit.Before)

Example 2 with ClientManager

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));
    }
}
Also used : PushDataWrapper(com.alibaba.nacos.naming.push.v2.PushDataWrapper) Subscriber(com.alibaba.nacos.naming.pojo.Subscriber) ClientManager(com.alibaba.nacos.naming.core.v2.client.manager.ClientManager) Client(com.alibaba.nacos.naming.core.v2.client.Client) NoRequiredRetryException(com.alibaba.nacos.naming.push.v2.NoRequiredRetryException)

Example 3 with ClientManager

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);
}
Also used : Subscriber(com.alibaba.nacos.naming.pojo.Subscriber) Service(com.alibaba.nacos.naming.core.v2.pojo.Service) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Aggregations

Subscriber (com.alibaba.nacos.naming.pojo.Subscriber)2 Before (org.junit.Before)2 Client (com.alibaba.nacos.naming.core.v2.client.Client)1 IpPortBasedClient (com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient)1 ClientManager (com.alibaba.nacos.naming.core.v2.client.manager.ClientManager)1 Service (com.alibaba.nacos.naming.core.v2.pojo.Service)1 NoRequiredRetryException (com.alibaba.nacos.naming.push.v2.NoRequiredRetryException)1 PushDataWrapper (com.alibaba.nacos.naming.push.v2.PushDataWrapper)1 LinkedList (java.util.LinkedList)1