boolean scheduleMoveReplica(DBlock db, Source source, List<StorageType> targetTypes) { // Match storage on the same node if (chooseTargetInSameNode(db, source, targetTypes)) { return true; } if (dispatcher.getCluster().isNodeGroupAware()) { if (chooseTarget(db, source, targetTypes, Matcher.SAME_NODE_GROUP)) { return true; } } // Then, match nodes on the same rack if (chooseTarget(db, source, targetTypes, Matcher.SAME_RACK)) { return true; } // At last, match all remaining nodes return chooseTarget(db, source, targetTypes, Matcher.ANY_OTHER); }
boolean chooseTarget(DBlock db, Source source, List<StorageType> targetTypes, Matcher matcher) { final NetworkTopology cluster = dispatcher.getCluster(); for (StorageType t : targetTypes) { for(StorageGroup target : storages.getTargetStorages(t)) { if (matcher.match(cluster, source.getDatanodeInfo(), target.getDatanodeInfo())) { final PendingMove pm = source.addPendingMove(db, target); if (pm != null) { dispatcher.executePendingMove(pm); return true; } } } } return false; }
boolean scheduleMoveReplica(DBlock db, Source source, List<StorageType> targetTypes) { if (dispatcher.getCluster().isNodeGroupAware()) { if (chooseTarget(db, source, targetTypes, Matcher.SAME_NODE_GROUP)) { return true; } } // Then, match nodes on the same rack if (chooseTarget(db, source, targetTypes, Matcher.SAME_RACK)) { return true; } // At last, match all remaining nodes return chooseTarget(db, source, targetTypes, Matcher.ANY_OTHER); }