Search in sources :

Example 1 with DoubleWriteDelayTaskEngine

use of com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.delay.DoubleWriteDelayTaskEngine in project nacos by alibaba.

the class UpgradeJudgement method checkForUpgrade.

private boolean checkForUpgrade() {
    if (!useGrpcFeatures.get()) {
        boolean selfCheckResult = selfUpgradeChecker.isReadyToUpgrade(serviceManager, doubleWriteDelayTaskEngine);
        Member self = memberManager.getSelf();
        self.setExtendVal(MemberMetaDataConstants.READY_TO_UPGRADE, selfCheckResult);
        memberManager.updateMember(self);
        if (!selfCheckResult) {
            NamingExecuteTaskDispatcher.getInstance().dispatchAndExecuteTask(AsyncServicesCheckTask.class, new AsyncServicesCheckTask(doubleWriteDelayTaskEngine, this));
        }
    }
    boolean result = true;
    for (Member each : memberManager.allMembers()) {
        Object isReadyToUpgrade = each.getExtendVal(MemberMetaDataConstants.READY_TO_UPGRADE);
        result &= null != isReadyToUpgrade && (boolean) isReadyToUpgrade;
    }
    return result;
}
Also used : AsyncServicesCheckTask(com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.execute.AsyncServicesCheckTask) Member(com.alibaba.nacos.core.cluster.Member)

Example 2 with DoubleWriteDelayTaskEngine

use of com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.delay.DoubleWriteDelayTaskEngine in project nacos by alibaba.

the class DoubleWriteEventListenerTest method testOnEvent.

@Test
public void testOnEvent() {
    Mockito.when(upgradeJudgement.isUseGrpcFeatures()).thenReturn(true);
    Service service = Service.newService("A", "B", "C");
    ServiceEvent.ServiceChangedEvent serviceChangedEvent = new ServiceEvent.ServiceChangedEvent(service);
    doubleWriteEventListener.onEvent(serviceChangedEvent);
    Mockito.verify(doubleWriteDelayTaskEngine).addTask(Mockito.any(), Mockito.any());
}
Also used : ServiceEvent(com.alibaba.nacos.naming.core.v2.event.service.ServiceEvent) Service(com.alibaba.nacos.naming.core.v2.pojo.Service) Test(org.junit.Test)

Example 3 with DoubleWriteDelayTaskEngine

use of com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.delay.DoubleWriteDelayTaskEngine in project nacos by alibaba.

the class DoubleWriteEventListenerTest method testDoubleWriteMetadataToV1.

@Test
public void testDoubleWriteMetadataToV1() {
    Mockito.when(upgradeJudgement.isUseGrpcFeatures()).thenReturn(true);
    Service service = Service.newService("A", "B", "C");
    doubleWriteEventListener.doubleWriteMetadataToV1(service, false);
    Mockito.verify(doubleWriteDelayTaskEngine).addTask(Mockito.any(), Mockito.any());
}
Also used : Service(com.alibaba.nacos.naming.core.v2.pojo.Service) Test(org.junit.Test)

Aggregations

Service (com.alibaba.nacos.naming.core.v2.pojo.Service)2 Test (org.junit.Test)2 Member (com.alibaba.nacos.core.cluster.Member)1 ServiceEvent (com.alibaba.nacos.naming.core.v2.event.service.ServiceEvent)1 AsyncServicesCheckTask (com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.execute.AsyncServicesCheckTask)1