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;
}
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;
}
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();
}
}
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);
}
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());
}
Aggregations