Search in sources :

Example 1 with DcTbl

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();
    }
}
Also used : DcClusterTbl(com.ctrip.xpipe.redis.console.model.DcClusterTbl) ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) DcClusterTbl(com.ctrip.xpipe.redis.console.model.DcClusterTbl)

Example 2 with DcTbl

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());
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) SentinelModel(com.ctrip.xpipe.redis.console.model.SentinelModel) HostPort(com.ctrip.xpipe.endpoint.HostPort) SetinelTbl(com.ctrip.xpipe.redis.console.model.SetinelTbl) Test(org.junit.Test)

Example 3 with DcTbl

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));
    }
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) ClusterStatus(com.ctrip.xpipe.redis.console.migration.status.ClusterStatus) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 4 with DcTbl

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());
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 5 with DcTbl

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);
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) HashMap(java.util.HashMap) DefaultMigrationCluster(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster) DefaultMigrationShard(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard) Before(org.junit.Before)

Aggregations

DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)13 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)5 Test (org.junit.Test)5 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 Before (org.junit.Before)3 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)2 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 ParallelCommandChain (com.ctrip.xpipe.command.ParallelCommandChain)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 DcClusterTbl (com.ctrip.xpipe.redis.console.model.DcClusterTbl)1 OrganizationTbl (com.ctrip.xpipe.redis.console.model.OrganizationTbl)1 SentinelModel (com.ctrip.xpipe.redis.console.model.SentinelModel)1 SetinelTbl (com.ctrip.xpipe.redis.console.model.SetinelTbl)1 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 DcMetaBuilder (com.ctrip.xpipe.redis.console.service.vo.DcMetaBuilder)1