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);
}
}
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);
}
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);
}
}
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;
}
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));
}
Aggregations