use of org.apache.airavata.orchestrator.core.exception.OrchestratorException in project airavata by apache.
the class OrchestratorServerHandler method getModuleId.
private String getModuleId(AppCatalog appCatalog, String applicationId) throws AppCatalogException, OrchestratorException {
ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(applicationId);
List<String> applicationModules = applicationInterface.getApplicationModules();
if (applicationModules.size() == 0) {
throw new OrchestratorException("No modules defined for application " + applicationId);
}
// AiravataAPI airavataAPI = getAiravataAPI();
String selectedModuleId = applicationModules.get(0);
return selectedModuleId;
}
use of org.apache.airavata.orchestrator.core.exception.OrchestratorException in project airavata by apache.
the class GFACPassiveJobSubmitter method submit.
/**
* Submit the job to a shared launch.queue accross multiple gfac instances
*
* @param experimentId
* @param processId
* @param tokenId
* @return
* @throws OrchestratorException
*/
public boolean submit(String experimentId, String processId, String tokenId) throws OrchestratorException {
try {
String gatewayId = null;
CredentialReader credentialReader = GFacUtils.getCredentialReader();
if (credentialReader != null) {
try {
gatewayId = credentialReader.getGatewayID(tokenId);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
}
}
if (gatewayId == null || gatewayId.isEmpty()) {
gatewayId = ServerSettings.getDefaultUserGateway();
}
ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent(processId, gatewayId, experimentId, tokenId);
MessageContext messageContext = new MessageContext(processSubmitEvent, MessageType.LAUNCHPROCESS, "LAUNCH" + ".PROCESS-" + UUID.randomUUID().toString(), gatewayId);
messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
publisher.publish(messageContext);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new OrchestratorException(e);
}
return true;
}
use of org.apache.airavata.orchestrator.core.exception.OrchestratorException in project airavata by apache.
the class SimpleOrchestratorImpl method createAndSaveTasks.
public String createAndSaveTasks(String gatewayId, ProcessModel processModel, boolean autoSchedule) throws OrchestratorException {
try {
ExperimentCatalog experimentCatalog = orchestratorContext.getRegistry().getExperimentCatalog();
AppCatalog appCatalog = orchestratorContext.getRegistry().getAppCatalog();
ComputationalResourceSchedulingModel resourceSchedule = processModel.getProcessResourceSchedule();
String userGivenQueueName = resourceSchedule.getQueueName();
int userGivenWallTime = resourceSchedule.getWallTimeLimit();
String resourceHostId = resourceSchedule.getResourceHostId();
if (resourceHostId == null) {
throw new OrchestratorException("Compute Resource Id cannot be null at this point");
}
ComputeResourceDescription computeResource = appCatalog.getComputeResource().getComputeResource(resourceHostId);
JobSubmissionInterface preferredJobSubmissionInterface = OrchestratorUtils.getPreferredJobSubmissionInterface(orchestratorContext, processModel, gatewayId);
ComputeResourcePreference resourcePreference = OrchestratorUtils.getComputeResourcePreference(orchestratorContext, processModel, gatewayId);
List<String> taskIdList = new ArrayList<>();
if (resourcePreference.getPreferredJobSubmissionProtocol() == JobSubmissionProtocol.UNICORE) {
// TODO - breakdown unicore all in one task to multiple tasks, then we don't need to handle UNICORE here.
taskIdList.addAll(createAndSaveSubmissionTasks(gatewayId, preferredJobSubmissionInterface, processModel, userGivenWallTime));
} else {
taskIdList.addAll(createAndSaveEnvSetupTask(gatewayId, processModel, experimentCatalog));
taskIdList.addAll(createAndSaveInputDataStagingTasks(processModel, gatewayId));
if (autoSchedule) {
List<BatchQueue> definedBatchQueues = computeResource.getBatchQueues();
for (BatchQueue batchQueue : definedBatchQueues) {
if (batchQueue.getQueueName().equals(userGivenQueueName)) {
int maxRunTime = batchQueue.getMaxRunTime();
if (maxRunTime < userGivenWallTime) {
resourceSchedule.setWallTimeLimit(maxRunTime);
// need to create more job submissions
int numOfMaxWallTimeJobs = ((int) Math.floor(userGivenWallTime / maxRunTime));
for (int i = 1; i <= numOfMaxWallTimeJobs; i++) {
taskIdList.addAll(createAndSaveSubmissionTasks(gatewayId, preferredJobSubmissionInterface, processModel, maxRunTime));
}
int leftWallTime = userGivenWallTime % maxRunTime;
if (leftWallTime != 0) {
taskIdList.addAll(createAndSaveSubmissionTasks(gatewayId, preferredJobSubmissionInterface, processModel, leftWallTime));
}
} else {
taskIdList.addAll(createAndSaveSubmissionTasks(gatewayId, preferredJobSubmissionInterface, processModel, userGivenWallTime));
}
}
}
} else {
taskIdList.addAll(createAndSaveSubmissionTasks(gatewayId, preferredJobSubmissionInterface, processModel, userGivenWallTime));
}
taskIdList.addAll(createAndSaveOutputDataStagingTasks(processModel, gatewayId));
}
// update process scheduling
experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processModel.getProcessId());
return getTaskDag(taskIdList);
} catch (Exception e) {
throw new OrchestratorException("Error during creating process", e);
}
}
use of org.apache.airavata.orchestrator.core.exception.OrchestratorException in project airavata by apache.
the class SimpleOrchestratorImpl method createAndSaveSubmissionTasks.
private List<String> createAndSaveSubmissionTasks(String gatewayId, JobSubmissionInterface jobSubmissionInterface, ProcessModel processModel, int wallTime) throws TException, RegistryException, OrchestratorException {
JobSubmissionProtocol jobSubmissionProtocol = jobSubmissionInterface.getJobSubmissionProtocol();
MonitorMode monitorMode = null;
if (jobSubmissionProtocol == JobSubmissionProtocol.SSH || jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK) {
SSHJobSubmission sshJobSubmission = OrchestratorUtils.getSSHJobSubmission(orchestratorContext, jobSubmissionInterface.getJobSubmissionInterfaceId());
monitorMode = sshJobSubmission.getMonitorMode();
} else if (jobSubmissionProtocol == JobSubmissionProtocol.UNICORE) {
monitorMode = MonitorMode.FORK;
} else if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL) {
monitorMode = MonitorMode.LOCAL;
} else if (jobSubmissionProtocol == JobSubmissionProtocol.CLOUD) {
monitorMode = MonitorMode.CLOUD_JOB_MONITOR;
} else {
logger.error("expId : {}, processId : {} :- Unsupported Job submission protocol {}.", processModel.getExperimentId(), processModel.getProcessId(), jobSubmissionProtocol.name());
throw new OrchestratorException("Unsupported Job Submission Protocol " + jobSubmissionProtocol.name());
}
List<String> submissionTaskIds = new ArrayList<>();
TaskModel taskModel = new TaskModel();
taskModel.setParentProcessId(processModel.getProcessId());
taskModel.setCreationTime(new Date().getTime());
taskModel.setLastUpdateTime(taskModel.getCreationTime());
TaskStatus taskStatus = new TaskStatus(TaskState.CREATED);
taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
taskModel.setTaskStatuses(Arrays.asList(taskStatus));
taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
JobSubmissionTaskModel submissionSubTask = new JobSubmissionTaskModel();
submissionSubTask.setMonitorMode(monitorMode);
submissionSubTask.setJobSubmissionProtocol(jobSubmissionProtocol);
submissionSubTask.setWallTime(wallTime);
byte[] bytes = ThriftUtils.serializeThriftObject(submissionSubTask);
taskModel.setSubTaskModel(bytes);
String taskId = (String) orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.TASK, taskModel, processModel.getProcessId());
taskModel.setTaskId(taskId);
submissionTaskIds.add(taskModel.getTaskId());
// create monitor task for this Email based monitor mode job
if (monitorMode == MonitorMode.JOB_EMAIL_NOTIFICATION_MONITOR || monitorMode == MonitorMode.CLOUD_JOB_MONITOR) {
TaskModel monitorTaskModel = new TaskModel();
monitorTaskModel.setParentProcessId(processModel.getProcessId());
monitorTaskModel.setCreationTime(new Date().getTime());
monitorTaskModel.setLastUpdateTime(monitorTaskModel.getCreationTime());
TaskStatus monitorTaskStatus = new TaskStatus(TaskState.CREATED);
monitorTaskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
monitorTaskModel.setTaskStatuses(Arrays.asList(monitorTaskStatus));
monitorTaskModel.setTaskType(TaskTypes.MONITORING);
MonitorTaskModel monitorSubTaskModel = new MonitorTaskModel();
monitorSubTaskModel.setMonitorMode(monitorMode);
monitorTaskModel.setSubTaskModel(ThriftUtils.serializeThriftObject(monitorSubTaskModel));
String mTaskId = (String) orchestratorContext.getRegistry().getExperimentCatalog().add(ExpCatChildDataType.TASK, monitorTaskModel, processModel.getProcessId());
monitorTaskModel.setTaskId(mTaskId);
submissionTaskIds.add(monitorTaskModel.getTaskId());
}
return submissionTaskIds;
}
use of org.apache.airavata.orchestrator.core.exception.OrchestratorException in project airavata by apache.
the class SimpleOrchestratorImpl method createProcesses.
public List<ProcessModel> createProcesses(String experimentId, String gatewayId) throws OrchestratorException {
List<ProcessModel> processModels = new ArrayList<ProcessModel>();
try {
Registry registry = orchestratorContext.getRegistry();
ExperimentModel experimentModel = (ExperimentModel) registry.getExperimentCatalog().get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
List<Object> processList = registry.getExperimentCatalog().get(ExperimentCatalogModelType.PROCESS, Constants.FieldConstants.ExperimentConstants.EXPERIMENT_ID, experimentId);
if (processList != null && !processList.isEmpty()) {
for (Object processObject : processList) {
ProcessModel processModel = (ProcessModel) processObject;
processModels.add(processModel);
}
} else {
ProcessModel processModel = ExperimentModelUtil.cloneProcessFromExperiment(experimentModel);
String processId = (String) registry.getExperimentCatalog().add(ExpCatChildDataType.PROCESS, processModel, experimentId);
processModel.setProcessId(processId);
processModels.add(processModel);
}
} catch (Exception e) {
throw new OrchestratorException("Error during creating process");
}
return processModels;
}
Aggregations