Search in sources :

Example 11 with DistroKey

use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.

the class DistroHttpCombinedKeyExecuteTask method run.

@Override
public void run() {
    try {
        DistroKey newKey = new DistroKey(DistroHttpCombinedKey.getSequenceKey(), DistroHttpCombinedKeyDelayTask.class.getSimpleName(), singleDistroKey.getTargetServer());
        DistroHttpCombinedKeyDelayTask combinedTask = new DistroHttpCombinedKeyDelayTask(newKey, taskAction, DistroConfig.getInstance().getSyncDelayMillis(), globalConfig.getBatchSyncKeyCount());
        combinedTask.getActualResourceKeys().add(singleDistroKey.getResourceKey());
        distroDelayTaskExecuteEngine.addTask(newKey, combinedTask);
    } catch (Exception e) {
        Loggers.DISTRO.error("[DISTRO-FAILED] Combined key for http failed. ", e);
    }
}
Also used : DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey)

Example 12 with DistroKey

use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.

the class DistroClientDataProcessor method syncToVerifyFailedServer.

private void syncToVerifyFailedServer(ClientEvent.ClientVerifyFailedEvent event) {
    Client client = clientManager.getClient(event.getClientId());
    if (null == client || !client.isEphemeral() || !clientManager.isResponsibleClient(client)) {
        return;
    }
    DistroKey distroKey = new DistroKey(client.getClientId(), TYPE);
    // Verify failed data should be sync directly.
    distroProtocol.syncToTarget(distroKey, DataOperation.ADD, event.getTargetServer(), 0L);
}
Also used : Client(com.alibaba.nacos.naming.core.v2.client.Client) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey)

Example 13 with DistroKey

use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.

the class DistroClientDataProcessor method syncToAllServer.

private void syncToAllServer(ClientEvent event) {
    Client client = event.getClient();
    // Only ephemeral data sync by Distro, persist client should sync by raft.
    if (null == client || !client.isEphemeral() || !clientManager.isResponsibleClient(client)) {
        return;
    }
    if (event instanceof ClientEvent.ClientDisconnectEvent) {
        DistroKey distroKey = new DistroKey(client.getClientId(), TYPE);
        distroProtocol.sync(distroKey, DataOperation.DELETE);
    } else if (event instanceof ClientEvent.ClientChangedEvent) {
        DistroKey distroKey = new DistroKey(client.getClientId(), TYPE);
        distroProtocol.sync(distroKey, DataOperation.CHANGE);
    }
}
Also used : Client(com.alibaba.nacos.naming.core.v2.client.Client) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey) ClientEvent(com.alibaba.nacos.naming.core.v2.event.client.ClientEvent)

Example 14 with DistroKey

use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.

the class DistroDataRequestHandler method handleQueryData.

private DistroDataResponse handleQueryData(DistroData distroData) {
    DistroDataResponse result = new DistroDataResponse();
    DistroKey distroKey = distroData.getDistroKey();
    DistroData queryData = distroProtocol.onQuery(distroKey);
    result.setDistroData(queryData);
    return result;
}
Also used : DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey) DistroDataResponse(com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Example 15 with DistroKey

use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.

the class DistroConsistencyServiceImplTest method testPutWithListener.

@Test
public void testPutWithListener() throws NacosException {
    String key = KeyBuilder.buildInstanceListKey(TEST_NAMESPACE, TEST_SERVICE_NAME, true);
    distroConsistencyService.listen(key, recordListener);
    distroConsistencyService.put(key, instances);
    verify(distroProtocol).sync(new DistroKey(key, KeyBuilder.INSTANCE_LIST_KEY_PREFIX), DataOperation.CHANGE, 1000L);
    verify(notifier).addTask(key, DataOperation.CHANGE);
    verify(dataStore).put(eq(key), any(Datum.class));
}
Also used : Datum(com.alibaba.nacos.naming.consistency.Datum) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey) Test(org.junit.Test) BaseTest(com.alibaba.nacos.naming.BaseTest)

Aggregations

DistroKey (com.alibaba.nacos.core.distributed.distro.entity.DistroKey)16 DistroData (com.alibaba.nacos.core.distributed.distro.entity.DistroData)5 Datum (com.alibaba.nacos.naming.consistency.Datum)4 Client (com.alibaba.nacos.naming.core.v2.client.Client)4 DistroDelayTask (com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask)3 BaseTest (com.alibaba.nacos.naming.BaseTest)2 Serializer (com.alibaba.nacos.naming.cluster.transport.Serializer)2 UpgradeJudgement (com.alibaba.nacos.naming.core.v2.upgrade.UpgradeJudgement)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 DistroSyncChangeTask (com.alibaba.nacos.core.distributed.distro.task.execute.DistroSyncChangeTask)1 DistroSyncDeleteTask (com.alibaba.nacos.core.distributed.distro.task.execute.DistroSyncDeleteTask)1 DistroDataResponse (com.alibaba.nacos.naming.cluster.remote.response.DistroDataResponse)1 ClientSyncData (com.alibaba.nacos.naming.core.v2.client.ClientSyncData)1 ClientSyncDatumSnapshot (com.alibaba.nacos.naming.core.v2.client.ClientSyncDatumSnapshot)1 ClientEvent (com.alibaba.nacos.naming.core.v2.event.client.ClientEvent)1 HashMap (java.util.HashMap)1