Skip to content

Commit

Permalink
improve findAllByDcIdAndInClusterTypes by divide it to some smaller t…
Browse files Browse the repository at this point in the history
…asks
  • Loading branch information
qifanwang committed Aug 12, 2024
1 parent afdf916 commit e08cb97
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,33 @@ protected void doExecute() throws Exception {
dc2DcClusterShardMap = Maps.newHashMap();

List<DcClusterShardTbl> allDcClusterShards = new LinkedList<>();
ParallelCommandChain chain = new ParallelCommandChain(executors, false);

for (DcTbl dcTbl : allDcsTblList) {
allDcClusterShards.addAll(dcClusterShardService.findAllByDcIdAndInClusterTypes(dcTbl.getId(), interestClusterTypes));
chain.add(new AbstractCommand<Object>() {
@Override
public String getName() {
return "FindAllByDcIdAndInClusterTypes";
}

@Override
protected void doExecute() throws Throwable {
List<DcClusterShardTbl> res = dcClusterShardService.findAllByDcIdAndInClusterTypes(dcTbl.getId(), interestClusterTypes);
synchronized (allDcClusterShards) {
allDcClusterShards.addAll(res);
}
future().setSuccess();
}

@Override
protected void doReset() {

}
});
}

chain.execute().get();

for (DcClusterShardTbl dcClusterShardTbl : allDcClusterShards) {
if (dcClusterShardTbl.getDcClusterInfo() == null) {
getLogger().warn("dcClusterInfo in dcClusterShard null");
Expand Down

0 comments on commit e08cb97

Please sign in to comment.