Search in sources :

Example 61 with AppCatalogException

use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.

the class ComputeResourceImpl method updateResourceJobManager.

@Override
public void updateResourceJobManager(String resourceJobManagerId, ResourceJobManager updatedResourceJobManager) throws AppCatalogException {
    try {
        ResourceJobManagerResource resource = AppCatalogThriftConversion.getResourceJobManager(updatedResourceJobManager);
        resource.setResourceJobManagerId(resourceJobManagerId);
        resource.save();
        Map<JobManagerCommand, String> jobManagerCommands = updatedResourceJobManager.getJobManagerCommands();
        if (jobManagerCommands != null && jobManagerCommands.size() != 0) {
            for (JobManagerCommand commandType : jobManagerCommands.keySet()) {
                JobManagerCommandResource r = new JobManagerCommandResource();
                Map<String, String> ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, resourceJobManagerId);
                ids.put(AppCatAbstractResource.JobManagerCommandConstants.COMMAND_TYPE, commandType.toString());
                JobManagerCommandResource existingCommand;
                if (r.isExists(ids)) {
                    existingCommand = (JobManagerCommandResource) r.get(ids);
                } else {
                    existingCommand = new JobManagerCommandResource();
                }
                if (jobManagerCommands.get(commandType) != null && !jobManagerCommands.get(commandType).isEmpty()) {
                    existingCommand.setCommandType(commandType.toString());
                    existingCommand.setCommand(jobManagerCommands.get(commandType));
                    existingCommand.setResourceJobManagerId(resource.getResourceJobManagerId());
                    existingCommand.save();
                }
            }
        }
        Map<ApplicationParallelismType, String> parallelismPrefix = updatedResourceJobManager.getParallelismPrefix();
        if (parallelismPrefix != null && parallelismPrefix.size() != 0) {
            for (ApplicationParallelismType commandType : parallelismPrefix.keySet()) {
                ParallelismPrefixCommandResource r = new ParallelismPrefixCommandResource();
                Map<String, String> ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.ParallelismCommandConstants.RESOURCE_JOB_MANAGER_ID, resourceJobManagerId);
                ids.put(AppCatAbstractResource.ParallelismCommandConstants.COMMAND_TYPE, commandType.toString());
                ParallelismPrefixCommandResource existingCommand;
                if (r.isExists(ids)) {
                    existingCommand = (ParallelismPrefixCommandResource) r.get(ids);
                } else {
                    existingCommand = new ParallelismPrefixCommandResource();
                }
                if (parallelismPrefix.get(commandType) != null && !parallelismPrefix.get(commandType).isEmpty()) {
                    existingCommand.setCommandType(commandType.toString());
                    existingCommand.setCommand(parallelismPrefix.get(commandType));
                    existingCommand.setResourceJobManagerId(resource.getResourceJobManagerId());
                    existingCommand.save();
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating resource job manager..", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) HashMap(java.util.HashMap) ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 62 with AppCatalogException

use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.

the class ComputeResourceImpl method getAllComputeResourceList.

@Override
public List<ComputeResourceDescription> getAllComputeResourceList() throws AppCatalogException {
    List<ComputeResourceDescription> computeResourceDescriptions = new ArrayList<ComputeResourceDescription>();
    try {
        ComputeResourceResource resource = new ComputeResourceResource();
        List<AppCatalogResource> resources = resource.getAll();
        if (resources != null && !resources.isEmpty()) {
            computeResourceDescriptions = AppCatalogThriftConversion.getComputeDescriptionList(resources);
        }
    } catch (Exception e) {
        logger.error("Error while retrieving compute resource list...", e);
        throw new AppCatalogException(e);
    }
    return computeResourceDescriptions;
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ArrayList(java.util.ArrayList) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 63 with AppCatalogException

use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.

the class ComputeResourceImpl method getComputeResource.

@Override
public ComputeResourceDescription getComputeResource(String resourceId) throws AppCatalogException {
    try {
        ComputeResourceResource resource = new ComputeResourceResource();
        ComputeResourceResource computeResource = (ComputeResourceResource) resource.get(resourceId);
        return AppCatalogThriftConversion.getComputeHostDescription(computeResource);
    } catch (Exception e) {
        logger.error("Error while retrieving compute resource...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 64 with AppCatalogException

use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.

the class ComputeResourceImpl method addUNICOREJobSubmission.

@Override
public String addUNICOREJobSubmission(UnicoreJobSubmission unicoreJobSubmission) throws AppCatalogException {
    try {
        unicoreJobSubmission.setJobSubmissionInterfaceId(AppCatalogUtils.getID("UNICORE"));
        UnicoreJobSubmissionResource resource = AppCatalogThriftConversion.getUnicoreJobSubmission(unicoreJobSubmission);
        resource.setUnicoreEndpointUrl(unicoreJobSubmission.getUnicoreEndPointURL());
        if (unicoreJobSubmission.getSecurityProtocol() != null) {
            resource.setSecurityProtocol(unicoreJobSubmission.getSecurityProtocol().toString());
        }
        resource.save();
        return resource.getjobSubmissionInterfaceId();
    } catch (Exception e) {
        logger.error("Error while retrieving SSH Job Submission...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 65 with AppCatalogException

use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.

the class ComputeResourceImpl method getSCPDataMovement.

// 
// @Override
// public List<SSHJobSubmission> getSSHJobSubmissionList(Map<String, String> filters) throws AppCatalogException {
// try {
// SshJobSubmissionResource resource = new SshJobSubmissionResource();
// for (String fieldName : filters.keySet() ){
// if (fieldName.equals(AbstractResource.SSHSubmissionConstants.RESOURCE_JOB_MANAGER)){
// List<Resource> resources = resource.get(AbstractResource.SSHSubmissionConstants.RESOURCE_JOB_MANAGER, filters.get(fieldName));
// if (resources != null && !resources.isEmpty()){
// return AppCatalogThriftConversion.getSSHSubmissionList(resources);
// }
// }else {
// logger.error("Unsupported field name for SSH Submission.", new IllegalArgumentException());
// throw new IllegalArgumentException("Unsupported field name for SSH Submission.");
// }
// }
// }catch (Exception e){
// logger.error("Error while retrieving SSH Submission list...", e);
// throw new AppCatalogException(e);
// }
// return null;
// }
@Override
public SCPDataMovement getSCPDataMovement(String dataMoveId) throws AppCatalogException {
    try {
        ScpDataMovementResource resource = new ScpDataMovementResource();
        ScpDataMovementResource dataMovementResource = (ScpDataMovementResource) resource.get(dataMoveId);
        return AppCatalogThriftConversion.getSCPDataMovementDescription(dataMovementResource);
    } catch (Exception e) {
        logger.error("Error while retrieving SCP Data Movement...", e);
        throw new AppCatalogException(e);
    }
}
Also used : AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Aggregations

AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)353 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)268 EntityManager (javax.persistence.EntityManager)261 Query (javax.persistence.Query)176 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)176 ArrayList (java.util.ArrayList)94 HashMap (java.util.HashMap)70 Map (java.util.Map)54 List (java.util.List)42 CompositeIdentifier (org.apache.airavata.registry.cpi.CompositeIdentifier)22 ComputeResource (org.apache.airavata.registry.core.app.catalog.model.ComputeResource)14 ApplicationDeployment (org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment)13 ApplicationInterface (org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface)10 ApplicationModule (org.apache.airavata.registry.core.app.catalog.model.ApplicationModule)8 GatewayProfile (org.apache.airavata.registry.core.app.catalog.model.GatewayProfile)6 ResourceJobManager (org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager)6 StorageResource (org.apache.airavata.registry.core.app.catalog.model.StorageResource)6 Initialize (org.apache.airavata.app.catalog.util.Initialize)5 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)5 GSISSHSubmission (org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission)5