Java Code Examples for org.jboss.netty.channel.Channel#setReadable()
The following examples show how to use
org.jboss.netty.channel.Channel#setReadable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyAsyncHttpProvider.java From ck with Apache License 2.0 | 6 votes |
private Channel lookupInCache(URI uri) { Channel channel = connectionsPool.remove(getBaseUrl(uri)); if (channel != null) { /** * The Channel will eventually be closed by Netty and will becomes invalid. * We might suffer a memory leak if we don't scan for closed channel. The * AsyncHttpClientConfig.reaper() will always make sure those are cleared. */ if (channel.isOpen()) { channel.setReadable(true); } else { return null; } } return channel; }
Example 2
Source File: NetworkFailureHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext context, ChannelStateEvent event) throws Exception { // Suspend incoming traffic until connected to the remote host. final Channel sourceChannel = event.getChannel(); sourceChannel.setReadable(false); boolean isBlocked = blocked.get(); LOG.debug("Attempt to open proxy channel from [{}] to [{}:{}] in state [blocked = {}]", sourceChannel.getLocalAddress(), remoteHost, remotePort, isBlocked); if (isBlocked) { sourceChannel.close(); return; } // Start the connection attempt. ClientBootstrap targetConnectionBootstrap = new ClientBootstrap(channelFactory); targetConnectionBootstrap.getPipeline().addLast(TARGET_CHANNEL_HANDLER_NAME, new TargetChannelHandler(event.getChannel(), blocked)); ChannelFuture connectFuture = targetConnectionBootstrap.connect(new InetSocketAddress(remoteHost, remotePort)); sourceToTargetChannels.put(sourceChannel, connectFuture.getChannel()); connectFuture.addListener(future -> { if (future.isSuccess()) { // Connection attempt succeeded: // Begin to accept incoming traffic. sourceChannel.setReadable(true); } else { // Close the connection if the connection attempt has failed. sourceChannel.close(); } }); }
Example 3
Source File: NetworkFailureHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext context, ChannelStateEvent event) throws Exception { // Suspend incoming traffic until connected to the remote host. final Channel sourceChannel = event.getChannel(); sourceChannel.setReadable(false); boolean isBlocked = blocked.get(); LOG.debug("Attempt to open proxy channel from [{}] to [{}:{}] in state [blocked = {}]", sourceChannel.getLocalAddress(), remoteHost, remotePort, isBlocked); if (isBlocked) { sourceChannel.close(); return; } // Start the connection attempt. ClientBootstrap targetConnectionBootstrap = new ClientBootstrap(channelFactory); targetConnectionBootstrap.getPipeline().addLast(TARGET_CHANNEL_HANDLER_NAME, new TargetChannelHandler(event.getChannel(), blocked)); ChannelFuture connectFuture = targetConnectionBootstrap.connect(new InetSocketAddress(remoteHost, remotePort)); sourceToTargetChannels.put(sourceChannel, connectFuture.getChannel()); connectFuture.addListener(future -> { if (future.isSuccess()) { // Connection attempt succeeded: // Begin to accept incoming traffic. sourceChannel.setReadable(true); } else { // Close the connection if the connection attempt has failed. sourceChannel.close(); } }); }
Example 4
Source File: ManageSieveChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
private void turnSSLon(Channel channel) { if (sslContext != null) { channel.setReadable(false); SslHandler filter = new SslHandler(sslContext.createSSLEngine(), false); filter.getEngine().setUseClientMode(false); if (enabledCipherSuites != null && enabledCipherSuites.length > 0) { filter.getEngine().setEnabledCipherSuites(enabledCipherSuites); } channel.getPipeline().addFirst(SSL_HANDLER, filter); channel.setReadable(true); } }
Example 5
Source File: NetworkFailureHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext context, ChannelStateEvent event) throws Exception { // Suspend incoming traffic until connected to the remote host. final Channel sourceChannel = event.getChannel(); sourceChannel.setReadable(false); boolean isBlocked = blocked.get(); LOG.debug("Attempt to open proxy channel from [{}] to [{}:{}] in state [blocked = {}]", sourceChannel.getLocalAddress(), remoteHost, remotePort, isBlocked); if (isBlocked) { sourceChannel.close(); return; } // Start the connection attempt. ClientBootstrap targetConnectionBootstrap = new ClientBootstrap(channelFactory); targetConnectionBootstrap.getPipeline().addLast(TARGET_CHANNEL_HANDLER_NAME, new TargetChannelHandler(event.getChannel(), blocked)); ChannelFuture connectFuture = targetConnectionBootstrap.connect(new InetSocketAddress(remoteHost, remotePort)); sourceToTargetChannels.put(sourceChannel, connectFuture.getChannel()); connectFuture.addListener(future -> { if (future.isSuccess()) { // Connection attempt succeeded: // Begin to accept incoming traffic. sourceChannel.setReadable(true); } else { // Close the connection if the connection attempt has failed. sourceChannel.close(); } }); }
Example 6
Source File: MongoProxyInboundHandler.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void channelOpen( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { // Suspend incoming traffic until connected to the remote host. final Channel inboundChannel = e.getChannel(); inboundChannel.setReadable( false ); // Start the connection attempt. ClientBootstrap cb = new ClientBootstrap( cf ); cb.setOption( "bufferFactory", HeapChannelBufferFactory.getInstance( ByteOrder.LITTLE_ENDIAN ) ); cb.getPipeline().addLast( "framer", new MongoMessageFrame() ); cb.getPipeline().addLast( "handler", new OutboundHandler( e.getChannel() ) ); ChannelFuture f = cb.connect( new InetSocketAddress( remoteHost, remotePort ) ); outboundChannel = f.getChannel(); f.addListener( new ChannelFutureListener() { @Override public void operationComplete( ChannelFuture future ) throws Exception { if ( future.isSuccess() ) { // Connection attempt succeeded: // Begin to accept incoming traffic. inboundChannel.setReadable( true ); } else { // Close the connection if the connection attempt has // failed. inboundChannel.close(); } } } ); }
Example 7
Source File: StormChannelGroup.java From jstorm with Apache License 2.0 | 5 votes |
public synchronized boolean suspendChannel(String remoteAddress) { Channel ch = channelMap.get(remoteAddress); if (ch != null) { LOG.debug("Suspend channel={}", remoteAddress); ch.setReadable(false); return true; } else { LOG.debug("Channel to be suspended is null!"); return false; } }
Example 8
Source File: StormChannelGroup.java From jstorm with Apache License 2.0 | 5 votes |
public synchronized boolean resumeChannel(String remoteAddress) { Channel ch = channelMap.get(remoteAddress); if (ch != null) { LOG.debug("Resume channel={}", remoteAddress); ch.setReadable(true); return true; } else { LOG.debug("Channel to be resumed is null"); return false; } }