Search in sources :

Example 26 with DataGridResource

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;
}
Also used : ArrayList(java.util.ArrayList) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataGridServer(com.emc.metalnx.core.domain.entity.DataGridServer)

Example 27 with DataGridResource

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;
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) JargonException(org.irods.jargon.core.exception.JargonException) Resource(org.irods.jargon.core.pub.domain.Resource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) ZoneAO(org.irods.jargon.core.pub.ZoneAO)

Example 28 with DataGridResource

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());
}
Also used : DataGridRule(com.emc.metalnx.core.domain.entity.DataGridRule) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource)

Example 29 with DataGridResource

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);
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) HashMap(java.util.HashMap) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 30 with DataGridResource

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

Aggregations

DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)34 ArrayList (java.util.ArrayList)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)6 DataGridServer (com.emc.metalnx.core.domain.entity.DataGridServer)5 IOException (java.io.IOException)4 UnknownHostException (java.net.UnknownHostException)4 JargonException (org.irods.jargon.core.exception.JargonException)4 ResourceAO (org.irods.jargon.core.pub.ResourceAO)4 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 Date (java.util.Date)3 JSONObject (org.codehaus.jettison.json.JSONObject)3 DataGridResourceType (com.emc.metalnx.core.domain.entity.DataGridResourceType)2 DataGridRule (com.emc.metalnx.core.domain.entity.DataGridRule)2 DataGridServerException (com.emc.metalnx.core.domain.exceptions.DataGridServerException)2 ResourceForm (com.emc.metalnx.modelattribute.resource.ResourceForm)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSONArray (org.codehaus.jettison.json.JSONArray)2