use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class SmisCommandHelper method callRefreshSystem.
public Object callRefreshSystem(StorageSystem storage, SimpleFunction toCallAfterRefresh, boolean force) throws WBEMException {
Object result = null;
String lockKey = String.format("callRefreshSystem-%s", storage.getId().toString());
try {
if (_locker.acquireLock(lockKey, MAX_REFRESH_LOCK_WAIT_TIME)) {
storage = _dbClient.queryObject(StorageSystem.class, storage.getId());
long currentMillis = Calendar.getInstance().getTimeInMillis();
long deltaLastRefreshValue = currentMillis - storage.getLastRefresh();
if (deltaLastRefreshValue < REFRESH_THRESHOLD && force) {
// In case of SRDF Active mode resume operation, its possible that second call
// to refreshSystem might be done where REFRESH_THRESHOLD value might not be met so we
// will pause thread for the remainder of the time as we need to make sure refresh
// system is executed to be able to get correct access state for the target volumes.
long sleepDuration = REFRESH_THRESHOLD - deltaLastRefreshValue;
_log.info(String.format("Sleep for %d msecs before calling refresh because last " + "refresh was done %d msecs ago", sleepDuration, deltaLastRefreshValue));
pauseThread(sleepDuration);
currentMillis = Calendar.getInstance().getTimeInMillis();
deltaLastRefreshValue = currentMillis - storage.getLastRefresh();
}
// again so soon.
if (deltaLastRefreshValue >= REFRESH_THRESHOLD) {
_log.info(String.format("Difference between current time %d and " + "lastRefresh %d is %d, greater than or equal to threshold %d - will " + "attempt EMCRefresh", currentMillis, storage.getLastRefresh(), deltaLastRefreshValue, REFRESH_THRESHOLD));
CIMObjectPath seSystemRegistrationSvc = getRegistrationService(storage);
UnsignedInteger32[] syncType = new UnsignedInteger32[] { new UnsignedInteger32(REPLICATION_DATA_SYNC_TYPE), new UnsignedInteger32(DEVICES_SYNC_TYPE) };
CIMObjectPath[] systems = new CIMObjectPath[] { _cimPath.getStorageSystem(storage) };
CIMArgument[] refreshArgs = new CIMArgument[] { _cimArgument.uint32Array(CP_SYNC_TYPE, syncType), _cimArgument.referenceArray(CP_SYSTEMS, systems) };
CIMArgument[] outArgs = new CIMArgument[5];
result = invokeMethod(storage, seSystemRegistrationSvc, EMC_REFRESH_SYSTEM, refreshArgs, outArgs);
currentMillis = Calendar.getInstance().getTimeInMillis();
storage.setLastRefresh(currentMillis);
_dbClient.persistObject(storage);
_log.info(String.format("Did EMCRefresh against StorageSystem %s. " + "Last refresh set to %d", storage.getNativeGuid(), currentMillis));
if (toCallAfterRefresh != null) {
toCallAfterRefresh.call();
}
} else {
_log.info(String.format("Did not run EMCRefresh against " + "StorageSystem %s because it was done %d msecs ago, " + "which is within in the refresh threshold %d", storage.getNativeGuid(), deltaLastRefreshValue, REFRESH_THRESHOLD));
}
} else {
_log.info(String.format("Could not get the EMCRefresh lock after %d seconds.", MAX_REFRESH_LOCK_WAIT_TIME));
}
} finally {
_locker.releaseLock(lockKey);
}
return result;
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeCreation.
/*
* (non-Javadoc) Update DB with volume creation output from SMI-S.
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob
* #updateStatus
*/
public Set<URI> processVolumeCreation(StorageSystem storageSystem, URI storagePoolURI, List<Volume> volumes, CIMArgument[] outArgs) throws Exception {
Set<URI> volumeURIs = new HashSet<URI>(volumes.size());
StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume creation"));
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
Calendar now = Calendar.getInstance();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
updateStoragePoolCapacity(client, storagePool);
StringMap reservationMap = storagePool.getReservedCapacityMap();
for (Volume volume : volumes) {
reservationMap.remove(volume.getId().toString());
}
_dbClient.persistObject(storagePool);
CIMObjectPath[] elements = (CIMObjectPath[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENTS);
UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
List<Volume> volumesToSave = new ArrayList<Volume>(elements.length);
if (elements != null && returnCoedes != null) {
for (int i = 0; i < elements.length; i++) {
URI volumeId = volumes.get(i).getId();
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
volumesToSave.add(volume);
volumeURIs.add(volumeId);
boolean isSuccess = false;
CIMObjectPath volumePath = elements[i];
if (volumePath != null) {
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(IBMSmisConstants.CP_DEVICE_ID);
if (deviceID != null) {
String nativeID = deviceID.getValue();
if ((nativeID != null) && (nativeID.length() != 0)) {
isSuccess = true;
volume.setPool(storagePoolURI);
processVolume(volumePath, nativeID, volume, client, logMsgBuilder, now);
}
}
}
if (!isSuccess) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Failed to create volume: %s with return code: %s", volumeId, returnCoedes[i].toString()));
volume.setInactive(true);
}
}
}
if (!volumesToSave.isEmpty()) {
_dbClient.persistObject(volumesToSave);
}
_log.info(logMsgBuilder.toString());
return volumeURIs;
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class StorageProcessor method processResultbyChunk.
@SuppressWarnings("unchecked")
protected void processResultbyChunk(Object resultObj, Map<String, Object> keyMap) {
CloseableIterator<CIMInstance> instances = null;
EnumerateResponse<CIMInstance> instChunks = null;
CIMObjectPath objPath = null;
WBEMClient client = null;
try {
client = SMICommunicationInterface.getCIMClient(keyMap);
objPath = getObjectPathfromCIMArgument(_args);
instChunks = (EnumerateResponse<CIMInstance>) resultObj;
// process entries returned in the Open operation
_logger.info("Processing initial return");
instances = instChunks.getResponses();
int count = processInstances(instances, client);
while (!instChunks.isEnd()) {
_logger.info("Processing next chunk of size {}", BATCH_SIZE);
instChunks = client.getInstancesWithPath(objPath, instChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
instances = instChunks.getResponses();
count += processInstances(instances, client);
}
_logger.info("Total instances processed {}", count);
} catch (Exception e) {
_logger.error("Processing chunk failed :", e);
} finally {
if (null != instances) {
instances.close();
}
if (null != instChunks) {
try {
client.closeEnumeration(objPath, instChunks.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class VolumeAccessStateProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
CloseableIterator<CIMInstance> volumeInstances = null;
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
_unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
if (pool == null) {
_logger.error("Skipping unmanaged volume discovery of Access Sattes as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
return;
}
EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
volumeInstances = volumeInstanceChunks.getResponses();
processVolumes(volumeInstances, keyMap, operation);
while (!volumeInstanceChunks.isEnd()) {
_logger.debug("Processing Next Volume Chunk of size {}", BATCH_SIZE);
volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(volumeInstanceChunks.getResponses(), keyMap, operation);
}
if (null != _unManagedVolumesUpdate && !_unManagedVolumesUpdate.isEmpty()) {
_partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
}
} catch (Exception e) {
_logger.error("Discovering Access States of unManaged Volumes failed", e);
} finally {
volumeInstances.close();
}
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class ArrayAffinityExportProcessor method processResult.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
* java.lang.Object, java.util.Map)
*/
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
initialize(operation, resultObj, keyMap);
CloseableIterator<CIMInstance> it = null;
EnumerateResponse<CIMInstance> response = null;
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
try {
// get lun masking view CIM path
CIMObjectPath path = getObjectPathfromCIMArgument(_args, keyMap);
_logger.info("looking at lun masking view: " + path.toString());
response = (EnumerateResponse<CIMInstance>) resultObj;
processVolumesAndInitiatorsPaths(response.getResponses(), path.toString(), client);
while (!response.isEnd()) {
_logger.info("Processing next Chunk");
response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(MAX_OBJECT_COUNT));
processVolumesAndInitiatorsPaths(response.getResponses(), path.toString(), client);
}
} catch (Exception e) {
_logger.error("Processing lun maksing view failed", e);
} finally {
if (it != null) {
it.close();
}
wrapUp();
if (response != null) {
try {
client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
Aggregations