Search in sources :

Example 1 with QueryStats

use of com.emc.nas.vnxfile.xmlapi.QueryStats in project coprhd-controller by CoprHD.

the class VNXFileArgsCreator method fetchFileSystemUsageStats.

/**
 * create a FileSystemUsage XML request and returns a stream after marshalling.
 *
 * @param argument
 * @param keyMap
 * @param index
 * @return
 * @throws VNXFilePluginException
 */
public InputStream fetchFileSystemUsageStats(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("Creating filesystem usage query");
    InputStream iStream = null;
    try {
        QueryStats queryStats = new QueryStats();
        FileSystemUsageSet fsUsageSet = new FileSystemUsageSet();
        queryStats.setFileSystemUsage(fsUsageSet);
        iStream = _vnxFileInputRequestBuilder.getSingleQueryStatsPacket(queryStats);
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while generating input xml for fileSystem usage info", jaxbException.getCause());
    }
    return iStream;
}
Also used : FileSystemUsageSet(com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet) QueryStats(com.emc.nas.vnxfile.xmlapi.QueryStats) InputStream(java.io.InputStream) JAXBException(javax.xml.bind.JAXBException)

Example 2 with QueryStats

use of com.emc.nas.vnxfile.xmlapi.QueryStats in project coprhd-controller by CoprHD.

the class VNXFileArgsCreator method fetchMoverStats.

/**
 * create Mover stats query and returns its stream after marshalling.
 *
 * @param argument
 * @param keyMap
 * @param index
 * @return
 * @throws VNXFilePluginException
 */
public InputStream fetchMoverStats(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("VNX Mover Stats query");
    InputStream iStream = null;
    List<QueryStats> statsList = new ArrayList<QueryStats>();
    try {
        Set<String> movers = (Set<String>) keyMap.get(VNXFileConstants.MOVERLIST);
        if (null != movers && !movers.isEmpty()) {
            for (String moverID : movers) {
                QueryStats queryStats = new QueryStats();
                MoverStatsSetQueryParams moverStatsSetQueryParams = new MoverStatsSetQueryParams();
                moverStatsSetQueryParams.setStatsSet(MoverStatsSetType.NETWORK_DEVICES);
                moverStatsSetQueryParams.setMover(moverID);
                queryStats.setMoverStats(moverStatsSetQueryParams);
                statsList.add(queryStats);
            }
            iStream = _vnxFileInputRequestBuilder.getMultiRequestQueryStatsPacket(statsList);
        } else {
            _logger.error("No movers found to construct volumeStats query.");
        }
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while generating input xml for celerra mover stats", jaxbException.getCause());
    }
    return iStream;
}
Also used : FileSystemUsageSet(com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet) Set(java.util.Set) QueryStats(com.emc.nas.vnxfile.xmlapi.QueryStats) InputStream(java.io.InputStream) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) MoverStatsSetQueryParams(com.emc.nas.vnxfile.xmlapi.MoverStatsSetQueryParams)

Example 3 with QueryStats

use of com.emc.nas.vnxfile.xmlapi.QueryStats in project coprhd-controller by CoprHD.

the class VNXFileArgsCreator method fetchVolumeStats.

/**
 * Create volume stats XML request query and returns a stream after marshalling.
 *
 * @param argument
 * @param keyMap
 * @param index
 * @return
 * @throws VNXFilePluginException
 */
@SuppressWarnings("unchecked")
public InputStream fetchVolumeStats(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("Creating volume stats query");
    InputStream iStream = null;
    List<QueryStats> statList = new ArrayList<QueryStats>();
    try {
        Set<String> movers = (Set<String>) keyMap.get(VNXFileConstants.MOVERLIST);
        if (null != movers && !movers.isEmpty()) {
            for (String moverID : movers) {
                QueryStats queryStats = new QueryStats();
                VolumeStatsSetQueryParams params = new VolumeStatsSetQueryParams();
                params.setStatsSet(VolumeStatsSetType.ALL);
                params.setMover(moverID);
                queryStats.setVolumeStats(params);
                statList.add(queryStats);
            }
            iStream = _vnxFileInputRequestBuilder.getMultiRequestQueryStatsPacket(statList);
        } else {
            _logger.error("No movers found to construct volumeStats query.");
        }
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while fetching fileSystem info", jaxbException.getCause());
    }
    return iStream;
}
Also used : FileSystemUsageSet(com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet) Set(java.util.Set) QueryStats(com.emc.nas.vnxfile.xmlapi.QueryStats) InputStream(java.io.InputStream) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) VolumeStatsSetQueryParams(com.emc.nas.vnxfile.xmlapi.VolumeStatsSetQueryParams)

Example 4 with QueryStats

use of com.emc.nas.vnxfile.xmlapi.QueryStats in project coprhd-controller by CoprHD.

the class VNXFileInputRequestBuilder method getMultiRequestQueryStatsPacket.

/**
 * This method responsible to generate a multiple request packets
 * for the given list of QueryStats.
 *
 * @param stats : list of QueryStats.
 * @return : stream
 */
public InputStream getMultiRequestQueryStatsPacket(List<QueryStats> stats) throws JAXBException {
    InputStream inputStream = null;
    List<Request> requests = new ArrayList<Request>(stats.size());
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    RequestPacket requestPacket = new RequestPacket();
    try {
        // Create a new Request object for each QueryStat
        for (QueryStats querStat : stats) {
            Request request = new Request();
            request.setQueryStats(querStat);
            requests.add(request);
        }
        requestPacket.getRequestOrRequestEx().addAll(requests);
        _marshaller.marshal(requestPacket, outputStream);
        inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    } finally {
        try {
            outputStream.close();
        } catch (IOException e) {
            _logger.error("IOException occurred while querying due to ", e);
        }
    }
    return inputStream;
}
Also used : RequestPacket(com.emc.nas.vnxfile.xmlapi.RequestPacket) QueryStats(com.emc.nas.vnxfile.xmlapi.QueryStats) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Request(com.emc.nas.vnxfile.xmlapi.Request) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

QueryStats (com.emc.nas.vnxfile.xmlapi.QueryStats)4 InputStream (java.io.InputStream)4 FileSystemUsageSet (com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet)3 ArrayList (java.util.ArrayList)3 JAXBException (javax.xml.bind.JAXBException)3 Set (java.util.Set)2 MoverStatsSetQueryParams (com.emc.nas.vnxfile.xmlapi.MoverStatsSetQueryParams)1 Request (com.emc.nas.vnxfile.xmlapi.Request)1 RequestPacket (com.emc.nas.vnxfile.xmlapi.RequestPacket)1 VolumeStatsSetQueryParams (com.emc.nas.vnxfile.xmlapi.VolumeStatsSetQueryParams)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1