Search in sources :

Example 16 with UnsignedInteger32

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;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 17 with UnsignedInteger32

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;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) Calendar(java.util.Calendar) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) ArrayList(java.util.ArrayList) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) HashSet(java.util.HashSet)

Example 18 with UnsignedInteger32

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);
            }
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 19 with UnsignedInteger32

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();
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 20 with UnsignedInteger32

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);
            }
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Aggregations

UnsignedInteger32 (javax.cim.UnsignedInteger32)29 CIMObjectPath (javax.cim.CIMObjectPath)22 CIMArgument (javax.cim.CIMArgument)15 WBEMClient (javax.wbem.client.WBEMClient)14 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 CIMInstance (javax.cim.CIMInstance)11 WBEMException (javax.wbem.WBEMException)7 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)6 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 EnumerateResponse (javax.wbem.client.EnumerateResponse)5 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)4 Volume (com.emc.storageos.db.client.model.Volume)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)3 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 IOException (java.io.IOException)3