Search in sources :

Example 6 with DataGridServer

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

the class DashboardController method isRMDRunningOnAllServers.

/**
 * Checks if the RMD package is running on all data grid servers
 *
 * @return true, if the package is running on all servers. False, otherwise.
 */
private boolean isRMDRunningOnAllServers() {
    logger.info("isRMDRunningOnAllServers()");
    boolean isRunning = true;
    serverMap = new HashMap<>();
    for (DataGridServer server : servers) {
        serverMap.put(server.getHostname(), server);
        if (!server.isRmdPackageRunning()) {
            isRunning = false;
        }
    }
    return isRunning;
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer)

Example 7 with DataGridServer

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

the class ServerServiceImpl method getAllNonResourceServers.

@Override
public List<DataGridServer> getAllNonResourceServers(List<DataGridServer> servers, HashMap<String, DataGridServer> serverMapInCache, List<DataGridResource> dataGridResources) throws DataGridConnectionRefusedException {
    logger.info("Getting the list of all non-resource servers from the Grid using Resource cache");
    List<DataGridServer> nonResourceServers = new ArrayList<DataGridServer>();
    for (DataGridServer server : servers) {
        if (server.getHostname().compareToIgnoreCase("localhost") == 0) {
            continue;
        }
        ObjectMapper mapper = new ObjectMapper();
        String mounts = null;
        try {
            String serverInfo = getServerInfo(server.getHostname());
            JsonNode json = mapper.readTree(serverInfo);
            mounts = json.get("mounts").toString();
        } catch (JsonProcessingException e) {
            logger.error("Could not parse server information", e.getMessage());
        } catch (IOException e) {
            logger.error("Could not parse server information", e.getMessage());
        }
        if (mounts != null && !mounts.isEmpty()) {
            HashMap<String, String> hashMap = ServerUtil.getNFSMountMap(mounts);
            List<DataGridResource> resources = null;
            try {
                logger.info("Getting resources of a server {}", server.getHostname());
                resources = resourceService.getResourcesOfAServer(server.getHostname(), dataGridResources);
            } catch (DataGridConnectionRefusedException e) {
                // any
                if (serverMapInCache != null) {
                    resources = serverMapInCache.get(server.getHostname()).getResources();
                } else {
                    resources = new ArrayList<DataGridResource>();
                }
            }
            for (DataGridResource resource : resources) {
                if (hashMap.containsKey(resource.getPath())) {
                    String host = hashMap.get(resource.getPath());
                    DataGridServer newServer = new DataGridServer();
                    try {
                        host = reverseDnsLookup.compareTo("true") == 0 ? machineInfoService.getHostName(host) : host;
                        newServer.setHostname(host);
                        newServer.setIp(machineInfoService.getAddress(host));
                    } catch (UnknownHostException e) {
                        logger.error("Could not resolve IP address for " + host);
                    }
                    if (!nonResourceServers.contains(newServer)) {
                        nonResourceServers.add(newServer);
                    }
                }
            }
        }
    }
    return nonResourceServers.isEmpty() ? null : nonResourceServers;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) UnknownHostException(java.net.UnknownHostException) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 8 with DataGridServer

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

the class ServerServiceImpl method initServerThreads.

/**
 *****************************************************************************************
 */
/* CACHE METHODS */
/**
 *****************************************************************************************
 */
private void initServerThreads(List<DataGridServer> servers) {
    for (DataGridServer server : servers) {
        // Instantiating thread
        ServerInformationRetrievalThread t = new ServerInformationRetrievalThread(server.getHostname(), rmdConnectionPort, ServerRequestInfoType.ALL, Integer.parseInt(rmdConnectionTimeout));
        // Starting thread execution
        t.start();
        // Keeping track of the thread instance
        synchronized (threadList) {
            threadList.add(t);
        }
    }
    synchronized (threadList) {
        for (ServerInformationRetrievalThread t : threadList) {
            try {
                t.join();
                String results = t.getResult();
                if (results == null) {
                    results = "";
                }
                serverInfoCache.put(t.getServerHost(), results);
                cacheTimeToLive.put(t.getServerHost(), System.currentTimeMillis() + 5 * 1000);
            } catch (InterruptedException e) {
                logger.error("Could not get server information on [{}]", t.getServerHost(), e);
            }
        }
    }
    synchronized (threadList) {
        threadList.clear();
    }
}
Also used : DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer) ServerInformationRetrievalThread(com.emc.metalnx.services.machine.util.ServerInformationRetrievalThread)

Example 9 with DataGridServer

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

the class MSIServiceImpl method isMSIAPICompatibleInResc.

@Override
public boolean isMSIAPICompatibleInResc(String resource) throws DataGridConnectionRefusedException {
    if (servers == null || servers.isEmpty())
        getMSIInfoForAllServers();
    DataGridServer server = null;
    for (DataGridServer s : servers) {
        for (DataGridResource dgResc : s.getResources()) {
            if (resource.equals(dgResc.getName())) {
                server = s;
                break;
            }
        }
        if (server != null)
            break;
    }
    String apiVersionSupported = DataGridCoreUtils.getAPIVersion(configService.getMsiAPIVersionSupported());
    String apiVersionInstalled = server != null ? DataGridCoreUtils.getAPIVersion(server.getMSIVersion()) : "";
    return apiVersionSupported.equalsIgnoreCase(apiVersionInstalled);
}
Also used : DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer)

Example 10 with DataGridServer

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

the class TestPluginService method testServers.

@Test
public void testServers() throws DataGridConnectionRefusedException, DataGridRuleException {
    DataGridMSIPkgInfo msiPkgInfo = msiService.getMSIPkgInfo();
    assertEquals(2, msiPkgInfo.getServers().size());
    for (DataGridServer server : msiPkgInfo.getServers()) assertEquals(msiVersion, server.getMSIVersion());
}
Also used : DataGridMSIPkgInfo(com.emc.metalnx.core.domain.entity.DataGridMSIPkgInfo) 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