use of com.ctrip.xpipe.redis.console.model.DcClusterShardTbl in project x-pipe by ctripcorp.
the class DcClusterShardDao method deleteDcClusterShardsBatch.
@DalTransaction
public void deleteDcClusterShardsBatch(List<DcClusterShardTbl> dcClusterShards) throws DalException {
if (null == dcClusterShards || dcClusterShards.isEmpty()) {
logger.warn("[deleteDcClusterShardsBatch] Empty list: {}", dcClusterShards);
return;
}
List<RedisTbl> redises = new LinkedList<RedisTbl>();
for (final DcClusterShardTbl dcClusterShard : dcClusterShards) {
List<RedisTbl> relatedRedises = redisDao.findAllByDcClusterShard(dcClusterShard.getDcClusterShardId());
if (null != relatedRedises && !relatedRedises.isEmpty()) {
for (RedisTbl redis : relatedRedises) {
redis.setRunId(generateDeletedName(redis.getRunId()));
}
redises.addAll(relatedRedises);
}
}
redisDao.deleteRedisesBatch(redises);
queryHandler.handleBatchDelete(new DalQuery<int[]>() {
@Override
public int[] doQuery() throws DalException {
return dcClusterShardTblDao.deleteDcClusterShardsBatch(dcClusterShards.toArray(new DcClusterShardTbl[dcClusterShards.size()]), DcClusterShardTblEntity.UPDATESET_FULL);
}
}, true);
}
use of com.ctrip.xpipe.redis.console.model.DcClusterShardTbl in project x-pipe by ctripcorp.
the class DcClusterShardServiceImplTest method testUpdateDcClusterShard.
@Test
public void testUpdateDcClusterShard() throws Exception {
DcClusterShardTbl proto = service.find(dcNames[0], clusterName, shardNames[0]);
long sentinelId = proto.getSetinelId();
long expected = sentinelId + 1;
proto.setSetinelId(expected);
service.updateDcClusterShard(proto);
Assert.assertEquals(expected, service.find(dcNames[0], clusterName, shardNames[0]).getSetinelId());
}
use of com.ctrip.xpipe.redis.console.model.DcClusterShardTbl in project x-pipe by ctripcorp.
the class DcClusterShardServiceImplTest method testFindAllByDcId.
@Test
public void testFindAllByDcId() throws Exception {
List<DcClusterShardTbl> dcClusterShards = service.findAllByDcId(1L);
for (DcClusterShardTbl dcClusterShard : dcClusterShards) {
Assert.assertEquals(1L, dcClusterShard.getDcClusterInfo().getDcId());
Assert.assertNotEquals(0, dcClusterShard.getShardId());
Assert.assertNotNull(dcClusterShard.getRedisInfo());
}
logger.info("{}", dcClusterShards);
}
use of com.ctrip.xpipe.redis.console.model.DcClusterShardTbl in project x-pipe by ctripcorp.
the class DcMetaBuilderTest method getOrCreateShardMeta.
@Test
public void getOrCreateShardMeta() throws Exception {
DcClusterShardTbl dcClusterShard = dcClusterShards.get(0);
builder.getOrCreateClusterMeta(dcClusterShards.get(0).getClusterInfo());
ClusterMeta clusterMeta = dcMeta.getClusters().get(dcClusterShard.getClusterInfo().getClusterName());
logger.info("{}", dcClusterShard.getShardInfo());
builder.getOrCreateShardMeta(clusterMeta.getId(), dcClusterShard.getShardInfo(), dcClusterShard.getSetinelId());
String clusterId = dcClusterShard.getClusterInfo().getClusterName(), shardId = dcClusterShard.getShardInfo().getShardName();
ShardMeta shardMeta = dcMeta.findCluster(clusterId).findShard(shardId);
Assert.assertNotNull(shardMeta);
logger.info("{}", shardMeta);
}
Aggregations