use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getRPSystemStatistics.
/**
* Get RP site statistics for use in collectStatisticsInformation
*
* @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
*
* @param String journalWWNToDelete - WWN of the journal volume to delete
*
* @return RecoverPointStatisticsResponse
*
* @throws RecoverPointException
*/
public RecoverPointStatisticsResponse getRPSystemStatistics() throws RecoverPointException {
logger.info("Collecting RecoverPoint System Statistics.");
RecoverPointStatisticsResponse response = new RecoverPointStatisticsResponse();
try {
Map<Long, Double> siteAvgCPUUsageMap = new HashMap<Long, Double>();
Map<Long, Long> siteInputAvgThroughput = new HashMap<Long, Long>();
Map<Long, Long> siteOutputAvgThroughput = new HashMap<Long, Long>();
Map<Long, Long> siteIncomingAvgWrites = new HashMap<Long, Long>();
SystemStatistics systemStatistics = functionalAPI.getSystemStatistics();
Set<ClusterUID> ClusterUIDList = new HashSet<ClusterUID>();
List<RpaStatistics> rpaStatisticsList = systemStatistics.getRpaStatistics();
for (RpaStatistics rpaStatistics : rpaStatisticsList) {
ClusterUID siteID = rpaStatistics.getRpaUID().getClusterUID();
boolean foundSite = false;
for (ClusterUID siteListUID : ClusterUIDList) {
if (siteID.getId() == siteListUID.getId()) {
foundSite = true;
break;
}
}
if (!foundSite) {
ClusterUIDList.add(siteID);
}
}
for (ClusterUID ClusterUID : ClusterUIDList) {
List<Double> rpaCPUList = new LinkedList<Double>();
List<Long> rpaSiteInputAvgThroughputList = new LinkedList<Long>();
List<Long> rpaSiteOutputAvgThroughputList = new LinkedList<Long>();
List<Long> rpaSiteInputAvgIncomingWritesList = new LinkedList<Long>();
for (RpaStatistics rpaStatistics : rpaStatisticsList) {
if (rpaStatistics.getRpaUID().getClusterUID().getId() == ClusterUID.getId()) {
rpaCPUList.add(Double.valueOf(rpaStatistics.getCpuUsage()));
rpaSiteInputAvgThroughputList.add(rpaStatistics.getTraffic().getApplicationThroughputStatistics().getInThroughput());
for (ConnectionOutThroughput cot : rpaStatistics.getTraffic().getApplicationThroughputStatistics().getConnectionsOutThroughputs()) {
rpaSiteOutputAvgThroughputList.add(cot.getOutThroughput());
}
rpaSiteInputAvgIncomingWritesList.add(rpaStatistics.getTraffic().getApplicationIncomingWrites());
}
}
Double cpuTotalUsage = 0.0;
Long incomingWritesTotal = Long.valueOf(0);
Long inputThoughputTotal = Long.valueOf(0);
Long outputThoughputTotal = Long.valueOf(0);
for (Double rpaCPUs : rpaCPUList) {
cpuTotalUsage += rpaCPUs;
}
for (Long siteInputThroughput : rpaSiteInputAvgThroughputList) {
inputThoughputTotal += siteInputThroughput;
}
for (Long siteOutputThroughput : rpaSiteOutputAvgThroughputList) {
outputThoughputTotal += siteOutputThroughput;
}
for (Long incomingWrites : rpaSiteInputAvgIncomingWritesList) {
incomingWritesTotal += incomingWrites;
}
logger.info("Average CPU usage for site: " + ClusterUID.getId() + " is " + cpuTotalUsage / rpaCPUList.size());
logger.info("Average input throughput for site: " + ClusterUID.getId() + " is " + inputThoughputTotal / rpaCPUList.size() + " kb/s");
logger.info("Average output throughput for site: " + ClusterUID.getId() + " is " + outputThoughputTotal / rpaCPUList.size() + " kb/s");
logger.info("Average incoming writes for site: " + ClusterUID.getId() + " is " + incomingWritesTotal / rpaCPUList.size() + " writes/s");
siteAvgCPUUsageMap.put(ClusterUID.getId(), cpuTotalUsage / rpaCPUList.size());
siteInputAvgThroughput.put(ClusterUID.getId(), inputThoughputTotal / rpaCPUList.size());
siteOutputAvgThroughput.put(ClusterUID.getId(), outputThoughputTotal / rpaCPUList.size());
siteIncomingAvgWrites.put(ClusterUID.getId(), incomingWritesTotal / rpaCPUList.size());
}
response.setSiteCPUUsageMap(siteAvgCPUUsageMap);
response.setSiteInputAvgIncomingWrites(siteIncomingAvgWrites);
response.setSiteOutputAvgThroughput(siteOutputAvgThroughput);
response.setSiteInputAvgThroughput(siteInputAvgThroughput);
List<ProtectionSystemParameters> systemParameterList = new LinkedList<ProtectionSystemParameters>();
MonitoredParametersStatus monitoredParametersStatus = functionalAPI.getMonitoredParametersStatus();
List<MonitoredParameter> monitoredParameterList = monitoredParametersStatus.getParameters();
for (MonitoredParameter monitoredParameter : monitoredParameterList) {
ProtectionSystemParameters param = response.new ProtectionSystemParameters();
param.parameterName = monitoredParameter.getKey().getParameterType().value();
param.parameterLimit = monitoredParameter.getValue().getParameterWaterMarks().getLimit();
param.currentParameterValue = monitoredParameter.getValue().getValue();
if (monitoredParameter.getKey().getClusterUID() != null) {
param.siteID = monitoredParameter.getKey().getClusterUID().getId();
}
systemParameterList.add(param);
}
response.setParamList(systemParameterList);
for (ProtectionSystemParameters monitoredParameter : response.getParamList()) {
logger.info("Key: " + monitoredParameter.parameterName);
logger.info("Current Value: " + monitoredParameter.currentParameterValue);
logger.info("Max Value: " + monitoredParameter.parameterLimit);
}
return response;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToGetStatistics(e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToGetStatistics(e);
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToGetStatistics(e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method addJournalVolumesToCG.
/**
* Operation to add journal volumes to an existing recoverpoint consistency group
*
* @param request - contains both the consistency group
* and the journals to add to the consistency group
* @param copyType - indicates whether the copy is production, local or remote
* @return boolean indicating the result of the operation
*/
public boolean addJournalVolumesToCG(CGRequestParams request, int copyType) {
// Make sure the CG name is unique.
ConsistencyGroupUID cgUID = null;
List<ConsistencyGroupUID> allCgs;
String copyName = "not determined";
Map<ConsistencyGroupCopyUID, DeviceUID> addedJournalVolumes = new HashMap<ConsistencyGroupCopyUID, DeviceUID>();
try {
allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
cgUID = settings.getGroupUID();
break;
}
}
if (cgUID == null) {
// The CG does not exist so we cannot add replication sets
throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
}
List<CreateCopyParams> copyParams = request.getCopies();
// determine if the volumes are visible to the recoverpoint appliance
Set<RPSite> allSites = scan(copyParams, null);
for (CreateCopyParams copyParam : copyParams) {
for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
copyName = journalVolume.getRpCopyName();
ClusterUID clusterId = RecoverPointUtils.getRPSiteID(functionalAPI, journalVolume.getInternalSiteName());
ConsistencyGroupCopyUID copyUID = getCGCopyUid(clusterId, getCopyType(copyType), cgUID);
DeviceUID journalDevice = RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn());
addedJournalVolumes.put(copyUID, journalDevice);
functionalAPI.addJournalVolume(copyUID, journalDevice);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToAddJournalVolumeToConsistencyGroup(copyName, getCause(e));
} catch (FunctionalAPIInternalError_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(copyName, getCause(e));
}
return true;
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception 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.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteJournalFromCopy.
/**
* Delete a journal volume (WWN) from the consistency group copy specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
*
* @param String journalWWNToDelete - WWN of the journal volume to delete
*
* @return void
*
* @throws RecoverPointException
*/
public void deleteJournalFromCopy(RecoverPointVolumeProtectionInfo copyToModify, String journalWWNToDelete) throws RecoverPointException {
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToModify);
String copyName = null;
String cgName = null;
try {
copyName = functionalAPI.getGroupCopyName(cgCopyUID);
cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Request to delete journal " + journalWWNToDelete + " from copy " + copyName + " for consistency group " + cgName);
Set<RPSite> allSites = getAssociatedRPSites();
DeviceUID journalDeviceUIDToDelete = RecoverPointUtils.getDeviceID(allSites, journalWWNToDelete);
if (journalDeviceUIDToDelete == null) {
throw RecoverPointException.exceptions.cannotFindJournal(journalWWNToDelete);
}
functionalAPI.removeJournalVolume(cgCopyUID, journalDeviceUIDToDelete);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteCopy.
/**
* Delete the consistency group copy specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG copy to delete (can't be production)
*
* @return void
*
* @throws RecoverPointException
*/
public void deleteCopy(RecoverPointVolumeProtectionInfo copyToDelete) throws RecoverPointException {
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToDelete);
String copyName = null;
String cgName = null;
try {
copyName = functionalAPI.getGroupCopyName(cgCopyUID);
cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
if (RecoverPointUtils.copiesEqual(productionCopyUID, cgCopyUID)) {
// Can't call delete copy using the production CG copy
throw RecoverPointException.exceptions.cantCallDeleteCopyUsingProductionVolume(copyName, cgName);
}
functionalAPI.removeConsistencyGroupCopy(cgCopyUID);
logger.info("Deleted copy " + copyName + " for consistency group " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteCopy(copyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteCopy(copyName, cgName, e);
}
}
Aggregations