@SuppressWarnings("synthetic-access") private void handleOperationFailed(Throwable reason) { if (log.isDebugEnabled()) { log.debug("doWriteIfPossible({}) failed ({}) to complete write of {} out of {}: {}", stream, reason.getClass().getSimpleName(), length, total, reason.getMessage()); } if (log.isTraceEnabled()) { log.trace("doWriteIfPossible(" + this + ") write failure details", reason); } boolean nullified = pendingWrite.compareAndSet(future, null); if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) failed write len={}, more={}", stream, total, !nullified); } future.setValue(reason); } });
@Override public synchronized IoWriteFuture writePacket(Buffer buffer) throws IOException { if (isClosing()) { throw new EOFException("Closed"); } IoWriteFutureImpl future = new IoWriteFutureImpl(packetWriteId, buffer); if (!pendingWrite.compareAndSet(null, future)) { throw new WritePendingException("No write pending future"); } doWriteIfPossible(false); return future; }
protected void startWriting() throws IOException { IoWriteFutureImpl future = writes.peek(); if (future == null) { return; } if (!currentWrite.compareAndSet(null, future)) { return; } out.writePacket(future.getBuffer()).addListener(new SshFutureListener<IoWriteFuture>() { @Override public void operationComplete(IoWriteFuture f) { if (f.isWritten()) { future.setValue(Boolean.TRUE); } else { future.setValue(f.getException()); } finishWrite(); } @SuppressWarnings("synthetic-access") private void finishWrite() { writes.remove(future); currentWrite.compareAndSet(future, null); try { startWriting(); } catch (IOException e) { log.error("finishWrite({}) failed ({}) re-start writing", out, e.getClass().getSimpleName()); } } }); }
@Override public IoWriteFuture writePacket(Buffer buffer) throws IOException { if (isClosing()) { throw new EOFException("Closed"); } IoWriteFutureImpl future = new IoWriteFutureImpl(getId(), buffer); writes.add(future); startWriting(); return future; }
protected void startWriting() throws IOException { IoWriteFutureImpl future = writes.peek(); if (future == null) { return; } if (!currentWrite.compareAndSet(null, future)) { return; } out.writePacket(future.getBuffer()).addListener(new SshFutureListener<IoWriteFuture>() { @Override public void operationComplete(IoWriteFuture f) { if (f.isWritten()) { future.setValue(Boolean.TRUE); } else { future.setValue(f.getException()); } finishWrite(); } @SuppressWarnings("synthetic-access") private void finishWrite() { writes.remove(future); currentWrite.compareAndSet(future, null); try { startWriting(); } catch (IOException e) { log.error("finishWrite({}) failed ({}) re-start writing", out, e.getClass().getSimpleName()); } } }); }
@SuppressWarnings("synthetic-access") private void handleOperationCompleted() { if (total > length) { if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) completed write of {} out of {}", stream, length, total); } doWriteIfPossible(false); } else { boolean nullified = pendingWrite.compareAndSet(future, null); if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) completed write len={}, more={}", stream, total, !nullified); } future.setValue(Boolean.TRUE); } }
@Override public IoWriteFuture writePacket(Buffer buffer) throws IOException { if (isClosing()) { throw new EOFException("Closed"); } IoWriteFutureImpl future = new IoWriteFutureImpl(getId(), buffer); writes.add(future); startWriting(); return future; }
@SuppressWarnings("synthetic-access") private void handleOperationFailed(Throwable reason) { if (log.isDebugEnabled()) { log.debug("doWriteIfPossible({}) failed ({}) to complete write of {} out of {}: {}", stream, reason.getClass().getSimpleName(), length, total, reason.getMessage()); } if (log.isTraceEnabled()) { log.trace("doWriteIfPossible(" + this + ") write failure details", reason); } boolean nullified = pendingWrite.compareAndSet(future, null); if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) failed write len={}, more={}", stream, total, !nullified); } future.setValue(reason); } });
@Override public synchronized IoWriteFuture writePacket(Buffer buffer) throws IOException { if (isClosing()) { throw new EOFException("Closed"); } IoWriteFutureImpl future = new IoWriteFutureImpl(packetWriteId, buffer); if (!pendingWrite.compareAndSet(null, future)) { throw new WritePendingException("No write pending future"); } doWriteIfPossible(false); return future; }
@SuppressWarnings("synthetic-access") private void handleOperationCompleted() { if (total > length) { if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) completed write of {} out of {}", stream, length, total); } doWriteIfPossible(false); } else { boolean nullified = pendingWrite.compareAndSet(future, null); if (log.isTraceEnabled()) { log.trace("doWriteIfPossible({}) completed write len={}, more={}", stream, total, !nullified); } future.setValue(Boolean.TRUE); } }