RedisServiceImpl extends AbstractConsoleService<RedisTblDao> implements RedisService { @Override public void deleteRedises(String dcId, String clusterId, String shardId, List<Pair<String, Integer>> redisAddresses) throws ResourceNotFoundException { List<RedisTbl> redisTbls = findRedisesByDcClusterShard(dcId, clusterId, shardId); List<RedisTbl> toDelete = inter(redisAddresses, redisTbls); logger.info("[deleteRedises]{}", toDelete); queryHandler.handleQuery(new DalQuery<int[]>() { @Override public int[] doQuery() throws DalException { redisDao.deleteRedisesBatch(toDelete); return null; } }); notifyClusterUpdate(dcId, clusterId); }  @Override RedisTbl find(final long id); @Override List<RedisTbl> findAllRedisWithSameIP(String ip); @Override List<RedisTbl> findAllByDcClusterShard(final long dcClusterShardId); @Override List<RedisTbl> findAllRedisesByDcClusterName(String dcId, String clusterId); @Override List<RedisTbl> findAllByDcClusterShard(String dcId, String clusterId, String shardId); @Override List<RedisTbl> findRedisesByDcClusterShard(String dcId, String clusterId, String shardId); @Override List<RedisTbl> findKeepersByDcClusterShard(String dcId, String clusterId, String shardId); @Override synchronized void insertRedises(String dcId, String clusterId, String shardId,
                                           List<Pair<String, Integer>> redisAddresses); @Override synchronized int insertKeepers(String dcId, String clusterId, String shardId,
                                          List<KeeperBasicInfo> keepers); @Override List<RedisTbl> deleteKeepers(String dcId, String clusterId, String shardId); @Override void deleteRedises(String dcId, String clusterId, String shardId, List<Pair<String, Integer>> redisAddresses); @Override void updateByPK(final RedisTbl redis); @Override void updateBatchMaster(List<RedisTbl> redises); @Override void updateBatchKeeperActive(List<RedisTbl> redises); @Override void updateRedises(String dcName, String clusterName, String shardName, ShardModel shardModel); @Override List<RedisTbl> findAllKeeperContainerCountInfo(); @Override List<Long> findClusterIdsByKeeperContainer(long keeperContainerId); void insertInstancesToDb(long dcClusterShardId, String role, Pair<String, Integer>... addrs);  }
@Test public void testDeleteRedises() throws DalException, ResourceNotFoundException{ List<RedisTbl> redises = redisService.findRedisesByDcClusterShard(dcName, clusterName, shardName); int expect_length = redises.size() - 1; List<Pair<String, Integer>> redisAddresses = new LinkedList<>(); redisAddresses.add(new Pair<>(redises.get(0).getRedisIp(), redises.get(0).getRedisPort())); redisService.deleteRedises(dcName, clusterName, shardName, redisAddresses); redises = redisService.findRedisesByDcClusterShard(dcName, clusterName, shardName); Assert.assertEquals(expect_length, redises.size()); }