Search in sources :

Example 1 with DistroDelayTask

use of com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask 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);
    }
}
Also used : DistroDelayTask(com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey)

Example 2 with DistroDelayTask

use of com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask in project nacos by alibaba.

the class DistroClientTaskFailedHandler method retry.

@Override
public void retry(DistroKey distroKey, DataOperation action) {
    DistroDelayTask retryTask = new DistroDelayTask(distroKey, action, DistroConfig.getInstance().getSyncRetryDelayMillis());
    distroTaskEngineHolder.getDelayTaskExecuteEngine().addTask(distroKey, retryTask);
}
Also used : DistroDelayTask(com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask)

Example 3 with DistroDelayTask

use of com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask 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);
    }
}
Also used : DistroDelayTask(com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey)

Example 4 with DistroDelayTask

use of com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask 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;
}
Also used : DistroDelayTask(com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask) DistroKey(com.alibaba.nacos.core.distributed.distro.entity.DistroKey)

Aggregations

DistroDelayTask (com.alibaba.nacos.core.distributed.distro.task.delay.DistroDelayTask)4 DistroKey (com.alibaba.nacos.core.distributed.distro.entity.DistroKey)3