Java 类org.jboss.netty.channel.ChannelStateEvent 实例源码

项目:https-github.com-apache-zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }

    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);

    if (secure) {
        SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
        ChannelFuture handshakeFuture = sslHandler.handshake();
        handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
    } else {
        allChannels.add(ctx.getChannel());
        addCnxn(cnxn);
    }
}
项目:athena    文件:OspfInterfaceChannelHandler.java   
@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();
    }
}
项目:athena    文件:PcepChannelHandler.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    log.info("Pcc disconnected callback for pc:{}. Cleaning up ...", getClientInfoString());
    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());
    }
}
项目:QoS-floodlight    文件:OFChannelHandler.java   
@Override
@LogMessageDoc(message="Disconnected switch {switch information}",
               explanation="The specified switch has disconnected.")
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent e) throws Exception {
    controller.removeSwitchChannel(this);
    if (this.sw != null) {
        // TODO: switchDisconnected() will check if we've previously
        // activated the switch. Nevertheless, we might want to check
        // here as well.
        controller.switchDisconnected(this.sw);
        this.sw.setConnected(false);
    }

    log.info("Disconnected switch {}", getSwitchInfoString());
}
项目:SecureKeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }

    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);

    //SECUREKEEPER: Enable ssl only if specified
    //if (secure) {
    if(encryption.equals("ssl")){
        SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
        ChannelFuture handshakeFuture = sslHandler.handshake();
        handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
    } else {
        allChannels.add(ctx.getChannel());
        addCnxn(cnxn);
    }
}
项目:SecureKeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }

    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);

    //SECUREKEEPER: Enable ssl only if specified
    //if (secure) {
    if(encryption.equals("ssl")){
        SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
        ChannelFuture handshakeFuture = sslHandler.handshake();
        handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
    } else {
        allChannels.add(ctx.getChannel());
        addCnxn(cnxn);
    }
}
项目:voyage    文件:NettyRpcServerHandler.java   
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
        throws Exception {
    if (null != channelGroups) {
        channelGroups.add(e.getChannel());
    }
}
项目:EatDubbo    文件:NettyHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler);
    try {
        if (channel != null) {
            channels.put(NetUtils.toAddressString((InetSocketAddress) ctx.getChannel().getRemoteAddress()), channel);
        }
        handler.connected(channel);
    } finally {
        NettyChannel.removeChannelIfDisconnected(ctx.getChannel());
    }
}
项目:EatDubbo    文件:NettyHandler.java   
@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());
    }
}
项目:fuck_zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel closed " + e);
    }
    allChannels.remove(ctx.getChannel());
}
项目:fuck_zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }
    allChannels.add(ctx.getChannel());
    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);
    addCnxn(cnxn);
}
项目:fuck_zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel disconnected " + e);
    }
    NettyServerCnxn cnxn = (NettyServerCnxn) ctx.getAttachment();
    if (cnxn != null) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Channel disconnect caused close " + e);
        }
        cnxn.close();
    }
}
项目:dubbo2    文件:NettyHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler);
    try {
        if (channel != null) {
            channels.put(NetUtils.toAddressString((InetSocketAddress) ctx.getChannel().getRemoteAddress()), channel);
        }
        handler.connected(channel);
    } finally {
        NettyChannel.removeChannelIfDisconnected(ctx.getChannel());
    }
}
项目:dubbo2    文件:NettyHandler.java   
@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());
    }
}
项目:HiBangClient    文件:ClientHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
        throws Exception {
    MyToast.ShowMessage(SMsgManage.getManager().getCurrContext(), e.toString());
    Log.i(ClientHandler.class.getName(), e.toString());
    super.channelConnected(ctx, e);
}
项目:https-github.com-apache-zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel closed " + e);
    }
    allChannels.remove(ctx.getChannel());
}
项目:https-github.com-apache-zookeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel disconnected " + e);
    }
    NettyServerCnxn cnxn = (NettyServerCnxn) ctx.getAttachment();
    if (cnxn != null) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Channel disconnect caused close " + e);
        }
        cnxn.close();
    }
}
项目:traccar-service    文件:MainEventHandler.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
    Log.info(formatChannel(e.getChannel()) + " disconnected");
    closeChannel(e.getChannel());

    BaseProtocolDecoder protocolDecoder = (BaseProtocolDecoder) ctx.getPipeline().get("objectDecoder");
    if (ctx.getPipeline().get("httpDecoder") == null
            && !connectionlessProtocols.contains(protocolDecoder.getProtocolName())) {
        Context.getConnectionManager().removeActiveDevice(e.getChannel());
    }
}
项目:dubbox-hystrix    文件:NettyHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    NettyChannel channel = NettyChannel.getOrAddChannel(ctx.getChannel(), url, handler);
    try {
        if (channel != null) {
            channels.put(NetUtils.toAddressString((InetSocketAddress) ctx.getChannel().getRemoteAddress()), channel);
        }
        handler.connected(channel);
    } finally {
        NettyChannel.removeChannelIfDisconnected(ctx.getChannel());
    }
}
项目:dubbox-hystrix    文件:NettyHandler.java   
@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());
    }
}
项目:hadoop    文件:ShuffleHandler.java   
@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);

}
项目:hadoop    文件:SimpleTcpClientHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
  // Send the request
  if (LOG.isDebugEnabled()) {
    LOG.debug("sending PRC request");
  }
  ChannelBuffer outBuf = XDR.writeMessageTcp(request, true);
  e.getChannel().write(outBuf);
}
项目:athena    文件:OspfInterfaceChannelHandlerTest.java   
/**
 * 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);
}
项目:athena    文件:OspfInterfaceChannelHandlerTest.java   
/**
 * Tests channelDisconnected() method.
 */
