use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SmisCreateMaskingViewJob method enableRecoverPointTag.
/**
* Method will set the EMCRecoverPointEnabled flag on the device masking group for VMAX.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - WBEMClient used for reading/writing from/to SMI-S
* @param deviceGroupPath [in] - CIMObjectPath referencing the volume
*/
private void enableRecoverPointTag(DbClient dbClient, WBEMClient client, CIMObjectPath deviceGroupPath) {
try {
boolean isRPTagNeeded = false;
// Check if the volumes being protected are RP volumes
for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
URI volumeURI = volUriHlu.getVolumeURI();
BlockObject bo = null;
if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
} else if (URIUtil.isType(volumeURI, Volume.class)) {
bo = dbClient.queryObject(Volume.class, volumeURI);
}
if (bo != null && BlockObject.checkForRP(dbClient, bo.getId())) {
isRPTagNeeded = true;
break;
}
}
// Do nothing and return from if none of the volumes are RP protected
if (isRPTagNeeded) {
_log.info("Attempting to enable RecoverPoint tag on Device Group : " + deviceGroupPath.toString());
CIMPropertyFactory factoryRef = (CIMPropertyFactory) ControllerServiceImpl.getBean("CIMPropertyFactory");
CIMInstance toUpdate = new CIMInstance(deviceGroupPath, new CIMProperty[] { factoryRef.bool(SmisConstants.EMC_RECOVERPOINT_ENABLED, true) });
_log.debug("Params: " + toUpdate.toString());
client.modifyInstance(toUpdate, SmisConstants.CP_EMC_RECOVERPOINT_ENABLED);
_log.info(String.format("Device group has been successfully set with RecoverPoint tag "));
}
} catch (WBEMException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SmisCreateMaskingViewJob method enableRecoverPointTagOn803.
/**
* Method will set the EMCRecoverPointEnabled flag on all the volumes within 8.0.3 Provider.
* 8.0.3 Provider doesnt support setting RP tag on Storage Groups.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - WBEMClient used for reading/writing from/to SMI-S
* @param deviceGroupPath [in] - CIMObjectPath referencing the volume
*/
private void enableRecoverPointTagOn803(DbClient dbClient, WBEMClient client, StorageSystem storage, JobContext jobContext) {
try {
boolean isRPTagNeeded = false;
List<URI> blockObjectUris = new ArrayList<URI>();
for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
URI volumeURI = volUriHlu.getVolumeURI();
BlockObject bo = null;
if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
} else if (URIUtil.isType(volumeURI, Volume.class)) {
bo = dbClient.queryObject(Volume.class, volumeURI);
}
if (bo != null) {
blockObjectUris.add(bo.getId());
if (BlockObject.checkForRP(dbClient, bo.getId())) {
isRPTagNeeded = true;
}
}
}
// Do nothing and return from if none of the volumes are RP protected
if (isRPTagNeeded) {
SmisCommandHelper helper = jobContext.getSmisCommandHelper();
helper.setRecoverPointTag(storage, helper.getVolumeMembers(storage, blockObjectUris), true);
}
} catch (WBEMException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
} catch (Exception e) {
_log.error("Encountered an error while trying to set the RecoverPoint tag", e);
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SmisCreateMultiVolumeJob method changeVolumeName.
/**
* Method will modify the name of a given volume to a generate name.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - WBEMClient used for reading/writing from/to SMI-S
* @param volumePath [in] - CIMObjectPath referencing the volume
* @param volume [in] - Volume object
*/
private void changeVolumeName(DbClient dbClient, WBEMClient client, CIMObjectPath volumePath, Volume volume, String name) {
Lease lease = null;
try {
_log.info(String.format("Attempting to modify volume %s to %s", volumePath.toString(), name));
if (_propertyFactoryRef.get() == null) {
_propertyFactoryRef.compareAndSet(null, (CIMPropertyFactory) ControllerServiceImpl.getBean("CIMPropertyFactory"));
}
CIMInstance toUpdate = new CIMInstance(volumePath, new CIMProperty[] { _propertyFactoryRef.get().string(SmisConstants.CP_ELEMENT_NAME, name) });
if (_distributedLock.get() == null) {
if (_coordinator.get() == null) {
_coordinator.compareAndSet(null, (CoordinatorClient) ControllerServiceImpl.getBean("coordinator"));
}
_distributedLock.compareAndSet(null, _coordinator.get().getSemaphore(this.getClass().getSimpleName(), MAX_PERMITS));
}
lease = _distributedLock.get().acquireLease();
client.modifyInstance(toUpdate, SmisConstants.PS_ELEMENT_NAME);
_distributedLock.get().returnLease(lease);
lease = null;
volume.setDeviceLabel(name);
dbClient.persistObject(volume);
_log.info(String.format("Volume name has been modified to %s", name));
} catch (WBEMException e) {
_log.error("Encountered an error while trying to set the volume name", e);
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the volume name", e);
} catch (Exception e) {
_log.error("Encountered an error while trying to set the volume name", e);
} finally {
if (lease != null) {
try {
_distributedLock.get().returnLease(lease);
} catch (Exception e) {
_log.error("Exception when trying to return lease", e);
}
}
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class VDCRoleMigrationCallback method findRootTenant.
private TenantOrg findRootTenant(DbClient _dbClient) {
URIQueryResultList tenants = new URIQueryResultList();
try {
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getTenantOrgSubTenantConstraint(URI.create(TenantOrg.NO_PARENT)), tenants);
if (tenants.iterator().hasNext() == false) {
throw new IllegalStateException("The CF of Root Tenant is not found");
}
URI root = tenants.iterator().next();
return _dbClient.queryObject(TenantOrg.class, root);
} catch (DatabaseException ex) {
throw new IllegalStateException("Error in finding the CF of root tenant", ex);
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class DBClient method queryForCustomDayStats.
/**
* Query stats
*
* @param dateTime
*/
public void queryForCustomDayStats(DateTime dateTime, String filename) {
System.out.println("\n\n -> Querying Stats");
ExecutorService executor = Executors.newFixedThreadPool(100);
StatQueryResult result = new StatQueryResult(filename);
try {
_dbClient.queryTimeSeries(StatTimeSeries.class, dateTime, TimeSeriesMetadata.TimeBucket.HOUR, result, executor);
System.out.println(" --- Job Exceution for Querying Stats completed ---\n\n");
return;
} catch (DatabaseException e) {
System.err.println("Exception Query " + e);
log.error("Exception Query ", e);
}
}
Aggregations