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