use of org.smartdata.hdfs.action.move.StorageGroup in project SSM by Intel-bigdata.
the class MovePlanMaker method chooseTargetInSameNode.
/**
* Choose the target storage within same Datanode if possible.
*/
boolean chooseTargetInSameNode(DBlock db, Source source, List<String> targetTypes) {
for (String t : targetTypes) {
StorageGroup target = storages.getTarget(source.getDatanodeInfo().getDatanodeUuid(), t);
if (target == null) {
continue;
}
addPlan(source, target, db.getBlock().getBlockId());
return true;
}
return false;
}
use of org.smartdata.hdfs.action.move.StorageGroup in project SSM by Intel-bigdata.
the class MovePlanMaker method scheduleMoveBlock.
/**
* TODO: consider the case that fails to move some blocks, i.e., scheduleMoveReplica fails.
*/
void scheduleMoveBlock(StorageTypeDiff diff, LocatedBlock lb, HdfsFileStatus status) {
final List<MLocation> locations = MLocation.toLocations(lb);
if (!CompatibilityHelperLoader.getHelper().isLocatedStripedBlock(lb)) {
// Shuffle replica locations to make storage medium in balance.
// E.g., if three replicas are under ALL_SSD policy and ONE_SSD is the target policy,
// with shuffling locations, two randomly picked replicas will be moved to DISK.
Collections.shuffle(locations);
}
// EC block case is considered.
final DBlock db = CompatibilityHelperLoader.getHelper().newDBlock(lb, status);
for (MLocation ml : locations) {
StorageGroup source = storages.getSource(ml);
if (source != null) {
db.addLocation(source);
}
}
for (int index = 0; index < diff.existing.size(); index++) {
String t = diff.existing.get(index);
Iterator<MLocation> iter = locations.iterator();
while (iter.hasNext()) {
MLocation ml = iter.next();
final Source source = storages.getSource(ml);
// in diff's existing list. If so, try to schedule the moving.
if (ml.getStorageType() == t && source != null) {
// The corresponding storage type in diff's expected list is used.
if (scheduleMoveReplica(db, source, Arrays.asList(diff.expected.get(index)))) {
// If the replica is successfully scheduled to move.
// No need to consider it any more.
iter.remove();
// Tackle the next storage type in diff existing list.
break;
}
}
}
}
}
Aggregations