use of com.emc.fapiclient.ws.ConsistencyGroupLinkUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method prepareLinkSettings.
/**
* Prepares the link settings between the new production copy and all other copies.
*
* @param newProductionCopyUID the failover/new production copy
* @throws RecoverPointException
*/
private void prepareLinkSettings(ConsistencyGroupCopyUID newProductionCopyUID) throws RecoverPointException {
logger.info("Preparing link settings between new production copy and local/remote copies after failover.");
String cgName = null;
String newProductionCopyName = null;
try {
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(newProductionCopyUID.getGroupUID());
List<ConsistencyGroupLinkSettings> cgLinkSettings = groupSettings.getActiveLinksSettings();
List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
newProductionCopyName = functionalAPI.getGroupCopyName(newProductionCopyUID);
cgName = functionalAPI.getGroupName(newProductionCopyUID.getGroupUID());
// Go through the existing production copies
for (ConsistencyGroupCopyUID existingProductionCopyUID : productionCopiesUIDs) {
List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
ConsistencyGroupLinkSettings linkSettings = null;
for (ConsistencyGroupCopySettings copySetting : copySettings) {
// are identified by not being the existing production copy or the new production copy.
if (!RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), existingProductionCopyUID) && !RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), newProductionCopyUID)) {
String copyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
logger.info(String.format("Checking to see if there is an active link between %s and %s.", newProductionCopyName, copyName));
// Check to see if a link setting already exists for the link between the 2 copies
linkSettings = findLinkSettings(cgLinkSettings, newProductionCopyUID.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), newProductionCopyName, copyName);
if (linkSettings == null) {
// Link settings for the source/target copies does not exist so we need to create one. Just grab the
// first link settings that's available and base the new link off of that.
linkSettings = cgLinkSettings.get(0);
if (linkSettings != null) {
ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
firstCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getFirstCopy());
firstCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
secondCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getSecondCopy());
secondCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
logger.info(String.format("Generating new link settings between [%s] and [%s] based on existing link settings between copy [%s] and [%s].", newProductionCopyName, copyName, firstCopyName, secondCopyName));
ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
// Set the link copies appropriately
GlobalCopyUID sourceCopy = newProductionCopyUID.getGlobalCopyUID();
GlobalCopyUID targetCopy = copySetting.getCopyUID().getGlobalCopyUID();
cgLinkUID.setFirstCopy(sourceCopy);
cgLinkUID.setSecondCopy(targetCopy);
ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
// Check the copy cluster information to determine if this is a local or remote copy
if (sourceCopy.getClusterUID().getId() == targetCopy.getClusterUID().getId()) {
// local copy
logger.info(String.format("Creating new local copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(false);
} else {
// remote copy
logger.info(String.format("Creating new remote copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
}
functionalAPI.addConsistencyGroupLink(cgLinkUID, linkPolicy);
}
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupLinkUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method configureLinkPolicies.
/**
* Configure the valid links between each production and each local and/or remote copy in a new CG
* configured links are added to fullConsistencyGroupPolicy
*
* @param fullConsistencyGroupPolicy CG policy with copies populated
* @param request request create cg request used for copy mode and rpo
* @param productionCopiesUID the map of production copies
* @param targetCopiesUID the map of non-production copies
* @param cgCopyNames the map of CG copy UIDs to their actual names
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
private void configureLinkPolicies(FullConsistencyGroupPolicy fullConsistencyGroupPolicy, CGRequestParams request, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> targetCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
for (Map.Entry<Long, ConsistencyGroupCopyUID> productionCopyEntry : productionCopiesUID.entrySet()) {
Long productionCopyClusterUID = productionCopyEntry.getKey();
ConsistencyGroupCopyUID productionCopyUID = productionCopyEntry.getValue();
String prodCopyName = cgCopyNames.get(productionCopyUID);
for (Map.Entry<Long, ConsistencyGroupCopyUID> nonProductionCopyEntry : targetCopiesUID.entrySet()) {
// Determine what links need to be configured based on known production and non-production copies.
// The production/non-production copy maps are keyed on ClusterUID. If a ClusterUID from the non-production
// copy map matches one from the production copy map, that is considered a local copy - so a single link will be configured
// between that production copy and the non-production copy matching the ClusterUID. If a ClusterUID
// from the non-production map doesn't match any ClusterUIDs from the production copy map, that copy is
// considered a remote copy - so links will be configured between all production copies and this remote copy. Based on that
// information we will configure the valid links between the production copies and the local/remote copies.
Long nonProductionCopyClusterUID = nonProductionCopyEntry.getKey();
ConsistencyGroupCopyUID nonProductionCopyUID = nonProductionCopyEntry.getValue();
String nonProdCopyName = cgCopyNames.get(nonProductionCopyUID);
// local copy. Or, the non-production ClusterUID doesn't match any production ClusterUIDs - this is a remote copy.
if (nonProductionCopyClusterUID.equals(productionCopyClusterUID) || !productionCopiesUID.containsKey(nonProductionCopyClusterUID)) {
ConsistencyGroupLinkUID linkUid = new ConsistencyGroupLinkUID();
linkUid.setFirstCopy(productionCopyUID.getGlobalCopyUID());
linkUid.setSecondCopy(nonProductionCopyUID.getGlobalCopyUID());
logger.info(String.format("Configuring a copy link between copies %s and %s", prodCopyName, nonProdCopyName));
RecoverPointCGCopyType copyType = (productionCopyClusterUID == nonProductionCopyClusterUID) ? RecoverPointCGCopyType.LOCAL : RecoverPointCGCopyType.REMOTE;
ConsistencyGroupLinkPolicy linkPolicy = createLinkPolicy(copyType, request.getCgPolicy().getCopyMode(), request.getCgPolicy().getRpoType(), request.getCgPolicy().getRpoValue());
FullConsistencyGroupCopyPolicy copyPolicy = getCopyPolicy(fullConsistencyGroupPolicy, nonProductionCopyUID);
// Set the snapshot policy on the link based off the existing non-production copy policy
if (copyPolicy != null && copyPolicy.getCopyPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() > 0) {
SnapshotShippingPolicy snapPolicy = new SnapshotShippingPolicy();
snapPolicy.setIntervaInMinutes(1L);
snapPolicy.setMode(SnapshotShippingMode.PERIODICALLY);
linkPolicy.setSnapshotShippingPolicy(snapPolicy);
} else {
logger.warn("Not setting the snapshot policy on link because there is no existing copy snapshot policy to base this off of.");
}
FullConsistencyGroupLinkPolicy fullLinkPolicy = new FullConsistencyGroupLinkPolicy();
fullLinkPolicy.setLinkPolicy(linkPolicy);
fullLinkPolicy.setLinkUID(linkUid);
fullConsistencyGroupPolicy.getLinksPolicies().add(fullLinkPolicy);
}
}
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupLinkUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method getStandbyCopyLinkSettings.
/**
* in a Metropoint environment, fetches link(s) between the primary copy(s) and the remote/DR copy
*
* @param activeProdCopy the CG copy uid of the active production copy
* @param standbyProdCopy the CG copy uid of the standby production copy
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIValidationException_Exception
* @throws RecoverPointException
*/
private List<ConsistencyGroupLinkSettings> getStandbyCopyLinkSettings(ConsistencyGroupCopyUID activeProdCopy, ConsistencyGroupCopyUID standbyProdCopy) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
logger.info("Preparing link settings between standby production copy and remote copy after Metropoint swap production copies.");
ConsistencyGroupLinkSettings standByCopyLinkSettings = new ConsistencyGroupLinkSettings();
List<ConsistencyGroupLinkSettings> cgLinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
String activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopy);
String standbyCgCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
String cgName = functionalAPI.getGroupName(activeProdCopy.getGroupUID());
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(activeProdCopy.getGroupUID());
// find the remote copy; with metropoint, you're only allowed one remote copy
// so it must be the one with cluster id not equal to the active or standby cluster ids
ClusterUID activeClusterId = activeProdCopy.getGlobalCopyUID().getClusterUID();
ClusterUID standbyClusterId = standbyProdCopy.getGlobalCopyUID().getClusterUID();
for (ConsistencyGroupCopySettings copySetting : groupSettings.getGroupCopiesSettings()) {
// see if this is the remote copy; that is it's not the active and not the standby
ClusterUID copyClusterId = copySetting.getCopyUID().getGlobalCopyUID().getClusterUID();
if (copyClusterId.getId() != activeClusterId.getId() && copyClusterId.getId() != standbyClusterId.getId()) {
String targetCopyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
// get the link settings for the active production copy and remote copy
ConsistencyGroupLinkSettings linkSettings = findLinkSettings(groupSettings.getActiveLinksSettings(), activeProdCopy.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), activeCgCopyName, targetCopyName);
if (linkSettings != null) {
logger.info(String.format("Generate new link settings between %s and %s based on existing link settings between the current production copy %s and %s.", standbyCgCopyName, targetCopyName, activeCgCopyName, targetCopyName));
cgLinkSettings.add(linkSettings);
ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
// Set the link copies appropriately
GlobalCopyUID standbyCopyUid = standbyProdCopy.getGlobalCopyUID();
GlobalCopyUID remoteTargetCopyUid = copySetting.getCopyUID().getGlobalCopyUID();
cgLinkUID.setFirstCopy(standbyCopyUid);
cgLinkUID.setSecondCopy(remoteTargetCopyUid);
ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
// Build the link between the standby production copy and the remote copy
// this has to be a remote copy
logger.info(String.format("Build new remote copy link settings between %s and %s, for consistency group %s.", standbyCgCopyName, targetCopyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
standByCopyLinkSettings.setGroupLinkUID(cgLinkUID);
standByCopyLinkSettings.setLinkPolicy(linkPolicy);
standByCopyLinkSettings.setLocalLink(false);
standByCopyLinkSettings.setTransferEnabled(true);
cgLinkSettings.add(standByCopyLinkSettings);
break;
}
}
}
return cgLinkSettings;
}
use of com.emc.fapiclient.ws.ConsistencyGroupLinkUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method setLinkPolicy.
/**
* Convenience method to set the link policy.
*
* @param remote whether to set the "protect over wan" to true
* @param prodCopyUID production copy id
* @param targetCopyUID target copy id
* @param cgUID cg id
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
*/
private void setLinkPolicy(boolean remote, ConsistencyGroupCopyUID prodCopyUID, ConsistencyGroupCopyUID targetCopyUID, ConsistencyGroupUID cgUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
ConsistencyGroupLinkUID groupLink = new ConsistencyGroupLinkUID();
ConsistencyGroupLinkPolicy linkPolicy = new ConsistencyGroupLinkPolicy();
linkPolicy.setAdvancedPolicy(new LinkAdvancedPolicy());
linkPolicy.getAdvancedPolicy().setPerformLongInitialization(true);
linkPolicy.getAdvancedPolicy().setSnapshotGranularity(SnapshotGranularity.FIXED_PER_SECOND);
linkPolicy.setProtectionPolicy(new LinkProtectionPolicy());
linkPolicy.getProtectionPolicy().setBandwidthLimit(0.0);
linkPolicy.getProtectionPolicy().setCompression(WanCompression.NONE);
linkPolicy.getProtectionPolicy().setDeduplication(false);
linkPolicy.getProtectionPolicy().setMeasureLagToTargetRPA(true);
linkPolicy.getProtectionPolicy().setProtectionType(ProtectionMode.ASYNCHRONOUS);
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(remote);
linkPolicy.getProtectionPolicy().setRpoPolicy(new RpoPolicy());
linkPolicy.getProtectionPolicy().getRpoPolicy().setAllowRegulation(false);
linkPolicy.getProtectionPolicy().getRpoPolicy().setMaximumAllowedLag(getQuantity(QuantityType.MICROSECONDS, 25000000));
linkPolicy.getProtectionPolicy().getRpoPolicy().setMinimizationType(RpoMinimizationType.IRRELEVANT);
linkPolicy.getProtectionPolicy().setSyncReplicationLatencyThresholds(new SyncReplicationThreshold());
linkPolicy.getProtectionPolicy().getSyncReplicationLatencyThresholds().setResumeSyncReplicationBelow(getQuantity(QuantityType.MICROSECONDS, 3000));
linkPolicy.getProtectionPolicy().getSyncReplicationLatencyThresholds().setStartAsyncReplicationAbove(getQuantity(QuantityType.MICROSECONDS, 5000));
linkPolicy.getProtectionPolicy().getSyncReplicationLatencyThresholds().setThresholdEnabled(false);
linkPolicy.getProtectionPolicy().setSyncReplicationThroughputThresholds(new SyncReplicationThreshold());
linkPolicy.getProtectionPolicy().getSyncReplicationThroughputThresholds().setResumeSyncReplicationBelow(getQuantity(QuantityType.KB, 35000));
linkPolicy.getProtectionPolicy().getSyncReplicationThroughputThresholds().setStartAsyncReplicationAbove(getQuantity(QuantityType.KB, 45000));
linkPolicy.getProtectionPolicy().getSyncReplicationThroughputThresholds().setThresholdEnabled(false);
linkPolicy.getProtectionPolicy().setWeight(1);
groupLink.setFirstCopy(prodCopyUID.getGlobalCopyUID());
groupLink.setSecondCopy(targetCopyUID.getGlobalCopyUID());
groupLink.setGroupUID(cgUID);
functionalAPI.addConsistencyGroupLink(groupLink, linkPolicy);
waitForRpOperation();
}
Aggregations