use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.
the class DistroDelayTaskProcessor method process.
@Override
public boolean process(NacosTask task) {
if (!(task instanceof DistroDelayTask)) {
return true;
}
DistroDelayTask distroDelayTask = (DistroDelayTask) task;
DistroKey distroKey = distroDelayTask.getDistroKey();
switch(distroDelayTask.getAction()) {
case DELETE:
DistroSyncDeleteTask syncDeleteTask = new DistroSyncDeleteTask(distroKey, distroComponentHolder);
distroTaskEngineHolder.getExecuteWorkersManager().addTask(distroKey, syncDeleteTask);
return true;
case CHANGE:
case ADD:
DistroSyncChangeTask syncChangeTask = new DistroSyncChangeTask(distroKey, distroComponentHolder);
distroTaskEngineHolder.getExecuteWorkersManager().addTask(distroKey, syncChangeTask);
return true;
default:
return false;
}
}
use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.
the class DistroProtocol method syncToTarget.
/**
* Start to sync to target server.
*
* @param distroKey distro key of sync data
* @param action the action of data operation
* @param targetServer target server
* @param delay delay time for sync
*/
public void syncToTarget(DistroKey distroKey, DataOperation action, String targetServer, long delay) {
DistroKey distroKeyWithTarget = new DistroKey(distroKey.getResourceKey(), distroKey.getResourceType(), targetServer);
DistroDelayTask distroDelayTask = new DistroDelayTask(distroKeyWithTarget, action, delay);
distroTaskEngineHolder.getDelayTaskExecuteEngine().addTask(distroKeyWithTarget, distroDelayTask);
if (Loggers.DISTRO.isDebugEnabled()) {
Loggers.DISTRO.debug("[DISTRO-SCHEDULE] {} to {}", distroKey, targetServer);
}
}
use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.
the class DistroHttpCombinedKeyDelayTask method getDistroKey.
@Override
public DistroKey getDistroKey() {
DistroKey taskKey = super.getDistroKey();
DistroHttpCombinedKey result = new DistroHttpCombinedKey(KeyBuilder.INSTANCE_LIST_KEY_PREFIX, taskKey.getTargetServer());
result.setResourceKey(taskKey.getResourceKey());
result.getActualResourceTypes().addAll(actualResourceKeys);
return result;
}
use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.
the class DistroHttpCombinedKeyTaskFailedHandler method retry.
@Override
public void retry(DistroKey distroKey, DataOperation action) {
DistroHttpCombinedKey combinedKey = (DistroHttpCombinedKey) distroKey;
for (String each : combinedKey.getActualResourceTypes()) {
DistroKey newKey = new DistroKey(each, KeyBuilder.INSTANCE_LIST_KEY_PREFIX, distroKey.getTargetServer());
DistroDelayTask newTask = new DistroDelayTask(newKey, action, DistroConfig.getInstance().getSyncRetryDelayMillis());
distroTaskEngineHolder.getDelayTaskExecuteEngine().addTask(newKey, newTask);
}
}
use of com.alibaba.nacos.core.distributed.distro.entity.DistroKey in project nacos by alibaba.
the class DistroHttpDelayTaskProcessor method process.
@Override
public boolean process(NacosTask task) {
DistroDelayTask distroDelayTask = (DistroDelayTask) task;
DistroKey distroKey = distroDelayTask.getDistroKey();
DistroHttpCombinedKeyExecuteTask executeTask = new DistroHttpCombinedKeyExecuteTask(globalConfig, distroTaskEngineHolder.getDelayTaskExecuteEngine(), distroKey, distroDelayTask.getAction());
distroTaskEngineHolder.getExecuteWorkersManager().addTask(distroKey, executeTask);
return true;
}
Aggregations