protected void doFetchLiveLog() { JobOutput currentOutput = this.model.getCurrentOutput(); final String jobId = currentOutput.getJobId(); if (!(currentOutput.isLive() && currentOutput.isLiveEnabled())) { LogModel.getInstance() .logMessage("stop fetching live logs and disable live for job " + jobId); return; } SchedulerServiceAsync scheduler = Scheduler.getSchedulerService(); scheduler.getLiveLogJob( LoginModel.getInstance().getSessionId(), jobId, new AsyncCallback<String>() { public void onSuccess(String result) { if (result.length() > 0) { LogModel.getInstance() .logMessage( "Fetched livelog chunk for job " + jobId + " (" + result.length() + " chars)"); model.appendLiveOutput(jobId, result); } } public void onFailure(Throwable caught) { String msg = JSONUtils.getJsonErrorMessage(caught); LogModel.getInstance() .logImportantMessage("Failed to fetch live log for job " + jobId + ": " + msg); } }); }
public void changeCurrentOutput(String jobId, boolean resetIfNotComplete) { if (jobId == null) { this.model.setCurrentOutput(null); } else { JobOutput jobOutput = this.model.getJobOutput(jobId, true); if (resetIfNotComplete && !jobOutput.isLive() && !jobOutput.isComplete()) { jobOutput.resetLines(); } this.model.setCurrentOutput(jobOutput); } }
public void toggleLive(boolean live) { if (live) { this.cancelCurrentRequests(); this.startLiveOutput(); } else { this.stopLiveOutput(); JobOutput jobOutput = this.model.getCurrentOutput(); if (!jobOutput.isComplete()) { jobOutput.resetLines(); } } this.model.setLive(live, true); }
public Collection<List<String>> getLinesToDisplay(JobOutput output) { if (this.model.getSelectionTarget() == SelectionTarget.TASK_TARGET) { Task task = this.parentController.getSelectedTask(); List<String> lines = output.getLines(task); Collection<List<String>> result = new ArrayList<List<String>>(1); if (lines != null) { result.add(lines); } return result; } else { return output.getLines(); } }
/** * 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); }