本文整理汇总了Java中org.jboss.netty.channel.ChannelStateEvent.getChannel方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelStateEvent.getChannel方法的具体用法?Java ChannelStateEvent.getChannel怎么用?Java ChannelStateEvent.getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.channel.ChannelStateEvent
的用法示例。
在下文中一共展示了ChannelStateEvent.getChannel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void channelConnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
channel = e.getChannel();
log.info("New switch connection from {}",
channel.getRemoteAddress());
/*
hack to wait for the switch to tell us what it's
max version is. This is not spec compliant and should
be removed as soon as switches behave better.
*/
//sendHandshakeHelloMessage();
setState(ChannelState.WAIT_HELLO);
}
示例2: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
channel = e.getChannel();
log.info("PCC connected from {}", channel.getRemoteAddress());
// Wait for open message from pcc client
setState(ChannelState.OPENWAIT);
}
示例3: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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 {
log.debug("channelConnected on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
counters.switchConnected.increment();
channel = e.getChannel();
log.info("New switch connection from {}",
channel.getRemoteAddress());
setState(new WaitHelloState());
}
示例4: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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);
}
示例5: channelOpen
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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();
}
});
}
示例6: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
log.info("OSPF channelConnected from {}", evt.getChannel().getRemoteAddress());
this.channel = evt.getChannel();
initialize();
}
示例7: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
log.info("ISIS channelConnected from {}", evt.getChannel().getRemoteAddress());
this.channel = evt.getChannel();
initialize();
}
示例8: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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);
}
}
示例9: channelDisconnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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;
}
stopKeepAliveTimer();
} else {
bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.IDLE);
log.warn("No bgp ip in channelHandler registered for " + "disconnected peer {}", getPeerInfoString());
}
}
示例10: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
/**
* This method will be called as soon as the client is connected and
* will start sending data.
*/
@Override
public void channelConnected(ChannelHandlerContext ctx,
ChannelStateEvent e) throws Exception {
// super.channelConnected(ctx, e);
// as soon as connected send data
Channel channel = e.getChannel();
boolean sentLines = false;
// --- Create ChannelBuffer for output chunk
ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024);
ChannelBufferOutputStream output = new ChannelBufferOutputStream(
channelBuffer);
protocol.send(clientHandlerContext.getHeader(),
clientHandlerContext.getFileLineStreamer().getCodec(),
output);
// write the fileInput to the channel buffer outBuffer
// we are reading several lines of data as configured in the
// FileLineStreamer
// and compressing the output to a channel buffer.
// this allows more file lines to be read as the in-memory storage
// is a
// compressed.
sentLines = clientHandlerContext.getFileLineStreamer()
.streamContent(
clientHandlerContext.getIntermediatePointer(),
clientHandlerContext.getReader(), output);
if (sentLines) {
// get the total message length, and write integer as first
// bytes of message
// this is needed to that the server can know how much bytes to
// expect in a message
int messageLen = channelBuffer.readableBytes();
ChannelBuffer messageLenBuffer = ChannelBuffers.buffer(4);
messageLenBuffer.writeInt(messageLen);
// create a wrapped composite buffer
ChannelBuffer messageBuffer = ChannelBuffers.wrappedBuffer(
messageLenBuffer, channelBuffer);
// write the composite buffer containing the message length and
// compressed data to the channel
channel.write(messageBuffer);
} else {
// close channel if no write
channel.close();
if (!exhanged.getAndSet(true)) {
exchanger.exchange(clientHandlerContext, sendTimeOut,
TimeUnit.MILLISECONDS);
}
}
super.channelConnected(ctx, e);
}
示例11: channelConnected
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@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()));
}
示例12: channelOpen
import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
this.channel = e.getChannel();
super.channelOpen(ctx, e);
}