Search in sources :

Example 1 with ConsistencyGroupState

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

the class RecoverPointClient method doesStandbyProdCopyExist.

/**
 * Determines if the consistency group associated with the volume protection info contains
 * a standby production copy.
 *
 * @param volume the volume protection information
 * @return true if the standby production copy exists, false otherwise
 */
public boolean doesStandbyProdCopyExist(RecoverPointVolumeProtectionInfo volume) {
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        if (standbyProdCopy != null) {
            String standbyProdCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
            logger.info(String.format("Determined that standby production copy %s exists in CG %s.", standbyProdCopyName, volume.getRpProtectionName()));
            return true;
        }
        logger.info(String.format("Determined that no standby production copy exists in CG %s.", volume.getRpProtectionName()));
        return false;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 2 with ConsistencyGroupState

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

the class RecoverPointImageManagementUtils method getCopyState.

/**
 * Verify that a copy is capable of being enabled.
 *
 * @param impl - RP handle
 * @param copyId - CG Copy, contains CG
 * @param cgCopyName - copy name
 * @param cgName - CG name
 * @throws RecoverPointException
 */
public ConsistencyGroupCopyState getCopyState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyId, String cgCopyName, String cgName) throws RecoverPointException {
    try {
        ConsistencyGroupUID groupUID = copyId.getGroupUID();
        ConsistencyGroupState groupState;
        List<ConsistencyGroupCopyState> cgCopyStateList;
        groupState = impl.getGroupState(groupUID);
        cgCopyStateList = groupState.getGroupCopiesStates();
        for (ConsistencyGroupCopyState cgCopyState : cgCopyStateList) {
            if (RecoverPointUtils.copiesEqual(cgCopyState.getCopyUID(), copyId)) {
                return cgCopyState;
            }
        }
        return null;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 3 with ConsistencyGroupState

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

the class RecoverPointImageManagementUtils method isGroupCopyImageEnabledForAPIT.

/**
 * Verify that a group copy image is enabled for an APIT time. 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 apitTime - An APIT time we are expecting to be enabled)
 *
 * @return boolean - true (enabled) or false (not enabled)
 *
 * @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
 *             InterruptedException
 */
private boolean isGroupCopyImageEnabledForAPIT(FunctionalAPIImpl port, ConsistencyGroupCopyUID groupCopy, boolean expectLoggedAccess, RecoverPointTimeStamp apitTime) 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);
    Timestamp enabledApitTime = null;
    // logger.debug ("isGroupCopyImageEnabledForAPIT called for copy " + cgCopyName + " of group " + cgName);
    for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
        if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
            StorageAccessState accessState = groupCopyState.getStorageAccessState();
            if (accessState == StorageAccessState.DIRECT_ACCESS) {
                // Not enabled
                logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in direct access mode.");
                return false;
            }
            if (accessState == StorageAccessState.NO_ACCESS) {
                // Not enabled
                logger.info("Copy image copy " + cgCopyName + " of group " + cgName + " is in NO access mode.");
                return false;
            }
            // Enabled. Check out the details
            logger.info("Copy image copy " + cgCopyName + " of group " + cgName + "  IS enabled. State is: " + accessState.toString());
            if (groupCopyState.getAccessedImage().getDescription().isEmpty()) {
                RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
                enabledApitTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
                logger.debug("No name. Mounted snapshot timestamp: " + enabledApitTime.toString());
            } else {
                // Unexpected, this is
                throw RecoverPointException.exceptions.expectingAPITMountFoundBookmark(groupCopyState.getAccessedImage().getDescription());
            }
            // Let's throw if its the wrong image
            if (apitTime != null) {
                // 
                // See if the time enabled is exactly the time we requested (regardless of whether it is
                // system generated, or AppSync generated.
                // 
                RecoverPointTimeStamp enabledTime = groupCopyState.getAccessedImage().getClosingTimeStamp();
                // Give it a 60 second variation
                if (Math.abs(enabledTime.getTimeInMicroSeconds() - apitTime.getTimeInMicroSeconds()) < (numMicroSecondsInSecond * 60)) {
                    // 
                    if (expectLoggedAccess) {
                        logger.debug("Seeing if copy is enabled for LOGGED_ACCESS");
                        if (accessState == StorageAccessState.LOGGED_ACCESS) {
                            logger.info("Copy image copy " + cgCopyName + " of group " + cgName + "  IS enabled in LOGGED_ACCESS");
                            return true;
                        }
                        logger.info("Copy image copy " + cgCopyName + " of group " + cgName + "  is NOT enabled in LOGGED_ACCESS. Image state is: " + accessState.toString());
                        return false;
                    } else {
                        logger.debug("APIT enabled for same time requested");
                        return true;
                    }
                }
                // 
                // It IS possible that an APIT image is not quite exactly the same time requested, but it is "close enough"
                // How do we tell? Well, we get the list of system snaps + or - 5 minutes from requested time, see if the one before the
                // requested APIT time is the one we are looking for. Limit the snaps we look at to 1 hour before/after requested APIT
                // time
                // 
                final Long timeDeviationInMicroSeconds = Long.valueOf(5 * 60 * numMicroSecondsInMilli * numMillisInSecond);
                TimeFrame window = new TimeFrame();
                RecoverPointTimeStamp endTime = new RecoverPointTimeStamp();
                RecoverPointTimeStamp startTime = new RecoverPointTimeStamp();
                RecoverPointTimeStamp prevSnapTime = null;
                // RecoverPointTimeStamp now = new RecoverPointTimeStamp();
                // now.setTimeInMicroSeconds (System.currentTimeMillis() * numMicroSecondsInMilli );
                // endTime.setTimeInMicroSeconds(now.getTimeInMicroSeconds() + timeDeviationInMicroSeconds);
                // startTime.setTimeInMicroSeconds(now.getTimeInMicroSeconds() - timeDeviationInMicroSeconds);
                endTime.setTimeInMicroSeconds(apitTime.getTimeInMicroSeconds() + timeDeviationInMicroSeconds);
                startTime.setTimeInMicroSeconds(apitTime.getTimeInMicroSeconds() - timeDeviationInMicroSeconds);
                window.setStartTime(startTime);
                window.setEndTime(endTime);
                // + " snapshots in the timeframe");
                for (Snapshot snapItem : port.getGroupCopySnapshotsForTimeFrameAndName(groupCopy, window, null).getSnapshots()) {
                    // logger.info("Checking snap with time: " + apitTimeStr.toString());
                    if (prevSnapTime == null) {
                        prevSnapTime = snapItem.getClosingTimeStamp();
                    } else {
                        if (prevSnapTime.getTimeInMicroSeconds() < snapItem.getClosingTimeStamp().getTimeInMicroSeconds()) {
                            prevSnapTime = snapItem.getClosingTimeStamp();
                        }
                    }
                }
                if (prevSnapTime != null) {
                    RecoverPointTimeStamp enabledTimeDisplay = groupCopyState.getAccessedImage().getClosingTimeStamp();
                    enabledApitTime = new Timestamp(enabledTimeDisplay.getTimeInMicroSeconds() / numMicroSecondsInMilli);
                    logger.debug("Previous snap time is : " + enabledApitTime.toString());
                    if (Math.abs(enabledTime.getTimeInMicroSeconds() - prevSnapTime.getTimeInMicroSeconds()) < numMicroSecondsInSecond) {
                        logger.debug("Currently enabled image is requested snap!");
                        if (expectLoggedAccess) {
                            logger.debug("Seeing if copy is enabled for LOGGED_ACCESS");
                            if (accessState == StorageAccessState.LOGGED_ACCESS) {
                                logger.info("Copy image copy " + cgCopyName + " of group " + cgName + "  IS enabled in LOGGED_ACCESS");
                                return true;
                            }
                            logger.info("Copy image copy " + cgCopyName + " of group " + cgName + "  is NOT enabled in LOGGED_ACCESS. Image state is: " + accessState.toString());
                            return false;
                        } else {
                            return true;
                        }
                    } else {
                        throw RecoverPointException.exceptions.wrongTimestampEnabled(enabledApitTime);
                    }
                }
            } else {
                return false;
            }
        }
    }
    logger.error("Could not locate CG copy state");
    return false;
}
Also used : TimeFrame(com.emc.fapiclient.ws.TimeFrame) RecoverPointTimeStamp(com.emc.fapiclient.ws.RecoverPointTimeStamp) Snapshot(com.emc.fapiclient.ws.Snapshot) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) StorageAccessState(com.emc.fapiclient.ws.StorageAccessState) Timestamp(java.sql.Timestamp) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 4 with ConsistencyGroupState

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

