Search in sources :

Example 26 with DataGridServer

use of com.emc.metalnx.core.domain.entity.DataGridServer in project metalnx-web by irods-contrib.

the class MSIServiceImpl method findServerByHostname.

/**
 * Looks for a server instance based on its hostname
 *
 * @param host
 *            server's hostname
 * @return server instance
 */
private DataGridServer findServerByHostname(String host) throws DataGridConnectionRefusedException {
    // update list of servers
    getMSIInfoForAllServers();
    DataGridServer server = null;
    for (DataGridServer s : servers) {
        if (host.equals(s.getHostname())) {
            server = s;
            break;
        }
    }
    return server;
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer)

Example 27 with DataGridServer

use of com.emc.metalnx.core.domain.entity.DataGridServer 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 28 with DataGridServer

use of com.emc.metalnx.core.domain.entity.DataGridServer 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)

Example 29 with DataGridServer

use of com.emc.metalnx.core.domain.entity.DataGridServer in project metalnx-web by irods-contrib.

the class StorageServiceImpl method totalUsedStorageOfGrid.

@Override
public long totalUsedStorageOfGrid(List<DataGridServer> servers) {
    logger.info("Get total used storage of the grid");
    long totalUsedStorage = 0;
    for (DataGridServer dataGridServer : servers) {
        totalUsedStorage += dataGridServer.getTotalStorageUsed();
    }
    return totalUsedStorage;
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer)

Example 30 with DataGridServer

use of com.emc.metalnx.core.domain.entity.DataGridServer in project metalnx-web by irods-contrib.

the class TestPluginService method testMSIListForIRODS41X.

@Test
public void testMSIListForIRODS41X() throws DataGridConnectionRefusedException, DataGridRuleException {
    when(mockRuleService.execGetMSIsRule(anyString())).thenReturn(new ArrayList<>());
    when(irodsServices.isAtLeastIrods420()).thenReturn(false);
    DataGridServer server = msiService.getMSIsInstalled("server1.test.com");
    assertFalse(server.isThereAnyMSI());
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer) Test(org.junit.Test)

Aggregations

DataGridServer (com.emc.metalnx.core.domain.entity.DataGridServer)31 Test (org.junit.Test)12 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)7 ArrayList (java.util.ArrayList)5 Matchers.anyString (org.mockito.Matchers.anyString)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 DataGridMSIPkgInfo (com.emc.metalnx.core.domain.entity.DataGridMSIPkgInfo)2 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 DataGridServerStatusComparator (com.emc.metalnx.services.machine.util.DataGridServerStatusComparator)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 IOException (java.io.IOException)2 UnknownHostException (java.net.UnknownHostException)2 Before (org.junit.Before)2 ServerInformationRetrievalThread (com.emc.metalnx.services.machine.util.ServerInformationRetrievalThread)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1