use of com.ctrip.xpipe.redis.console.model.RedisTbl in project x-pipe by ctripcorp.
the class RedisDaoTest method testUpdateBatchMaster.
@Test
public void testUpdateBatchMaster() throws DalException {
for (RedisTbl redisTbl : redises) {
redisTbl.setMaster(!redisTbl.isMaster());
}
redisDao.updateBatchMaster(redises);
for (RedisTbl redisTbl : redises) {
RedisTbl byPK = redisDao.findByPK(redisTbl.getId());
Assert.assertEquals(redisTbl.isMaster(), byPK.isMaster());
}
}
use of com.ctrip.xpipe.redis.console.model.RedisTbl 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.model.RedisTbl in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method createShard.
@Test
public void createShard() throws Exception {
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.model.RedisTbl in project x-pipe by ctripcorp.
the class RedisDaoTest method testUpdateBatchKeeperActive.
@Test
public void testUpdateBatchKeeperActive() throws DalException {
for (RedisTbl redisTbl : redises) {
redisTbl.setKeeperActive(!redisTbl.isKeeperActive());
}
redisDao.updateBatchKeeperActive(redises);
for (RedisTbl redisTbl : redises) {
RedisTbl byPK = redisDao.findByPK(redisTbl.getId());
Assert.assertEquals(redisTbl.isKeeperActive(), byPK.isKeeperActive());
}
}
use of com.ctrip.xpipe.redis.console.model.RedisTbl in project x-pipe by ctripcorp.
the class DefaultRedisMasterCollector method changeMasterRoleInDb.
private void changeMasterRoleInDb(RedisMasterSamplePlan plan, String newMasterIp, Integer newMasterPort) throws ResourceNotFoundException {
logger.info("[changeMasterRoleInDb]{}, {}:{}", plan, newMasterIp, newMasterPort);
List<RedisTbl> allByDcClusterShard = redisService.findAllByDcClusterShard(plan.getDcName(), plan.getClusterId(), plan.getShardId());
boolean changed = false;
for (RedisTbl redisTbl : allByDcClusterShard) {
if (newMasterIp.equalsIgnoreCase(redisTbl.getRedisIp()) && newMasterPort.equals(redisTbl.getRedisPort())) {
if (!redisTbl.isMaster()) {
redisTbl.setMaster(true);
changed = true;
}
} else if (redisTbl.isMaster()) {
redisTbl.setMaster(false);
changed = true;
}
}
logger.info("[changeMasterRoleInDb]{}", changed);
if (changed) {
redisService.updateBatchMaster(allByDcClusterShard);
}
}
Aggregations