Search in sources :

Example 1 with PushDataWrapper

use of com.alibaba.nacos.naming.push.v2.PushDataWrapper in project nacos by alibaba.

the class PushExecutorDelegateTest method setUp.

@Before
public void setUp() throws Exception {
    serviceMetadata = new ServiceMetadata();
    pushdata = new PushDataWrapper(serviceMetadata, new ServiceInfo("G@@S"));
    delegate = new PushExecutorDelegate(pushExecutorRpc, pushExecutorUdp);
}
Also used : PushDataWrapper(com.alibaba.nacos.naming.push.v2.PushDataWrapper) ServiceInfo(com.alibaba.nacos.api.naming.pojo.ServiceInfo) ServiceMetadata(com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata) Before(org.junit.Before)

Example 2 with PushDataWrapper

use of com.alibaba.nacos.naming.push.v2.PushDataWrapper in project nacos by alibaba.

the class PushExecuteTask method generatePushData.

private PushDataWrapper generatePushData() {
    ServiceInfo serviceInfo = delayTaskEngine.getServiceStorage().getPushData(service);
    ServiceMetadata serviceMetadata = delayTaskEngine.getMetadataManager().getServiceMetadata(service).orElse(null);
    return new PushDataWrapper(serviceMetadata, serviceInfo);
}
Also used : ServiceInfo(com.alibaba.nacos.api.naming.pojo.ServiceInfo) PushDataWrapper(com.alibaba.nacos.naming.push.v2.PushDataWrapper) ServiceMetadata(com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata)

Example 3 with PushDataWrapper

use of com.alibaba.nacos.naming.push.v2.PushDataWrapper 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 4 with PushDataWrapper

use of com.alibaba.nacos.naming.push.v2.PushDataWrapper in project nacos by alibaba.

the class PushExecutorRpcImplTest method setUp.

@Before
public void setUp() throws Exception {
    serviceMetadata = new ServiceMetadata();
    pushData = new PushDataWrapper(serviceMetadata, new ServiceInfo("G@@S"));
    pushExecutor = new PushExecutorRpcImpl(pushService);
    doAnswer(new CallbackAnswer()).when(pushService).pushWithCallback(eq(rpcClientId), any(NotifySubscriberRequest.class), eq(pushCallBack), eq(GlobalExecutor.getCallbackExecutor()));
}
Also used : PushDataWrapper(com.alibaba.nacos.naming.push.v2.PushDataWrapper) ServiceInfo(com.alibaba.nacos.api.naming.pojo.ServiceInfo) NotifySubscriberRequest(com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest) ServiceMetadata(com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata) Before(org.junit.Before)

Example 5 with PushDataWrapper

use of com.alibaba.nacos.naming.push.v2.PushDataWrapper in project nacos by alibaba.

the class PushExecutorUdpImplTest method setUp.

@Before
public void setUp() throws Exception {
    serviceMetadata = new ServiceMetadata();
    pushData = new PushDataWrapper(serviceMetadata, new ServiceInfo("G@@S"));
    pushExecutor = new PushExecutorUdpImpl(pushService);
    doAnswer(new CallbackAnswer()).when(pushService).pushDataWithCallback(eq(subscriber), any(ServiceInfo.class), eq(pushCallBack));
}
Also used : PushDataWrapper(com.alibaba.nacos.naming.push.v2.PushDataWrapper) ServiceInfo(com.alibaba.nacos.api.naming.pojo.ServiceInfo) ServiceMetadata(com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata) Before(org.junit.Before)

Aggregations

PushDataWrapper (com.alibaba.nacos.naming.push.v2.PushDataWrapper)5 ServiceInfo (com.alibaba.nacos.api.naming.pojo.ServiceInfo)4 ServiceMetadata (com.alibaba.nacos.naming.core.v2.metadata.ServiceMetadata)4 Before (org.junit.Before)3 NotifySubscriberRequest (com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest)1 Client (com.alibaba.nacos.naming.core.v2.client.Client)1 ClientManager (com.alibaba.nacos.naming.core.v2.client.manager.ClientManager)1 Subscriber (com.alibaba.nacos.naming.pojo.Subscriber)1 NoRequiredRetryException (com.alibaba.nacos.naming.push.v2.NoRequiredRetryException)1