/** * Fetch the output for a single task, store the result (or error message) in the model * * @param jobId id of the job containing this task * @param task task for which the output should be fetched * @param logMode one of {@link SchedulerServiceAsync#LOG_ALL}, {@link * SchedulerServiceAsync#LOG_STDERR}, {@link SchedulerServiceAsync#LOG_STDOUT} */ public void fetchTaskOutput(final String jobId, final Task task, final OutputMode logMode) { SchedulerServiceAsync scheduler = Scheduler.getSchedulerService(); Request req = scheduler.getTaskOutput( LoginModel.getInstance().getSessionId(), "" + jobId, task.getName(), logMode, new AsyncCallback<String>() { public void onFailure(Throwable caught) { String msg = JSONUtils.getJsonErrorMessage(caught); // might be an exception try { JSONObject json = JSONUtils.parseJSON(caught.getMessage()).isObject(); if (json.containsKey("stackTrace")) { msg = json.get("stackTrace").isString().stringValue(); msg = msg.replace("\t", " "); msg = msg.replace("\n", "<br>"); } } catch (Throwable t) { // not json } model.setTaskOutput( jobId, task, "[" + task.getName() + "] <span style='color:red;'>" + msg + "</span>"); LogModel.getInstance() .logMessage( "Failed to get output for task " + task.getName() + " in job " + jobId /* + ": " + msg */); taskOutputRequests.remove("" + task.getId()); } public void onSuccess(String result) { model.setTaskOutput(jobId, task, result); LogModel.getInstance() .logMessage( "Successfully fetched output for task " + task.getName() + " in job " + jobId); taskOutputRequests.remove("" + task.getId()); } }); this.taskOutputRequests.put("" + task.getId(), req); }
public void refreshOutput() { OutputMode outputMode = this.model.getOutputMode(); String jobId = this.model.getCurrentOutput().getJobId(); if (outputMode == OutputMode.LOG_FULL) { String sessionId = LoginModel.getInstance().getSessionId(); if (this.model.getSelectionTarget() == SelectionTarget.JOB_TARGET) { this.downloadFullJobLogs(sessionId, jobId); } else { Task task = this.parentController.getSelectedTask(); downloadFullTaskLogs(sessionId, jobId, task.getName()); } } else { if (this.model.getSelectionTarget() == SelectionTarget.JOB_TARGET) { this.fetchJobOutput(outputMode); } else { Task task = this.parentController.getSelectedTask(); this.fetchTaskOutput(jobId, task, outputMode); } } }
public void changeTaskOutputContext(Task task) { this.cancelCurrentRequests(); if (task == null) { this.changeCurrentOutput(null, false); } else { String jobId = Long.toString(task.getJobId()); this.changeCurrentOutput(jobId, false); } this.model.setLiveEnabled(false, false); this.model.setLive(false, false); }
/** * Fetch the output for the currently selected job store the result (or error msg) in the model * * @param logMode one of {@link SchedulerServiceAsync#LOG_ALL}, {@link * SchedulerServiceAsync#LOG_STDERR}, {@link SchedulerServiceAsync#LOG_STDOUT} */ public void fetchJobOutput(OutputMode logMode) { JobOutput currentOutput = this.model.getCurrentOutput(); String jobId = currentOutput.getJobId(); List<Task> tasks = this.model.getParentModel().getTasksModel().getTasks(); for (Task t : tasks) { switch (t.getStatus()) { case SKIPPED: case PENDING: case SUBMITTED: case NOT_STARTED: break; default: this.fetchTaskOutput(jobId, t, logMode); break; } } currentOutput.setComplete(true); }