the class RecoverPointImageManagementUtils method getCopyLinkState.

/**
 * Get the link state of a copy
 *
 * @param impl - RP handle
 * @param cgCopy - CG Copy, contains CG
 * @throws RecoverPointException
 */
public ConsistencyGroupLinkState getCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID cgCopy) throws RecoverPointException {
    String cgCopyName = NAME_UNKNOWN;
    String cgName = NAME_UNKNOWN;
    try {
        cgCopyName = impl.getGroupCopyName(cgCopy);
        cgName = impl.getGroupName(cgCopy.getGroupUID());
        ConsistencyGroupUID groupUID = cgCopy.getGroupUID();
        ConsistencyGroupState groupState = impl.getGroupState(groupUID);
        List<ConsistencyGroupLinkState> linkStates = groupState.getLinksStates();
        for (ConsistencyGroupLinkState cgLinkState : linkStates) {
            if ((RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getSecondCopy(), cgCopy.getGlobalCopyUID()) || (RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getFirstCopy(), cgCopy.getGlobalCopyUID())))) {
                return cgLinkState;
            }
        }
        return null;
    } 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) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState)

Example 5 with ConsistencyGroupState

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

the class RecoverPointClient method getProtectionInfoForVolume.

/**
 * The getProtectionInfoForVolume method takes the WWN, and looks for it in the RP site protection environment.
 * If it finds the WWN as a member of a consistency group, it fills in the information, and returns it to the caller.
 * If it does not find the WWN as a member of a consistency group, it returns null
 *
 * @param String volumeWWN - The WWN being checked for RecoverPoint protection
 *
 * @return RecoverPointVolumeProtectionInfo - description of protection information about the WWN, or null if not protected in CG
 *
 * @throws RecoverPointException
 */
