/** {@inheritDoc} */ @Override public GridNioFuture<?> pauseReads() { try { return chain().onPauseReads(this); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
/** {@inheritDoc} */ @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { GridNioServerBuffer nioBuf = ses.meta(BUF_META_KEY); // Decode for a given session is called per one thread, so there should not be any concurrency issues. // However, we make some additional checks. if (nioBuf == null) { nioBuf = new GridNioServerBuffer(); GridNioServerBuffer old = ses.addMeta(BUF_META_KEY, nioBuf); assert old == null; } return nioBuf.read(buf); }
/** {@inheritDoc} */ @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { GridNioDelimitedBuffer nioBuf = ses.meta(BUF_META_KEY); // Decode for a given session is called per one thread, so there should not be any concurrency issues. // However, we make some additional checks. if (nioBuf == null) { nioBuf = new GridNioDelimitedBuffer(delim); GridNioDelimitedBuffer old = ses.addMeta(BUF_META_KEY, nioBuf); assert old == null; } return nioBuf.read(buf); }
/** {@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); } }
/** * @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<?> resumeReads() { try { return chain().onResumeReads(this); } catch (IgniteCheckedException e) { close(); return new GridNioFinishedFuture<Object>(e); } }
/** {@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 void forceClose() { super.forceClose(); ses.close(); }
/** * Notifies SessionWriteRequests and it's messages when requests were actually written. * @param ses GridNioSession. * @param requests SessionWriteRequests. */ private void onRequestsWritten(GridSelectorNioSessionImpl ses, List<SessionWriteRequest> requests) { for (SessionWriteRequest request : requests) { request.onMessageWritten(); onMessageWritten(ses, (Message)request.message()); } }
/** {@inheritDoc} */ @Override public void proceedSessionIdleTimeout(GridNioSession ses) throws IgniteCheckedException { checkPrevious(); prevFilter.onSessionIdleTimeout(ses); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> proceedPauseReads(GridNioSession ses) throws IgniteCheckedException { checkNext(); return nextFilter.onPauseReads(ses); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> proceedSessionWrite( GridNioSession ses, Object msg, boolean fut, IgniteInClosure<IgniteException> ackC ) throws IgniteCheckedException { checkNext(); return nextFilter.onSessionWrite(ses, msg, fut, ackC); }
/** {@inheritDoc} */ @Override public void proceedSessionWriteTimeout(GridNioSession ses) throws IgniteCheckedException { checkPrevious(); prevFilter.onSessionWriteTimeout(ses); }
/** {@inheritDoc} */ @Override public void proceedSessionOpened(GridNioSession ses) throws IgniteCheckedException { checkPrevious(); prevFilter.onSessionOpened(ses); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> proceedResumeReads(GridNioSession ses) throws IgniteCheckedException { checkNext(); return nextFilter.onResumeReads(ses); }
/** {@inheritDoc} */ @Override public void proceedExceptionCaught(GridNioSession ses, IgniteCheckedException e) throws IgniteCheckedException { checkPrevious(); prevFilter.onExceptionCaught(ses, e); }
/** * Creates new client. * @param addr Address to connect to. * @param port Port to connect to. * @param locHost Local host. * @return Created client. * @throws IgniteCheckedException If client cannot be created. */ protected TestClient createClient(InetAddress addr, int port, InetAddress locHost) throws IgniteCheckedException { return new TestClient(createSocket(), addr, port, 0); }