Search in sources :

Example 6 with StorageGroup

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;
}
Also used : StorageGroup(org.smartdata.hdfs.action.move.StorageGroup)

Example 7 with StorageGroup

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;
                }
            }
        }
    }
}
Also used : StorageGroup(org.smartdata.hdfs.action.move.StorageGroup) DBlock(org.smartdata.hdfs.action.move.DBlock) MLocation(org.smartdata.hdfs.action.move.MLocation) Source(org.smartdata.hdfs.action.move.Source)

Aggregations

StorageGroup (org.smartdata.hdfs.action.move.StorageGroup)7 Source (org.smartdata.hdfs.action.move.Source)2 IOException (java.io.IOException)1 URI (java.net.URI)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 ExtendedBlock (org.apache.hadoop.hdfs.protocol.ExtendedBlock)1 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)1 DatanodeStorageReport (org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport)1 NetworkTopology (org.apache.hadoop.net.NetworkTopology)1 DBlock (org.smartdata.hdfs.action.move.DBlock)1 MLocation (org.smartdata.hdfs.action.move.MLocation)1 FileMovePlan (org.smartdata.model.action.FileMovePlan)1