ShardServiceImpl extends AbstractConsoleService<ShardTblDao> implements ShardService { @Override public synchronized ShardTbl findOrCreateShardIfNotExist(String clusterName, ShardTbl shard, Map<Long, SetinelTbl> sentinels) { logger.info("[findOrCreateShardIfNotExist] Begin find or create shard: {}", shard); String monitorName = shard.getSetinelMonitorName(); List<ShardTbl> shards = shardDao.queryAllShardsByClusterName(clusterName); Set<String> monitorNames = shardDao.queryAllShardMonitorNames(); ShardTbl dupShardTbl = null; if(shards != null) { for (ShardTbl shardTbl : shards) { if (shardTbl.getShardName().equals(shard.getShardName())) { logger.info("[findOrCreateShardIfNotExist] Shard exist as: {} for input shard: {}", shardTbl, shard); dupShardTbl = shardTbl; } } } if(StringUtil.isEmpty(monitorName)) { return generateMonitorNameAndReturnShard(dupShardTbl, monitorNames, clusterName, shard, sentinels); } else { return compareMonitorNameAndReturnShard(dupShardTbl, monitorNames, clusterName, shard, sentinels); } }  @Override ShardTbl find(final long shardId); @Override ShardTbl find(final String clusterName, final String shardName); @Override List<ShardTbl> findAllByClusterName(final String clusterName); @Override List<ShardTbl> findAllShardNamesByClusterName(final String clusterName); @Override synchronized ShardTbl createShard(final String clusterName, final ShardTbl shard,
											 final Map<Long, SetinelTbl> sentinels); @Override synchronized ShardTbl findOrCreateShardIfNotExist(String clusterName, ShardTbl shard,
															 Map<Long, SetinelTbl> sentinels); @Override void deleteShard(final String clusterName, final String shardName); @Override List<ShardListModel> findAllUnhealthy();  }
@Test public void findOrCreateShardIfNotExist() throws Exception { }