Search in sources :

Example 1 with DataGridServerStatusComparator

use of com.emc.metalnx.services.machine.util.DataGridServerStatusComparator in project metalnx-web by irods-contrib.

the class ServerServiceImpl method getAllServers.

@Override
public List<DataGridServer> getAllServers(List<DataGridResource> resources, HashMap<String, DataGridServer> serverMapInCache) throws DataGridConnectionRefusedException {
    logger.info("Getting the list of all servers of the Grid");
    List<DataGridServer> servers = resourceService.getAllResourceServers(resources);
    initServerThreads(servers);
    for (DataGridServer server : servers) {
        String serverHostName = server.getHostname();
        List<DataGridResource> serverResources = null;
        // Getting general status of the server
        String serverInfo = getServerInfo(serverHostName);
        ObjectMapper mapper = new ObjectMapper();
        String machineStatus = null;
        String diskInfo = null;
        String rmdInfo = null;
        try {
            JsonNode json = mapper.readTree(serverInfo);
            machineStatus = json.get("serverstatus").toString();
            diskInfo = json.get("disk").toString();
            rmdInfo = json.get("version").toString();
            serverResources = serverMapInCache.get(serverHostName).getResources();
        } catch (IOException | NullPointerException e) {
            logger.error("Could not parse server information: {}", e.getMessage());
        }
        ServerUtil.populateDataGridServerStatus(machineStatus, server);
        ServerUtil.setDataGridServerRMDInfo(rmdInfo, server);
        // Retrieving storage info
        long totalStorageAvailable = storageService.totalAvailableStorageOfAServer(serverHostName, diskInfo, serverResources);
        long totalStorageUsed = storageService.totalUsedStorageOfAServer(serverHostName, diskInfo, serverResources);
        long totalStorage = totalStorageAvailable + totalStorageUsed;
        server.setTotalStorage(totalStorage);
        server.setTotalStorageAvailable(totalStorageAvailable);
        server.setTotalStorageUsed(totalStorageUsed);
    }
    Collections.sort(servers, new DataGridServerStatusComparator());
    return servers;
}
Also used : DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DataGridServerStatusComparator(com.emc.metalnx.services.machine.util.DataGridServerStatusComparator)

Example 2 with DataGridServerStatusComparator

use of com.emc.metalnx.services.machine.util.DataGridServerStatusComparator in project metalnx-web by irods-contrib.

the class ServerServiceImpl method getAllIsilonServers.

@Override
public List<DataGridServer> getAllIsilonServers(List<DataGridResource> resources) {
    logger.info("Getting the list of all isilon servers of the Grid");
    List<DataGridServer> isilonServers = resourceService.getAllIsilonServers(resources);
    Collections.sort(isilonServers, new DataGridServerStatusComparator());
    return isilonServers == null || isilonServers.isEmpty() ? null : isilonServers;
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer) DataGridServerStatusComparator(com.emc.metalnx.services.machine.util.DataGridServerStatusComparator)

Aggregations

DataGridServer (com.emc.metalnx.core.domain.entity.DataGridServer)2 DataGridServerStatusComparator (com.emc.metalnx.services.machine.util.DataGridServerStatusComparator)2 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1