use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method getAllIsilonServers.
@Override
public List<DataGridServer> getAllIsilonServers(List<DataGridResource> resources) {
logger.info("Getting all isilon servers");
List<DataGridServer> isilonServers = new ArrayList<>();
for (DataGridResource resource : resources) {
logger.debug("Listing resource information: {}", resource);
if (resource.getContextString().contains("isi_host")) {
DataGridServer isilonServer = new DataGridServer();
String isilonHostIp = getIsilonProperties(resource.getContextString()).get("isi_host");
if (isilonHostIp == null) {
isilonHostIp = new String("");
}
isilonServer.setHostname(isilonHostIp);
isilonServer.setIp(isilonHostIp);
isilonServer.setType(DataGridServerType.ISILON);
if (!isilonServers.contains(isilonServer)) {
isilonServers.add(isilonServer);
}
}
}
Collections.sort(isilonServers);
logger.info("Isilon servers done");
return isilonServers;
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method createResource.
@Override
public boolean createResource(DataGridResource newDataGridResource) throws DataGridConnectionRefusedException {
try {
ResourceAO resourceAO = irodsServices.getResourceAO();
ZoneAO zoneAO = irodsServices.getZoneAO();
// mapping data grid resource to iRODS Resource
Resource irodsResource = new Resource();
irodsResource.setName(newDataGridResource.getName());
irodsResource.setType(newDataGridResource.getType());
irodsResource.setZone(zoneAO.getZoneByName(newDataGridResource.getZone()));
irodsResource.setCreateTime(newDataGridResource.getCreateTime());
irodsResource.setModifyTime(newDataGridResource.getModifyTime());
irodsResource.setStatus(newDataGridResource.getStatus());
irodsResource.setInfo(newDataGridResource.getInfo());
irodsResource.setParentName(newDataGridResource.getParent());
irodsResource.setVaultPath(newDataGridResource.getPath());
irodsResource.setLocation(newDataGridResource.getHost());
// context string is not always set
if (newDataGridResource.getContextString() != null) {
irodsResource.setContextString(newDataGridResource.getContextString());
}
// adding the new resource to iRODS
resourceAO.addResource(irodsResource);
return true;
} catch (JargonException e) {
logger.error("Could not create resource: ", e);
}
return false;
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class RuleServiceImpl method execEmptyTrashRule.
@Override
public void execEmptyTrashRule(String destResc, String objPath, boolean inAdminMode) throws DataGridConnectionRefusedException, DataGridRuleException {
logger.info("Empty Trash Rule called");
DataGridResource dgResc = rs.find(destResc);
DataGridRule rule = new DataGridRule(DataGridRule.EMPTY_TRASH_RULE, dgResc.getHost(), false);
String flag = inAdminMode ? "irodsAdminRmTrash=" : "irodsRmTrash=";
rule.setInputRuleParams(objPath, flag);
rule.setOutputRuleParams("out");
executeRule(rule.toString());
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listReplicasByResource.
@Override
public Map<DataGridCollectionAndDataObject, DataGridResource> listReplicasByResource(String path) throws DataGridConnectionRefusedException {
logger.info("listReplicasByResource()");
logger.info("Listing all replicas of " + path);
Map<DataGridCollectionAndDataObject, DataGridResource> map = new HashMap<DataGridCollectionAndDataObject, DataGridResource>();
String collectionAbsPath = null;
String fileName = null;
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
try {
collectionAbsPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
fileName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR) + 1, path.length());
List<DataObject> replicas = dataObjectAO.listReplicationsForFile(collectionAbsPath, fileName);
for (DataObject replica : replicas) {
DataGridCollectionAndDataObject dataGridCollectionAndDataObject = DataGridUtils.getDataGridCollectionAndDataObject(replica);
DataGridResource dataGridResource = resourceService.find(replica.getResourceName());
map.put(dataGridCollectionAndDataObject, dataGridResource);
}
} catch (JargonException e) {
logger.error("Could not list replicas by resource for " + path);
}
return DataGridUtils.sortReplicaResourceMap(map);
}
use of com.emc.metalnx.core.domain.entity.DataGridResource 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;
}
Aggregations