use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method addLocalSubmissionDetails.
/**
* Add a Local Job Submission details to a compute resource
* App catalog will return a jobSubmissionInterfaceId which will be added to the jobSubmissionInterfaces.
*
* @param computeResourceId The identifier of the compute resource to which JobSubmission protocol to be added
* @param priorityOrder Specify the priority of this job manager. If this is the only jobmanager, the priority can be zero.
* @param localSubmission The LOCALSubmission object to be added to the resource.
* @return status
* Returns the unique job submission id.
*/
@Override
public String addLocalSubmissionDetails(String computeResourceId, int priorityOrder, LOCALSubmission localSubmission) throws RegistryServiceException, TException {
try {
appCatalog = RegistryFactory.getAppCatalog();
ComputeResource computeResource = appCatalog.getComputeResource();
String submissionInterface = addJobSubmissionInterface(computeResource, computeResourceId, computeResource.addLocalJobSubmission(localSubmission), JobSubmissionProtocol.LOCAL, priorityOrder);
logger.debug("Airavata added local job submission for compute resource id: " + computeResourceId);
return submissionInterface;
} catch (AppCatalogException e) {
logger.error(computeResourceId, "Error while adding job submission interface to resource compute resource...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while adding job submission interface to resource compute resource. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method registerGatewayResourceProfile.
/**
* Register a Gateway Resource Profile.
*
* @param gatewayResourceProfile Gateway Resource Profile Object.
* The GatewayID should be obtained from Airavata gateway registration and passed to register a corresponding
* resource profile.
* @return status
* Returns a success/failure of the update.
*/
@Override
public String registerGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) throws RegistryServiceException, TException {
try {
if (!validateString(gatewayResourceProfile.getGatewayID())) {
logger.error("Cannot create gateway profile with empty gateway id");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Cannot create gateway profile with empty gateway id");
throw exception;
}
if (!isGatewayExistInternal(gatewayResourceProfile.getGatewayID())) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
String resourceProfile = gatewayProfile.addGatewayResourceProfile(gatewayResourceProfile);
logger.debug("Airavata registered gateway profile with gateway id : " + gatewayResourceProfile.getGatewayID());
return resourceProfile;
} catch (AppCatalogException e) {
logger.error("Error while registering gateway resource profile...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while registering gateway resource profile. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getJobStatuses.
/**
* Get Job Statuses for an Experiment
* This method to be used when need to get the job status of an Experiment. An experiment may have one or many jobs; there for one or many job statuses may turnup
*
* @param airavataExperimentId@return JobStatus
* Job status (string) for all all the existing jobs for the experiment will be returned in the form of a map
*/
@Override
public Map<String, JobStatus> getJobStatuses(String airavataExperimentId) throws RegistryServiceException, TException {
try {
experimentCatalog = RegistryFactory.getDefaultExpCatalog();
if (!experimentCatalog.isExist(ExperimentCatalogModelType.EXPERIMENT, airavataExperimentId)) {
logger.error(airavataExperimentId, "Error while retrieving job details, experiment {} doesn't exist.", airavataExperimentId);
throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
}
List<Object> processModels = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID, airavataExperimentId);
Map<String, JobStatus> jobStatus = new HashMap<String, JobStatus>();
if (processModels != null && !processModels.isEmpty()) {
for (Object process : processModels) {
ProcessModel processModel = (ProcessModel) process;
List<TaskModel> tasks = processModel.getTasks();
if (tasks != null && !tasks.isEmpty()) {
for (TaskModel task : tasks) {
String taskId = task.getTaskId();
List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
if (jobs != null && !jobs.isEmpty()) {
for (Object jobObject : jobs) {
JobModel jobModel = (JobModel) jobObject;
String jobID = jobModel.getJobId();
List<JobStatus> status = jobModel.getJobStatuses();
if (status != null && status.size() > 0) {
jobStatus.put(jobID, status.get(0));
}
}
}
}
}
}
}
logger.debug("Airavata retrieved job statuses for experiment with experiment id : " + airavataExperimentId);
return jobStatus;
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job statuses", e);
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Error while retrieving the job statuses. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method getGridFTPDataMovement.
/**
* This method returns GridFTP datamovement object
*
* @param dataMovementId The identifier of the datamovement Interface to be retrieved.
* @return GridFTPDataMovement instance
*/
@Override
public GridFTPDataMovement getGridFTPDataMovement(String dataMovementId) throws RegistryServiceException, TException {
try {
appCatalog = RegistryFactory.getAppCatalog();
GridFTPDataMovement gridFTPDataMovement = appCatalog.getComputeResource().getGridFTPDataMovement(dataMovementId);
logger.debug("Airavata retrieved GRIDFTP data movement with data movement id: " + dataMovementId);
return gridFTPDataMovement;
} catch (AppCatalogException e) {
String errorMsg = "Error while retrieving GridFTP data movement interface to resource compute resource...";
logger.error(dataMovementId, errorMsg, e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage(errorMsg + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.registry.api.exception.RegistryServiceException in project airavata by apache.
the class RegistryServerHandler method updateProject.
/**
* Update an Existing Project
*
* @param projectId The projectId of the project needed an update.
* @param updatedProject
* @return void
* Currently this does not return any value.
*/
@Override
public void updateProject(String projectId, Project updatedProject) throws RegistryServiceException, TException {
if (!validateString(projectId) || !validateString(projectId)) {
logger.error("Project id cannot be empty...");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Project id cannot be empty...");
throw exception;
}
try {
experimentCatalog = RegistryFactory.getExperimentCatalog(updatedProject.getGatewayId());
if (!experimentCatalog.isExist(ExperimentCatalogModelType.PROJECT, projectId)) {
logger.error("Project does not exist in the system. Please provide a valid project ID...");
ProjectNotFoundException exception = new ProjectNotFoundException();
exception.setMessage("Project does not exist in the system. Please provide a valid project ID...");
throw exception;
}
experimentCatalog.update(ExperimentCatalogModelType.PROJECT, updatedProject, projectId);
logger.debug("Airavata updated project with project Id : " + projectId);
} catch (RegistryException e) {
logger.error("Error while updating the project", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating the project. More info : " + e.getMessage());
throw exception;
}
}
Aggregations