/** * Persists the current state of {@link CpsThreadGroup}. */ @CpsVmThreadOnly void saveProgram() throws IOException { File f = execution.getProgramDataFile(); saveProgram(f); }
@Override public void onSuccess(CpsThreadGroup result) { try { // TODO keep track of whether the program was saved anyway after saveState was called but before now, and do not bother resaving it in that case if (result.getExecution().getDurabilityHint().isPersistWithEveryStep()) { result.getExecution().getStorage().flush(); result.saveProgram(); } f.set(null); } catch (Exception x) { f.setException(x); } } @Override public void onFailure(Throwable t) {
/** * Like {@link #saveProgram()} but will not fail. * @param enteringQuietState True if we're moving to quiet state - pausing or quieting down and need to write the program. */ @CpsVmThreadOnly void saveProgramIfPossible(boolean enteringQuietState) { if (this.getExecution() != null && (this.getExecution().getDurabilityHint().isPersistWithEveryStep() || enteringQuietState)) { try { // Program may depend on flownodes being saved, so save nodes FlowNodeStorage storage = this.execution.getStorage(); if (storage != null) { storage.flush(); } } catch (IOException ioe) { LOGGER.log(Level.WARNING, "Error persisting FlowNode storage before saving program", ioe); } try { saveProgram(); } catch (IOException x) { LOGGER.log(WARNING, "program state save failed", x); } } }