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