Search in sources :

Example 11 with ConsistencyGroupCopyState

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

Example 12 with ConsistencyGroupCopyState

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

the class RecoverPointImageManagementUtils method waitForCGCopyState.

/**
 * Wait for a CG copy to change state
 *
 * @param impl - the FAPI implementation
 * @param groupCopy - RP group copy we are looking at
 * @param accessState - Access modes we are waiting for
 *
 * @return void
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
public void waitForCGCopyState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID groupCopy, StorageAccessState accessState) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, InterruptedException, RecoverPointException {
    if (accessState == null) {
        throw RecoverPointException.exceptions.waitForInvalidCopyState("null");
    }
    ConsistencyGroupUID groupUID = groupCopy.getGroupUID();
    List<ConsistencyGroupCopyState> groupCopyStateList;
    String cgName = impl.getGroupName(groupCopy.getGroupUID());
    String cgCopyName = impl.getGroupCopyName(groupCopy);
    final int maxMinutes = 30;
    // seconds
    final int sleepTimeSeconds = 15;
    final int secondsPerMin = 60;
    final int numItersPerMin = secondsPerMin / sleepTimeSeconds;
    logger.info(String.format("Waiting up to %d minutes for consistency group copy state to change to %s.  Copy name: %s, consistency group name: %s.", maxMinutes, accessState.toString(), cgCopyName, cgName));
    for (int minIter = 0; minIter < maxMinutes; minIter++) {
        for (int perMinIter = 0; perMinIter < numItersPerMin; perMinIter++) {
            groupCopyStateList = impl.getGroupState(groupUID).getGroupCopiesStates();
            for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
                if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
                    StorageAccessState copyAccessState = groupCopyState.getStorageAccessState();
                    logger.info("Current Copy Access State: " + copyAccessState);
                    if (copyAccessState.equals(accessState)) {
                        logger.info(String.format("Copy %s of group %s is in %s state.", cgCopyName, cgName, copyAccessState.toString()));
                        return;
                    }
                }
            }
            logger.info("Copy image " + cgCopyName + " of group " + cgName + " not in correct state.  Sleeping " + sleepTimeSeconds + " seconds");
            try {
                Thread.sleep(Long.valueOf(sleepTimeSeconds * numMillisInSecond));
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
    throw RecoverPointException.exceptions.stateChangeNeverCompleted();
}
Also used : ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState)

Aggregations

ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)12 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)6 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)6 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)6 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)6 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)5 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)3 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)2 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)2 RecoverPointTimeStamp (com.emc.fapiclient.ws.RecoverPointTimeStamp)2 Timestamp (java.sql.Timestamp)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 ImageAccessMode (com.emc.fapiclient.ws.ImageAccessMode)1