Search in sources :

Example 11 with ClusterTbl

use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.

the class DefaultMigrationCluster method updateActiveDcIdToDestDcId.

@Override
public void updateActiveDcIdToDestDcId() {
    long destDcId = destDcId();
    ClusterTbl cluster = getCurrentCluster();
    cluster.setActivedcId(destDcId);
    clusterService.updateActivedcId(clusterId(), destDcId);
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)

Example 12 with ClusterTbl

use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.

the class DefaultMigrationClusterTest method testRollBackFailOnPartialSuccess.

@Test
@DirtiesContext
public void testRollBackFailOnPartialSuccess() {
    mockSuccessCheckCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcB);
    mockSuccessPrevPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
    mockFailNewPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, new Throwable("mocked new fail"));
    mockSuccessOtherDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcA);
    mockFailRollBackCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
    migrationCluster.process();
    sleep(1000);
    DcMeta DcAMeta = dcMetaService.getDcMeta(dcA);
    DcMeta DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcA, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcB, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.PartialSuccess, migrationCluster.getStatus());
    migrationCluster.rollback();
    sleep(1000);
    DcAMeta = dcMetaService.getDcMeta(dcA);
    DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcA, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcA, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.RollBack, migrationCluster.getStatus());
    ClusterTbl currentCluster = clusterService.find(1);
    Assert.assertEquals(ClusterStatus.Rollback.toString(), currentCluster.getStatus());
    Assert.assertEquals(1, currentCluster.getActivedcId());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) Test(org.junit.Test) AbstractMigrationTest(com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 13 with ClusterTbl

use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.

the class DefaultMigrationClusterTest method testRollBackOnPartialSuccess.

@Test
@DirtiesContext
public void testRollBackOnPartialSuccess() {
    mockSuccessCheckCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcB);
    mockSuccessPrevPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
    mockFailNewPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, new Throwable("mocked new fail"));
    mockSuccessOtherDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcA);
    mockSuccessRollBackCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
    migrationCluster.process();
    sleep(1000);
    DcMeta DcAMeta = dcMetaService.getDcMeta(dcA);
    DcMeta DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcA, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcB, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.PartialSuccess, migrationCluster.getStatus());
    migrationCluster.rollback();
    sleep(1000);
    DcAMeta = dcMetaService.getDcMeta(dcA);
    DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcA, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcA, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.Aborted, migrationCluster.getStatus());
    ClusterTbl currentCluster = clusterService.find(1);
    Assert.assertEquals(ClusterStatus.Normal.toString(), currentCluster.getStatus());
    Assert.assertEquals(1, currentCluster.getActivedcId());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) Test(org.junit.Test) AbstractMigrationTest(com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 14 with ClusterTbl

use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.

the class DefaultMigrationClusterTest method testForcePublishOnPartialSuccess.

@Test
@DirtiesContext
public void testForcePublishOnPartialSuccess() {
    mockSuccessCheckCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcB);
    mockSuccessPrevPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
    mockFailNewPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, new Throwable("mocked new fail"));
    mockSuccessOtherDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcA);
    migrationCluster.process();
    sleep(1000);
    DcMeta DcAMeta = dcMetaService.getDcMeta(dcA);
    DcMeta DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcA, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcB, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.PartialSuccess, migrationCluster.getStatus());
    migrationCluster.forcePublish();
    DcAMeta = dcMetaService.getDcMeta(dcA);
    DcBMeta = dcMetaService.getDcMeta(dcB);
    Assert.assertEquals(dcB, DcAMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(dcB, DcBMeta.findCluster("cluster1").getActiveDc());
    Assert.assertEquals(MigrationStatus.Success, migrationCluster.getStatus());
    ClusterTbl currentCluster = clusterService.find(1);
    Assert.assertEquals("Normal", currentCluster.getStatus());
    Assert.assertEquals(2, currentCluster.getActivedcId());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) Test(org.junit.Test) AbstractMigrationTest(com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 15 with ClusterTbl

use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.

the class MetaUpdateTest method testUpdateCLusterWithNoOrgIDFound.

@Test
public void testUpdateCLusterWithNoOrgIDFound() throws Exception {
    String CLUSTER_NAME = "cluster-name";
    long ORG_ID = 99L;
    String EXPECTED_MESSAGE = String.format("Organization Id: %d, could not be found", ORG_ID);
    ClusterTbl clusterTbl = new ClusterTbl().setClusterName(CLUSTER_NAME).setClusterDescription("").setActivedcId(1).setIsXpipeInterested(true).setStatus("normal").setClusterLastModifiedTime(DateTimeUtils.currentTimeAsString());
    clusterDao.createCluster(clusterTbl);
    ClusterCreateInfo clusterInfo = new ClusterCreateInfo();
    clusterInfo.setClusterName(CLUSTER_NAME);
    clusterInfo.setClusterAdminEmails("test@ctrip.com");
    clusterInfo.setOrganizationId(ORG_ID);
    RetMessage retMessage = clusterController.updateCluster(clusterInfo);
    logger.info("{}", retMessage.getMessage());
    RetMessage retMessage1 = clusterController.updateCluster(clusterInfo);
    Assert.assertEquals(RetMessage.FAIL_STATE, retMessage1.getState());
    Assert.assertEquals(EXPECTED_MESSAGE, retMessage1.getMessage());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Aggregations

ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)34 Test (org.junit.Test)28 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)20 DirtiesContext (org.springframework.test.annotation.DirtiesContext)19 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)10 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)10 AbstractMigrationTest (com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest)6 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)5 DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)3 ClusterCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo)3 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)1 XPipeConsoleConstant (com.ctrip.xpipe.redis.console.constant.XPipeConsoleConstant)1 KeeperContainerCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.KeeperContainerCreateInfo)1 ClusterDao (com.ctrip.xpipe.redis.console.dao.ClusterDao)1 ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)1 RetryCondition (com.ctrip.xpipe.redis.console.job.retry.RetryCondition)1 RetryNTimesOnCondition (com.ctrip.xpipe.redis.console.job.retry.RetryNTimesOnCondition)1 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1