Search in sources :

Example 46 with StringSetMap

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

the class BlockStorageScheduler method internalAssignStoragePorts.

/**
 * Allocates and assigns StoragePorts.
 *
 * @param system - The StorageSystem the ports will be assigned from.
 * @param varray - The VirtualArray (ex. Neighborhood) the initiators should be found in.
 * @param newInitiators - The new initiators to be provisioned.
 * @param volumeURIs - list of volumes
 * @param pathParams - Export path parameters (maxPaths, pathsPerInitiator)
 * @param existingZoningMap - A map of initiators to a set of previously allocated port URI strings.
 * @return Map<URI, List<URI>> Initiator URI to list of Target StoragePort URIs
 */
private Map<URI, List<URI>> internalAssignStoragePorts(StorageSystem system, URI varray, List<Initiator> newInitiators, Collection<URI> volumeURIs, ExportPathParams pathParams, StringSetMap existingZoningMap) {
    // Make reasonable defaults for the path parameters.
    checkPathParams(pathParams, system);
    _log.info(String.format("Assigning Ports for Array %s params %s Varray %s", system.getNativeGuid(), pathParams.toString(), varray));
    // Get the existing assignments in object form.
    Map<Initiator, List<StoragePort>> existingAssignments = generateInitiatorsToStoragePortsMap(existingZoningMap, varray);
    // Group the new initiators by their networks - filter out those not in a network
    Map<NetworkLite, List<Initiator>> initiatorsByNetwork = getInitiatorsByNetwork(newInitiators, existingZoningMap, _dbClient);
    Map<Initiator, NetworkLite> initiatorsToNetworkLiteMap = getInitiatorToNetworkLiteMap(initiatorsByNetwork);
    // Get the storage ports in the storage system that can be used in the initiators networks
    Map<NetworkLite, List<StoragePort>> portsByNetwork = selectStoragePortsInNetworks(system.getId(), initiatorsByNetwork.keySet(), varray, pathParams);
    // allocate ports balancing across networks and considering port metrics
    Map<NetworkLite, List<StoragePort>> allocatedPorts = allocatePorts(system, varray, initiatorsByNetwork, portsByNetwork, volumeURIs, pathParams, existingZoningMap);
    StoragePortsAssigner assigner = StoragePortsAssignerFactory.getAssigner(system.getSystemType());
    Map<Initiator, List<StoragePort>> assignments = new HashMap<Initiator, List<StoragePort>>();
    // Call StoragePortsAssigner once per host to do the assignments
    Map<URI, Map<URI, List<Initiator>>> hostsToNetToInitiators = getHostInitiatorsMapFromNetworkLite(initiatorsByNetwork);
    Map<URI, List<StoragePort>> allocatedPortsMap = getAllocatedPortsMap(allocatedPorts);
    // For each host, assign the ports to the appropriate initiators.
    for (URI hostURI : hostsToNetToInitiators.keySet()) {
        Map<URI, Map<String, List<Initiator>>> switchInitiatorsByNet = new HashMap<URI, Map<String, List<Initiator>>>();
        Map<URI, Map<String, List<StoragePort>>> switchStoragePortsByNet = new HashMap<URI, Map<String, List<StoragePort>>>();
        Map<URI, List<Initiator>> initiatorByNetMap = hostsToNetToInitiators.get(hostURI);
        PlacementUtils.getSwitchfoForInititaorsStoragePorts(initiatorByNetMap, allocatedPortsMap, _dbClient, system, switchInitiatorsByNet, switchStoragePortsByNet);
        assigner.assignPortsToHost(assignments, initiatorByNetMap, allocatedPortsMap, pathParams, existingAssignments, hostURI, initiatorsToNetworkLiteMap, switchInitiatorsByNet, switchStoragePortsByNet);
    }
    // Validate that minPaths was met across all assignments (existing and new).
    validateMinPaths(system, pathParams, existingAssignments, assignments, newInitiators);
    return convertAssignmentsToURIs(assignments);
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TreeMap(java.util.TreeMap)

Example 47 with StringSetMap

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

the class BlockStorageScheduler method getZoneMapFromAssignments.

/**
 * Returns a StringSetMap containing the Initiator to StoragePort URIs.
 *
 * @param assignments Map<URI, List<URI>>
 * @return StringSetMap with same information encoded
 */
public static StringSetMap getZoneMapFromAssignments(Map<URI, List<URI>> assignments) {
    StringSetMap zoneMap = new StringSetMap();
    for (URI initiatorURI : assignments.keySet()) {
        StringSet portIds = new StringSet();
        List<URI> portURIs = assignments.get(initiatorURI);
        for (URI portURI : portURIs) {
            portIds.add(portURI.toString());
        }
        zoneMap.put(initiatorURI.toString(), portIds);
    }
    return zoneMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI)

Example 48 with StringSetMap

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

the class BlockStorageScheduler method assignSelectedStoragePorts.

/**
 * Assigns storage ports to initiators.
 *
 * @param system storage system which contains storage ports
 * @param storagePorts storage ports to assign
 * @param virtualArray virtual array which contains storage ports
 * @param initiators list of initiators
 * @param pathParams the export path parameters
 * @param existingZoningMap existing zoning map in the mask
 * @return assignments of storage ports to initiators
 * @throws DeviceControllerException
 */
public Map<URI, List<URI>> assignSelectedStoragePorts(StorageSystem system, List<StoragePort> storagePorts, URI virtualArray, List<Initiator> initiators, ExportPathParams pathParams, StringSetMap existingZoningMap) throws DeviceControllerException {
    Map<Initiator, List<StoragePort>> assignments = new HashMap<>();
    try {
        // Group the new initiators by their networks - filter out those not in a network
        Map<NetworkLite, List<Initiator>> initiatorsByNetwork = getInitiatorsByNetwork(initiators, existingZoningMap, _dbClient);
        Map<Initiator, NetworkLite> initiatorsToNetworkLiteMap = getInitiatorToNetworkLiteMap(initiatorsByNetwork);
        // Get the storage ports that can be used in the initiators networks
        Map<NetworkLite, List<StoragePort>> portsByNetwork = selectStoragePortsInNetworks(storagePorts, initiatorsByNetwork.keySet(), virtualArray, pathParams);
        StoragePortsAssigner assigner = StoragePortsAssignerFactory.getAssigner(system.getSystemType());
        // Call StoragePortsAssigner once per host to do the assignments
        Map<URI, Map<URI, List<Initiator>>> hostsToNetToInitiators = getHostInitiatorsMapFromNetworkLite(initiatorsByNetwork);
        Map<URI, List<StoragePort>> allocatedPortsMap = getAllocatedPortsMap(portsByNetwork);
        // Get the existing assignments in object form.
        Map<Initiator, List<StoragePort>> existingAssignments = generateInitiatorsToStoragePortsMap(existingZoningMap, virtualArray);
        // For each host, assign the ports to the appropriate initiators.
        for (URI hostURI : hostsToNetToInitiators.keySet()) {
            assigner.assignPortsToHost(assignments, hostsToNetToInitiators.get(hostURI), allocatedPortsMap, pathParams, existingAssignments, hostURI, initiatorsToNetworkLiteMap, null, null);
        }
        // Validate that minPaths was met across all assignments (existing and new).
        validateMinPaths(system, pathParams, existingAssignments, assignments, initiators);
        return convertAssignmentsToURIs(assignments);
    } catch (PlacementException e) {
        _log.error("Unable to assign storage Ports", e);
        throw DeviceControllerException.exceptions.exceptionAssigningStoragePorts(e.getMessage(), e);
    } catch (Exception e) {
        _log.error("Unable to assign Storage Ports", e);
        throw DeviceControllerException.exceptions.unexpectedExceptionAssigningPorts(e);
    }
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TreeMap(java.util.TreeMap)

Example 49 with StringSetMap

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

the class ZonedPortsStoragePortsAssigner method isPortAssignableToInitiator.

@Override
public boolean isPortAssignableToInitiator(NetworkLite initiatorNetwork, Initiator initiator, StoragePort port) {
    StringSetMap zoneMap = zonesByNetwork.get(initiatorNetwork);
    StringSet initiatorZonedPorts = zoneMap.get(initiator.getId().toString());
    if (initiatorZonedPorts != null && !initiatorZonedPorts.isEmpty()) {
        for (String portId : initiatorZonedPorts) {
            if (portId.equals(port.getId().toString())) {
                return true;
            }
        }
    }
    return false;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 50 with StringSetMap

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

the class BlockConsistencyGroupUtils method getGroupNamesForSystemCG.

/**
 * Return a set of ReplicationGroup names for the given storage system and consistency group.
 *
 * @param consistencyGroup  Consistency group
 * @param storageSystem     Storage system
 * @return                  Set of group names or an empty set if none exist.
 */
public static Set<String> getGroupNamesForSystemCG(BlockConsistencyGroup consistencyGroup, StorageSystem storageSystem) {
    checkNotNull(consistencyGroup);
    checkNotNull(storageSystem);
    Set<String> result = new HashSet<>();
    StringSetMap systemConsistencyGroups = consistencyGroup.getSystemConsistencyGroups();
    if (systemConsistencyGroups != null) {
        StringSet cgsForSystem = systemConsistencyGroups.get(storageSystem.getId().toString());
        if (cgsForSystem != null || !cgsForSystem.isEmpty()) {
            result.addAll(cgsForSystem);
        }
    }
    return result;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet) HashSet(java.util.HashSet)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16