Java 类org.jboss.netty.channel.group.ChannelGroup 实例源码

项目:iTAP-controller    文件:OFSwitchManager.java   
/**
 * Bootstraps netty, the server that handles all openflow connections
 */
public void bootstrapNetty() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
            new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);

        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
        final ChannelGroup cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));

        log.info("Listening for switch connections on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:fast-failover-demo    文件:OFSwitchManager.java   
/**
 * Bootstraps netty, the server that handles all openflow connections
 */
public void bootstrapNetty() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
            new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);

        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
        final ChannelGroup cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));

        log.info("Listening for switch connections on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:floodlightLB    文件:OFSwitchManager.java   
/**
 * Bootstraps netty, the server that handles all openflow connections
 */
public void bootstrapNetty() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, ofBitmaps, defaultFactory, keyStore, keyStorePassword) :
            new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, ofBitmaps, defaultFactory);

        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
        final ChannelGroup cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));

        log.info("Listening for switch connections on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:DSC    文件:OFSwitchManager.java   
/**
 * Bootstraps netty, the server that handles all openflow connections
 * 启动netty,处理所有OF连接
 */
public void bootstrapNetty() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
            new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);

        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
        final ChannelGroup cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));

        log.info("Listening for switch connections on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:floodlight    文件:OFSwitchManager.java   
/**
 * Bootstraps netty, the server that handles all openflow connections
 */
public void bootstrapNetty() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact =
                new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);
        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
        final ChannelGroup cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));

        log.info("Listening for switch connections on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:pinpoint    文件:HealthCheckManagerTest.java   
@Test
public void withoutPacketTest() throws Exception {
    ChannelGroup channelGroup = new DefaultChannelGroup();

    HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup);
    healthCheckManager.start(1000);

    Channel mockChannel = createMockChannel(HealthCheckState.WAIT);
    channelGroup.add(mockChannel);

    try {
        verify(mockChannel, timeout(5000).atLeastOnce()).close();
    } finally {
        healthCheckManager.stop();
    }
}
项目:httptunnel    文件:HttpTunnelServerChannel.java   
protected HttpTunnelServerChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, ServerSocketChannelFactory inboundFactory, ChannelGroup realConnections) {
    super(factory, pipeline, sink);

    tunnelIdPrefix = Long.toHexString(random.nextLong());
    tunnels = new ConcurrentHashMap<String, HttpTunnelAcceptedChannel>();

    config = new HttpTunnelServerChannelConfig();
    realChannel = inboundFactory.newChannel(this.createRealPipeline(realConnections));
    config.setRealChannel(realChannel);

    opened = new AtomicBoolean(true);
    bindState = new AtomicReference<BindState>(BindState.UNBOUND);

    realConnections.add(realChannel);

    Channels.fireChannelOpen(this);
}
项目:hadoop    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:aliyun-oss-hadoop-fs    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:big-c    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:ikasoa    文件:NettyIkasoaFactory.java   
public NettyIkasoaFactory(NettyServerConfig nettyServerConfig, ChannelGroup channelGroup) {
    this.nettyServerConfig = nettyServerConfig;
    if (channelGroup == null)
        this.channelGroup = new DefaultChannelGroup();
    else
        this.channelGroup = channelGroup;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:hops    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:my-dev    文件:NettyServerUpstreamHandler.java   
public NettyServerUpstreamHandler(LoggerFactory loggerFactory, ChannelHandler channelHandler,
        ChannelGroup channelGroup) {
    this.logger = loggerFactory.create(this);
    this.ioErrorLogger = loggerFactory.create(this.getClass().getSimpleName() + ".IOError");
    this.channelHandler = channelHandler;
    this.allChannels = channelGroup;
}
项目:mandrel    文件:NettyServerTransport.java   
@Inject
public NettyServerTransport(final ThriftServerDef def, final NettyServerConfig nettyServerConfig, final ChannelGroup allChannels, final boolean local) {
    this.def = def;
    this.nettyServerConfig = nettyServerConfig;
    this.requestedPort = def.getServerPort();
    this.allChannels = allChannels;
    this.local = local;
    // connectionLimiter must be instantiated exactly once (and thus outside
    // the pipeline factory)
    final ConnectionLimiter connectionLimiter = new ConnectionLimiter(def.getMaxConnections());

    this.channelStatistics = new ChannelStatistics(allChannels);

    this.pipelineFactory = new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline cp = Channels.pipeline();
            TProtocolFactory inputProtocolFactory = def.getDuplexProtocolFactory().getInputProtocolFactory();
            NiftySecurityHandlers securityHandlers = def.getSecurityFactory().getSecurityHandlers(def, nettyServerConfig);
            cp.addLast("connectionContext", new ConnectionContextHandler());
            cp.addLast("connectionLimiter", connectionLimiter);
            cp.addLast(ChannelStatistics.NAME, channelStatistics);
            cp.addLast("encryptionHandler", securityHandlers.getEncryptionHandler());
            cp.addLast("frameCodec", def.getThriftFrameCodecFactory().create(def.getMaxFrameSize(), inputProtocolFactory));
            if (def.getClientIdleTimeout() != null) {
                // Add handlers to detect idle client connections and
                // disconnect them
                cp.addLast("idleTimeoutHandler", new IdleStateHandler(nettyServerConfig.getTimer(), def.getClientIdleTimeout().toMillis(),
                        NO_WRITER_IDLE_TIMEOUT, NO_ALL_IDLE_TIMEOUT, TimeUnit.MILLISECONDS));
                cp.addLast("idleDisconnectHandler", new IdleDisconnectHandler());
            }

            cp.addLast("authHandler", securityHandlers.getAuthenticationHandler());
            cp.addLast("dispatcher", new NiftyDispatcher(def, nettyServerConfig.getTimer()));
            cp.addLast("exceptionLogger", new NiftyExceptionLogger());
            return cp;
        }
    };
}
项目:CoVisor    文件:ClientChannelPipeline.java   
public ClientChannelPipeline(
        final OpenVirteXController openVirteXController,
        final ChannelGroup cg, final ThreadPoolExecutor pipelineExecutor,
        final ClientBootstrap bootstrap, final OVXSwitch sw) {
    super();
    this.ctrl = openVirteXController;
    this.pipelineExecutor = pipelineExecutor;
    this.timer = PhysicalNetwork.getTimer();
    this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0);
    this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30);
    this.bootstrap = bootstrap;
    this.sw = sw;
    this.cg = cg;
}
项目:CoVisor    文件:ReconnectHandler.java   
public ReconnectHandler(final OVXSwitch sw,
        final ClientBootstrap bootstrap, final Timer timer,
        final int maxBackOff, final ChannelGroup cg) {
    super();
    this.sw = sw;
    this.bootstrap = bootstrap;
    this.timer = timer;
    this.maxBackOff = maxBackOff;
    this.cg = cg;

}
项目:rest4j    文件:ChannelPoolLifecycle.java   
public ChannelPoolLifecycle(SocketAddress address, ClientBootstrap bootstrap, long getTimeout,
                            ScheduledExecutorService executor, ChannelGroup channelGroup)
{
  _remoteAddress = address;
  _rateLimiter = new RateLimiter(0, getTimeout / 2, Math.max(10, getTimeout / 32), executor);
  _bootstrap = bootstrap;
  _channelGroup = channelGroup;
}
项目:pinpoint    文件:HealthCheckManager.java   
public HealthCheckManager(Timer timer, long waitTimeMillis, ChannelGroup channelGroup) {
    Assert.requireNonNull(timer, "timer must not be null");
    Assert.isTrue(waitTimeMillis > 0, "waitTimeMillis is must greater than 0");
    Assert.requireNonNull(channelGroup, "channelGroup must not be null");

    this.timer = timer;
    this.waitTimeMillis = waitTimeMillis;

    this.channelGroup = channelGroup;
}
项目:pinpoint    文件:HealthCheckManagerTest.java   
@Test
public void legacyPingPacketTest() throws Exception {
    ChannelGroup channelGroup = new DefaultChannelGroup();

    HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup);
    healthCheckManager.start(1000);

    Channel mockChannel = createMockChannel(HealthCheckState.RECEIVED_LEGACY);
    channelGroup.add(mockChannel);
    try {
        verify(mockChannel, timeout(3000).atLeastOnce()).write(PingPacket.PING_PACKET);
    } finally {
        healthCheckManager.stop();
    }
}
项目:pinpoint    文件:HealthCheckManagerTest.java   
@Test
public void pingPacketTest() throws Exception {
    ChannelGroup channelGroup = new DefaultChannelGroup();

    HealthCheckManager healthCheckManager = new HealthCheckManager(timer, 3000, channelGroup);
    healthCheckManager.start(1000);

    Channel mockChannel = createMockChannel(HealthCheckState.RECEIVED);
    channelGroup.add(mockChannel);
    try {
        verify(mockChannel, timeout(3000).atLeastOnce()).write(PingSimplePacket.PING_PACKET);
    } finally {
        healthCheckManager.stop();
    }
}
项目:hadoop-on-lustre2    文件:RpcProgramPortmap.java   
RpcProgramPortmap(ChannelGroup allChannels) {
  this.allChannels = allChannels;
  PortmapMapping m = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_TCP, RpcProgram.RPCB_PORT);
  PortmapMapping m1 = new PortmapMapping(PROGRAM, VERSION,
      PortmapMapping.TRANSPORT_UDP, RpcProgram.RPCB_PORT);
  map.put(PortmapMapping.key(m), m);
  map.put(PortmapMapping.key(m1), m1);
}
项目:James    文件:AbstractConfigurableAsyncServer.java   
@Override
protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
    return new AbstractExecutorAwareChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group, enabledCipherSuites, getExecutionHandler()) {
        @Override
        protected SSLContext getSSLContext() {
            if (encryption == null) {
                return null;
            } else {
                return encryption.getContext();
            }
        }

        @Override
        protected boolean isSSLSocket() {
            return encryption != null && !encryption.isStartTLS();
        }


        @Override
        protected ChannelUpstreamHandler createHandler() {
            return AbstractConfigurableAsyncServer.this.createCoreHandler();

        }

        @Override
        protected ConnectionCountHandler getConnectionCountHandler() {
            return AbstractConfigurableAsyncServer.this.getConnectionCountHandler();
        }

    };
}
项目:usergrid    文件:WebSocketChannelHandler.java   
private ChannelGroup getChannelGroupWithDefault( String path ) {
    ChannelGroup group = subscribers.get( path );

    if ( group == null ) {
        group = subscribers.putIfAbsent( path, new DefaultChannelGroup() );
    }

    return group;
}
项目:usergrid    文件:WebSocketChannelHandler.java   
public void removeSubscription( String path, Channel channel ) {
    ChannelGroup group = subscribers.get( path );
    synchronized ( group ) {
        group.remove( channel );
        if ( group.isEmpty() ) {
            subscribers.remove( path, group );
        }
    }
}
项目:OpenVirteX    文件:ClientChannelPipeline.java   
public ClientChannelPipeline(
        final OpenVirteXController openVirteXController,
        final ChannelGroup cg, final ThreadPoolExecutor pipelineExecutor,
        final ClientBootstrap bootstrap, final OVXSwitch sw) {
    super();
    this.ctrl = openVirteXController;
    this.pipelineExecutor = pipelineExecutor;
    this.timer = PhysicalNetwork.getTimer();
    this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0);
    this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30);
    this.bootstrap = bootstrap;
    this.sw = sw;
    this.cg = cg;
}
项目:OpenVirteX    文件:ReconnectHandler.java   
public ReconnectHandler(final OVXSwitch sw,
        final ClientBootstrap bootstrap, final Timer timer,
        final int maxBackOff, final ChannelGroup cg) {
    super();
    this.sw = sw;
    this.bootstrap = bootstrap;
    this.timer = timer;
    this.maxBackOff = maxBackOff;
    this.cg = cg;

}
项目:httptunnel    文件:HttpTunnelServerChannel.java   
private ChannelPipeline createRealPipeline(ChannelGroup realConnections) {
    final ChannelPipelineFactory realPipelineFactory = new HttpTunnelAcceptedChannelPipelineFactory(this);

    final ChannelPipeline pipeline;
    try {
        pipeline = realPipelineFactory.getPipeline();
    }
    catch (Exception e) {
        throw new ChannelPipelineException("Failed to initialize a pipeline.", e);
    }

    pipeline.addFirst(HttpTunnelServerChannelHandler.NAME, new HttpTunnelServerChannelHandler(this, realPipelineFactory, realConnections));

    return pipeline;
}
项目:voyage    文件:NettyRpcServerHandler.java   
public NettyRpcServerHandler(ChannelGroup channelGroups) {
    this.channelGroups = channelGroups;
}
项目:voyage    文件:RpcServerBootstrap.java   
private void initHttpBootstrap(int myport) {
    logger.info("initHttpBootstrap...........");
    final ServerConfig serverConfig = new ServerConfig(myport);
    final ChannelGroup channelGroup = new DefaultChannelGroup(getClass().getName());
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            //建议用ThreadPoolExecutor代替
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool(), serverConfig.getThreadCnt()));
    //设置常见参数
    bootstrap.setOption("tcpNoDelay","true");//禁用nagle算法
    bootstrap.setOption("reuseAddress", "true");
    bootstrap.setOption("SO_RCVBUF",1024*128);
    bootstrap.setOption("SO_SNDBUF",1024*128);
    timer = new HashedWheelTimer();
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            int readTimeout = serverConfig.getReadTimeout();
            if (readTimeout > 0) {
                pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout, TimeUnit.MILLISECONDS));
            }
            pipeline.addLast("decoder", new RpcRequestDecode());
            pipeline.addLast("encoder", new RpcResponseEncode());
            pipeline.addLast("handler", new NettyRpcServerHandler(channelGroup));
            return pipeline;
        }
    });

    int port = serverConfig.getPort();
    if (!checkPortConfig(port)) {
        throw new IllegalStateException("port: " + port + " already in use!");
    }

    Channel channel = bootstrap.bind(new InetSocketAddress(port));
    channelGroup.add(channel);
    logger.info("voyage server started");

    waitForShutdownCommand();
    ChannelGroupFuture future = channelGroup.close();
    future.awaitUninterruptibly();
    bootstrap.releaseExternalResources();
    timer.stop();
    timer = null;

    logger.info("voyage server stoped");

}
项目:traccar-service    文件:TrackerServer.java   
public ChannelGroup getChannelGroup() {
    return allChannels;
}
项目:DigitalMediaServer    文件:RequestHandlerV2.java   
public RequestHandlerV2(ChannelGroup group) {
    this.group = group;
}
项目:DigitalMediaServer    文件:HttpServerPipelineFactory.java   
public HttpServerPipelineFactory(ChannelGroup group) {
    this.group = group;
}
项目:ikasoa    文件:NettyIkasoaFactory.java   
public ChannelGroup getChannelGroup() {
    return channelGroup;
}
项目:ikasoa    文件:NettyIkasoaFactory.java   
public void setChannelGroup(ChannelGroup channelGroup) {
    this.channelGroup = channelGroup;
}
项目:Android-Airplay-Server    文件:AirPlayServer.java   
public ChannelGroup getChannelGroup() {
    return channelGroup;
}
项目:navi    文件:NaviTCPHandler.java   
public NaviTCPHandler(ChannelGroup channelGroup) {
//      super(timer, channelIdleSecond, channelIdleSecond, channelIdleSecond);
        this.channelGroup = channelGroup;
        // session计数
        SessionIdCounter.getInstance().incAndGet();
    }
项目:navi    文件:NaviNettyHttpHandler.java   
public NaviNettyHttpHandler(ChannelGroup channelGroup) {
    super(channelGroup);
    listeners = new ArrayList<>();
}
项目:navi    文件:AbstractNaviNettyHttpHandler.java   
public AbstractNaviNettyHttpHandler(ChannelGroup channelGroup) {
    super(channelGroup);
}
项目:Camel    文件:NettyServerBootstrapConfiguration.java   
public ChannelGroup getChannelGroup() {
    return channelGroup;
}