Search in sources :

Example 1 with DistroDataProcessor

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

the class DistroProtocol method onReceive.

/**
 * Receive synced distro data, find processor to process.
 *
 * @param distroData Received data
 * @return true if handle receive data successfully, otherwise false
 */
public boolean onReceive(DistroData distroData) {
    Loggers.DISTRO.info("[DISTRO] Receive distro data type: {}, key: {}", distroData.getType(), distroData.getDistroKey());
    String resourceType = distroData.getDistroKey().getResourceType();
    DistroDataProcessor dataProcessor = distroComponentHolder.findDataProcessor(resourceType);
    if (null == dataProcessor) {
        Loggers.DISTRO.warn("[DISTRO] Can't find data process for received data {}", resourceType);
        return false;
    }
    return dataProcessor.processData(distroData);
}
Also used : DistroDataProcessor(com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor)

Example 2 with DistroDataProcessor

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

the class DistroProtocol method onVerify.

/**
 * Receive verify data, find processor to process.
 *
 * @param distroData    verify data
 * @param sourceAddress source server address, might be get data from source server
 * @return true if verify data successfully, otherwise false
 */
public boolean onVerify(DistroData distroData, String sourceAddress) {
    if (Loggers.DISTRO.isDebugEnabled()) {
        Loggers.DISTRO.debug("[DISTRO] Receive verify data type: {}, key: {}", distroData.getType(), distroData.getDistroKey());
    }
    String resourceType = distroData.getDistroKey().getResourceType();
    DistroDataProcessor dataProcessor = distroComponentHolder.findDataProcessor(resourceType);
    if (null == dataProcessor) {
        Loggers.DISTRO.warn("[DISTRO] Can't find verify data process for received data {}", resourceType);
        return false;
    }
    return dataProcessor.processVerifyData(distroData, sourceAddress);
}
Also used : DistroDataProcessor(com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor)

Example 3 with DistroDataProcessor

use of com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor 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 DistroDataProcessor

use of com.alibaba.nacos.core.distributed.distro.component.DistroDataProcessor 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

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