use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.
the class OrchestratorServerHandler method launchProcess.
@Override
public boolean launchProcess(String processId, String airavataCredStoreToken, String gatewayId) throws TException {
try {
ProcessModel processModel = (ProcessModel) experimentCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
String applicationId = processModel.getApplicationInterfaceId();
if (applicationId == null) {
log.error(processId, "Application interface id shouldn't be null.");
throw new OrchestratorException("Error executing the job, application interface id shouldn't be null.");
}
// set application deployment id to process model
ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(processModel, applicationId);
processModel.setApplicationDeploymentId(applicationDeploymentDescription.getAppDeploymentId());
// set compute resource id to process model, default we set the same in the user preferred compute host id
processModel.setComputeResourceId(processModel.getProcessResourceSchedule().getResourceHostId());
experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processModel.getProcessId());
return orchestrator.launchProcess(processModel, airavataCredStoreToken);
} catch (Exception e) {
log.error(processId, "Error while launching process ", e);
throw new TException(e);
}
}
use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.
the class ExperimentRegistry method getProcessIds.
public List<String> getProcessIds(String fieldName, Object value) throws RegistryException {
List<String> processIds = new ArrayList<String>();
List<ProcessModel> processes = getProcessList(fieldName, value);
for (ProcessModel td : processes) {
processIds.add(td.getProcessId());
}
return processIds;
}
use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.
the class ExperimentRegistry method getProcessList.
public List<ProcessModel> getProcessList(String fieldName, Object value) throws RegistryException {
List<ProcessModel> processes = new ArrayList<ProcessModel>();
try {
if (fieldName.equals(Constants.FieldConstants.ProcessConstants.EXPERIMENT_ID)) {
ExperimentResource experimentResource = new ExperimentResource();
experimentResource.setExperimentId((String) value);
List<ProcessResource> resources = experimentResource.getProcessList();
for (ProcessResource processResource : resources) {
ProcessModel processModel = ThriftDataModelConversion.getProcessModel(processResource);
processes.add(processModel);
}
return processes;
} else {
logger.error("Unsupported field name to retrieve process list...");
}
} catch (Exception e) {
logger.error("Error while getting process list...", e);
throw new RegistryException(e);
}
return processes;
}
use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.
the class RegistryServerHandler method getJobDetails.
/**
* Get Job Details for all the jobs within an Experiment.
* This method to be used when need to get the job details for one or many jobs of an Experiment.
*
* @param airavataExperimentId@return list of JobDetails
* Job details.
*/
@Override
public List<JobModel> getJobDetails(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);
List<JobModel> jobList = new ArrayList<>();
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 taskModel : tasks) {
String taskId = taskModel.getTaskId();
List<Object> jobs = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, taskId);
for (Object jobObject : jobs) {
jobList.add((JobModel) jobObject);
}
}
}
}
}
logger.debug("Airavata retrieved job models for experiment with experiment id : " + airavataExperimentId);
return jobList;
} catch (Exception e) {
logger.error(airavataExperimentId, "Error while retrieving the job details", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving the job details. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.
the class RegistryServerHandler method getDetailedExperimentTree.
/**
* Get Complete Experiment Details
* Fetch the completed nested tree structue of previously created experiment metadata which includes processes ->
* tasks -> jobs information.
*
* @param airavataExperimentId The identifier for the requested experiment. This is returned during the create experiment step.
* @return ExperimentModel
* This method will return the previously stored experiment metadata including application input parameters, computational resource scheduling
* information, special input output handling and additional quality of service parameters.
* @throws InvalidRequestException For any incorrect forming of the request itself.
* @throws ExperimentNotFoundException If the specified experiment is not previously created, then an Experiment Not Found Exception is thrown.
* @throws AiravataClientException The following list of exceptions are thrown which Airavata Client can take corrective actions to resolve:
* <p>
* UNKNOWN_GATEWAY_ID - If a Gateway is not registered with Airavata as a one time administrative
* step, then Airavata Registry will not have a provenance area setup. The client has to follow
* gateway registration steps and retry this request.
* <p>
* AUTHENTICATION_FAILURE - How Authentication will be implemented is yet to be determined.
* For now this is a place holder.
* <p>
* INVALID_AUTHORIZATION - This will throw an authorization exception. When a more robust security hand-shake
* is implemented, the authorization will be more substantial.
* @throws AiravataSystemException This exception will be thrown for any Airavata Server side issues and if the problem cannot be corrected by the client
* rather an Airavata Administrator will be notified to take corrective action.
*/
@Override
public ExperimentModel getDetailedExperimentTree(String airavataExperimentId) throws RegistryServiceException, TException {
try {
ExperimentModel experimentModel = getExperimentInternal(airavataExperimentId);
experimentCatalog = RegistryFactory.getDefaultExpCatalog();
List<Object> processObjects = experimentCatalog.get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentModel.getExperimentId());
List<ProcessModel> processList = new ArrayList<>();
if (processObjects != null) {
processObjects.stream().forEach(p -> {
// Process already has the task object
((ProcessModel) p).getTasks().stream().forEach(t -> {
try {
List<Object> jobObjects = experimentCatalog.get(ExperimentCatalogModelType.JOB, Constants.FieldConstants.JobConstants.TASK_ID, ((TaskModel) t).getTaskId());
List<JobModel> jobList = new ArrayList<JobModel>();
if (jobObjects != null) {
jobObjects.stream().forEach(j -> jobList.add((JobModel) j));
Collections.sort(jobList, new Comparator<JobModel>() {
@Override
public int compare(JobModel o1, JobModel o2) {
return (int) (o1.getCreationTime() - o2.getCreationTime());
}
});
t.setJobs(jobList);
}
} catch (RegistryException e) {
logger.error(e.getMessage(), e);
}
});
processList.add((ProcessModel) p);
});
experimentModel.setProcesses(processList);
}
logger.debug("Airavata retrieved detailed experiment with experiment id : " + airavataExperimentId);
return experimentModel;
} catch (Exception e) {
logger.error("Error while retrieving the experiment", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving the experiment. More info : " + e.getMessage());
throw exception;
}
}
Aggregations