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