Search in sources :

Example 21 with DataGridConnectionRefusedException

use of com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException in project metalnx-web by irods-contrib.

the class IRODSServicesImpl method findIRodsVersion.

@Override
public String findIRodsVersion() throws DataGridConnectionRefusedException {
    String version = "";
    try {
        EnvironmentalInfoAO envInfoAO = irodsAccessObjectFactory.getEnvironmentalInfoAO(irodsAccount);
        IrodsVersion iv = envInfoAO.getIRODSServerPropertiesFromIRODSServer().getIrodsVersion();
        version = String.format("%s.%s.%s", iv.getMajorAsString(), iv.getMinorAsString(), iv.getPatchAsString());
    } catch (JargonException e) {
        logger.error("Could not find iRODS version: ", e);
        if (e.getCause() instanceof ConnectException) {
            throw new DataGridConnectionRefusedException(e.getMessage());
        }
    }
    return version;
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) IrodsVersion(org.irods.jargon.core.connection.IrodsVersion) ConnectException(java.net.ConnectException)

Example 22 with DataGridConnectionRefusedException

use of com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException in project metalnx-web by irods-contrib.

the class IRODSServicesImpl method getTicketAdminService.

@Override
public TicketAdminService getTicketAdminService() throws DataGridConnectionRefusedException {
    TicketAdminService tas = null;
    try {
        TicketServiceFactory tsf = new TicketServiceFactoryImpl(irodsAccessObjectFactory);
        tas = tsf.instanceTicketAdminService(irodsAccount);
    } catch (JargonException e) {
        logger.error("Could not instantiate ticket admin service: ", e.getMessage());
        if (e.getCause() instanceof ConnectException) {
            throw new DataGridConnectionRefusedException(e.getMessage());
        }
    }
    return tas;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) TicketServiceFactory(org.irods.jargon.ticket.TicketServiceFactory) TicketServiceFactoryImpl(org.irods.jargon.ticket.TicketServiceFactoryImpl) JargonException(org.irods.jargon.core.exception.JargonException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService) ConnectException(java.net.ConnectException)

Example 23 with DataGridConnectionRefusedException

use of com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException in project metalnx-web by irods-contrib.

the class StorageServiceImpl method totalUsedStorageOfAServer.

@Override
public long totalUsedStorageOfAServer(String hostname, String diskInfoJson, List<DataGridResource> currentServerResources) throws DataGridConnectionRefusedException {
    logger.info("Get total used storage of a specific server {}", hostname);
    long totalUsed = 0;
    if (hostname == null || diskInfoJson == null || hostname.isEmpty() || diskInfoJson.isEmpty()) {
        return totalUsed;
    }
    HashMap<String, String> usedMap = null;
    List<DataGridResource> dataGridResources = null;
    try {
        dataGridResources = resourceService.getResourcesOfAServer(hostname, currentServerResources);
    } catch (DataGridConnectionRefusedException e) {
        logger.error("Could not get resources from server ", hostname);
        // we will use all known resources of this server stored in cache
        if (currentServerResources != null) {
            dataGridResources = currentServerResources;
        } else {
            dataGridResources = new ArrayList<DataGridResource>();
        }
    }
    try {
        usedMap = createMapPartitionAndAmountUsed(diskInfoJson);
        for (String mountedOn : usedMap.keySet()) {
            boolean foundResc = false;
            for (DataGridResource dataGridResource : dataGridResources) {
                String resourcePath = dataGridResource.getPath();
                if (resourcePath.startsWith(mountedOn)) {
                    totalUsed += Long.parseLong(usedMap.get(mountedOn));
                    foundResc = true;
                    dataGridResources.remove(dataGridResource);
                    break;
                }
            }
            if (foundResc) {
                continue;
            }
        }
    } catch (JsonProcessingException e) {
        logger.info("Could not parse total used storage information for: ", hostname);
    } catch (IOException e) {
        logger.info("Could not parse total used storage information for: ", hostname);
    } catch (NumberFormatException e) {
        logger.info("Could not format String:{} ", e.getMessage());
    }
    return totalUsed * blockSize;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) ArrayList(java.util.ArrayList) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 24 with DataGridConnectionRefusedException

use of com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException in project metalnx-web by irods-contrib.

the class StorageServiceImpl method totalAvailableStorageOfAServer.

@Override
public long totalAvailableStorageOfAServer(String hostname, String diskInfoJson, List<DataGridResource> currentServerResources) throws DataGridConnectionRefusedException {
    logger.info("Get total available storage of a specific server {}", hostname);
    long totalAvailable = 0;
    if (hostname == null || diskInfoJson == null || hostname.isEmpty() || diskInfoJson.isEmpty()) {
        return totalAvailable;
    }
    HashMap<String, String> availableMap = null;
    List<DataGridResource> dataGridResources = null;
    try {
        dataGridResources = resourceService.getResourcesOfAServer(hostname, currentServerResources);
    } catch (DataGridConnectionRefusedException e) {
        logger.error("Could not get resources from server ", hostname);
        // we will use all known resources of this server stored in cache
        if (currentServerResources != null) {
            dataGridResources = currentServerResources;
        } else {
            dataGridResources = new ArrayList<DataGridResource>();
        }
    }
    try {
        availableMap = createMapPartitionAndAmountAvailable(diskInfoJson);
        for (String mountedOn : availableMap.keySet()) {
            boolean foundResc = false;
            for (DataGridResource dataGridResource : dataGridResources) {
                String resourcePath = dataGridResource.getPath();
                if (resourcePath.startsWith(mountedOn)) {
                    totalAvailable += Long.parseLong(availableMap.get(mountedOn));
                    foundResc = true;
                    dataGridResources.remove(dataGridResource);
                    break;
                }
            }
            if (foundResc) {
                continue;
            }
        }
    } catch (JsonProcessingException e) {
        logger.info("Could not parse total available storage information for: ", hostname);
    } catch (IOException e) {
        logger.info("Could not parse total available storage information for: ", hostname);
    } catch (NumberFormatException e) {
        logger.info("Could not format String:{} ", e.getMessage());
    }
    return totalAvailable * blockSize;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) ArrayList(java.util.ArrayList) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)24 JargonException (org.irods.jargon.core.exception.JargonException)17 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)10 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 IOException (java.io.IOException)7 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)6 ArrayList (java.util.ArrayList)6 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 HashMap (java.util.HashMap)5 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)5 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)4 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 DataGridPageContext (com.emc.metalnx.core.domain.entity.DataGridPageContext)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ConnectException (java.net.ConnectException)3 UserGroupAO (org.irods.jargon.core.pub.UserGroupAO)3 DataGridGroup (com.emc.metalnx.core.domain.entity.DataGridGroup)2