Search in sources :

Example 1 with MetroPointType

use of com.emc.storageos.db.client.model.VirtualPool.MetroPointType in project coprhd-controller by CoprHD.

the class RPRecommendation method getMetroPointType.

/**
 * Gets the MetroPoint configuration type for the recommendation.  Looks specifically
 * at the protection copy types to figure out the configuration.  If any of the
 * protection copy types is not set, we cannot properly determine the configuration
 * so we must return null;
 *
 * @return the MetroPoint configuration type
 */
public MetroPointType getMetroPointType() {
    MetroPointType metroPointType = null;
    int primaryLocalCopyCount = 0;
    int primaryRemoteCopyCount = 0;
    int secondaryLocalCopyCount = 0;
    int secondaryRemoteCopyCount = 0;
    List<RPRecommendation> targetRecs = this.getTargetRecommendations();
    // Return invalid configuration if there is no primary protection specified.
    if (targetRecs == null || targetRecs.isEmpty()) {
        return MetroPointType.INVALID;
    }
    for (RPRecommendation targetRec : targetRecs) {
        if (targetRec.getProtectionType() == null) {
            // MetroPoint specific code.
            return MetroPointType.INVALID;
        }
        if (targetRec.getProtectionType() == ProtectionType.LOCAL) {
            primaryLocalCopyCount++;
        } else if (targetRec.getProtectionType() == ProtectionType.REMOTE) {
            primaryRemoteCopyCount++;
        }
    }
    RPRecommendation secondaryRecommendation = null;
    if (this.getHaRecommendation() != null) {
        // There will only ever be 1 secondary recommendation in a MetroPoint case.
        secondaryRecommendation = this.getHaRecommendation();
    } else {
        // configuration.
        return MetroPointType.INVALID;
    }
    // Return invalid configuration if there is no secondary protection specified.
    if (secondaryRecommendation.getTargetRecommendations().isEmpty()) {
        return MetroPointType.INVALID;
    }
    for (RPRecommendation secondaryTargetRec : secondaryRecommendation.getTargetRecommendations()) {
        if (secondaryTargetRec.getProtectionType() == null) {
            // MetroPoint specific code.
            return MetroPointType.INVALID;
        }
        if (secondaryTargetRec.getProtectionType() == ProtectionType.LOCAL) {
            secondaryLocalCopyCount++;
        } else if (secondaryTargetRec.getProtectionType() == ProtectionType.REMOTE) {
            secondaryRemoteCopyCount++;
        }
    }
    boolean singleRemoteCopy = false;
    boolean primaryLocalCopy = false;
    boolean secondaryLocalCopy = false;
    if (primaryRemoteCopyCount == 1 && secondaryRemoteCopyCount == 1) {
        singleRemoteCopy = true;
    }
    if (primaryLocalCopyCount == 1) {
        primaryLocalCopy = true;
    }
    if (secondaryLocalCopyCount == 1) {
        secondaryLocalCopy = true;
    }
    metroPointType = MetroPointType.INVALID;
    if (singleRemoteCopy && primaryLocalCopy && secondaryLocalCopy) {
        metroPointType = MetroPointType.TWO_LOCAL_REMOTE;
    } else if (singleRemoteCopy && ((!primaryLocalCopy && secondaryLocalCopy) || (primaryLocalCopy && !secondaryLocalCopy))) {
        metroPointType = MetroPointType.ONE_LOCAL_REMOTE;
    } else if (singleRemoteCopy && !primaryLocalCopy && !secondaryLocalCopy) {
        metroPointType = MetroPointType.SINGLE_REMOTE;
    } else if (!singleRemoteCopy && primaryLocalCopy && secondaryLocalCopy) {
        metroPointType = MetroPointType.LOCAL_ONLY;
    }
    return metroPointType;
}
Also used : MetroPointType(com.emc.storageos.db.client.model.VirtualPool.MetroPointType)

Aggregations

MetroPointType (com.emc.storageos.db.client.model.VirtualPool.MetroPointType)1