use of com.emc.storageos.recoverpoint.requests.CreateRSetParams in project coprhd-controller by CoprHD.
the class RecoverPointClient method addCopyToCG.
/**
* adds one copy to an existing CG
*
* @param cgUID CG uid where new copy should be added
* @param allSites list of sites that see journal and copy file WWN's
* @param copyParams the copy to be added
* @param rSets replication set to which the user volumes have to be added
* @param copyType either production, local or remote
* @param linkSettings for the copy being added
* @param copyUid of the copy being added
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIValidationException_Exception
*/
private void addCopyToCG(ConsistencyGroupUID cgUID, Set<RPSite> allSites, CreateCopyParams copyParams, List<CreateRSetParams> rSets, RecoverPointCGCopyType copyType, List<ConsistencyGroupLinkSettings> linkSettings, ConsistencyGroupCopyUID copyUid) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
boolean isProduction = copyType == RecoverPointCGCopyType.PRODUCTION;
String copyTypeStr = copyType.toString();
logger.info(String.format("Adding new copy %s to cg", copyParams.getName()));
ConsistencyGroupCopySettingsParam copySettingsParam = new ConsistencyGroupCopySettingsParam();
copySettingsParam.setCopyName(copyParams.getName());
copySettingsParam.setCopyPolicy(null);
copySettingsParam.setEnabled(false);
copySettingsParam.setGroupCopy(copyUid);
copySettingsParam.setProductionCopy(isProduction);
copySettingsParam.setTransferEnabled(false);
copySettingsParam.getGroupLinksSettings().addAll(linkSettings);
// we can't call validateAddConsistencyGroupCopy here because during a swap operation, it throws an exception
// which is just a warning that a full sweep will be required. There didn't seem to be a way to catch
// just the warning and let other errors propagate as errors.
logger.info(String.format("Add Production copy %s (no validation): ", copyParams.getName(), copyParams.toString()));
functionalAPI.addConsistencyGroupCopy(copySettingsParam);
// add journals
for (CreateVolumeParams journalVolume : copyParams.getJournals()) {
logger.info(String.format("Adding Journal for Production copy %s : %s", copyParams.getName(), journalVolume.toString()));
functionalAPI.addJournalVolume(copyUid, RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
}
if (rSets != null) {
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgUID);
// Keep track of volumes added so we don't add the same one again. Prevents an exception from being thrown.
List<String> volumesAdded = new ArrayList<String>();
for (CreateRSetParams rSet : rSets) {
ReplicationSetUID rSetUid = null;
if (rSet != null && rSet.getName() != null && !rSet.getName().isEmpty()) {
for (ReplicationSetSettings rSetSetting : groupSettings.getReplicationSetsSettings()) {
if (rSetSetting.getReplicationSetName().equalsIgnoreCase(rSet.getName())) {
rSetUid = rSetSetting.getReplicationSetUID();
break;
}
}
}
if (rSetUid != null) {
for (CreateVolumeParams volume : rSet.getVolumes()) {
if ((isProduction && volume.isProduction()) || (!isProduction && !volume.isProduction()) && !volumesAdded.contains(volume.getWwn())) {
logger.info(String.format("Adding %s copy volume : %s", copyTypeStr, volume.toString()));
functionalAPI.addUserVolume(copyUid, rSetUid, RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
volumesAdded.add(volume.getWwn());
}
}
}
}
}
}
use of com.emc.storageos.recoverpoint.requests.CreateRSetParams 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;
}
use of com.emc.storageos.recoverpoint.requests.CreateRSetParams in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method createCGParamsHelper.
public CGRequestParams createCGParamsHelper(boolean createCDP, boolean createCRR, int numRSets) {
CGRequestParams params = new CGRequestParams();
params.setJunitTest(true);
if (createCDP && createCRR) {
params.setCgName("BourneRPTestCDPAndCRR");
logger.info("Create CG for CDP and CRR: BourneRPTestCDPAndCRR");
} else if (createCDP) {
params.setCgName("BourneRPTestCDPOnly");
logger.info("Create CG for CDP: BourneRPTestCDPOnly");
} else {
params.setCgName("BourneRPTestCRROnly");
logger.info("Create CG for CRR: BourneRPTestCRROnly");
}
List<CreateRSetParams> rsetParamList = new LinkedList<CreateRSetParams>();
// Production copy (VNX: 10.247.160.30)
CreateVolumeParams copyprodVolumeParams = new CreateVolumeParams();
copyprodVolumeParams.setWwn(BourneRPTestProdLUN1WWN);
copyprodVolumeParams.setInternalSiteName(site1InternalSiteName);
copyprodVolumeParams.setProduction(true);
List<CreateVolumeParams> rsetVolumeList = new ArrayList<CreateVolumeParams>();
rsetVolumeList.add(copyprodVolumeParams);
if (createCDP) {
CreateVolumeParams copylocalVolumeParams = new CreateVolumeParams();
copylocalVolumeParams.setWwn(BourneRPTestCDPLUN1WWN);
copylocalVolumeParams.setInternalSiteName(site1InternalSiteName);
copylocalVolumeParams.setProduction(false);
rsetVolumeList.add(copylocalVolumeParams);
}
if (createCRR) {
CreateVolumeParams copyremoteVolumeParams = new CreateVolumeParams();
copyremoteVolumeParams.setWwn(BourneRPTestCRRLUN1WWN);
copyremoteVolumeParams.setInternalSiteName(site2InternalSiteName);
copyremoteVolumeParams.setProduction(false);
rsetVolumeList.add(copyremoteVolumeParams);
}
CreateRSetParams rset = new CreateRSetParams();
rset.setName("RSet1");
rset.setVolumes(rsetVolumeList);
rsetParamList.add(rset);
// Replication set 2
if (numRSets > 1) {
CreateVolumeParams r2copyprodVolumeParams = new CreateVolumeParams();
r2copyprodVolumeParams.setWwn(BourneRPTestProdLUN2WWN);
r2copyprodVolumeParams.setInternalSiteName(site1InternalSiteName);
r2copyprodVolumeParams.setProduction(true);
rsetVolumeList = new ArrayList<CreateVolumeParams>();
rsetVolumeList.add(r2copyprodVolumeParams);
if (createCDP) {
CreateVolumeParams r2copylocalVolumeParams = new CreateVolumeParams();
r2copylocalVolumeParams = new CreateVolumeParams();
r2copylocalVolumeParams.setWwn(BourneRPTestCDPLUN2WWN);
r2copylocalVolumeParams.setInternalSiteName(site1InternalSiteName);
r2copylocalVolumeParams.setProduction(false);
rsetVolumeList.add(r2copylocalVolumeParams);
}
if (createCRR) {
CreateVolumeParams r2copyremoteVolumeParams = new CreateVolumeParams();
r2copyremoteVolumeParams = new CreateVolumeParams();
r2copyremoteVolumeParams.setWwn(BourneRPTestCRRLUN2WWN);
r2copyremoteVolumeParams.setInternalSiteName(site2InternalSiteName);
r2copyremoteVolumeParams.setProduction(false);
rsetVolumeList.add(r2copyremoteVolumeParams);
}
rset = new CreateRSetParams();
rset.setName("RSet2");
rset.setVolumes(rsetVolumeList);
rsetParamList.add(rset);
}
params.setRsets(rsetParamList);
CreateCopyParams prodCopyParams = new CreateCopyParams();
CreateCopyParams localCopyParams = new CreateCopyParams();
CreateCopyParams remoteCopyParams = new CreateCopyParams();
CreateVolumeParams prodJournalParams = new CreateVolumeParams();
prodJournalParams.setWwn(BourneRPTestJrnlLUN1WWN);
prodJournalParams.setInternalSiteName(site1InternalSiteName);
// necessary for now
prodJournalParams.setProduction(true);
List<CreateVolumeParams> prodJournalVolumeList = new ArrayList<CreateVolumeParams>();
prodJournalVolumeList.add(prodJournalParams);
if (isSymmDevices) {
// extra jrnl for symm
CreateVolumeParams prodJournalParams2 = new CreateVolumeParams();
prodJournalParams2.setWwn(BourneRPTestJrnlLUN3WWN);
prodJournalParams2.setInternalSiteName(site1InternalSiteName);
prodJournalParams2.setProduction(true);
prodJournalVolumeList.add(prodJournalParams2);
}
prodCopyParams.setName("production");
prodCopyParams.setJournals(prodJournalVolumeList);
List<CreateCopyParams> copyList = new ArrayList<CreateCopyParams>();
copyList.add(prodCopyParams);
if (createCDP) {
CreateVolumeParams localJournalParams = new CreateVolumeParams();
localJournalParams.setWwn(BourneRPTestJrnlLUN2WWN);
localJournalParams.setInternalSiteName(site1InternalSiteName);
localJournalParams.setProduction(false);
List<CreateVolumeParams> localJournalVolumeList = new ArrayList<CreateVolumeParams>();
localJournalVolumeList.add(localJournalParams);
if (isSymmDevices) {
// extra jrnl for symm
CreateVolumeParams localJournalParams2 = new CreateVolumeParams();
localJournalParams2.setWwn(BourneRPTestJrnlLUN4WWN);
localJournalParams2.setInternalSiteName(site1InternalSiteName);
localJournalParams2.setProduction(false);
localJournalVolumeList.add(localJournalParams2);
}
//
localCopyParams.setName("local");
localCopyParams.setJournals(localJournalVolumeList);
copyList.add(localCopyParams);
}
if (createCRR) {
CreateVolumeParams remoteJournalParams = new CreateVolumeParams();
remoteJournalParams.setWwn(BourneRPTestJrnlLUN5WWN);
remoteJournalParams.setInternalSiteName(site2InternalSiteName);
remoteJournalParams.setProduction(false);
List<CreateVolumeParams> remoteJournalVolumeList = new ArrayList<CreateVolumeParams>();
remoteJournalVolumeList.add(remoteJournalParams);
if (isSymmDevices) {
// extra jrnl for symm
CreateVolumeParams remoteJournalParams2 = new CreateVolumeParams();
remoteJournalParams2.setWwn(BourneRPTestJrnlLUN6WWN);
remoteJournalParams2.setInternalSiteName(site2InternalSiteName);
remoteJournalParams2.setProduction(false);
remoteJournalVolumeList.add(remoteJournalParams2);
}
remoteCopyParams.setName("remote");
remoteCopyParams.setJournals(remoteJournalVolumeList);
copyList.add(remoteCopyParams);
}
params.setCopies(copyList);
logger.info(params.toString());
return params;
}
use of com.emc.storageos.recoverpoint.requests.CreateRSetParams in project coprhd-controller by CoprHD.
the class RPDeviceController method getCGRequestParams.
/**
* Create the RP Client consistency group request object based on the incoming prepared volumes.
*
* @param volumeDescriptors
* volume descriptor objects
* @param rpSystem
* @return RP request to create CG
* @throws DatabaseException
*/
private CGRequestParams getCGRequestParams(List<VolumeDescriptor> volumeDescriptors, ProtectionSystem rpSystem) throws DatabaseException {
_log.info("Creating CG Request param...");
// Maps of replication set request objects, where the key is the rset name itself
Map<String, CreateRSetParams> rsetParamsMap = new HashMap<String, CreateRSetParams>();
// Maps of the copy request objects, where the key is the copy name itself
Map<String, CreateCopyParams> copyParamsMap = new HashMap<String, CreateCopyParams>();
// The parameters we need at the CG Level that we can only get from looking at the Volumes
Project project = null;
String cgName = null;
Set<String> productionCopies = new HashSet<String>();
BlockConsistencyGroup cg = null;
String copyMode = null;
String rpoType = null;
Long rpoValue = null;
int maxNumberOfSnapShots = 0;
Map<URI, Volume> volumeMap = new HashMap<URI, Volume>();
// Sort the volume descriptors using the natural order of the enum.
// In this case sort as:
// SOURCE, TARGET, JOURNAL
// We want SOURCE volumes to be processed first below to populate the
// productionCopies in order.
VolumeDescriptor.sortByType(volumeDescriptors);
// Next create all of the request objects we need
for (VolumeDescriptor volumeDescriptor : volumeDescriptors) {
Volume volume = null;
if (volumeMap.containsKey(volumeDescriptor.getVolumeURI())) {
volume = volumeMap.get(volumeDescriptor.getVolumeURI());
} else {
volume = _dbClient.queryObject(Volume.class, volumeDescriptor.getVolumeURI());
volumeMap.put(volume.getId(), volume);
}
boolean isMetroPoint = RPHelper.isMetroPointVolume(_dbClient, volume);
boolean isRPSource = RPHelper.isRPSource(volumeDescriptor);
boolean isRPTarget = RPHelper.isRPTarget(volumeDescriptor);
boolean extraParamsGathered = false;
if (volumeDescriptor.getCapabilitiesValues() != null) {
maxNumberOfSnapShots = volumeDescriptor.getCapabilitiesValues().getRPMaxSnaps();
}
// Set up the source and target volumes in their respective replication sets
if (isRPSource || isRPTarget) {
// Gather the extra params we need (once is sufficient)
if (isRPSource && !extraParamsGathered) {
project = _dbClient.queryObject(Project.class, volume.getProject());
cg = _dbClient.queryObject(BlockConsistencyGroup.class, volumeDescriptor.getCapabilitiesValues().getBlockConsistencyGroup());
cgName = cg.getCgNameOnStorageSystem(rpSystem.getId());
if (cgName == null) {
cgName = CG_NAME_PREFIX + cg.getLabel();
}
copyMode = volumeDescriptor.getCapabilitiesValues().getRpCopyMode();
rpoType = volumeDescriptor.getCapabilitiesValues().getRpRpoType();
rpoValue = volumeDescriptor.getCapabilitiesValues().getRpRpoValue();
// Flag so we only grab this information once
extraParamsGathered = true;
}
if (isMetroPoint && isRPSource) {
// we need to handle metropoint request a bit differently.
// since the same metro volume will be part of 2 (production) copies in the replication set,
// we need to fetch the correct internal site names and other site related parameters from the
// backing volume.
StringSet backingVolumes = volume.getAssociatedVolumes();
if (null == backingVolumes || backingVolumes.isEmpty()) {
_log.error("VPLEX volume {} has no backend volumes.", volume.forDisplay());
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(volume.forDisplay());
}
for (String backingVolumeStr : backingVolumes) {
Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backingVolumeStr));
CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), backingVolume.getVirtualArray(), backingVolume.getInternalSiteName(), true, backingVolume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
_log.info(String.format("Creating RSet Param for MetroPoint RP PROD - VOLUME: [%s] Name: [%s]", backingVolume.getLabel(), volume.getRSetName()));
populateRsetsMap(rsetParamsMap, volumeParams, volume);
productionCopies.add(backingVolume.getRpCopyName());
}
} else {
CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), volume.getVirtualArray(), volume.getInternalSiteName(), isRPSource, volume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
String type = isRPSource ? "PROD" : "TARGET";
_log.info(String.format("Creating RSet Param for RP %s - VOLUME: [%s] Name: [%s]", type, volume.getLabel(), volume.getRSetName()));
populateRsetsMap(rsetParamsMap, volumeParams, volume);
if (isRPSource) {
productionCopies.add(volume.getRpCopyName());
}
}
}
// Set up the journal volumes in the copy objects
if (volumeDescriptor.getType().equals(VolumeDescriptor.Type.RP_JOURNAL) || volumeDescriptor.getType().equals(VolumeDescriptor.Type.RP_VPLEX_VIRT_JOURNAL)) {
if (cgName == null) {
project = _dbClient.queryObject(Project.class, volume.getProject());
cg = _dbClient.queryObject(BlockConsistencyGroup.class, volumeDescriptor.getCapabilitiesValues().getBlockConsistencyGroup());
cgName = cg.getCgNameOnStorageSystem(rpSystem.getId());
if (cgName == null) {
cgName = CG_NAME_PREFIX + cg.getLabel();
}
}
CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), volume.getVirtualArray(), volume.getInternalSiteName(), RPHelper.isProductionJournal(productionCopies, volume), volume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
String key = volume.getRpCopyName();
_log.info(String.format("Creating Copy Param for RP JOURNAL: VOLUME - [%s] Name: [%s]", volume.getLabel(), key));
if (copyParamsMap.containsKey(key)) {
copyParamsMap.get(key).getJournals().add(volumeParams);
} else {
CreateCopyParams copyParams = new CreateCopyParams();
copyParams.setName(key);
copyParams.setJournals(new ArrayList<CreateVolumeParams>());
copyParams.getJournals().add(volumeParams);
copyParamsMap.put(key, copyParams);
}
}
}
// Set up the CG Request
CGRequestParams cgParams = new CGRequestParams();
cgParams.setCopies(new ArrayList<CreateCopyParams>());
cgParams.getCopies().addAll(copyParamsMap.values());
cgParams.setRsets(new ArrayList<CreateRSetParams>());
cgParams.getRsets().addAll(rsetParamsMap.values());
cgParams.setCgName(cgName);
cgParams.setCgUri(cg.getId());
cgParams.setProject(project.getId());
cgParams.setTenant(project.getTenantOrg().getURI());
CGPolicyParams policyParams = new CGPolicyParams();
policyParams.setCopyMode(copyMode);
policyParams.setRpoType(rpoType);
policyParams.setRpoValue(rpoValue);
cgParams.setCgPolicy(policyParams);
_log.info(String.format("CG Request param complete:%n %s", cgParams));
return cgParams;
}
use of com.emc.storageos.recoverpoint.requests.CreateRSetParams in project coprhd-controller by CoprHD.
the class RPDeviceController method waitForCGToBeCreated.
/**
* If the RP CG hasn't been created yet and the current request does not have
* the journal information, then wait. The request can not proceed without
* journals.
*
* Waiting forever is not an option and eventually this will timeout to allow the
* request to go through. If that is the case, an exception could be thrown by RP
* for a request to add replication sets to a new CG without journals.
*
* @param cgId ID of the RP CG being used
* @param cgParams The current request params
*/
private void waitForCGToBeCreated(URI cgId, CGRequestParams cgParams) {
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
// and at least one of those requests has the journals defined.
if (!cg.created() && CollectionUtils.isEmpty(cgParams.getCopies())) {
// Get the names of the RSets to be added - used for
// meaningful log messages.
StringBuffer rsetNames = new StringBuffer();
Iterator<CreateRSetParams> rsetIter = cgParams.getRsets().iterator();
while (rsetIter.hasNext()) {
CreateRSetParams rsetParam = rsetIter.next();
rsetNames.append(rsetParam.getName());
rsetNames.append(", ");
}
rsetNames.delete(rsetNames.length() - 2, rsetNames.length());
// Now, let the waiting begin...
int waitingOnCGCreate = 0;
while (!cg.created() && (waitingOnCGCreate < MAX_ATTEMPTS_TO_WAIT_FOR_CG_CREATE)) {
_log.info(String.format("RP CG [%s] has not been created yet. Wait to add replication set(s) [%s], " + "sleeping for %s seconds.", cgParams.getCgName(), rsetNames.toString(), SECONDS_TO_WAIT_FOR_CG_CREATE));
try {
Thread.sleep(SECONDS_TO_WAIT_FOR_CG_CREATE * 1000);
} catch (InterruptedException e) {
_log.error(e.getMessage());
}
waitingOnCGCreate++;
// Reload the CG to see if it has been updated
cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
}
if (waitingOnCGCreate >= MAX_ATTEMPTS_TO_WAIT_FOR_CG_CREATE) {
_log.warn(String.format("Maximum wait has been reached while waiting for RP CG [%s] to be created. " + "Releasing request to add replication set(s) [%s]. The request may potentially fail.", cgParams.getCgName(), rsetNames.toString()));
} else {
_log.info(String.format("RP CG [%s] created. Releasing request to add replication set(s) [%s].", cgParams.getCgName(), rsetNames.toString()));
}
}
}
Aggregations