Search in sources :

Example 1 with ConsistencyGroupLinkState

use of com.emc.fapiclient.ws.ConsistencyGroupLinkState in project coprhd-controller by CoprHD.

the class RecoverPointImageManagementUtils method getCopyLinkState.

/**
 * Get the link state of a copy
 *
 * @param impl - RP handle
 * @param cgCopy - CG Copy, contains CG
 * @throws RecoverPointException
 */
public ConsistencyGroupLinkState getCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID cgCopy) throws RecoverPointException {
    String cgCopyName = NAME_UNKNOWN;
    String cgName = NAME_UNKNOWN;
    try {
        cgCopyName = impl.getGroupCopyName(cgCopy);
        cgName = impl.getGroupName(cgCopy.getGroupUID());
        ConsistencyGroupUID groupUID = cgCopy.getGroupUID();
        ConsistencyGroupState groupState = impl.getGroupState(groupUID);
        List<ConsistencyGroupLinkState> linkStates = groupState.getLinksStates();
        for (ConsistencyGroupLinkState cgLinkState : linkStates) {
            if ((RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getSecondCopy(), cgCopy.getGlobalCopyUID()) || (RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getFirstCopy(), cgCopy.getGlobalCopyUID())))) {
                return cgLinkState;
            }
        }
        return null;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    }
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 2 with ConsistencyGroupLinkState

use of com.emc.fapiclient.ws.ConsistencyGroupLinkState in project coprhd-controller by CoprHD.

the class RecoverPointClient method getCGState.

/**
 * Return the state of a consistency group.
 *
 * @param cgUID - CG identifier
 *
 * @return the state of the CG
 *
 * @throws RecoverPointException
 */
