use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class ClusterController method findAllClusters.
@RequestMapping(value = "/clusters/all", method = RequestMethod.GET)
public List<ClusterTbl> findAllClusters(@RequestParam(required = false) String activeDcName) {
if (StringUtil.isEmpty(activeDcName)) {
return valueOrEmptySet(ClusterTbl.class, clusterService.findAllClustersWithOrgInfo());
} else {
DcTbl dc = dcService.findByDcName(activeDcName);
if (dc != null) {
List<ClusterTbl> clusters = clusterService.findClustersWithOrgInfoByActiveDcId(dc.getId());
if (!clusters.isEmpty()) {
List<Long> clusterIds = new ArrayList<Long>(clusters.size());
for (ClusterTbl c : clusters) {
clusterIds.add(c.getId());
}
List<DcClusterTbl> dcClusters = dcClusterService.findByClusterIds(clusterIds);
return joinClusterAndDcCluster(clusters, dcClusters);
}
}
return Collections.emptyList();
}
}
use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class SentinelUpdateControllerTest method testConvert2SentinelTbl.
@Test
public void testConvert2SentinelTbl() throws Exception {
when(dcService.find(anyString())).thenReturn(new DcTbl().setId(1));
SentinelModel sentinelModel = new SentinelModel().setDcName("JQ").setDesc("test").setSentinels(Arrays.asList(new HostPort("127.0.0.1", 6379), new HostPort("127.0.0.1", 6380), new HostPort("127.0.0.1", 6381)));
SetinelTbl setinelTbl = controller.convert2SentinelTbl(sentinelModel);
Assert.assertEquals(1, setinelTbl.getDcId());
Assert.assertEquals("test", setinelTbl.getSetinelDescription());
Assert.assertEquals("127.0.0.1:6379,127.0.0.1:6380,127.0.0.1:6381", setinelTbl.getSetinelAddress());
}
use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class ClusterMetaServiceImplTest method testGetClusterMetaCurrentPrimaryDcNotMigrating.
@Test
public void testGetClusterMetaCurrentPrimaryDcNotMigrating() {
long currentActiveDcId = randomInt();
long clusterId = randomInt();
long destinationDcId = currentActiveDcId + 1;
DcTbl dcTbl = new DcTbl();
ClusterTbl clusterTbl = new ClusterTbl();
clusterTbl.setId(clusterId);
clusterTbl.setActivedcId(currentActiveDcId);
when(migrationService.findLatestUnfinishedMigrationCluster(clusterId)).thenReturn(new MigrationClusterTbl().setDestinationDcId(destinationDcId));
dcTbl.setId(destinationDcId);
for (ClusterStatus clusterStatus : ClusterStatus.values()) {
if (clusterStatus == ClusterStatus.Migrating) {
continue;
}
clusterTbl.setStatus(clusterStatus.toString());
Assert.assertEquals(currentActiveDcId, clusterMetaServiceImpl.getClusterMetaCurrentPrimaryDc(dcTbl, clusterTbl));
}
}
use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class DcServiceTest method testLoad.
@Test
public void testLoad() {
DcTbl target_result = new DcTbl().setId(1).setDcName("NTGXH").setDcDescription("Mocked DC").setDcLastModifiedTime("1234567");
assertEquals(dcService.find("NTGXH").getId(), target_result.getId());
assertEquals(dcService.find("NTGXH").getClusterName(), target_result.getClusterName());
}
use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class DefaultMigrationClusterTest method prepare.
@Before
public void prepare() {
MockitoAnnotations.initMocks(this);
dcA = dcNames[0];
dcB = dcNames[1];
MigrationClusterTbl migrationClusterTbl = migrationService.findMigrationCluster(1L, 1L);
migrationCluster = new DefaultMigrationCluster(executors, scheduled, migrationEvent, migrationClusterTbl, dcService, clusterService, shardService, redisService, migrationService);
Map<Long, DcTbl> dcs = new HashMap<>();
for (DcTbl dc : dcService.findClusterRelatedDc("cluster1")) {
dcs.put(dc.getId(), dc);
}
migrationShard = new DefaultMigrationShard(migrationCluster, migrationService.findMigrationShards(1).get(0), shardService.find(1), dcs, migrationService, migrationCommandBuilder);
migrationCluster.addNewMigrationShard(migrationShard);
}
Aggregations