org.jboss.netty.channel.ChannelStateEvent Java Examples
The following examples show how to use
org.jboss.netty.channel.ChannelStateEvent.
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: OspfInterfaceChannelHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) { log.debug("OspfChannelHandler::channelDisconnected...!!!"); for (Integer interfaceIndex : ospfInterfaceMap.keySet()) { OspfInterface anInterface = ospfInterfaceMap.get(interfaceIndex); if (anInterface != null) { anInterface.interfaceDown(); anInterface.stopDelayedAckTimer(); } } if (controller != null) { controller.connectPeer(); } }
Example #2
Source File: FpmSessionHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { SocketAddress socketAddress = ctx.getChannel().getRemoteAddress(); if (!(socketAddress instanceof InetSocketAddress)) { throw new IllegalStateException("Address type is not InetSocketAddress"); } us = FpmPeer.fromSocketAddress((InetSocketAddress) socketAddress); if (!fpmListener.peerConnected(us)) { log.error("Received new FPM connection while already connected"); ctx.getChannel().close(); return; } channel = ctx.getChannel(); fpmManager.addSessionChannel(e.getChannel()); fpmManager.processStaticRoutes(e.getChannel()); }
Example #3
Source File: PcepChannelHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channel = e.getChannel(); log.info("PCC connected from {}", channel.getRemoteAddress()); address = channel.getRemoteAddress(); if (!(address instanceof InetSocketAddress)) { throw new IOException("Invalid peer connection."); } inetAddress = (InetSocketAddress) address; peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString(); // Wait for open message from pcc client setState(ChannelState.OPENWAIT); controller.peerStatus(peerAddr, PcepCfg.State.OPENWAIT.toString(), sessionId); }
Example #4
Source File: HandshakeInitializationHandler.java From canal with Apache License 2.0 | 6 votes |
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // add new socket channel in channel container, used to manage sockets. if (childGroups != null) { childGroups.add(ctx.getChannel()); } final byte[] seed = org.apache.commons.lang3.RandomUtils.nextBytes(8); byte[] body = Packet.newBuilder() .setType(CanalPacket.PacketType.HANDSHAKE) .setVersion(NettyUtils.VERSION) .setBody(Handshake.newBuilder().setSeeds(ByteString.copyFrom(seed)).build().toByteString()) .build() .toByteArray(); NettyUtils.write(ctx.getChannel(), body, new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { ctx.getPipeline().get(HandshakeInitializationHandler.class.getName()); ClientAuthenticationHandler handler = (ClientAuthenticationHandler) ctx.getPipeline() .get(ClientAuthenticationHandler.class.getName()); handler.setSeed(seed); } }); logger.info("send handshake initialization packet to : {}", ctx.getChannel()); }
Example #5
Source File: AbstractRPCChannelHandler.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channelState = ChannelState.CONNECTED; HelloMessage m = new HelloMessage(); if (getLocalNodeId() != null) m.setNodeId(getLocalNodeId()); AsyncMessageHeader header = new AsyncMessageHeader(); header.setTransactionId(getTransactionId()); m.setHeader(header); switch (getAuthScheme()) { case NO_AUTH: channelState = ChannelState.AUTHENTICATED; m.setAuthScheme(org.sdnplatform.sync.thrift. AuthScheme.NO_AUTH); break; case CHALLENGE_RESPONSE: AuthChallengeResponse cr = new AuthChallengeResponse(); cr.setChallenge(generateChallenge()); m.setAuthScheme(org.sdnplatform.sync.thrift. AuthScheme.CHALLENGE_RESPONSE); m.setAuthChallengeResponse(cr); break; } SyncMessage bsm = new SyncMessage(MessageType.HELLO); bsm.setHello(m); ctx.getChannel().write(bsm); }
Example #6
Source File: BootstrapTimeoutHandler.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (timeout != null) { timeout.cancel(); timeout = null; } }
Example #7
Source File: OFControllerChannelHandler.java From FlowSpaceFirewall with Apache License 2.0 | 5 votes |
@Override @LogMessageDoc(message="New controller connection to {ip address}", explanation="Connecting to a new controller") public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channel = e.getChannel(); log.info("New controller connection to {}", channel.getRemoteAddress()); log.debug("Sending HELLO"); sendHandShakeMessage(OFType.HELLO); setState(ChannelState.WAIT_HELLO); }
Example #8
Source File: OspfInterfaceChannelHandlerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests channelConnected() method. */ @Test(expected = Exception.class) public void testChannelConnected() throws Exception { channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); channelStateEvent = EasyMock.createMock(ChannelStateEvent.class); ospfInterfaceChannelHandler.channelConnected(channelHandlerContext, channelStateEvent); }
Example #9
Source File: HandshakeInitializationHandler.java From canal with Apache License 2.0 | 5 votes |
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { // add new socket channel in channel container, used to manage sockets. if (childGroups != null) { childGroups.add(ctx.getChannel()); } final byte[] seed = org.apache.commons.lang3.RandomUtils.nextBytes(8); byte[] body = Packet.newBuilder() .setType(AdminPacket.PacketType.HANDSHAKE) .setVersion(AdminNettyUtils.VERSION) .setBody(Handshake.newBuilder().setSeeds(ByteString.copyFrom(seed)).build().toByteString()) .build() .toByteArray(); AdminNettyUtils.write(ctx.getChannel(), body, new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { logger.info("remove unused channel handlers after authentication is done successfully."); ctx.getPipeline().get(HandshakeInitializationHandler.class.getName()); ClientAuthenticationHandler handler = (ClientAuthenticationHandler) ctx.getPipeline() .get(ClientAuthenticationHandler.class.getName()); handler.setSeed(seed); } }); logger.info("send handshake initialization packet to : {}", ctx.getChannel()); }
Example #10
Source File: MongoProxyInboundHandler.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void channelInterestChanged( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { // If inboundChannel is not saturated anymore, continue accepting // the incoming traffic from the outboundChannel. synchronized ( trafficLock ) { if ( e.getChannel().isWritable() ) { outboundChannel.setReadable( true ); } } }
Example #11
Source File: DefaultPinpointClientHandler.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final Channel channel = e.getChannel(); if ((null == channel) || (this.channel != channel)) { throw new IllegalArgumentException("Invalid channel variable. this.channel:" + this.channel + ", channel:" + channel + "."); } logger.info("{} channelConnected() started. channel:{}", objectUniqName, channel); SocketStateChangeResult stateChangeResult = state.toConnected(); if (!stateChangeResult.isChange()) { throw new IllegalStateException("Invalid state:" + stateChangeResult.getCurrentState()); } prepareChannel(channel); stateChangeResult = state.toRunWithoutHandshake(); if (!stateChangeResult.isChange()) { throw new IllegalStateException("Failed to execute channelConnected() method. Error:" + stateChangeResult); } registerPing(); handshaker.handshakeStart(channel); connectFuture.setResult(Result.SUCCESS); logger.info("{} channelConnected() completed.", objectUniqName); }
Example #12
Source File: MongoProxyInboundHandler.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void channelInterestChanged( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { // If outboundChannel is not saturated anymore, continue accepting // the incoming traffic from the inboundChannel. synchronized ( trafficLock ) { if ( e.getChannel().isWritable() ) { inboundChannel.setReadable( true ); } } }
Example #13
Source File: OFChannelHandler.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override @LogMessageDoc(message="New switch connection from {ip address}", explanation="A new switch has connected from the " + "specified IP address") public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { counters.switchConnected.updateCounterWithFlush(); channel = e.getChannel(); log.info("New switch connection from {}", channel.getRemoteAddress()); sendHandShakeMessage(OFType.HELLO); setState(ChannelState.WAIT_HELLO); }
Example #14
Source File: PinpointServerAcceptor.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final Channel channel = e.getChannel(); logger.info("channelConnected started. channel:{}", channel); if (released) { logger.warn("already released. channel:{}", channel); channel.write(new ServerClosePacket()).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { future.getChannel().close(); } }); return; } final boolean accept = channelConnectedFilter.accept(channel); if (!accept) { logger.debug("channelConnected() channel discard. {}", channel); return; } DefaultPinpointServer pinpointServer = createPinpointServer(channel); channel.setAttachment(pinpointServer); channelGroup.add(channel); pinpointServer.start(); super.channelConnected(ctx, e); }
Example #15
Source File: NetworkEventHandler.java From android-netty with Apache License 2.0 | 5 votes |
/** The channel is going to closed. */ @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { LogByCodeLab.w(String.format("%s.channelClosed()", NetworkEventHandler.class.getSimpleName())); super.channelClosed(ctx, e); mService.scheduleToReconnect(); }
Example #16
Source File: BootstrapTimeoutHandler.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (timeoutNanos > 0) { timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx), timeoutNanos, TimeUnit.NANOSECONDS); } ctx.sendUpstream(e); }
Example #17
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception { if ((maxShuffleConnections > 0) && (accepted.size() >= maxShuffleConnections)) { LOG.info(String.format("Current number of shuffle connections (%d) is " + "greater than or equal to the max allowed shuffle connections (%d)", accepted.size(), maxShuffleConnections)); evt.getChannel().close(); return; } accepted.add(evt.getChannel()); super.channelOpen(ctx, evt); }
Example #18
Source File: NSQHandler.java From TrendrrNSQClient with MIT License | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) { Connection con = (Connection)e.getChannel().getAttachment(); if (con != null) { log.warn("Channel disconnected! " + con); con._disconnected(); } else { log.warn("No connection set for : " + e.getChannel()); } }
Example #19
Source File: BasicChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
/** * Call the {@link ConnectHandler} instances which are stored in the {@link ProtocolHandlerChain} */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { try (Closeable closeable = mdcContextFactory.from(protocol, ctx)) { List<ConnectHandler> connectHandlers = chain.getHandlers(ConnectHandler.class); List<ProtocolHandlerResultHandler> resultHandlers = chain.getHandlers(ProtocolHandlerResultHandler.class); ProtocolSession session = (ProtocolSession) ctx.getAttachment(); LOGGER.info("Connection established from {}", session.getRemoteAddress().getAddress().getHostAddress()); if (connectHandlers != null) { for (ConnectHandler cHandler : connectHandlers) { long start = System.currentTimeMillis(); Response response = cHandler.onConnect(session); long executionTime = System.currentTimeMillis() - start; for (ProtocolHandlerResultHandler resultHandler : resultHandlers) { resultHandler.onResponse(session, response, executionTime, cHandler); } if (response != null) { // TODO: This kind of sucks but I was able to come up with something more elegant here ((ProtocolSessionImpl) session).getProtocolTransport().writeResponse(response, session); } } } super.channelConnected(ctx, e); } }
Example #20
Source File: TcpWorker.java From parallec with Apache License 2.0 | 5 votes |
/** * Why not use channelClosed: if fail to establish a channel * (e.g. connection refused). will also call channelClosed. * * @param ctx the ctx * @param e the e * @throws Exception the exception */ @Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { logger.debug("channel is closed. "); int statusCodeInt = 0; String statusCode = statusCodeInt + " SUCCESSFUL"; tcpWorker.onComplete(tcpWorker.responseSb.toString(), false, null, null, statusCode, statusCodeInt); }
Example #21
Source File: NettyHandler.java From anima with GNU General Public License v3.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(conf,ctx.getChannel(), handler); try { InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); String key = address.getAddress().getHostAddress() + ":" + address.getPort(); channels.remove(key); handler.disconnected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }
Example #22
Source File: NettyHandler.java From anima with GNU General Public License v3.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(conf,ctx.getChannel(), handler); try { if (channel != null) { InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); String key = address.getAddress().getHostAddress() + ":" + address.getPort(); channels.put(key, channel); } handler.connected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }
Example #23
Source File: BasicChannelUpstreamHandler.java From james-project with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { try (Closeable closeable = mdcContextFactory.from(protocol, ctx)) { List<DisconnectHandler> connectHandlers = chain.getHandlers(DisconnectHandler.class); ProtocolSession session = (ProtocolSession) ctx.getAttachment(); if (connectHandlers != null) { for (DisconnectHandler connectHandler : connectHandlers) { connectHandler.onDisconnect(session); } } super.channelDisconnected(ctx, e); } }
Example #24
Source File: NettySend.java From jlogstash-input-plugin with Apache License 2.0 | 5 votes |
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { logger.warn("channel closed.do connect after:{} seconds.", CONN_DELAY); //重连 timer.newTimeout( new TimerTask() { @Override public void run(Timeout timeout) throws Exception { ChannelFuture channelfuture = client.getBootstrap().connect(); client.setChannel(channelfuture); } }, CONN_DELAY, TimeUnit.SECONDS); }
Example #25
Source File: RaopRtspPipelineFactory.java From Android-Airplay-Server with MIT License | 5 votes |
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); final AirPlayServer airPlayServer = AirPlayServer.getIstance(); pipeline.addLast("executionHandler", airPlayServer.getChannelExecutionHandler()); pipeline.addLast("closeOnShutdownHandler", new SimpleChannelUpstreamHandler() { @Override public void channelOpen(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { airPlayServer.getChannelGroup().add(e.getChannel()); super.channelOpen(ctx, e); } }); pipeline.addLast("exceptionLogger", new ExceptionLoggingHandler()); pipeline.addLast("decoder", new RtspRequestDecoder()); pipeline.addLast("encoder", new RtspResponseEncoder()); pipeline.addLast("logger", new RtspLoggingHandler()); pipeline.addLast("errorResponse", new RtspErrorResponseHandler()); pipeline.addLast("challengeResponse", new RaopRtspChallengeResponseHandler(NetworkUtils.getInstance().getHardwareAddress())); pipeline.addLast("header", new RaopRtspHeaderHandler()); pipeline.addLast("options", new RaopRtspOptionsHandler()); pipeline.addLast("audio", new RaopAudioHandler(airPlayServer.getExecutorService())); pipeline.addLast("unsupportedResponse", new RtspUnsupportedResponseHandler()); return pipeline; }
Example #26
Source File: RaopRtpTimingHandler.java From Android-Airplay-Server with MIT License | 5 votes |
@Override public void channelClosed(final ChannelHandlerContext ctx, final ChannelStateEvent evt) throws Exception { synchronized(this) { if (synchronizationThread != null) synchronizationThread.interrupt(); } }
Example #27
Source File: RaopAudioHandler.java From Android-Airplay-Server with MIT License | 5 votes |
@Override public void channelClosed(final ChannelHandlerContext ctx, final ChannelStateEvent evt) throws Exception { LOG.info("RTSP connection was shut down, closing RTP channels and audio output queue"); synchronized(this) { reset(); } super.channelClosed(ctx, evt); }
Example #28
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 #29
Source File: NettyHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler); try { channels.remove(NetUtils.toAddressString((InetSocketAddress) ctx.getChannel().getRemoteAddress())); handler.disconnected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }
Example #30
Source File: NettyHandler.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler); try { channels.remove(NetUtils.toAddressString((InetSocketAddress) ctx.getChannel().getRemoteAddress())); handler.disconnected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.getChannel()); } }