public RecoverPointVolumeProtectionInfo getProtectionInfoForVolume(String volumeWWN) throws RecoverPointException {
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    try {
        // logger.info("getProtectionInfoForVolume called for: " + volumeWWN);
        protectionInfo = new RecoverPointVolumeProtectionInfo();
        List<ConsistencyGroupSettings> cgsSettings = functionalAPI.getAllGroupsSettings();
        for (ConsistencyGroupSettings cgSettings : cgsSettings) {
            // See if it is a production source, or an RP target
            for (ReplicationSetSettings rsSettings : cgSettings.getReplicationSetsSettings()) {
                for (UserVolumeSettings uvSettings : rsSettings.getVolumes()) {
                    if (matchesVolumeWWN(uvSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = uvSettings.getGroupCopyUID().getGroupUID();
                        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(uvSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(uvSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpCopyName(cgCopyName);
                        protectionInfo.setRpSiteName(getRecoverPointClusterName(uvSettings.getClusterUID()));
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(uvSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeRSetID(rsSettings.getReplicationSetUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(uvSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            if (RecoverPointUtils.isStandbyProductionCopy(uvSettings.getGroupCopyUID(), state, productionCopiesUIDs)) {
                                // In the case of MetroPoint, we will have 2 production copies for the same volume (active and standby).
                                // We want to always match on the active production copy. If this is a MetroPoint CG, skip over the
                                // standby production copy.
                                logger.info(String.format("Found production volume %s on copy %s.  Skipping because it is not the active production copy.", volumeWWN, cgCopyName));
                                continue;
                            }
                            logger.info("Production volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE);
                        } else {
                            logger.info("Target volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET);
                        }
                        return protectionInfo;
                    }
                }
            }
            // See if it is a journal volume
            for (ConsistencyGroupCopySettings cgCopySettings : cgSettings.getGroupCopiesSettings()) {
                ConsistencyGroupCopyJournal cgJournal = cgCopySettings.getJournal();
                List<JournalVolumeSettings> journalVolumeSettingsList = cgJournal.getJournalVolumes();
                for (JournalVolumeSettings journalVolumeSettings : journalVolumeSettingsList) {
                    if (matchesVolumeWWN(journalVolumeSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = journalVolumeSettings.getGroupCopyUID().getGroupUID();
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(journalVolumeSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(journalVolumeSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(journalVolumeSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(journalVolumeSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            logger.info("Production journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.SOURCE_JOURNAL);
                        } else {
                            logger.info("Target journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.TARGET_JOURNAL);
                        }
                        return protectionInfo;
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    }
    throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN);
}
Also used : JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupCopyJournal(com.emc.fapiclient.ws.ConsistencyGroupCopyJournal) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

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