Search in sources :

Example 96 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class HDSVolumeExpandJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext
 *            The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    LogicalUnit logicalUnit = null;
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        // from pool's reserved capacity map.
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            HDSUtils.updateStoragePoolCapacity(dbClient, hdsApiClient, storagePool);
            StringMap reservationMap = storagePool.getReservedCapacityMap();
            URI volumeId = getTaskCompleter().getId();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(storagePool);
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
        if (_status == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            // set requested capacity
            volume.setCapacity(taskCompleter.getSize());
            // set meta related properties
            volume.setIsComposite(taskCompleter.isComposite());
            volume.setCompositionType(taskCompleter.getMetaVolumeType());
            logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
            if (null != logicalUnit) {
                long capacityInBytes = (Long.valueOf(logicalUnit.getCapacityInKB())) * 1024L;
                volume.setProvisionedCapacity(capacityInBytes);
                volume.setAllocatedCapacity(capacityInBytes);
            }
            logMsgBuilder.append(String.format("%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
            if (volume.getIsComposite()) {
                logMsgBuilder.append(String.format("%n  Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
            }
            _log.info(logMsgBuilder.toString());
            dbClient.persistObject(volume);
            // Reset list of meta members native ids in WF data (when meta
            // is created meta members are removed from array)
            WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for HDSVolumeExpandJob", e);
        setErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 97 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class VNXUnityCommunicationInterface method computeStaticLoadMetrics.

/**
 * Compute static load metrics.
 *
 * @param accessProfile
 * @return
 */
private void computeStaticLoadMetrics(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = accessProfile.getSystemId();
    StorageSystem storageSystem = null;
    try {
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        _logger.info("started computeStaticLoadMetrics for storagesystem: {}", storageSystem.getLabel());
        VNXeApiClient client = getVnxUnityClient(accessProfile);
        List<VNXeNasServer> nasServers = client.getNasServers();
        for (VNXeNasServer nasServer : nasServers) {
            if ((nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) || nasServer.getIsReplicationDestination()) {
                _logger.debug("Found a replication destination NasServer");
                continue;
            }
            if (nasServer.getIsSystem()) {
                // skip system nasServer
                continue;
            }
            VirtualNAS virtualNAS = findvNasByNativeId(storageSystem, nasServer.getId());
            if (virtualNAS != null) {
                _logger.info("Process db metrics for nas server : {}", nasServer.getName());
                StringMap dbMetrics = virtualNAS.getMetrics();
                if (dbMetrics == null) {
                    dbMetrics = new StringMap();
                }
                // process db metrics
                StringMap tmpDbMetrics = populateDbMetrics(nasServer, client);
                dbMetrics.putAll(tmpDbMetrics);
                // set dbMetrics in db
                virtualNAS.setMetrics(dbMetrics);
                _dbClient.updateObject(virtualNAS);
            }
        }
    } catch (Exception e) {
        _logger.error("CollectStatisticsInformation failed. Storage system: {}", storageSystemId, e);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem)

Example 98 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class VNXUnityCommunicationInterface method populateDbMetrics.

/**
 * Calculate nas server metrics
 *
 * @param nasServer
 * @param apiClient
 * @return StringMap containing calculated metrics
 */
private StringMap populateDbMetrics(final VNXeNasServer nasServer, VNXeApiClient client) {
    StringMap dbMetrics = new StringMap();
    long totalProvCap = 0L;
    long totalFsCount = 0L;
    // get total exports
    int nfsSharesCount = 0;
    int cifsSharesCount = 0;
    List<VNXeFileSystem> fileSystemList = client.getFileSystemsForNasServer(nasServer.getId());
    if (fileSystemList != null && !fileSystemList.isEmpty()) {
        for (VNXeFileSystem fs : fileSystemList) {
            totalProvCap = totalProvCap + fs.getSizeTotal();
            totalFsCount++;
            List<VNXeNfsShare> nfsShares = client.getNfsSharesForFileSystem(fs.getId());
            if (nfsShares != null && !nfsShares.isEmpty()) {
                nfsSharesCount = nfsSharesCount + nfsShares.size();
            }
            List<VNXeCifsShare> cifsShares = client.getCifsSharesForFileSystem(fs.getId());
            if (cifsShares != null && !cifsShares.isEmpty()) {
                cifsSharesCount = cifsSharesCount + cifsShares.size();
            }
            List<VNXeFileSystemSnap> snapshotsList = client.getFileSystemSnaps(fs.getId());
            if (snapshotsList != null && !snapshotsList.isEmpty()) {
                for (VNXeFileSystemSnap snap : snapshotsList) {
                    totalProvCap = totalProvCap + snap.getSize();
                    totalFsCount++;
                    List<VNXeNfsShare> snapNfsShares = client.getNfsSharesForSnap(snap.getId());
                    if (snapNfsShares != null && !snapNfsShares.isEmpty()) {
                        nfsSharesCount = nfsSharesCount + snapNfsShares.size();
                    }
                    List<VNXeCifsShare> snapCifsShares = client.getCifsSharesForSnap(snap.getId());
                    if (snapCifsShares != null && !snapCifsShares.isEmpty()) {
                        cifsSharesCount = cifsSharesCount + snapCifsShares.size();
                    }
                }
            }
        }
    }
    if (totalProvCap > 0) {
        totalProvCap = (totalProvCap / KB_IN_BYTES);
    }
    _logger.info("Total fs Count {} for nas server : {}", String.valueOf(totalFsCount), nasServer.getName());
    _logger.info("Total fs Capacity {} for nas server : {}", String.valueOf(totalProvCap), nasServer.getName());
    // Set max limits in dbMetrics
    StringMap maxDbMetrics = getMaxDbMetrics(client);
    dbMetrics.putAll(maxDbMetrics);
    // set total nfs and cifs exports for this nas server
    dbMetrics.put(MetricsKeys.totalNfsExports.name(), String.valueOf(nfsSharesCount));
    dbMetrics.put(MetricsKeys.totalCifsShares.name(), String.valueOf(cifsSharesCount));
    // set total fs objects and their sum of capacity for this nas server
    dbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalFsCount));
    dbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalProvCap));
    Long maxExports = MetricsKeys.getLong(MetricsKeys.maxExports, dbMetrics);
    Long maxStorObjs = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, dbMetrics);
    Long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, dbMetrics);
    Long totalExports = Long.valueOf(nfsSharesCount + cifsSharesCount);
    // setting overLoad factor (true or false)
    String overLoaded = FALSE;
    if (totalExports >= maxExports || totalProvCap >= maxCapacity || totalFsCount >= maxStorObjs) {
        overLoaded = TRUE;
    }
    double percentageLoadExports = 0.0;
    // percentage calculator
    if (totalExports > 0.0) {
        percentageLoadExports = ((double) (totalExports) / maxExports) * 100;
    }
    double percentageLoadStorObj = ((double) (totalProvCap) / maxCapacity) * 100;
    double percentageLoad = (percentageLoadExports + percentageLoadStorObj) / 2;
    dbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
    dbMetrics.put(MetricsKeys.overLoaded.name(), overLoaded);
    return dbMetrics;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) VNXeCifsShare(com.emc.storageos.vnxe.models.VNXeCifsShare)

