Search in sources :

Example 6 with StorageAccessState

use of com.emc.fapiclient.ws.StorageAccessState 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)6 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)6 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)4 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)2 RecoverPointTimeStamp (com.emc.fapiclient.ws.RecoverPointTimeStamp)2 Timestamp (java.sql.Timestamp)2 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)1 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 ImageAccessMode (com.emc.fapiclient.ws.ImageAccessMode)1 Snapshot (com.emc.fapiclient.ws.Snapshot)1 TimeFrame (com.emc.fapiclient.ws.TimeFrame)1 RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)1 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1