use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method findFirstLevelResources.
@Override
public List<DataGridResource> findFirstLevelResources() throws DataGridConnectionRefusedException {
logger.info("Find all first level resources in the grid");
List<DataGridResource> firstLevelResources = new ArrayList<>();
List<DataGridResource> allResources = findAll();
for (DataGridResource resc : allResources) {
if (resc.isFirstLevelResc()) {
firstLevelResources.add(resc);
}
}
return firstLevelResources;
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method getDataGridResource.
private DataGridResource getDataGridResource(Resource irodsResource) {
logger.info("getDataGridResource()");
try {
long irodsResourceId = Long.valueOf(irodsResource.getId());
String irodsResourceName = irodsResource.getName();
String irodsResourceZone = irodsResource.getZone().getZoneName();
String irodsResourceType = irodsResource.getType();
String irodsResourcePath = irodsResource.getVaultPath();
long irodsResourceFreeSpace = irodsResource.getFreeSpace();
Date irodsResourceFreeSpaceTimeStamp = irodsResource.getFreeSpaceTime();
List<String> irodsResourceChildren = irodsResource.getImmediateChildren();
String irodsResourceParent = irodsResource.getParentName();
String irodsResourceStatus = irodsResource.getStatus();
String irodsResourceHost = irodsResource.getLocation();
Date irodsResourceCreateTime = irodsResource.getCreateTime();
Date irodsResourceModifyTime = irodsResource.getModifyTime();
String irodsResourceInfo = irodsResource.getInfo();
String irodsContextString = irodsResource.getContextString();
int irodsResourceTotalRecords = irodsResource.getTotalRecords();
if (irodsResourceParent == null || irodsResourceParent.isEmpty()) {
irodsResourceParent = irodsServices.getCurrentUserZone();
}
if (irodsResourceType == null || irodsResourceType.isEmpty()) {
irodsResourceType = irodsContextString;
}
DataGridResource newDataGridResource = new DataGridResource(irodsResourceId, irodsResourceName, irodsResourceZone, irodsResourceType, irodsResourcePath, irodsResourceFreeSpace, irodsResourceFreeSpaceTimeStamp, irodsResourceChildren, irodsResourceParent, irodsResourceStatus, irodsResourceHost, irodsResourceCreateTime, irodsResourceModifyTime, irodsResourceInfo, irodsResourceTotalRecords, irodsContextString);
logger.debug("got dataGridResource:{}", newDataGridResource);
return newDataGridResource;
} catch (Throwable t) {
logger.error("intercepted exception getting data grid resource", t);
throw new DataGridServerException(t.getMessage());
}
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method findAll.
@Override
public List<DataGridResource> findAll() throws DataGridConnectionRefusedException {
logger.info("Find all resources in the grid");
List<DataGridResource> dataGridResources = new ArrayList<DataGridResource>();
ResourceAO resourceAO = irodsServices.getResourceAO();
try {
List<Resource> resources = resourceAO.findAll();
for (Resource irodsResource : resources) {
DataGridResource newDataGridResource = getDataGridResource(irodsResource);
dataGridResources.add(newDataGridResource);
for (Resource r : resources) {
if (r.getParentName().equals(irodsResource.getName())) {
newDataGridResource.addChildResc(r.getName());
}
}
}
} catch (JargonException e) {
logger.error("Could not find all resources: ", e);
}
logger.debug("got all resources");
// sorting this list alphabetically
Collections.sort(dataGridResources);
logger.debug("sorted...");
return dataGridResources;
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class RuleServiceImpl method execReplDataObjRule.
@Override
public void execReplDataObjRule(String destResc, String path, boolean inAdminMode) throws DataGridRuleException, DataGridConnectionRefusedException {
logger.info("Get Replication Rule called");
String flags = String.format("destRescName=%s%s", destResc, inAdminMode ? "++++irodsAdmin=" : "");
DataGridResource dgResc = rs.find(destResc);
DataGridRule rule = new DataGridRule(DataGridRule.REPL_DATA_OBJ_RULE, dgResc.getHost());
rule.setInputRuleParams(path, flags, "null");
executeRule(rule.toString());
}
use of com.emc.metalnx.core.domain.entity.DataGridResource in project metalnx-web by irods-contrib.
the class ResourceController method getDataGridResource.
/**
* Creates a DataGridResource from a ResourceForm
*
* @param resourceForm
* @return DataGridResource object
*/
private DataGridResource getDataGridResource(ResourceForm resourceForm) {
Date currentDate = new Date();
DataGridResource newDataGridResource = new DataGridResource();
newDataGridResource.setName(resourceForm.getName());
newDataGridResource.setType(resourceForm.getType());
newDataGridResource.setZone(resourceForm.getZone());
newDataGridResource.setCreateTime(currentDate);
newDataGridResource.setModifyTime(currentDate);
newDataGridResource.setFreeSpaceDate(currentDate);
newDataGridResource.setPath(resourceForm.getPath());
newDataGridResource.setInfo(resourceForm.getInfo());
newDataGridResource.setStatus(resourceForm.getStatus());
newDataGridResource.setParent(resourceForm.getParent());
newDataGridResource.setHost(resourceForm.getHost());
newDataGridResource.setComment(resourceForm.getComment());
newDataGridResource.setChildren(resourceForm.getChildren());
if (resourceForm.getType().compareToIgnoreCase(DataGridServerType.ISILON.name()) == 0) {
// Builds Isilon context string containing the HDFS credentials to access file
// system
String context = String.format(ISILON_CONTEXT_STRING, resourceForm.getIsiHost(), resourceForm.getIsiPort(), resourceForm.getIsiUser());
newDataGridResource.setContextString(context);
}
return newDataGridResource;
}
Aggregations