Example #1
0
 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);
   }
 }
Example #2
0
 public void resume() {
   if (!done) {
     synchronized (this) {
       if (cmd == null) {
         suspended = false;
         return;
       }
     }
     cmd.resume();
   }
 }
Example #3
0
 public void suspend() {
   if (!done) {
     synchronized (this) {
       if (cmd == null) {
         suspended = true;
         return;
       }
     }
     cmd.suspend();
   }
 }
Example #4
0
 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());
   }
 }