/** {@inheritDoc} */ @Override public GridNioFuture<Boolean> close() { return new GridNioFinishedFuture<>(true); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> send(Object msg) { return new GridNioFinishedFuture<>(true); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public GridNioFuture<Boolean> close() { markedForClose = true; try { return filterChain.onSessionClose(this); } catch (IgniteCheckedException e) { return new GridNioFinishedFuture<>(e); } }
/** {@inheritDoc} */ @Override public GridNioFuture<Boolean> close() { return new GridNioFinishedFuture<>(true); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> send(Object msg) { return new GridNioFinishedFuture<>(true); }
/** * Handles write events on chain. * * @param msg Buffer to send. * @return Send result. */ private GridNioFuture<?> send(ByteBuffer msg) { assert writeBuf.hasArray(); try { while (msg.hasRemaining()) { writeBuf.clear(); writeBuf.put(msg); endp.outputStream().write(writeBuf.array(), 0, writeBuf.position()); } } catch (IOException | IgniteCheckedException e) { return new GridNioFinishedFuture<Object>(e); } return new GridNioFinishedFuture<>((Object)null); }
/** * Handles write events on chain. * * @param msg Buffer to send. * @return Send result. */ private GridNioFuture<?> send(Message msg) { assert writeBuf.hasArray(); try { int cnt = U.writeMessageFully(msg, endp.outputStream(), writeBuf, writerFactory.writer(ses)); metricsLsnr.onBytesSent(cnt); } catch (IOException | IgniteCheckedException e) { return new GridNioFinishedFuture<Object>(e); } return new GridNioFinishedFuture<>((Object)null); }
/** * @param ses Session. * @param op Operation. * @return Future for operation. */ private GridNioFuture<?> pauseResumeReads(GridNioSession ses, NioOperation op) { assert ses instanceof GridSelectorNioSessionImpl; assert op == NioOperation.PAUSE_READ || op == NioOperation.RESUME_READ; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (impl.closed()) return new GridNioFinishedFuture(new IOException("Failed to pause/resume reads " + "(connection was closed): " + ses)); NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, op); impl.offerStateChange(fut); return fut; }
/** {@inheritDoc} */ @Override public GridNioFuture<?> resumeReads() { try { return chain().onResumeReads(this); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
/** * @param ses Session to close. * @return Future for operation. */ public GridNioFuture<Boolean> close(GridNioSession ses) { assert ses instanceof GridSelectorNioSessionImpl : ses; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (impl.closed()) return new GridNioFinishedFuture<>(false); NioOperationFuture<Boolean> fut = new NioOperationFuture<>(impl, NioOperation.CLOSE); impl.offerStateChange(fut); return fut; }
/** {@inheritDoc} */ @Override public GridNioFuture<?> pauseReads() { try { return chain().onPauseReads(this); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
/** * @param ch Channel. * @param meta Session meta. */ public GridNioFuture<GridNioSession> cancelConnect(final SocketChannel ch, Map<Integer, ?> meta) { if (!closed) { NioOperationFuture<GridNioSession> req = new NioOperationFuture<>(ch, false, meta); req.op = NioOperation.CANCEL_CONNECT; Integer idx = (Integer)meta.get(WORKER_IDX_META_KEY); assert idx != null : meta; clientWorkers.get(idx).offer(req); return req; } else return new GridNioFinishedFuture<>( new IgniteCheckedException("Failed to cancel connection, server is stopped.")); }
return new GridNioFinishedFuture<>( new IgniteCheckedException("Failed to create session, server is stopped.")); return new GridNioFinishedFuture<>(e);
/** {@inheritDoc} */ @Override public GridNioFuture<?> send(Object msg) { try { resetSendScheduleTime(); return chain().onSessionWrite(this, msg, true, null); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
return new GridNioFinishedFuture<Object>(null); return new GridNioFinishedFuture<Object>(new IOException("Failed to send data (secure session was " + "already closed): " + ses));
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public GridNioFuture<Boolean> close() { markedForClose = true; try { return filterChain.onSessionClose(this); } catch (IgniteCheckedException e) { return new GridNioFinishedFuture<>(e); } }
/** * Handles write events on chain. * * @param msg Buffer to send. * @return Send result. */ private GridNioFuture<?> send(Message msg) { assert writeBuf.hasArray(); try { int cnt = U.writeMessageFully(msg, endp.outputStream(), writeBuf, writerFactory.writer(ses)); metricsLsnr.onBytesSent(cnt); } catch (IOException | IgniteCheckedException e) { return new GridNioFinishedFuture<Object>(e); } return new GridNioFinishedFuture<>((Object)null); }
/** * @param ses Session. * @param op Operation. * @return Future for operation. */ private GridNioFuture<?> pauseResumeReads(GridNioSession ses, NioOperation op) { assert ses instanceof GridSelectorNioSessionImpl; assert op == NioOperation.PAUSE_READ || op == NioOperation.RESUME_READ; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (impl.closed()) return new GridNioFinishedFuture(new IOException("Failed to pause/resume reads " + "(connection was closed): " + ses)); NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, op); impl.offerStateChange(fut); return fut; }
/** {@inheritDoc} */ @Override public GridNioFuture<?> pauseReads() { try { return chain().onPauseReads(this); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
/** * @param ses Session to close. * @return Future for operation. */ public GridNioFuture<Boolean> close(GridNioSession ses) { assert ses instanceof GridSelectorNioSessionImpl : ses; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (impl.closed()) return new GridNioFinishedFuture<>(false); NioOperationFuture<Boolean> fut = new NioOperationFuture<>(impl, NioOperation.CLOSE); impl.offerStateChange(fut); return fut; }