Search in sources :

Example 11 with ConsistencyGroupState

use of com.emc.fapiclient.ws.ConsistencyGroupState 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)

Aggregations

ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)11 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)9 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)8 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)5 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)5 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)4 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)4 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)3 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 JournalVolumeSettings (com.emc.fapiclient.ws.JournalVolumeSettings)2 PipeState (com.emc.fapiclient.ws.PipeState)2 RecoverPointTimeStamp (com.emc.fapiclient.ws.RecoverPointTimeStamp)2 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ConsistencyGroupCopyJournal (com.emc.fapiclient.ws.ConsistencyGroupCopyJournal)1 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)1