Java Code Examples for org.jboss.netty.channel.ChannelStateEvent#getChannel()
The following examples show how to use
org.jboss.netty.channel.ChannelStateEvent#getChannel() .
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: 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 2
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 3
Source File: PcepChannelHandler.java From onos with Apache License 2.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { log.info("Pcc disconnected callback for pc:{}. Cleaning up ...", getClientInfoString()); controller.peerStatus(peerAddr, PcepCfg.State.DOWN.toString(), sessionId); channel = e.getChannel(); address = channel.getRemoteAddress(); if (!(address instanceof InetSocketAddress)) { throw new IOException("Invalid peer connection."); } inetAddress = (InetSocketAddress) address; peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString(); if (thispccId != null) { if (!duplicatePccIdFound) { // if the disconnected client (on this ChannelHandler) // was not one with a duplicate-dpid, it is safe to remove all // state for it at the controller. Notice that if the disconnected // client was a duplicate-ip, calling the method below would clear // all state for the original client (with the same ip), // which we obviously don't want. log.debug("{}:removal called", getClientInfoString()); if (pc != null) { pc.removeConnectedClient(); } } else { // A duplicate was disconnected on this ChannelHandler, // this is the same client reconnecting, but the original state was // not cleaned up - XXX check liveness of original ChannelHandler log.debug("{}:duplicate found", getClientInfoString()); duplicatePccIdFound = Boolean.FALSE; } } else { log.warn("no pccip in channelHandler registered for " + "disconnected client {}", getClientInfoString()); } }
Example 4
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 5
Source File: PinpointServerAcceptor.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final Channel channel = e.getChannel(); channelGroup.remove(channel); super.channelClosed(ctx, e); }
Example 6
Source File: PinpointServerAcceptor.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final Channel channel = e.getChannel(); DefaultPinpointServer pinpointServer = (DefaultPinpointServer) channel.getAttachment(); if (pinpointServer != null) { pinpointServer.stop(released); } super.channelDisconnected(ctx, e); }
Example 7
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 8
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 9
Source File: DefaultPinpointClientHandler.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { final Channel channel = e.getChannel(); logger.debug("{} channelOpen() started. channel:{}", objectUniqName, channel); this.channel = channel; }
Example 10
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 11
Source File: MyServerHandler.java From whiteboard with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) { Channel channel = e.getChannel(); Commons.currentClientIP = ((InetSocketAddress) e.getChannel() .getRemoteAddress()).getAddress().getHostAddress(); // MetadataRepositories.getInstance().getChannels().put( // Commons.currentClientIP, channel); System.out.println("�ͻ�: " + Commons.currentClientIP + " ���룡"); sendAllShapesToClient(channel); }
Example 12
Source File: MyClientHandler.java From whiteboard with Apache License 2.0 | 5 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) { Log.i(TAG, "ͨ�����ӳɹ�"); Commons.currentChannel = e.getChannel(); if (mConnectStateListener != null) { mConnectStateListener.channelConnected(); } }
Example 13
Source File: StormClientHandler.java From jstorm with Apache License 2.0 | 5 votes |
/** * Sometime when connecting to a bad channel which isn't writable, this method will be called */ @Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) { // register the newly established channel Channel channel = event.getChannel(); LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress()); client.connectChannel(ctx.getChannel()); client.handleResponse(ctx.getChannel(), null); }
Example 14
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 15
Source File: OspfInterfaceChannelHandler.java From onos with Apache License 2.0 | 4 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) { log.info("OSPF channelConnected from {}", evt.getChannel().getRemoteAddress()); this.channel = evt.getChannel(); initialize(); }
Example 16
Source File: TSOClient.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) { currentChannel = e.getChannel(); LOG.debug("HANDLER (CHANNEL CONNECTED): Connection {}. Sending connected event to FSM", e); fsm.sendEvent(new ConnectedEvent(e.getChannel())); }
Example 17
Source File: IsisChannelHandler.java From onos with Apache License 2.0 | 4 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception { log.info("ISIS channelConnected from {}", evt.getChannel().getRemoteAddress()); this.channel = evt.getChannel(); initialize(); }
Example 18
Source File: BgpChannelHandler.java From onos with Apache License 2.0 | 4 votes |
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channel = e.getChannel(); log.info("BGP connected from {}", channel.getRemoteAddress()); address = channel.getRemoteAddress(); if (!(address instanceof InetSocketAddress)) { throw new IOException("Invalid peer connection."); } // Connection should establish only if local ip and Autonomous system number is configured. if (bgpconfig.getState() != BgpCfg.State.IP_AS_CONFIGURED) { sendNotification(BgpErrorType.CEASE, BgpErrorType.CONNECTION_REJECTED, null); channel.close(); log.info("BGP local AS and router ID not configured"); return; } inetAddress = (InetSocketAddress) address; peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString(); // if peer is not configured disconnect session if (!bgpconfig.isPeerConfigured(peerAddr)) { log.debug("Peer is not configured {}", peerAddr); sendNotification(BgpErrorType.CEASE, BgpErrorType.CONNECTION_REJECTED, null); channel.close(); return; } // if connection is already established close channel if (peerManager.isPeerConnected(BgpId.bgpId(IpAddress.valueOf(peerAddr)))) { log.debug("Duplicate connection received, peer {}", peerAddr); channel.close(); return; } if (null != channel.getPipeline().get("PassiveHandler")) { log.info("BGP handle connection request from peer"); // Wait for open message from bgp peer setState(ChannelState.OPENWAIT); } else if (null != channel.getPipeline().get("ActiveHandler")) { log.info("BGP handle connection response from peer"); sendHandshakeOpenMessage(); bgpPacketStats.addOutPacket(); setState(ChannelState.OPENSENT); bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.OPENSENT); } }
Example 19
Source File: BgpChannelHandler.java From onos with Apache License 2.0 | 4 votes |
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channel = e.getChannel(); log.info("BGP disconnected callback for bgp:{}. Cleaning up ...", getPeerInfoString()); address = channel.getRemoteAddress(); if (!(address instanceof InetSocketAddress)) { throw new IOException("Invalid peer connection."); } inetAddress = (InetSocketAddress) address; peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString(); if (thisbgpId != null) { if (!duplicateBgpIdFound) { // if the disconnected peer (on this ChannelHandler) // was not one with a duplicate, it is safe to remove all // state for it at the controller. Notice that if the disconnected // peer was a duplicate-ip, calling the method below would clear // all state for the original peer (with the same ip), // which we obviously don't want. log.debug("{}:removal called", getPeerInfoString()); if (bgpPeer != null) { BgpPeerImpl peer = (BgpPeerImpl) bgpPeer; peerManager.removeConnectedPeer(thisbgpId); peer.updateLocalRibOnPeerDisconnect(); } // Retry connection if connection is lost to bgp speaker/peer if ((channel != null) && (null != channel.getPipeline().get("ActiveHandler"))) { BgpConnectPeerImpl connectPeer; BgpPeerCfg.State peerCfgState; peerCfgState = bgpconfig.getPeerConnState(peerAddr); // on session disconnect using configuration, do not retry if (!peerCfgState.equals(BgpPeerCfg.State.IDLE)) { log.debug("Connection reset by peer, retry, STATE:{}", peerCfgState); BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr); bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE); connectPeer = new BgpConnectPeerImpl(bgpController, peerAddr, Controller.getBgpPortNum()); peerConfig.setConnectPeer(connectPeer); } } else { bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE); } } else { // A duplicate was disconnected on this ChannelHandler, // this is the same peer reconnecting, but the original state was // not cleaned up - XXX check liveness of original ChannelHandler log.debug("{}:duplicate found", getPeerInfoString()); duplicateBgpIdFound = Boolean.FALSE; } stopSessionTimers(); } else { bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE); log.warn("No bgp ip in channelHandler registered for " + "disconnected peer {}", getPeerInfoString()); } }
Example 20
Source File: MessageHandler.java From msgpack-rpc-java with Apache License 2.0 | 4 votes |
@Override public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { this.adaptor = new ChannelAdaptor(e.getChannel()); ctx.sendUpstream(e); }