ShardDao extends AbstractXpipeConsoleDAO { public Set<String> queryAllShardMonitorNames() { List<ShardTbl> shards = queryHandler.handleQuery(new DalQuery<List<ShardTbl>>() { @Override public List<ShardTbl> doQuery() throws DalException { return shardTblDao.queryAllMonitorNames(ShardTblEntity.READSET_MONITOR_NAME); } }); Set<String> monitorNames = Sets.newHashSetWithExpectedSize(shards.size()); shards.forEach(shardTbl -> monitorNames.add(shardTbl.getSetinelMonitorName())); return monitorNames; }  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 testQueryAllShardMonitors() throws Exception { Set<String> expectedMonitors = Sets.newHashSet("shard1", "shard2", "cluster2shard1", "cluster2shard2", "cluster3shard1", "cluster3shard2"); Set<String> monitors = shardDao.queryAllShardMonitorNames(); Assert.assertEquals(expectedMonitors, monitors); }