Example 99 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class VPlexCommunicationInterface method discoverClusterIdentification.

/**
 * Implementation for discovering assembly ID (serial number) to cluster id (0 or 1)
 * mapping used in placement algorithms such as RP and VPLEX.
 *
 * @param vplex VPLEX storage system to discovery cluster info for
 * @param client a reference to the VPLEX API client
 */
private void discoverClusterIdentification(StorageSystem vplex, VPlexApiClient client) {
    try {
        if (vplex.getVplexAssemblyIdtoClusterId() != null && !vplex.getVplexAssemblyIdtoClusterId().isEmpty()) {
            // to retrieve it again. (This information is not expected to change)
            return;
        }
        // Get the cluster information
        List<VPlexClusterInfo> clusterInfoList = client.getClusterInfoLite();
        // Get the cluster assembly identifiers and form the
        // system serial number based on these identifiers.
        StringMap assemblyIdToClusterId = new StringMap();
        for (VPlexClusterInfo clusterInfo : clusterInfoList) {
            String assemblyId = clusterInfo.getTopLevelAssembly();
            if (VPlexApiConstants.NULL_ATT_VAL.equals(assemblyId)) {
                throw VPlexCollectionException.exceptions.failedScanningManagedSystemsNullAssemblyId(vplex.getIpAddress(), clusterInfo.getName());
            }
            assemblyIdToClusterId.put(assemblyId, clusterInfo.getClusterId());
        }
        // Store the vplex assembly ID -> cluster ID mapping
        if (vplex.getVplexAssemblyIdtoClusterId() == null) {
            vplex.setVplexAssemblyIdtoClusterId(assemblyIdToClusterId);
        } else {
            vplex.getVplexAssemblyIdtoClusterId().putAll(assemblyIdToClusterId);
        }
    } catch (Exception e) {
        if (vplex != null) {
            s_logger.error("Error discovering cluster identification for the VPLEX storage system {}:", vplex.getIpAddress(), e);
            throw VPlexCollectionException.exceptions.failedPortsDiscovery(vplex.getId().toString(), e.getLocalizedMessage(), e);
        }
        s_logger.error("Error discovering cluster identification for the VPLEX storage system", e);
        throw VPlexCollectionException.exceptions.failedPortsDiscovery("None", e.getLocalizedMessage(), e);
    }
}
Also used : VPlexClusterInfo(com.emc.storageos.vplex.api.VPlexClusterInfo) StringMap(com.emc.storageos.db.client.model.StringMap) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) IOException(java.io.IOException)

