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