boolean chooseTarget(DBlock db, Source source, List<StorageType> targetTypes, Matcher matcher) { final NetworkTopology cluster = dispatcher.getCluster(); for (StorageType t : targetTypes) { final List<StorageGroup> targets = storages.getTargetStorages(t); Collections.shuffle(targets); for (StorageGroup target : targets) { 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; } }
private boolean matchStorageGroups(StorageGroup left, StorageGroup right, Matcher matcher) { return left.getStorageType() == right.getStorageType() && matcher.match(dispatcher.getCluster(), left.getDatanodeInfo(), right.getDatanodeInfo()); }
/** * Decide all <source, target> pairs and * the number of bytes to move from a source to a target * Maximum bytes to be moved per storage group is * min(1 Band worth of bytes, MAX_SIZE_TO_MOVE). * @return total number of bytes to move in this iteration */ private long chooseStorageGroups() { // First, match nodes on the same node group if cluster is node group aware if (dispatcher.getCluster().isNodeGroupAware()) { chooseStorageGroups(Matcher.SAME_NODE_GROUP); } // Then, match nodes on the same rack chooseStorageGroups(Matcher.SAME_RACK); // At last, match all remaining nodes chooseStorageGroups(Matcher.ANY_OTHER); return dispatcher.bytesToMove(); }
if (dispatcher.getCluster().isNodeGroupAware()) { if (chooseTarget(db, source, targetTypes, Matcher.SAME_NODE_GROUP)) { return true;
boolean chooseTarget(DBlock db, Source source, List<StorageType> targetTypes, Matcher matcher) { final NetworkTopology cluster = dispatcher.getCluster(); for (StorageType t : targetTypes) { final List<StorageGroup> targets = storages.getTargetStorages(t); Collections.shuffle(targets); for (StorageGroup target : targets) { 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 chooseTarget(DBlock db, Source source, List<StorageType> targetTypes, Matcher matcher) { final NetworkTopology cluster = dispatcher.getCluster(); for (StorageType t : targetTypes) { final List<StorageGroup> targets = storages.getTargetStorages(t); Collections.shuffle(targets); for (StorageGroup target : targets) { 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; } }
private boolean matchStorageGroups(StorageGroup left, StorageGroup right, Matcher matcher) { return left.getStorageType() == right.getStorageType() && matcher.match(dispatcher.getCluster(), left.getDatanodeInfo(), right.getDatanodeInfo()); }
private boolean matchStorageGroups(StorageGroup left, StorageGroup right, Matcher matcher) { return left.getStorageType() == right.getStorageType() && matcher.match(dispatcher.getCluster(), left.getDatanodeInfo(), right.getDatanodeInfo()); }
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); }
/** * Decide all <source, target> pairs and * the number of bytes to move from a source to a target * Maximum bytes to be moved per storage group is * min(1 Band worth of bytes, MAX_SIZE_TO_MOVE). * @return total number of bytes to move in this iteration */ private long chooseStorageGroups() { // First, match nodes on the same node group if cluster is node group aware if (dispatcher.getCluster().isNodeGroupAware()) { chooseStorageGroups(Matcher.SAME_NODE_GROUP); } // Then, match nodes on the same rack chooseStorageGroups(Matcher.SAME_RACK); // At last, match all remaining nodes chooseStorageGroups(Matcher.ANY_OTHER); return dispatcher.bytesToMove(); }
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); }
/** * Decide all <source, target> pairs and * the number of bytes to move from a source to a target * Maximum bytes to be moved per storage group is * min(1 Band worth of bytes, MAX_SIZE_TO_MOVE). * @return total number of bytes to move in this iteration */ private long chooseStorageGroups() { // First, match nodes on the same node group if cluster is node group aware if (dispatcher.getCluster().isNodeGroupAware()) { chooseStorageGroups(Matcher.SAME_NODE_GROUP); } // Then, match nodes on the same rack chooseStorageGroups(Matcher.SAME_RACK); // At last, match all remaining nodes chooseStorageGroups(Matcher.ANY_OTHER); return dispatcher.bytesToMove(); }