Search in sources :

Example 1 with DataGridResource

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

Example 2 with DataGridResource

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

Example 3 with DataGridResource

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

Example 4 with DataGridResource

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

Example 5 with DataGridResource

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

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