Search in sources :

Example 1 with XtremIOLunMapFull

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull in project coprhd-controller by CoprHD.

the class XtremIOProvUtils method getLunMapAndVolumes.

public static Map<String, List<XtremIOVolume>> getLunMapAndVolumes(Set<String> igNameSet, String clusterName, XtremIOClient client, Map<String, List<XtremIOVolume>> igNameToVolMap) throws Exception {
    List<XtremIOLunMapFull> igLunMaps = new ArrayList<>();
    long starttime = 0l;
    starttime = System.nanoTime();
    igLunMaps = client.getLunMapsForAllInitiatorGroups(igNameSet, clusterName);
    _log.debug("Time taken for All Lun API Call : " + "total time = " + String.format("%2.6f", (System.nanoTime() - starttime) / 1000000000.0) + " seconds");
    HashMap<String, List<String>> map = new HashMap<>();
    HashMap<String, XtremIOVolume> indexInfoMap = new HashMap<>();
    StringBuilder volumeURL = new StringBuilder();
    String indexFilter = "index:eq:";
    int indexSize = 0;
    long starttime1 = System.nanoTime();
    for (XtremIOLunMapFull lunMapFull : igLunMaps) {
        for (XtremIOLunMap lunmap : lunMapFull.getContent()) {
            if (map.containsKey(lunmap.getIgName())) {
                map.get(lunmap.getIgName()).add(lunmap.getVolumeIndex());
                map.put(lunmap.getIgName(), map.get(lunmap.getIgName()));
                volumeURL = volumeURL.append(indexFilter).append(lunmap.getVolumeIndex()).append(",");
                indexSize++;
            } else {
                List<String> volumeIndexList = new ArrayList<>();
                volumeIndexList.add(lunmap.getVolumeIndex());
                map.put(lunmap.getIgName(), volumeIndexList);
                volumeURL = volumeURL.append(indexFilter).append(lunmap.getVolumeIndex()).append(",");
                indexSize++;
            }
            if (indexSize >= XtremIOConstants.XTREMIO_MAX_Filters) {
                starttime = System.nanoTime();
                XtremIOVolumesFull volumes = client.getVolumesForAllInitiatorGroups(clusterName, volumeURL);
                _log.debug("Time taken for Volume API Call : " + "total time = " + String.format("%2.6f", (System.nanoTime() - starttime) / 1000000000.0) + " seconds , numFilters = " + indexSize);
                for (XtremIOVolume volume : volumes.getContent()) {
                    indexInfoMap.put(volume.getVolInfo().get(2), volume);
                }
                volumeURL = new StringBuilder();
                indexSize = 0;
            }
        }
    }
    starttime = System.nanoTime();
    XtremIOVolumesFull volumes = client.getVolumesForAllInitiatorGroups(clusterName, volumeURL);
    _log.debug("Time taken for Volume API Call : " + "total time = " + String.format("%2.6f", (System.nanoTime() - starttime) / 1000000000.0) + " seconds , numFilters = " + indexSize);
    _log.debug("Time taken for All Volume API Call : " + "total time = " + String.format("%2.6f", (System.nanoTime() - starttime1) / 1000000000.0) + " seconds ");
    for (XtremIOVolume volume : volumes.getContent()) {
        indexInfoMap.put(volume.getVolInfo().get(2), volume);
    }
    for (Map.Entry<String, List<String>> entry1 : map.entrySet()) {
        List<XtremIOVolume> discoveredVolumes = new ArrayList<>();
        for (Map.Entry<String, XtremIOVolume> entry2 : indexInfoMap.entrySet()) {
            if (entry1.getValue().contains(entry2.getKey())) {
                discoveredVolumes.add(entry2.getValue());
            }
        }
        igNameToVolMap.put(entry1.getKey(), discoveredVolumes);
    }
    return igNameToVolMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) XtremIOVolumesFull(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumesFull) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) XtremIOLunMapFull(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) Map(java.util.Map) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap)

Example 2 with XtremIOLunMapFull

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull in project coprhd-controller by CoprHD.

the class XtremIOV2Client method getLunMapsForAllInitiatorGroups.

@Override
public List<XtremIOLunMapFull> getLunMapsForAllInitiatorGroups(Set<String> igNameSet, String clusterName) throws Exception {
    String filterString = String.format(XtremIOConstants.XTREMIO_LUNMAP_IG_FILTER_FULL_STR, clusterName);
    List<XtremIOLunMapFull> igLunMapsList = new ArrayList<>();
    int indexSize = 0;
    for (String igName : igNameSet) {
        if (igName != null) {
            filterString = filterString + "ig-name:eq:" + igName + ",";
            indexSize++;
        }
        if (indexSize >= XtremIOConstants.XTREMIO_MAX_Filters) {
            filterString = filterString.substring(0, filterString.length() - 1);
            String uriString = XtremIOConstants.XTREMIO_V2_LUNMAPS_STR.concat(filterString);
            ClientResponse response = get(URI.create(uriString));
            XtremIOLunMapFull lunMapLinks = getResponseObject(XtremIOLunMapFull.class, response);
            igLunMapsList.add(lunMapLinks);
            indexSize = 0;
            filterString = String.format(XtremIOConstants.XTREMIO_LUNMAP_IG_FILTER_FULL_STR, clusterName);
        }
    }
    filterString = filterString.substring(0, filterString.length() - 1);
    String uriString = XtremIOConstants.XTREMIO_V2_LUNMAPS_STR.concat(filterString);
    ClientResponse response = get(URI.create(uriString));
    XtremIOLunMapFull lunMapLinks = getResponseObject(XtremIOLunMapFull.class, response);
    igLunMapsList.add(lunMapLinks);
    return igLunMapsList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOLunMapFull(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull) ArrayList(java.util.ArrayList)

Aggregations

XtremIOLunMapFull (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMapFull)2 ArrayList (java.util.ArrayList)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 XtremIOLunMap (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap)1 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)1 XtremIOVolumesFull (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumesFull)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1