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);
}
}
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();
}
Aggregations