use of com.emc.metalnx.core.domain.entity.DataGridResource 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.entity.DataGridResource 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;
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class TestPluginService method testMSICompatibility.
@Test
public void testMSICompatibility() throws DataGridConnectionRefusedException, DataGridRuleException {
DataGridResource resc = new DataGridResource();
resc.setName("demoResc");
List<DataGridResource> rescs = new ArrayList<>();
rescs.add(resc);
servers.get(0).setResources(rescs);
assertTrue(msiService.isMSIAPICompatibleInResc("demoResc"));
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class TestResourceService method setUp.
@Before
public void setUp() throws DataGridConnectionRefusedException {
long time = System.currentTimeMillis();
parentRescName = "testResc" + time;
childRescName = "testRescChild" + time;
Date date = new Date();
parentResc = new DataGridResource();
parentResc.setName(parentRescName);
parentResc.setType("compound");
parentResc.setZone(zone);
parentResc.setCreateTime(date);
parentResc.setModifyTime(date);
parentResc.setFreeSpaceDate(date);
parentResc.setPath("/var/lib/irods/iRODS/Vault2");
parentResc.setHost(host);
childResc = new DataGridResource();
childResc.setName(childRescName);
childResc.setType("unixfilesystem");
childResc.setZone(zone);
childResc.setCreateTime(date);
childResc.setModifyTime(date);
childResc.setFreeSpaceDate(date);
childResc.setPath("/var/lib/irods/iRODS/Vault2");
childResc.setHost(host);
resourceService.createResource(parentResc);
}
Aggregations