use of org.smartdata.hdfs.action.move.DBlock 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;
}
}
}
}
}
use of org.smartdata.hdfs.action.move.DBlock in project SSM by Intel-bigdata.
the class CompatibilityHelper2 method newDBlock.
public DBlock newDBlock(LocatedBlock lb, HdfsFileStatus status) {
Block blk = lb.getBlock().getLocalBlock();
DBlock db = new DBlock(blk);
return db;
}
use of org.smartdata.hdfs.action.move.DBlock in project SSM by Intel-bigdata.
the class CompatibilityHelper31 method newDBlock.
@Override
public DBlock newDBlock(LocatedBlock lb, HdfsFileStatus status) {
Block blk = lb.getBlock().getLocalBlock();
ErasureCodingPolicy ecPolicy = status.getErasureCodingPolicy();
DBlock db;
if (lb.isStriped()) {
LocatedStripedBlock lsb = (LocatedStripedBlock) lb;
byte[] indices = new byte[lsb.getBlockIndices().length];
for (int i = 0; i < indices.length; i++) {
indices[i] = (byte) lsb.getBlockIndices()[i];
}
db = (DBlock) new DBlockStriped(blk, indices, (short) ecPolicy.getNumDataUnits(), ecPolicy.getCellSize());
} else {
db = new DBlock(blk);
}
return db;
}
Aggregations