public void write(boolean last, byte[] data) throws IOException { try { done = last; cmd.getBuffer().queue(last, ByteBuffer.wrap(data)); } catch (InterruptedException e) { cmd.getBuffer().error(e); } }
public void resume() { if (!done) { synchronized (this) { if (cmd == null) { suspended = false; return; } } cmd.resume(); } }
public void suspend() { if (!done) { synchronized (this) { if (cmd == null) { suspended = true; return; } } cmd.suspend(); } }
public void setLength(long len) throws IOException { try { RemoteFile uri = new RemoteFile(dst); cmd = new CustomPutFileCmd(src, "file://localhost/" + uri.getPath(), len, this); channel = ChannelManager.getManager().getExistingChannel("id://" + uri.getHost(), null); cmd.executeAsync(channel, this); cb.info(String.valueOf(cmd.getId())); synchronized (this) { if (!suspended) { return; } } if (logger.isInfoEnabled()) { logger.info(cmd.getId() + " suspended before. Sending signal."); } cmd.suspend(); } catch (Exception e) { throw new IOException(e.getMessage()); } }