ClusterServiceImpl extends AbstractConsoleService<ClusterTblDao> implements ClusterService { @Override public void updateActivedcId(long id, long activeDcId) { ClusterTbl clusterTbl = new ClusterTbl(); clusterTbl.setId(id); clusterTbl.setActivedcId(activeDcId); queryHandler.handleUpdate(new DalQuery<Integer>() { @Override public Integer doQuery() throws DalException { return dao.updateActivedcId(clusterTbl, ClusterTblEntity.UPDATESET_FULL); } }); }  @Override ClusterTbl find(final String clusterName); @Override List<ClusterTbl> findAllByNames(List<String> clusterNames); @Override ClusterStatus clusterStatus(String clusterName); @Override List<DcTbl> getClusterRelatedDcs(String clusterName); @Override ClusterTbl find(final long clusterId); @Override List<String> findAllClusterNames(); @Override Long getAllCount(); @Override @DalTransaction synchronized ClusterTbl createCluster(ClusterModel clusterModel); long getOrgIdFromClusterOrgName(ClusterTbl cluster); @Override ClusterTbl findClusterAndOrg(String clusterName); @Override List<ClusterTbl> findClustersWithOrgInfoByActiveDcId(long activeDc); @Override List<ClusterTbl> findAllClustersWithOrgInfo(); @Override List<ClusterTbl> findClustersWithOrgInfoByClusterType(String clusterType); @Override void updateCluster(String clusterName, ClusterTbl cluster); @Override void updateActivedcId(long id, long activeDcId); @Override void updateStatusById(long id, ClusterStatus clusterStatus); @Override void deleteCluster(String clusterName); @Override void bindDc(String clusterName, String dcName); @Override void unbindDc(String clusterName, String dcName); @Override void update(final ClusterTbl cluster); boolean checkEmails(String emails); @Override List<String> reBalanceSentinels(String dcName, final int numOfClusters, final boolean activeOnly); @Override void reBalanceClusterSentinels(String dcName, final List<String> clusters); @Override List<ClusterListUnhealthyClusterModel> findUnhealthyClusters(); @Override List<ClusterTbl> findAllClusterByDcNameBind(String dcName); @Override List<ClusterTbl> findActiveClustersByDcName(String dcName); @Override List<ClusterTbl> findAllClustersByDcName(String dcName); @Override List<ClusterTbl> findAllClusterByKeeperContainer(long keeperContainerId);  }
@Test public void testUpdateActivedcId(){ ClusterTbl clusterTbl = clusterService.find(clusterName); long oldActiveDcId = clusterTbl.getActivedcId(); long newActiveDcId = clusterTbl.getActivedcId() + 1; clusterService.updateActivedcId(clusterTbl.getId(), newActiveDcId); ClusterTbl newCluster = clusterService.find(clusterName); Assert.assertEquals(newActiveDcId, newCluster.getActivedcId()); newCluster.setActivedcId(oldActiveDcId); Assert.assertEquals(clusterTbl.toString(), newCluster.toString()); }