use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecreateReplicationSetRequestParams method getConsistencyGroupUID.
public ConsistencyGroupUID getConsistencyGroupUID() {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(cgID);
return cgUID;
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method createCGBookmarks.
/**
* Create bookmarks for a CG
*
* @param impl - RP handle to use for RP operations
* @param rpCGMap - The mapping of RP CGs to WWNs. Used to create a list of CGs to bookmark
* @param request - Information about the bookmark to request
*
* @return CreateBookmarkResponse - Results of the create bookmark.
* TODO: Return bookmark information (date/time)
*
* @throws RecoverPointException
*/
public CreateBookmarkResponse createCGBookmarks(FunctionalAPIImpl impl, Map<String, RPConsistencyGroup> rpCGMap, CreateBookmarkRequestParams request) throws RecoverPointException {
Set<ConsistencyGroupUID> uniqueCGUIDSet = new HashSet<ConsistencyGroupUID>();
List<ConsistencyGroupUID> uniqueCGUIDlist = new LinkedList<ConsistencyGroupUID>();
Set<RPConsistencyGroup> rpCGSet = new HashSet<RPConsistencyGroup>();
CreateBookmarkResponse response = new CreateBookmarkResponse();
for (String volume : rpCGMap.keySet()) {
RPConsistencyGroup rpCG = rpCGMap.get(volume);
if (rpCG.getCGUID() != null) {
boolean foundCGUID = false;
ConsistencyGroupUID cguid = rpCG.getCGUID();
for (ConsistencyGroupUID cguidunique : uniqueCGUIDSet) {
if (cguidunique.getId() == cguid.getId()) {
foundCGUID = true;
break;
}
}
if (!foundCGUID) {
logger.info("Adding CG: " + rpCG.getName() + " with ID " + rpCG.getCGUID().getId() + " to unique CGUID list");
uniqueCGUIDSet.add(cguid);
uniqueCGUIDlist.add(cguid);
rpCGSet.add(rpCG);
}
}
}
// Make sure the CG is in a good state before we make bookmarks
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
for (ConsistencyGroupUID cgID : uniqueCGUIDlist) {
// Make sure the CG is ready for enable
imageManager.waitForCGLinkState(impl, cgID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgID), PipeState.PAUSED);
}
try {
impl.createBookmark(uniqueCGUIDlist, request.getBookmark(), BookmarkConsolidationPolicy.NEVER_CONSOLIDATE, SnapshotConsistencyType.APPLICATION_CONSISTENT);
logger.info(String.format("Created RP Bookmark successfully: %s", request.getBookmark()));
response.setCgBookmarkMap(findRPBookmarks(impl, rpCGSet, request));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToCreateBookmarkOnRecoverPoint(e);
}
return response;
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method verifyGroupCopyImageIsEnabled.
/**
* Verify that a group copy image is enabled. Not a "wait for", just a check
*
* @param port - RP handle to use for RP operations
* @param groupCopy - CG copy we are checking
* @param expectLoggedAccess - We are explicitly checking for LOGGED_ACCESS
* @param bookmarkName - A bookmark we are expecting to be enabled (null means don't care)
*
* @return boolean - true (enabled) or false (not enabled)
*
* @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
* InterruptedException
*/
private boolean verifyGroupCopyImageIsEnabled(FunctionalAPIImpl port, ConsistencyGroupCopyUID groupCopy, boolean expectLoggedAccess, String bookmarkName) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, RecoverPointException {
ConsistencyGroupUID groupUID = groupCopy.getGroupUID();
ConsistencyGroupState groupState;
List<ConsistencyGroupCopyState> groupCopyStateList;
groupState = port.getGroupState(groupUID);
groupCopyStateList = groupState.getGroupCopiesStates();
String cgName = port.getGroupName(groupCopy.getGroupUID());
String cgCopyName = port.getGroupCopyName(groupCopy);
boolean isAPITCheck = false;
RecoverPointTimeStamp apitTimeStamp = null;
if (bookmarkName == null) {
// Most "recent"
isAPITCheck = true;
} else {
apitTimeStamp = new RecoverPointTimeStamp();
isAPITCheck = true;
apitTimeStamp.setTimeInMicroSeconds(Long.parseLong(bookmarkName) * numMicroSecondsInMilli);
}
logger.info("verifyGroupCopyImageIsEnabled called for copy " + cgCopyName + " of group " + cgName + " and bookmarkName/APIT: " + bookmarkName);
for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
StorageAccessState accessState = groupCopyState.getStorageAccessState();
if (expectLoggedAccess) {
// Explicitly looking for LOGGED_ACCESS
logger.debug("Seeing if copy is enabled for LOGGED_ACCESS");
if (accessState == StorageAccessState.LOGGED_ACCESS) {
if (!bookmarkName.equals(groupCopyState.getAccessedImage().getDescription())) {
// Enabled, but for a different snapshot image
if (groupCopyState.getAccessedImage().getDescription().length() > 0) {
throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, groupCopyState.getAccessedImage().getDescription());
} else {
Timestamp enabledAPITTime = null;
RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
enabledAPITTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, enabledAPITTime.toString());
}
}
logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " IS enabled in LOGGED_ACCESS");
return true;
} else {
logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is NOT enabled in LOGGED_ACCESS. Image state is: " + accessState.toString());
return false;
}
}
logger.debug("Seeing if copy is enabled for any access mode other than DIRECT_ACCESS or NO_ACCESS");
if (accessState == StorageAccessState.DIRECT_ACCESS) {
logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in direct access mode");
return false;
}
if (accessState == StorageAccessState.NO_ACCESS) {
logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in NO access mode");
return false;
}
if (groupCopyState.getAccessedImage() != null) {
logger.info("Copy image IS enabled. State is: " + accessState.toString() + ". Mounted snapshot name: " + groupCopyState.getAccessedImage().getDescription());
} else {
logger.info("Copy image IS enabled. State is: " + accessState.toString() + ". Enabled image: restore state");
}
// Let's throw if its the wrong image, otherwise return true
if (!isAPITCheck) {
if ((bookmarkName == null) && (groupCopyState.getAccessedImage() == null)) {
return true;
}
if ((bookmarkName != null) && !bookmarkName.equals(groupCopyState.getAccessedImage().getDescription())) {
// Enabled, but for a different snapshot image
if (groupCopyState.getAccessedImage().getDescription().length() > 0) {
throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, groupCopyState.getAccessedImage().getDescription());
} else {
Timestamp enabledAPITTime = null;
RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
enabledAPITTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
throw RecoverPointException.exceptions.wrongSnapshotImageEnabled(bookmarkName, enabledAPITTime.toString());
}
}
return true;
} else {
if (bookmarkName == null) {
return true;
} else {
return isGroupCopyImageEnabledForAPIT(port, groupCopy, expectLoggedAccess, apitTimeStamp);
}
}
}
}
logger.error("Could not locate CG copy state");
return false;
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID 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