public SshPutTaskWrapper newTask() { dirty = false; return new SshPutTaskWrapper(this); }
@Override public Task<Void> asTask() { return getTask(); }
@Override public Void call() throws Exception { try { Preconditions.checkNotNull(getMachine(), "machine"); String remoteFile = getRemoteFile(); if (li>=0) { remoteDir = remoteDir.substring(0, li+1); exitCodeOfCreate = getMachine().execCommands("creating directory for "+getSummary(), Arrays.asList("mkdir -p "+remoteDir)); } else { log.debug("SSH put "+getRemoteFile()+" (create dir, in task "+getSummary()+") to "+getMachine()+" threw exception: "+e); exception = e; if (!allowFailure) { if (exception != null) { throw new IllegalStateException(getSummary()+" (creating dir "+remoteDir+" for SSH put task) ended with exception, in "+Tasks.current()+": "+exception, exception); exception = new IllegalStateException(getSummary()+" (creating dir "+remoteDir+" SSH put task) ended with exit code "+exitCodeOfCreate+", in "+Tasks.current()); throw exception; exitCodeOfCopy = getMachine().copyTo(config.getAllConfig(), contents.get(), remoteFile); log.debug("SSH put "+getRemoteFile()+" (task "+getSummary()+") to "+getMachine()+" completed with exit code "+exitCodeOfCopy); } catch (Exception e) { if (log.isDebugEnabled()) log.debug("SSH put "+getRemoteFile()+" (task "+getSummary()+") to "+getMachine()+" threw exception: "+e); exception = e;
SshPutTaskWrapper(SshPutTaskFactory constructor) { super(constructor); TaskBuilder<Void> tb = TaskBuilder.<Void>builder().dynamic(false).name(getSummary()); task = tb.body(new SshPutJob()).build(); }
/** blocks until the task completes; does not throw */ public SshPutTaskWrapper block() { getTask().blockUntilEnded(); return this; }
/** blocks, throwing if there was an exception */ public Void get() { return getTask().getUnchecked(); }
/** true iff the ssh job has completed (with or without failure) */ public boolean isDone() { return getTask().isDone(); }