/** * @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; }
NioOperationFuture<String> opFut = new NioOperationFuture<>(null, NioOperation.DUMP_STATS);
NioOperationFuture<String> opFut = new NioOperationFuture<>(null, NioOperation.DUMP_STATS);
ch.configureBlocking(false); NioOperationFuture<GridNioSession> req = new NioOperationFuture<>(ch, false, meta);
NioOperationFuture<String> opFut = new NioOperationFuture<>(null, NioOperation.DUMP_STATS);
NioOperationFuture<String> opFut = new NioOperationFuture<>(null, NioOperation.DUMP_STATS);
/** * Adds message at the front of the queue without acquiring back pressure semaphore. * * @param ses Session. * @param msg Message. * @param lsnr Future listener notified from the session thread. * @throws IgniteCheckedException If session was closed. */ public void sendSystem(GridNioSession ses, Message msg, @Nullable IgniteInClosure<? super IgniteInternalFuture<?>> lsnr) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (lsnr != null) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, skipRecoveryPred.apply(msg), null); fut.listen(lsnr); assert !fut.isDone(); send0(impl, fut, true); } else { SessionWriteRequest req = new WriteRequestSystemImpl(ses, msg); send0(impl, req, true); } }
/** * @param ses Session. * @param msg Message. * @param createFut {@code True} if future should be created. * @param ackC Closure invoked when message ACK is received. * @return Future for operation. */ GridNioFuture<?> send(GridNioSession ses, Message msg, boolean createFut, IgniteInClosure<IgniteException> ackC) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (createFut) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, skipRecoveryPred.apply(msg), ackC); send0(impl, fut, false); return fut; } else { SessionWriteRequest req = new WriteRequestImpl(ses, msg, skipRecoveryPred.apply(msg), ackC); send0(impl, req, false); return null; } }
/** * @param ses Session. * @param msg Message. * @param createFut {@code True} if future should be created. * @param ackC Closure invoked when message ACK is received. * @return Future for operation. */ GridNioFuture<?> send(GridNioSession ses, ByteBuffer msg, boolean createFut, IgniteInClosure<IgniteException> ackC) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl : ses; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (createFut) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, ackC); send0(impl, fut, false); return fut; } else { SessionWriteRequest req = new WriteRequestImpl(ses, msg, true, ackC); send0(impl, req, false); return null; } }
/** * @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.")); }
/** * @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; }
/** * @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; }
ch.configureBlocking(false); NioOperationFuture<GridNioSession> req = new NioOperationFuture<>(ch, false, meta);
/** * Adds message at the front of the queue without acquiring back pressure semaphore. * * @param ses Session. * @param msg Message. * @param lsnr Future listener notified from the session thread. * @throws IgniteCheckedException If session was closed. */ public void sendSystem(GridNioSession ses, Message msg, @Nullable IgniteInClosure<? super IgniteInternalFuture<?>> lsnr) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (lsnr != null) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, skipRecoveryPred.apply(msg), null); fut.listen(lsnr); assert !fut.isDone(); send0(impl, fut, true); } else { SessionWriteRequest req = new WriteRequestSystemImpl(ses, msg); send0(impl, req, true); } }
/** * @param ses Session. * @param msg Message. * @param createFut {@code True} if future should be created. * @param ackC Closure invoked when message ACK is received. * @return Future for operation. */ GridNioFuture<?> send(GridNioSession ses, Message msg, boolean createFut, IgniteInClosure<IgniteException> ackC) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (createFut) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, skipRecoveryPred.apply(msg), ackC); send0(impl, fut, false); return fut; } else { SessionWriteRequest req = new WriteRequestImpl(ses, msg, skipRecoveryPred.apply(msg), ackC); send0(impl, req, false); return null; } }
/** * @param ses Session. * @param msg Message. * @param createFut {@code True} if future should be created. * @param ackC Closure invoked when message ACK is received. * @return Future for operation. */ GridNioFuture<?> send(GridNioSession ses, ByteBuffer msg, boolean createFut, IgniteInClosure<IgniteException> ackC) throws IgniteCheckedException { assert ses instanceof GridSelectorNioSessionImpl : ses; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; if (createFut) { NioOperationFuture<?> fut = new NioOperationFuture<Void>(impl, NioOperation.REQUIRE_WRITE, msg, ackC); send0(impl, fut, false); return fut; } else { SessionWriteRequest req = new WriteRequestImpl(ses, msg, true, ackC); send0(impl, req, false); return null; } }
/** * @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.")); }
/** * @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; }