private void removeHandlers() { if (readTimeout > 0) { channel.getPipeline().remove(READ_TIMEOUT_HANDLER_NAME); } channel.getPipeline().remove(LAST_HANDLER_NAME); } }
public static ChannelPipeline getPipeLineOfConnection( NettyTCPMessageSender messageSender) { if(null != messageSender){ Channel channel = messageSender.getChannel(); ChannelPipeline pipeline = channel.getPipeline(); return pipeline; } return null; }
/** * Sends a {@code "channelInterestChanged"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} once the io-thread runs again. */ public static ChannelFuture fireChannelInterestChangedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { public void run() { fireChannelInterestChanged(channel); } }); }
/** * Sends a {@code "exceptionCaught"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} once the io-thread runs again. */ public static ChannelFuture fireExceptionCaughtLater(final Channel channel, final Throwable cause) { return channel.getPipeline().execute(new Runnable() { public void run() { fireExceptionCaught(channel, cause); } }); }
/** * Sends a {@code "writeComplete"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} in the next io-thread. */ public static ChannelFuture fireWriteCompleteLater(final Channel channel, final long amount) { return channel.getPipeline().execute(new Runnable() { public void run() { fireWriteComplete(channel, amount); } }); }
/** * Sends a {@code "channelUnbound"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} once the io-thread runs again. */ public static ChannelFuture fireChannelUnboundLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { public void run() { fireChannelUnbound(channel); } }); }
/** * Sends a {@code "channelClosed"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} once the io-thread runs again. */ public static ChannelFuture fireChannelClosedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { public void run() { fireChannelClosed(channel); } }); }
/** * Sends a {@code "channelDisconnected"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} once the io-thread runs again. */ public static ChannelFuture fireChannelDisconnectedLater(final Channel channel) { return channel.getPipeline().execute(new Runnable() { public void run() { fireChannelDisconnected(channel); } }); } /**
@Override public void enableRecv() { if (throttled) { throttled = false; if (LOG.isDebugEnabled()) { LOG.debug("Sending unthrottle event " + this); } channel.getPipeline().sendUpstream(new ResumeMessageEvent(channel)); } }
public ServerImpl(NetworkSystemImpl system, Channel channel) { this.channel = channel; metricsSource = (NetMetricSource) channel.getPipeline().get(MetricRecordingHandler.NAME); this.networkSystem = system; this.time = (EngineTime) CoreRegistry.get(Time.class); }
/** * Sends a {@code "exceptionCaught"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. */ public static void fireExceptionCaught(Channel channel, Throwable cause) { channel.getPipeline().sendUpstream( new DefaultExceptionEvent(channel, cause)); }
private static void fireChildChannelStateChanged( Channel channel, Channel childChannel) { channel.getPipeline().sendUpstream( new DefaultChildChannelStateEvent(channel, childChannel)); }
/** * Sends a {@code "channelDisconnected"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. */ public static void fireChannelDisconnected(Channel channel) { channel.getPipeline().sendUpstream( new UpstreamChannelStateEvent( channel, ChannelState.CONNECTED, null)); }
/** * Sends a {@code "channelInterestChanged"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. */ public static void fireChannelInterestChanged(Channel channel) { channel.getPipeline().sendUpstream( new UpstreamChannelStateEvent( channel, ChannelState.INTEREST_OPS, Channel.OP_READ)); }
/** * Sends a {@code "writeComplete"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. */ public static void fireWriteComplete(Channel channel, long amount) { if (amount == 0) { return; } channel.getPipeline().sendUpstream( new DefaultWriteCompletionEvent(channel, amount)); }
/** * Sends a {@code "channelUnbound"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. */ public static void fireChannelUnbound(Channel channel) { channel.getPipeline().sendUpstream(new UpstreamChannelStateEvent( channel, ChannelState.BOUND, null)); }
/** * Sends a {@code "channelConnected"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param remoteAddress * the remote address where the specified channel is connected */ public static void fireChannelConnected(Channel channel, SocketAddress remoteAddress) { channel.getPipeline().sendUpstream( new UpstreamChannelStateEvent( channel, ChannelState.CONNECTED, remoteAddress)); }
/** * Sends a {@code "messageReceived"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel} belongs. * * @param message the received message * @param remoteAddress the remote address where the received message * came from */ public static void fireMessageReceived(Channel channel, Object message, SocketAddress remoteAddress) { channel.getPipeline().sendUpstream( new UpstreamMessageEvent(channel, message, remoteAddress)); }
/** * Sends a {@code "channelBound"} event to the first * {@link ChannelUpstreamHandler} in the {@link ChannelPipeline} of * the specified {@link Channel}. * * @param localAddress * the local address where the specified channel is bound */ public static void fireChannelBound(Channel channel, SocketAddress localAddress) { channel.getPipeline().sendUpstream( new UpstreamChannelStateEvent( channel, ChannelState.BOUND, localAddress)); }
public Future<ServerInfoMessage> requestInfo(final String address, final int port) { return pool.submit(() -> { InetSocketAddress remoteAddress = new InetSocketAddress(address, port); ChannelFuture connectCheck = bootstrap.connect(remoteAddress); connectCheck.syncUninterruptibly(); Channel channel = connectCheck.getChannel(); channel.getCloseFuture().syncUninterruptibly(); ServerInfoRequestHandler handler = channel.getPipeline().get(ServerInfoRequestHandler.class); ServerInfoMessage serverInfo = handler.getServerInfo(); return serverInfo; }); }