ShardMetaServiceImpl extends AbstractMetaService implements ShardMetaService { @Override public ShardMeta getShardMeta(final String dcName, final String clusterName, final String shardName) { ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5); Future<DcTbl> future_dcInfo = fixedThreadPool.submit(new Callable<DcTbl>() { @Override public DcTbl call() throws DalException { return dcService.find(dcName); } }); Future<ClusterTbl> future_clusterInfo = fixedThreadPool.submit(new Callable<ClusterTbl>() { @Override public ClusterTbl call() throws DalException { return clusterService.find(clusterName); } }); Future<ShardTbl> future_shardInfo = fixedThreadPool.submit(new Callable<ShardTbl>() { @Override public ShardTbl call() throws DalException { return shardService.find(clusterName, shardName); } }); Future<DcClusterTbl> future_dcClusterInfo = fixedThreadPool.submit(new Callable<DcClusterTbl>() { @Override public DcClusterTbl call() throws DalException { return dcClusterService.find(dcName, clusterName); } }); Future<DcClusterShardTbl> future_dcClusterShardInfo = fixedThreadPool.submit(new Callable<DcClusterShardTbl>() { @Override public DcClusterShardTbl call() throws DalException { return dcClusterShardService.find(dcName, clusterName, shardName); } }); try { if(null == future_dcInfo.get() || null == future_clusterInfo.get() || null == future_shardInfo.get() || null == future_dcClusterInfo.get() || null == future_dcClusterShardInfo.get()) { return new ShardMeta().setId(shardName); } return getShardMeta(future_dcInfo.get(),future_clusterInfo.get(),future_shardInfo.get(), future_dcClusterInfo.get(), future_dcClusterShardInfo.get()); } catch (ExecutionException e) { throw new DataNotFoundException("Cannot construct shard-meta", e); } catch (InterruptedException e) { throw new ServerException("Concurrent execution failed.", e); } finally { fixedThreadPool.shutdown(); } }  @Override ShardMeta loadShardMeta(ClusterMeta clusterMeta,ClusterTbl clusterTbl, ShardTbl shardTbl, DcMetaQueryVO dcMetaQueryVO); @Override ShardMeta getShardMeta(final String dcName, final String clusterName, final String shardName); @Override ShardMeta getShardMeta(final DcTbl dcInfo, final ClusterTbl clusterInfo, final ShardTbl shardInfo);  }
@Test public void getShardMetaTest() { String dcName = "dc1", clusterName = "cluster1", shardName = "shard1"; ShardMeta shardMeta = shardMetaService.getShardMeta(dcName, clusterName, shardName); Assert.assertEquals(shardName, shardMeta.getId()); Assert.assertEquals(Long.valueOf(shardName.hashCode()), shardMeta.getSentinelId()); Assert.assertEquals(SentinelUtil.getSentinelMonitorName(clusterName, shardName, dcName), shardMeta.getSentinelMonitorName()); shardMeta = shardMetaService.getShardMeta(mockDcInfo(dcName), mockClusterTbl(clusterName), mockShardTbl(clusterName, shardName)); Assert.assertEquals(shardName, shardMeta.getId()); Assert.assertEquals(Long.valueOf(shardName.hashCode()), shardMeta.getSentinelId()); Assert.assertEquals(SentinelUtil.getSentinelMonitorName(clusterName, shardName, dcName), shardMeta.getSentinelMonitorName()); }