ClusterDao extends AbstractXpipeConsoleDAO { @DalTransaction public void deleteCluster(final ClusterTbl cluster) throws DalException { List<ShardTbl> shards = queryHandler.handleQuery(new DalQuery<List<ShardTbl>>() { @Override public List<ShardTbl> doQuery() throws DalException { return shardTblDao.findAllByClusterId(cluster.getId(), ShardTblEntity.READSET_FULL); } }); List<DcClusterTbl> dcClusters = queryHandler.handleQuery(new DalQuery<List<DcClusterTbl>>() { @Override public List<DcClusterTbl> doQuery() throws DalException { return dcClusterTblDao.findAllByClusterId(cluster.getId(), DcClusterTblEntity.READSET_FULL); } }); if(null != shards && !shards.isEmpty()) { shardDao.deleteShardsBatch(shards); } if(null != dcClusters && !dcClusters.isEmpty()) { dcClusterDao.deleteDcClustersBatch(dcClusters); } ClusterTbl proto = cluster; proto.setClusterName(generateDeletedName(cluster.getClusterName())); queryHandler.handleDelete(new DalQuery<Integer>() { @Override public Integer doQuery() throws DalException { return clusterTblDao.deleteCluster(proto, ClusterTblEntity.UPDATESET_FULL); } }, true); }  @DalTransaction ClusterTbl createCluster(final ClusterTbl cluster); @DalTransaction void updateCluster(ClusterTbl cluster); @DalTransaction void deleteCluster(final ClusterTbl cluster); @DalTransaction int bindDc(final ClusterTbl cluster, final DcTbl dc, SetinelTbl sentinel); @DalTransaction int unbindDc(final ClusterTbl cluster, final DcTbl dc); @DalTransaction ClusterTbl findClusterAndOrgByName(final String clusterName); List<ClusterTbl> findAllClusterWithOrgInfo(); List<ClusterTbl> findClusterWithOrgInfoByClusterType(String type); List<ClusterTbl> findClustersWithOrgInfoByActiveDcId(final long dcId); List<ClusterTbl> findAllByDcId(final long dcId); List<ClusterTbl> findClustersWithName(List<String> clusterNames);  }
@Test public void testDeleteCluster() throws Exception { clusterDao.createCluster(clusterTbl); clusterDao.deleteCluster(clusterTbl); }