/** {@inheritDoc} */ @Override public void onExceptionCaught(GridNioSession ses, IgniteCheckedException ex) throws IgniteCheckedException { proceedExceptionCaught(ses, ex); }
@Override protected void body() { try { proceedMessageReceived(ses, msg); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
/** {@inheritDoc} */ @Override public GridNioFuture<Boolean> onSessionClose(GridNioSession ses) throws IgniteCheckedException { return proceedSessionClose(ses); }
/** * Gets filters used by communication. * * @return Filters array. */ private GridNioFilter[] filters() { return new GridNioFilter[] { new GridNioAsyncNotifyFilter(igniteInstanceName, execSvc, log), new HandshakeAndBackpressureFilter(), new HadoopMarshallerFilter(marsh), new GridNioCodecFilter(new GridBufferedParser(directBuf, ByteOrder.nativeOrder()), log, false) }; }
/** {@inheritDoc} */ @Override public GridNioFuture<?> onSessionWrite( GridNioSession ses, Object msg, boolean fut, IgniteInClosure<IgniteException> ackC ) throws IgniteCheckedException { return proceedSessionWrite(ses, msg, fut, ackC); }
@Override protected void body() { try { proceedSessionOpened(ses); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
@Override protected void body() { try { proceedSessionClosed(ses); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
/** {@inheritDoc} */ @Override public void onSessionWriteTimeout(GridNioSession ses) throws IgniteCheckedException { proceedSessionWriteTimeout(ses); }
/** {@inheritDoc} */ @Override public void onSessionIdleTimeout(GridNioSession ses) throws IgniteCheckedException { proceedSessionIdleTimeout(ses); }
@Override public void onMessageReceived(GridNioSession ses, Object msg) throws IgniteCheckedException { ClientListenerConnectionContext connCtx = ses.meta(ClientListenerNioListener.CONN_CTX_META_KEY); if (connCtx != null && connCtx.parser() != null) { byte[] inMsg; int cmdType; long reqId; try { inMsg = (byte[])msg; cmdType = connCtx.parser().decodeCommandType(inMsg); reqId = connCtx.parser().decodeRequestId(inMsg); } catch (Exception e) { U.error(log, "Failed to parse client request.", e); ses.close(); return; } if (connCtx.handler().isCancellationCommand(cmdType)) { proceedMessageReceived(ses, msg); CANCEL_COUNTER.incrementAndGet(); } else { connCtx.handler().registerRequest(reqId, cmdType); super.onMessageReceived(ses, msg); } } else super.onMessageReceived(ses, msg); } };
/** * Starts the server. * * @throws IgniteCheckedException If failed. */ public void start() throws IgniteCheckedException { try { String igniteInstanceName = "test"; srv = GridNioServer.<GridClientMessage>builder() .address(InetAddress.getByName("127.0.0.1")) .port(port) .listener(new TestListener()) .logger(log) .selectorCount(2) .igniteInstanceName(igniteInstanceName) .byteOrder(ByteOrder.nativeOrder()) .tcpNoDelay(true) .directBuffer(false) .filters( new GridNioAsyncNotifyFilter(igniteInstanceName, Executors.newFixedThreadPool(2), log), new GridNioCodecFilter(new TestParser(), log, false) ) .build(); } catch (UnknownHostException e) { throw new IgniteCheckedException("Failed to determine localhost address.", e); } srv.start(); }
/** {@inheritDoc} */ @Override public GridNioFuture<?> onSessionWrite( GridNioSession ses, Object msg, boolean fut, IgniteInClosure<IgniteException> ackC ) throws IgniteCheckedException { return proceedSessionWrite(ses, msg, fut, ackC); }
@Override protected void body() { try { proceedSessionOpened(ses); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
@Override protected void body() { try { proceedSessionClosed(ses); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
/** {@inheritDoc} */ @Override public void onSessionWriteTimeout(GridNioSession ses) throws IgniteCheckedException { proceedSessionWriteTimeout(ses); }
/** {@inheritDoc} */ @Override public void onSessionIdleTimeout(GridNioSession ses) throws IgniteCheckedException { proceedSessionIdleTimeout(ses); }
/** * @param ses Session. * @param ex Exception. */ private void handleException(GridNioSession ses, IgniteCheckedException ex) { try { proceedExceptionCaught(ses, ex); } catch (IgniteCheckedException e) { U.warn(log, "Failed to forward exception to the underlying filter (will ignore) [ses=" + ses + ", " + "originalEx=" + ex + ", ex=" + e + ']'); } } }
/** {@inheritDoc} */ @Override public GridNioFuture<Boolean> onSessionClose(GridNioSession ses) throws IgniteCheckedException { return proceedSessionClose(ses); }
@Override protected void body() { try { proceedMessageReceived(ses, msg); } catch (IgniteCheckedException e) { handleException(ses, e); } } });
/** {@inheritDoc} */ @Override public void onExceptionCaught(GridNioSession ses, IgniteCheckedException ex) throws IgniteCheckedException { proceedExceptionCaught(ses, ex); }