Example 100 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method createUnManagedFileSystem.

/**
 * create StorageFileSystem Info Object
 *
 * @param unManagedFileSystem
 * @param unManagedFileSystemNativeGuid
 * @param system
 * @param pool
 * @param storagePort
 * @param fileSystem
 * @return UnManagedFileSystem
 * @throws IOException
 * @throws VNXFileCollectionException
 */
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, String unManagedFileSystemNativeGuid, StorageSystem system, StoragePool pool, StoragePort storagePort, VNXFileSystem fileSystem) throws IOException, VNXFileCollectionException {
    if (null == unManagedFileSystem) {
        unManagedFileSystem = new UnManagedFileSystem();
        unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
        unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
        unManagedFileSystem.setStorageSystemUri(system.getId());
        unManagedFileSystem.setStoragePoolUri(pool.getId());
        unManagedFileSystem.setHasExports(false);
        unManagedFileSystem.setHasShares(false);
    }
    Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
    StringMap unManagedFileSystemCharacteristics = new StringMap();
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
    if (fileSystem.getType().equals(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name())) {
        unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), FALSE);
    } else {
        unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
    if (null != system) {
        StringSet systemTypes = new StringSet();
        systemTypes.add(system.getSystemType());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
    }
    if (null != pool) {
        StringSet pools = new StringSet();
        pools.add(pool.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
        // We should check matched vpool based on storagepool of type for given fs.
        // In vipr, storagepool of thin is taken as THICK
        StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
        _logger.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
        if (null == matchedVPools || matchedVPools.isEmpty()) {
            // clear all existing supported vpools.
            unManagedFileSystem.getSupportedVpoolUris().clear();
        } else {
            // replace with new StringSet
            unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
            _logger.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
        }
    }
    if (null != storagePort) {
        StringSet storagePorts = new StringSet();
        storagePorts.add(storagePort.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
    // Set attributes of FileSystem
    StringSet fsPath = new StringSet();
    fsPath.add("/" + fileSystem.getFsName());
    StringSet fsMountPath = new StringSet();
    fsMountPath.add("/" + fileSystem.getFsName());
    StringSet fsName = new StringSet();
    fsName.add(fileSystem.getFsName());
    StringSet fsId = new StringSet();
    fsId.add(fileSystem.getFsId() + "");
    unManagedFileSystem.setLabel(fileSystem.getFsName());
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAME.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NATIVE_ID.toString(), fsId);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PATH.toString(), fsPath);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
    StringSet allocatedCapacity = new StringSet();
    String usedCapacity = "0";
    if (fileSystem.getUsedCapacity() != null) {
        usedCapacity = fileSystem.getUsedCapacity();
    }
    allocatedCapacity.add(usedCapacity);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    StringSet provisionedCapacity = new StringSet();
    String capacity = "0";
    if (fileSystem.getTotalCapacity() != null) {
        capacity = fileSystem.getTotalCapacity();
    }
    provisionedCapacity.add(capacity);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
    // Add fileSystemInformation and Characteristics.
    unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
    unManagedFileSystem.setFileSystemCharacterstics(unManagedFileSystemCharacteristics);
    return unManagedFileSystem;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)257 URI (java.net.URI)108 ArrayList (java.util.ArrayList)90 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)59 StringSet (com.emc.storageos.db.client.model.StringSet)57 HashMap (java.util.HashMap)57 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)48 ExportMask (com.emc.storageos.db.client.model.ExportMask)43 Volume (com.emc.storageos.db.client.model.Volume)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)41 StoragePool (com.emc.storageos.db.client.model.StoragePool)39 Initiator (com.emc.storageos.db.client.model.Initiator)38 List (java.util.List)34 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)33 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)31 HashSet (java.util.HashSet)30 Project (com.emc.storageos.db.client.model.Project)24 StoragePort (com.emc.storageos.db.client.model.StoragePort)23 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Network (com.emc.storageos.db.client.model.Network)21