KeeperContainerServiceImpl extends AbstractConsoleService<KeepercontainerTblDao> implements KeeperContainerService { @Override public List<KeeperContainerInfoModel> findAllInfos() { List<KeepercontainerTbl> baseInfos = findContainerBaseInfos(); HashMap<Long, KeeperContainerInfoModel> containerInfoMap = new HashMap<>(); baseInfos.forEach(baseInfo -> { KeeperContainerInfoModel model = new KeeperContainerInfoModel(); model.setId(baseInfo.getKeepercontainerId()); model.setAddr(new HostPort(baseInfo.getKeepercontainerIp(), baseInfo.getKeepercontainerPort())); model.setDcName(baseInfo.getDcInfo().getDcName()); model.setOrgName(baseInfo.getOrgInfo().getOrgName()); containerInfoMap.put(model.getId(), model); }); List<RedisTbl> containerLoad = redisService.findAllKeeperContainerCountInfo(); containerLoad.forEach(load -> { if (!containerInfoMap.containsKey(load.getKeepercontainerId())) return; KeeperContainerInfoModel model = containerInfoMap.get(load.getKeepercontainerId()); model.setKeeperCount(load.getCount()); model.setClusterCount(load.getDcClusterShardInfo().getClusterCount()); model.setShardCount(load.getDcClusterShardInfo().getShardCount()); }); return new ArrayList<>(containerInfoMap.values()); }  @Override KeepercontainerTbl find(final long id); @Override List<KeepercontainerTbl> findAllByDcName(final String dcName); @Override List<KeepercontainerTbl> findAllActiveByDcName(String dcName); @Override List<KeepercontainerTbl> findKeeperCount(String dcName); @Override List<KeepercontainerTbl> findBestKeeperContainersByDcCluster(String dcName, String clusterName); @Override void addKeeperContainer(final KeeperContainerCreateInfo createInfo); @Override List<KeeperContainerCreateInfo> getDcAllKeeperContainers(String dc); @Override void updateKeeperContainer(KeeperContainerCreateInfo createInfo); @Override List<KeeperContainerInfoModel> findAllInfos();  }
@Test public void testFindAllInfos() { List<KeeperContainerInfoModel> infos = keeperContainerService.findAllInfos(); Assert.assertTrue(infos.size() > 0); for (KeeperContainerInfoModel info: infos) { Assert.assertTrue(info.getId() > 0); Assert.assertNotNull(info.getAddr()); Assert.assertFalse(StringUtil.isEmpty(info.getDcName())); } Assert.assertEquals(2, infos.get(0).getClusterCount()); Assert.assertEquals(2, infos.get(0).getShardCount()); Assert.assertEquals(2, infos.get(0).getKeeperCount()); }