private RecoverPointCGState getCGState(ConsistencyGroupUID cgUID) throws RecoverPointException {
    ConsistencyGroupSettings cgSettings = null;
    ConsistencyGroupState cgState = null;
    try {
        cgSettings = functionalAPI.getGroupSettings(cgUID);
        cgState = functionalAPI.getGroupState(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    } catch (FunctionalAPIInternalError_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    }
    if (!cgSettings.isEnabled()) {
        return RecoverPointCGState.STOPPED;
    }
    // First check for disabled copies
    boolean someCopiesEnabled = false;
    boolean someCopiesDisabled = false;
    for (ConsistencyGroupCopyState cgCopyState : cgState.getGroupCopiesStates()) {
        if (cgCopyState.isEnabled()) {
            someCopiesEnabled = true;
        } else {
            someCopiesDisabled = true;
        }
    }
    if (someCopiesDisabled && !someCopiesEnabled) {
        // All copies are disabled
        return RecoverPointCGState.STOPPED;
    }
    // Now check to see if all the copies are paused
    boolean someCopiesPaused = false;
    boolean someCopiesNotPaused = false;
    List<ConsistencyGroupLinkState> cgLinkStateList;
    try {
        cgLinkStateList = functionalAPI.getGroupState(cgUID).getLinksStates();
    } catch (FunctionalAPIActionFailedException_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    } catch (FunctionalAPIInternalError_Exception e) {
        // No longer exists
        return RecoverPointCGState.DELETED;
    }
    for (ConsistencyGroupLinkState cgLinkState : cgLinkStateList) {
        // OK, this is our link that we just restored. Check the link state to see if it is active
        if (PipeState.ACTIVE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_IDLE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_SHIPPING.equals(cgLinkState.getPipeState()) || PipeState.STAND_BY.equals(cgLinkState.getPipeState())) {
            someCopiesNotPaused = true;
        } else {
            someCopiesPaused = true;
        }
    }
    if (someCopiesPaused && !someCopiesNotPaused) {
        // All copies are paused
        return RecoverPointCGState.PAUSED;
    }
    if (someCopiesPaused || someCopiesDisabled) {
        return RecoverPointCGState.MIXED;
    }
    return RecoverPointCGState.READY;
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 3 with ConsistencyGroupLinkState

use of com.emc.fapiclient.ws.ConsistencyGroupLinkState in project coprhd-controller by CoprHD.

the class RecoverPointImageManagementUtils method waitForCGLinkState.

/**
 * Wait for CG copy links to become ACTIVE
 *
 * @param cgUID - Consistency group we are looking at
 * @param desiredPipeState - Desired state of the pipe
 * @param port - RP handle to use for RP operations
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGLinkState(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID, PipeState... desiredPipeState) throws RecoverPointException {
    int numRetries = 0;
    String cgName = null;
    try {
        cgName = impl.getGroupName(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    boolean isInitializing = false;
    boolean allLinksInDesiredState = false;
    int maxRetries = getLinkStateWaitTime() * 4;
    logger.debug("CG link state wait time is {} min and Max retry is {}", getLinkStateWaitTime(), maxRetries);
    while ((!allLinksInDesiredState && numRetries++ < maxRetries) || isInitializing) {
        ConsistencyGroupState cgState = null;
        isInitializing = false;
        try {
            cgState = impl.getGroupState(cgUID);
            List<String> desiredPipeStates = new ArrayList<String>();
            if (desiredPipeState != null) {
                // build the list of desired pipe states
                for (PipeState pipeState : desiredPipeState) {
                    desiredPipeStates.add(pipeState.name());
                }
            }
            // allLinksInDesiredState = true;
            for (ConsistencyGroupLinkState linkstate : cgState.getLinksStates()) {
                PipeState pipeState = linkstate.getPipeState();
                logger.info("CG link state is " + pipeState.toString() + "; desired states are: " + desiredPipeStates.toString());
                // Special consideration if we want the link to be in the active state.
                if (desiredPipeStates.contains(PipeState.ACTIVE.name())) {
                    if (PipeState.ACTIVE.equals(pipeState)) {
                        allLinksInDesiredState = true;
                    } else if (PipeState.STAND_BY.equals(pipeState)) {
                        // STAND_BY is a valid state for a MetroPoint link but we need
                        // an ACTIVE link state as well.
                        logger.info("CG link state is STAND_BY, valid state for MetroPoint.");
                    } else if (PipeState.PAUSED.equals(pipeState)) {
                        if (desiredPipeStates.contains(PipeState.PAUSED.name())) {
                            // When DIRECT_ACCESS mode is set on a target copy, the link will be paused. If one of
                            // the desired states is PAUSED, we must respect that and not attempt to start group
                            // transfer.
                            logger.info("CG link state is PAUSED.");
                            allLinksInDesiredState = true;
                        } else {
                            // We only want to start group transfer if the only desired state is the active state. When
                            // target copies are in DIRECT_ACCESS mode, the link will be paused and we do not want
                            // to resume group transfer.
                            logger.info("CG link state is PAUSED.  Resume link.");
                            impl.startGroupTransfer(cgUID);
                            allLinksInDesiredState = false;
                            break;
                        }
                    } else if (PipeState.INITIALIZING.equals(pipeState)) {
                        logger.info("CG link state is INITIALIZING.");
                        isInitializing = true;
                        allLinksInDesiredState = false;
                        break;
                    } else {
                        logger.info("CG link state is not active. It is: " + pipeState.toString());
                        allLinksInDesiredState = false;
                        break;
                    }
                } else if (desiredPipeStates.contains(PipeState.SNAP_IDLE.name())) {
                    if (PipeState.SNAP_IDLE.equals(pipeState) || PipeState.SNAP_SHIPPING.equals(pipeState)) {
                        allLinksInDesiredState = true;
                        break;
                    }
                } else {
                    // Other desired states (like UNKNOWN [inactive])
                    if (desiredPipeStates.contains(pipeState.name())) {
                        logger.info("CG link state matches the desired state.");
                        allLinksInDesiredState = true;
                    } else {
                        // This makes sure that if you wanted to act on the entire CG, but there's still a copy
                        // in the undesired state, we still need to wait for it.
                        logger.info("CG link state is not in desired state. It is: " + pipeState.toString());
                        allLinksInDesiredState = false;
                        break;
                    }
                }
            }
            if (allLinksInDesiredState) {
                return;
            } else {
                logger.info("All links not in desired state.  Sleep 15 seconds and retry");
                Thread.sleep(WAIT_FOR_LINKS_SLEEP_INTERVAL);
            }
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (InterruptedException e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        }
    }
    throw RecoverPointException.exceptions.cgLinksFailedToBecomeActive(cgName);
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ArrayList(java.util.ArrayList) PipeState(com.emc.fapiclient.ws.PipeState) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 4 with ConsistencyGroupLinkState

use of com.emc.fapiclient.ws.ConsistencyGroupLinkState in project coprhd-controller by CoprHD.

the class RecoverPointImageManagementUtils method waitForCGCopyLinkState.

/**
 * Wait for CG copy links to become ACTIVE
 *
 * @param impl access to RP
 * @param copyUID copy ID
 * @param desiredPipeState - Desired state of the pipe
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyUID, PipeState... desiredPipeState) throws RecoverPointException {
    int numRetries = 0;
    String cgName = null;
    try {
        cgName = impl.getGroupName(copyUID.getGroupUID());
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
    }
    List<String> desiredPipeStates = new ArrayList<String>();
    if (desiredPipeState != null) {
        // build the list of desired pipe states
        for (PipeState pipeState : desiredPipeState) {
            desiredPipeStates.add(pipeState.name());
        }
    }
    while (numRetries++ < MAX_RETRIES) {
        ConsistencyGroupState cgState = null;
        try {
            cgState = impl.getGroupState(copyUID.getGroupUID());
            for (ConsistencyGroupLinkState linkstate : cgState.getLinksStates()) {
                // The copy we're interested in may be in the FirstCopy or SecondCopy, so we need to find the link
                // state where our copy is the first or second copy and the other copy is a production. There may be
                // multiple production copies, so account for that, too. (you can assume there aren't multiple productions
                // going to the same target. We used to assume that the targets are "second copy", but that is not true.
                boolean found = false;
                // Loop through production copies
                if (!cgState.getSourceCopiesUIDs().isEmpty()) {
                    for (ConsistencyGroupCopyUID groupCopyUID : cgState.getSourceCopiesUIDs()) {
                        if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
                            found = true;
                        }
                        if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID())) {
                            found = true;
                        }
                    }
                } else {
                    // the link source and copy. Just find our copy in the link and go with it.
                    if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID()) || RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
                        found = true;
                    }
                }
                if (!found) {
                    continue;
                }
                if (desiredPipeStates.contains(PipeState.ACTIVE.name())) {
                    // Treat SNAP_IDLE as ACTIVE
                    if (linkstate.getPipeState().equals(PipeState.SNAP_IDLE)) {
                        linkstate.setPipeState(PipeState.ACTIVE);
                    }
                }
                PipeState pipeState = linkstate.getPipeState();
                logger.info("Copy link state is " + pipeState.toString() + "; desired states are: " + desiredPipeStates.toString());
                if (desiredPipeStates.contains(pipeState.name())) {
                    logger.info("Copy link state matches the desired state.");
                    return;
                } else {
                    // This makes sure that if you wanted to act on the entire CG, but there's still a copy
                    // in the undesired state, we still need to wait for it.
                    logger.info("Copy link state is not in desired state. It is: " + pipeState.toString());
                    break;
                }
            }
            logger.info("Copy link not in desired state.  Sleep 15 seconds and retry");
            Thread.sleep(WAIT_FOR_LINKS_SLEEP_INTERVAL);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        } catch (InterruptedException e) {
            throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
        }
    }
    throw RecoverPointException.exceptions.cgLinksFailedToBecomeActive(cgName);
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ArrayList(java.util.ArrayList) PipeState(com.emc.fapiclient.ws.PipeState) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 5 with ConsistencyGroupLinkState

use of com.emc.fapiclient.ws.ConsistencyGroupLinkState in project coprhd-controller by CoprHD.

the class RecoverPointImageManagementUtils method verifyCopyCapableOfEnableImageAccess.

/**
 * Verify that a copy is capable of being enabled.
 *
 * @param impl - RP handle
 * @param cgCopy - CG Copy, contains CG
 * @param failover - for a failover operation?
 * @return true if the copy is capable of enable image access, false if it's in some other state
 * @throws RecoverPointException
 */
public boolean verifyCopyCapableOfEnableImageAccess(FunctionalAPIImpl impl, ConsistencyGroupCopyUID cgCopy, String copyToEnable, boolean failover) throws RecoverPointException {
    String cgCopyName = NAME_UNKNOWN;
    String cgName = NAME_UNKNOWN;
    try {
        cgCopyName = impl.getGroupCopyName(cgCopy);
        cgName = impl.getGroupName(cgCopy.getGroupUID());
        ConsistencyGroupCopyState cgCopyState = getCopyState(impl, cgCopy);
        if (cgCopyState != null) {
            StorageAccessState copyAccessState = cgCopyState.getStorageAccessState();
            logger.info("Current Copy Access State: " + copyAccessState);
            // Check for NO_ACCESS state (or LOGGED ACCESS for failover)
            if (copyAccessState == StorageAccessState.NO_ACCESS) {
                return true;
            }
            // Failover-test state
            if ((copyAccessState == StorageAccessState.LOGGED_ACCESS) && failover) {
                ConsistencyGroupLinkState cgLinkState = getCopyLinkState(impl, cgCopy);
                if ((cgLinkState != null) && (cgLinkState.getPipeState() == PipeState.PAUSED)) {
                    return true;
                }
            }
            // return true if CG is already in LOGGED_ACCESS state
            if (copyAccessState == StorageAccessState.LOGGED_ACCESS && cgCopyState.getAccessedImage().getDescription().equals(copyToEnable)) {
                return true;
            }
        }
        return false;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    }
}
Also used : ConsistencyGroupLinkState(com.emc.fapiclient.ws.ConsistencyGroupLinkState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState)

Aggregations

ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)5 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)5 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)5 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)2 PipeState (com.emc.fapiclient.ws.PipeState)2 ArrayList (java.util.ArrayList)2 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)1