@Test
public void testChannelDisconnected() throws Exception {
    channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
    channelStateEvent = EasyMock.createMock(ChannelStateEvent.class);
    ospfInterfaceChannelHandler.channelDisconnected(channelHandlerContext, channelStateEvent);
    assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
}
项目:athena    文件:HandshakeTimeoutHandler.java   
@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);
}
项目:athena    文件:HandshakeTimeoutHandler.java   
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
        throws Exception {
    if (timeout != null) {
        timeout.cancel();
        timeout = null;
    }
}
项目:athena    文件:OFChannelHandler.java   
@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);
}
项目:athena    文件:OFChannelHandler.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception {
    log.info("Switch disconnected callback for sw:{}. Cleaning up ...",
            getSwitchInfoString());
    if (thisdpid != 0) {
        if (!duplicateDpidFound) {
            // if the disconnected switch (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
            // switch was a duplicate-dpid, calling the method below would clear
            // all state for the original switch (with the same dpid),
            // which we obviously don't want.
            log.info("{}:removal called", getSwitchInfoString());
            if (sw != null) {
                sw.removeConnectedSwitch();
            }
        } else {
            // A duplicate was disconnected on this ChannelHandler,
            // this is the same switch reconnecting, but the original state was
            // not cleaned up - XXX check liveness of original ChannelHandler
            log.info("{}:duplicate found", getSwitchInfoString());
            duplicateDpidFound = Boolean.FALSE;
        }
    } else {
        log.warn("no dpid in channelHandler registered for "
                + "disconnected switch {}", getSwitchInfoString());
    }
}
项目:athena    文件:PcepChannelHandler.java   
@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);
}
项目:athena    文件:IsisChannelHandler.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
    log.debug("IsisChannelHandler::channelDisconnected...!!!");
    if (controller != null) {
        controller.connectPeer();
        stopHelloSender();
    }
}
项目:athena    文件:IsisChannelHandlerTest.java   
@Before
public void setUp() throws Exception {
    controller = EasyMock.createNiceMock(Controller.class);
    isisProcess = EasyMock.createNiceMock(IsisProcess.class);
    channelHandlerContext = EasyMock.createNiceMock(ChannelHandlerContext.class);
    channelStateEvent = EasyMock.createNiceMock(ChannelStateEvent.class);
    exceptionEvent = EasyMock.createNiceMock(ExceptionEvent.class);
    messageEvent = EasyMock.createNiceMock(MessageEvent.class);
    isisMessage = EasyMock.createNiceMock(L1L2HelloPdu.class);
    isisMessage.setInterfaceIndex(2);
    isisChannelHandler = new IsisChannelHandler(controller, isisProcessList);
}
项目:athena    文件:FpmSessionHandler.java   
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
        throws Exception {
    if (!fpmListener.peerConnected(ctx.getChannel().getRemoteAddress())) {
        log.error("Received new FPM connection while already connected");
        ctx.getChannel().close();
        return;
    }

    channel = ctx.getChannel();
}
项目:athena    文件:BgpSession.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
                             ChannelStateEvent channelEvent) {
    localInfo.setAddress(ctx.getChannel().getLocalAddress());
    remoteInfo.setAddress(ctx.getChannel().getRemoteAddress());

    // Assign the local and remote IPv4 addresses
    InetAddress inetAddr;
    if (localInfo.address() instanceof InetSocketAddress) {
        inetAddr = ((InetSocketAddress) localInfo.address()).getAddress();
        localInfo.setIp4Address(Ip4Address.valueOf(inetAddr.getAddress()));
    }
    if (remoteInfo.address() instanceof InetSocketAddress) {
        inetAddr = ((InetSocketAddress) remoteInfo.address()).getAddress();
        remoteInfo.setIp4Address(Ip4Address.valueOf(inetAddr.getAddress()));
    }

    log.debug("BGP Session Connected from {} on {}",
              remoteInfo.address(), localInfo.address());
    if (!bgpSessionManager.peerConnected(this)) {
        log.debug("Cannot setup BGP Session Connection from {}. Closing...",
                  remoteInfo.address());
        ctx.getChannel().close();
    }

    //
    // Assign the local BGP ID
    // NOTE: This should be configuration-based
    //
    localInfo.setBgpId(bgpSessionManager.getMyBgpId());
}
项目:athena    文件:BgpSession.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx,
                                ChannelStateEvent channelEvent) {
    log.debug("BGP Session Disconnected from {} on {}",
              ctx.getChannel().getRemoteAddress(),
              ctx.getChannel().getLocalAddress());
    processChannelDisconnected();
}
项目:athena    文件:TestBgpPeerChannelHandler.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
                             ChannelStateEvent channelEvent) {
    this.savedCtx = ctx;
    // Prepare and transmit BGP OPEN message
    ChannelBuffer message = BgpOpen.prepareBgpOpen(localInfo);
    ctx.getChannel().write(message);

    // Prepare and transmit BGP KEEPALIVE message
    message = BgpKeepalive.prepareBgpKeepalive();
    ctx.getChannel().write(message);
}
项目:ZooKeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel closed " + e);
    }
    allChannels.remove(ctx.getChannel());
}
项目:ZooKeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }
    allChannels.add(ctx.getChannel());
    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);
    addCnxn(cnxn);
}
项目:ZooKeeper    文件:NettyServerCnxnFactory.java   
@Override
public void channelDisconnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel disconnected " + e);
    }
    NettyServerCnxn cnxn = (NettyServerCnxn) ctx.getAttachment();
    if (cnxn != null) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Channel disconnect caused close " + e);
        }
        cnxn.close();
    }
}
项目:iTAP-controller    文件:AbstractRPCChannelHandler.java   
@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);
}
项目:iTAP-controller    文件:HandshakeTimeoutHandler.java   
@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);
}