use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard3.
@Test
public void createShard3() throws Exception {
ShardCreateInfo shardCreateInfo1 = new ShardCreateInfo();
shardCreateInfo1.setShardMonitorName(shardName);
shardCreateInfo1.setShardName(shardName + 1);
ShardCreateInfo shardCreateInfo2 = new ShardCreateInfo();
shardCreateInfo2.setShardMonitorName(clusterName + "-" + shardName);
shardCreateInfo2.setShardName(shardName + 2);
metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo1, shardCreateInfo2));
List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
RetMessage result = metaUpdate.createShard(clusterName, shardName, createInfo);
Assert.assertEquals(RetMessage.FAIL_STATE, result.getState());
Assert.assertEquals(String.format("Both %s and %s is assigned as sentinel monitor name", shardName, clusterName + "-" + shardName), result.getMessage());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard1.
@Test
public void createShard1() throws Exception {
ShardCreateInfo shardCreateInfo = new ShardCreateInfo();
shardCreateInfo.setShardMonitorName(shardName);
shardCreateInfo.setShardName(shardName);
metaUpdate.createShards(clusterName, Lists.newArrayList(new ShardCreateInfo()));
List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
metaUpdate.createShard(clusterName, shardName, createInfo);
ShardTbl shardTbl = shardService.find(clusterName, shardName);
List<RedisTbl> keepers = redisService.findKeepersByDcClusterShard(activeDC, clusterName, shardName);
List<RedisTbl> redisTbls = redisService.findRedisesByDcClusterShard(activeDC, clusterName, shardName);
logger.info("{}", shardTbl);
logger.info("{}", keepers);
logger.info("{}", redisTbls);
Assert.assertTrue(listEquals(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), redisTbls.stream().map((redisTbl) -> {
return redisTbl.getRedisIp() + ":" + redisTbl.getRedisPort();
}).collect(Collectors.toList())));
Assert.assertEquals(2, keepers.size());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard4.
@Test
public void createShard4() throws Exception {
ShardCreateInfo shardCreateInfo1 = new ShardCreateInfo();
shardCreateInfo1.setShardMonitorName(shardName);
shardCreateInfo1.setShardName(shardName);
metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo1));
List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
RetMessage result = metaUpdate.createShard(clusterName, shardName, createInfo);
Assert.assertEquals(RetMessage.SUCCESS_STATE, result.getState());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard2.
@Test
public void createShard2() throws Exception {
ShardCreateInfo shardCreateInfo = new ShardCreateInfo();
shardCreateInfo.setShardMonitorName(shardName);
shardCreateInfo.setShardName(shardName);
metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo));
List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
RetMessage result = metaUpdate.createShard(clusterName, shardName, clusterName + "-" + shardName, createInfo);
Assert.assertEquals(RetMessage.FAIL_STATE, result.getState());
Assert.assertEquals(String.format("Post shard monitor name %s diff from previous %s", clusterName + "-" + shardName, shardName), result.getMessage());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard6.
@Test
public void createShard6() throws Exception {
int taskNum = 3;
ThreadPoolExecutor executorService = new ThreadPoolExecutor(taskNum, taskNum, 1L, TimeUnit.SECONDS, new SynchronousQueue<>());
executorService.prestartAllCoreThreads();
executorService.allowsCoreThreadTimeOut();
for (int i = 0; i < taskNum; i++) {
executorService.execute(new Runnable() {
@Override
public void run() {
ShardCreateInfo shardCreateInfo = new ShardCreateInfo();
shardCreateInfo.setShardMonitorName(shardName);
shardCreateInfo.setShardName(shardName);
RetMessage result = metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo));
logger.info("{}", result);
}
});
}
waitConditionUntilTimeOut(() -> executorService.getCompletedTaskCount() == taskNum, 2000);
System.out.println("=========================");
List<ShardTbl> shards = shardService.findAllByClusterName(clusterName);
logger.info("{}", shards);
Assert.assertEquals(1, shards.size());
}
Aggregations