ShardDao extends AbstractXpipeConsoleDAO { @DalTransaction public void deleteShardsBatch(List<ShardTbl> shards) throws DalException { if(null == shards || shards.isEmpty()) { logger.warn("[deleteShardsBatch] Empty shards: {}", shards); return; } List<DcClusterShardTbl> relatedDcClusterShards = new LinkedList<DcClusterShardTbl>(); for(final ShardTbl shard : shards) { List<DcClusterShardTbl> dcClusterShards = queryHandler.handleQuery(new DalQuery<List<DcClusterShardTbl>>() { @Override public List<DcClusterShardTbl> doQuery() throws DalException { return dcClusterShardTblDao.findAllByShardId(shard.getId(), DcClusterShardTblEntity.READSET_FULL); } }); if(null != dcClusterShards) { relatedDcClusterShards.addAll(dcClusterShards); } } dcClusterShardDao.deleteDcClusterShardsBatch(relatedDcClusterShards); for(ShardTbl shard : shards) { shard.setShardName(generateDeletedName(shard.getShardName())); } queryHandler.handleBatchDelete(new DalQuery<int[]>() { @Override public int[] doQuery() throws DalException { return shardTblDao.deleteShardsBatch(shards.toArray(new ShardTbl[shards.size()]), ShardTblEntity.UPDATESET_FULL); } }, true); }  ShardTbl createShard(String clusterName, ShardTbl shard, Map<Long, SetinelTbl> sentinels); List<ShardTbl> queryAllShardsByClusterName(String clusterName); Set<String> queryAllShardMonitorNames(); @DalTransaction void deleteShardsBatch(List<ShardTbl> shards); @DalTransaction void deleteShardsBatch(final ShardTbl shard); @DalTransaction ShardTbl insertShard(String clusterName, ShardTbl shard, Map<Long, SetinelTbl> sentinels);  }
@Test public void testDeleteShardsBatch() throws Exception { shardDao.deleteShardsBatch(new LinkedList<ShardTbl>()); }