Search in sources :

Example 1 with DistroTransportAgent

use of com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent in project nacos by alibaba.

the class AbstractDistroExecuteTask method run.

@Override
public void run() {
    String type = getDistroKey().getResourceType();
    DistroTransportAgent transportAgent = distroComponentHolder.findTransportAgent(type);
    if (null == transportAgent) {
        Loggers.DISTRO.warn("No found transport agent for type [{}]", type);
        return;
    }
    Loggers.DISTRO.info("[DISTRO-START] {}", toString());
    if (transportAgent.supportCallbackTransport()) {
        doExecuteWithCallback(new DistroExecuteCallback());
    } else {
        executeDistroTask();
    }
}
Also used : DistroTransportAgent(com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent)

Example 2 with DistroTransportAgent

use of com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent in project nacos by alibaba.

the class DistroVerifyTimedTask method verifyForDataStorage.

private void verifyForDataStorage(String type, List<Member> targetServer) {
    DistroDataStorage dataStorage = distroComponentHolder.findDataStorage(type);
    if (!dataStorage.isFinishInitial()) {
        Loggers.DISTRO.warn("data storage {} has not finished initial step, do not send verify data", dataStorage.getClass().getSimpleName());
        return;
    }
    List<DistroData> verifyData = dataStorage.getVerifyData();
    if (null == verifyData || verifyData.isEmpty()) {
        return;
    }
    for (Member member : targetServer) {
        DistroTransportAgent agent = distroComponentHolder.findTransportAgent(type);
        if (null == agent) {
            continue;
        }
        executeTaskExecuteEngine.addTask(member.getAddress() + type, new DistroVerifyExecuteTask(agent, verifyData, member.getAddress(), type));
    }
}
Also used : DistroTransportAgent(com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent) DistroDataStorage(com.alibaba.nacos.core.distributed.distro.component.DistroDataStorage) Member(com.alibaba.nacos.core.cluster.Member) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Example 3 with DistroTransportAgent

use of com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent in project nacos by alibaba.

the class DistroClientComponentRegistryTest method testDoRegister.

@Test
public void testDoRegister() {
    distroClientComponentRegistry.doRegister();
    DistroDataStorage dataStorage = componentHolder.findDataStorage(DistroClientDataProcessor.TYPE);
    Assert.assertNotNull(dataStorage);
    DistroDataProcessor dataProcessor = componentHolder.findDataProcessor(DistroClientDataProcessor.TYPE);
    Assert.assertNotNull(dataProcessor);
    DistroFailedTaskHandler failedTaskHandler = componentHolder.findFailedTaskHandler(DistroClientDataProcessor.TYPE);
    Assert.assertNotNull(failedTaskHandler);
    DistroTransportAgent transportAgent = componentHolder.findTransportAgent(DistroClientDataProcessor.TYPE);
    Assert.assertNotNull(transportAgent);
}
Also used : DistroTransportAgent(com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent) DistroDataProcessor(com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor) DistroFailedTaskHandler(com.alibaba.nacos.core.distributed.distro.component.DistroFailedTaskHandler) DistroDataStorage(com.alibaba.nacos.core.distributed.distro.component.DistroDataStorage) Test(org.junit.Test)

Example 4 with DistroTransportAgent

use of com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent in project nacos by alibaba.

the class DistroClientComponentRegistry method doRegister.

/**
 * Register necessary component to distro protocol for v2 {@link com.alibaba.nacos.naming.core.v2.client.Client}
 * implement.
 */
@PostConstruct
public void doRegister() {
    DistroClientDataProcessor dataProcessor = new DistroClientDataProcessor(clientManager, distroProtocol, upgradeJudgement);
    DistroTransportAgent transportAgent = new DistroClientTransportAgent(clusterRpcClientProxy, serverMemberManager);
    DistroClientTaskFailedHandler taskFailedHandler = new DistroClientTaskFailedHandler(taskEngineHolder);
    componentHolder.registerDataStorage(DistroClientDataProcessor.TYPE, dataProcessor);
    componentHolder.registerDataProcessor(dataProcessor);
    componentHolder.registerTransportAgent(DistroClientDataProcessor.TYPE, transportAgent);
    componentHolder.registerFailedTaskHandler(DistroClientDataProcessor.TYPE, taskFailedHandler);
}
Also used : DistroTransportAgent(com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent) PostConstruct(javax.annotation.PostConstruct)

Example 5 with DistroTransportAgent

use of com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent in project nacos by alibaba.

the class DistroLoadDataTask method loadAllDataSnapshotFromRemote.

private boolean loadAllDataSnapshotFromRemote(String resourceType) {
    DistroTransportAgent transportAgent = distroComponentHolder.findTransportAgent(resourceType);
    DistroDataProcessor dataProcessor = distroComponentHolder.findDataProcessor(resourceType);
    if (null == transportAgent || null == dataProcessor) {
        Loggers.DISTRO.warn("[DISTRO-INIT] Can't find component for type {}, transportAgent: {}, dataProcessor: {}", resourceType, transportAgent, dataProcessor);
        return false;
    }
    for (Member each : memberManager.allMembersWithoutSelf()) {
        try {
            Loggers.DISTRO.info("[DISTRO-INIT] load snapshot {} from {}", resourceType, each.getAddress());
            DistroData distroData = transportAgent.getDatumSnapshot(each.getAddress());
            boolean result = dataProcessor.processSnapshot(distroData);
            Loggers.DISTRO.info("[DISTRO-INIT] load snapshot {} from {} result: {}", resourceType, each.getAddress(), result);
            if (result) {
                distroComponentHolder.findDataStorage(resourceType).finishInitial();
                return true;
            }
        } catch (Exception e) {
            Loggers.DISTRO.error("[DISTRO-INIT] load snapshot {} from {} failed.", resourceType, each.getAddress(), e);
        }
    }
    return false;
}
Also used : DistroTransportAgent(com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent) DistroDataProcessor(com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor) Member(com.alibaba.nacos.core.cluster.Member) DistroData(com.alibaba.nacos.core.distributed.distro.entity.DistroData)

Aggregations

DistroTransportAgent (com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent)6 Member (com.alibaba.nacos.core.cluster.Member)2 DistroDataProcessor (com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor)2 DistroDataStorage (com.alibaba.nacos.core.distributed.distro.component.DistroDataStorage)2 DistroData (com.alibaba.nacos.core.distributed.distro.entity.DistroData)2 DistroFailedTaskHandler (com.alibaba.nacos.core.distributed.distro.component.DistroFailedTaskHandler)1 PostConstruct (javax.annotation.PostConstruct)1 Test (org.junit.Test)1