Search in sources :

Example 1 with VolumeInformation

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

the class RecoverPointClient method scan.

/**
 * Walk through the journals and source/target volumes to see where the WWNS lie.
 *
 * @param copies
 * @param rSets
 * @return set of discovered RP sites
 */
private Set<RPSite> scan(List<CreateCopyParams> copies, List<CreateRSetParams> rSets) {
    // Setting the MAX_SCAN_WAIT_TOTAL_TRIES = 240
    // so that we loop for a max of 1 hour (240 * 15000 = 1 hour)
    final int MAX_SCAN_WAIT_TOTAL_TRIES = 240;
    final int MAX_SCAN_WAIT_RETRY_MILLISECONDS = 15000;
    int rescanTries = MAX_SCAN_WAIT_TOTAL_TRIES;
    // set to true to stay in the loop
    boolean needsScan = true;
    Set<RPSite> allSites = null;
    while (needsScan && rescanTries-- > 0) {
        // Reset scan flag. If something goes wrong, it'll get set to true.
        needsScan = false;
        if ((MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries) != 1) {
            logger.info("RecoverPointClient: Briefly sleeping to accommodate export group latencies (Attempt #{} / {})", MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries, MAX_SCAN_WAIT_TOTAL_TRIES);
            try {
                Thread.sleep(MAX_SCAN_WAIT_RETRY_MILLISECONDS);
            } catch (InterruptedException e1) {
                Thread.currentThread().interrupt();
            }
        }
        // Rescan the san
        logger.info("RecoverPointClient: Rescanning san volumes for endpoint: " + _endpoint.toASCIIString());
        try {
            functionalAPI.rescanSANVolumesInAllClusters(true);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            logger.warn("Exception in call to rescanSANVolumesInAllSites");
        } catch (FunctionalAPIInternalError_Exception e) {
            logger.warn("Exception in call to rescanSANVolumesInAllSites");
        }
        // Get all of the volumes
        allSites = getAssociatedRPSites();
        // 
        for (CreateCopyParams copy : copies) {
            for (CreateVolumeParams volumeParam : copy.getJournals()) {
                boolean found = false;
                for (RPSite rpSite : allSites) {
                    ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
                    for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
                        if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
                            logger.info("Found site and volume ID for journal: " + volumeParam.getWwn() + " for copy: " + copy.getName());
                            found = true;
                            break;
                        }
                    }
                    if (found) {
                        break;
                    }
                }
                if (!found) {
                    logger.warn(String.format("Could not find volume %s for copy %s and internal site %s on any RP site.  We will likely retry.", volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName()));
                    // set that we still need to scan.
                    needsScan = true;
                    if (rescanTries <= 0) {
                        for (RPSite rpSite : allSites) {
                            logger.error(String.format("Could not find volume %s on any RP site.  Retries exhausted.", volumeParam.getWwn()));
                            ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
                            for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
                                logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
                            }
                        }
                        throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForJournal(volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName());
                    }
                }
            }
        }
        // When adding new journal volumes only no need to look at source and target volumes
        if (rSets == null || rSets.isEmpty()) {
            continue;
        }
        // 
        for (CreateRSetParams rset : rSets) {
            for (CreateVolumeParams volumeParam : rset.getVolumes()) {
                boolean found = false;
                for (RPSite rpSite : allSites) {
                    ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
                    for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
                        if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
                            logger.info(String.format("Found site and volume ID for volume: %s for replication set: %s on site: %s (%s)", volumeParam.getWwn(), rset.getName(), rpSite.getSiteName(), volumeParam.getInternalSiteName()));
                            found = true;
                            break;
                        }
                    }
                    if (found) {
                        break;
                    }
                }
                if (!found) {
                    logger.warn(String.format("Could not find volume %s for internal site %s on any RP site.  We will likely retry.", volumeParam.getWwn(), volumeParam.getInternalSiteName()));
                    // set that we still need to scan
                    needsScan = true;
                    if (rescanTries <= 0) {
                        for (RPSite rpSite : allSites) {
                            logger.error(String.format("Could not find volume %s on any RP site.  Retries exhausted.", volumeParam.getWwn()));
                            ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
                            for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
                                logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
                            }
                        }
                        throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForVolume(volumeParam.getWwn(), rset.getName(), volumeParam.getInternalSiteName());
                    }
                }
            }
        }
    }
    return allSites;
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) ClusterSANVolumes(com.emc.fapiclient.ws.ClusterSANVolumes) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) VolumeInformation(com.emc.fapiclient.ws.VolumeInformation)

Aggregations

ClusterSANVolumes (com.emc.fapiclient.ws.ClusterSANVolumes)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 VolumeInformation (com.emc.fapiclient.ws.VolumeInformation)1 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)1 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)1 CreateRSetParams (com.emc.storageos.recoverpoint.requests.CreateRSetParams)1 CreateVolumeParams (com.emc.storageos.recoverpoint.requests.CreateVolumeParams)1