當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultChannelGroup類代碼示例

本文整理匯總了Java中io.netty.channel.group.DefaultChannelGroup的典型用法代碼示例。如果您正苦於以下問題:Java DefaultChannelGroup類的具體用法?Java DefaultChannelGroup怎麽用?Java DefaultChannelGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultChannelGroup類屬於io.netty.channel.group包,在下文中一共展示了DefaultChannelGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeConnectionAsync

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
@Override
public CompletionStage<NodeConnectionReport> closeConnectionAsync(
    SocketAddress connection, CloseType type) {
  Optional<Channel> channel =
      this.clientChannelGroup
          .stream()
          .filter(c -> c.remoteAddress().equals(connection))
          .findFirst();

  if (channel.isPresent()) {
    ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    channelGroup.add(channel.get());
    ClusterConnectionReport clusterReport = new ClusterConnectionReport(getCluster().getId());
    NodeConnectionReport report =
        clusterReport.addNode(this, Collections.singletonList(connection), getAddress());

    return closeChannelGroup(channelGroup, type).thenApply(f -> report);
  } else {
    CompletableFuture<NodeConnectionReport> failedFuture = new CompletableFuture<>();
    failedFuture.completeExceptionally(new IllegalArgumentException("Not found"));
    return failedFuture;
  }
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:24,代碼來源:BoundNode.java

示例2: RedisClient

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
@Deprecated
public RedisClient(final Timer timer, ExecutorService executor, EventLoopGroup group, Class<? extends SocketChannel> socketChannelClass, String host, int port, 
                    int connectTimeout, int commandTimeout) {
    RedisClientConfig config = new RedisClientConfig();
    config.setTimer(timer).setExecutor(executor).setGroup(group).setSocketChannelClass(socketChannelClass)
    .setAddress(host, port).setConnectTimeout(connectTimeout).setCommandTimeout(commandTimeout);
    
    this.config = config;
    this.executor = config.getExecutor();
    this.timer = config.getTimer();
    
    addr = new InetSocketAddress(config.getAddress().getHost(), config.getAddress().getPort());
    
    channels = new DefaultChannelGroup(config.getGroup().next());
    bootstrap = createBootstrap(config, Type.PLAIN);
    pubSubBootstrap = createBootstrap(config, Type.PUBSUB);
    
    this.commandTimeout = config.getCommandTimeout();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:20,代碼來源:RedisClient.java

示例3: init

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public void init() throws SyncException {
    cg = new DefaultChannelGroup("Cluster Bootstrap", GlobalEventExecutor.INSTANCE);

    workerExecutor = new NioEventLoopGroup();
    timer = new HashedWheelTimer();
    
    bootstrap = new Bootstrap()
    .group(workerExecutor)
    .channel(NioSocketChannel.class)
    .option(ChannelOption.SO_REUSEADDR, true)
    .option(ChannelOption.SO_KEEPALIVE, true)
    .option(ChannelOption.TCP_NODELAY, true)
    .option(ChannelOption.SO_SNDBUF, RPCService.SEND_BUFFER_SIZE)
    .option(ChannelOption.SO_RCVBUF, RPCService.SEND_BUFFER_SIZE)
    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, RPCService.CONNECT_TIMEOUT);
    
    pipelineFactory = new BootstrapChannelInitializer(timer, this);
    bootstrap.handler(pipelineFactory);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:20,代碼來源:BootstrapClient.java

示例4: init

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public void init() throws SyncException {
    cg = new DefaultChannelGroup("Cluster Bootstrap", GlobalEventExecutor.INSTANCE);

    workerExecutor = new NioEventLoopGroup();
    timer = new HashedWheelTimer();

    bootstrap = new Bootstrap()
    .group(workerExecutor)
    .channel(NioSocketChannel.class)
    .option(ChannelOption.SO_REUSEADDR, true)
    .option(ChannelOption.SO_KEEPALIVE, true)
    .option(ChannelOption.TCP_NODELAY, true)
    .option(ChannelOption.SO_SNDBUF, RPCService.SEND_BUFFER_SIZE)
    .option(ChannelOption.SO_RCVBUF, RPCService.SEND_BUFFER_SIZE)
    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, RPCService.CONNECT_TIMEOUT);

    pipelineFactory = new BootstrapChannelInitializer(timer, this);
    bootstrap.handler(pipelineFactory);
}
 
開發者ID:zhenshengcai,項目名稱:floodlight-hardware,代碼行數:20,代碼來源:BootstrapClient.java

示例5: NettyIoAcceptor

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public NettyIoAcceptor(NettyIoServiceFactory factory, IoHandler handler) {
    this.factory = factory;
    this.handler = handler;
    channelGroup = new DefaultChannelGroup("sshd-acceptor-channels", GlobalEventExecutor.INSTANCE);;
    bootstrap.group(factory.eventLoopGroup)
            .channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_BACKLOG, 100)
            .handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    p.addLast(new NettyIoSession(NettyIoAcceptor.this, handler).adapter);
                }
            });
}
 
開發者ID:aeshell,項目名稱:aesh-readline,代碼行數:17,代碼來源:NettyIoAcceptor.java

示例6: ReplicatorService

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
/**
 * ReplicatorService creates and starts fibers; it must be stopped (or failed) in
 * order to dispose them.
 */
public ReplicatorService(EventLoopGroup bossGroup,
                         EventLoopGroup workerGroup,
                         long nodeId,
                         int port,
                         ModuleInformationProvider moduleInformationProvider,
                         FiberSupplier fiberSupplier,
                         QuorumFileReaderWriter quorumFileReaderWriter) {
  this.bossGroup = bossGroup;
  this.workerGroup = workerGroup;
  this.nodeId = nodeId;
  this.port = port;
  this.moduleInformationProvider = moduleInformationProvider;
  this.fiberSupplier = fiberSupplier;

  this.allChannels = new DefaultChannelGroup(workerGroup.next());
  this.persister = new Persister(quorumFileReaderWriter);
}
 
開發者ID:cloud-software-foundation,項目名稱:c5-replicator,代碼行數:22,代碼來源:ReplicatorService.java

示例7: NettyIoAcceptor

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public NettyIoAcceptor(NettyIoServiceFactory factory, IoHandler handler) {
  this.factory = factory;
  this.handler = handler;
  channelGroup = new DefaultChannelGroup("sshd-acceptor-channels", GlobalEventExecutor.INSTANCE);;
  bootstrap.group(factory.eventLoopGroup)
      .channel(NioServerSocketChannel.class)
      .option(ChannelOption.SO_BACKLOG, 100)
      .handler(new LoggingHandler(LogLevel.INFO))
      .childHandler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
          ChannelPipeline p = ch.pipeline();
          p.addLast(new NettyIoSession(NettyIoAcceptor.this, handler).adapter);
        }
      });
}
 
開發者ID:termd,項目名稱:termd,代碼行數:17,代碼來源:NettyIoAcceptor.java

示例8: AbstractRedisClient

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
/**
 * Create a new instance with client resources.
 *
 * @param clientResources the client resources. If {@literal null}, the client will create a new dedicated instance of
 *        client resources and keep track of them.
 */
protected AbstractRedisClient(ClientResources clientResources) {

    if (clientResources == null) {
        sharedResources = false;
        this.clientResources = DefaultClientResources.create();
    } else {
        sharedResources = true;
        this.clientResources = clientResources;
    }

    unit = TimeUnit.SECONDS;

    genericWorkerPool = this.clientResources.eventExecutorGroup();
    channels = new DefaultChannelGroup(genericWorkerPool.next());
    timer = (HashedWheelTimer) this.clientResources.timer();
}
 
開發者ID:lettuce-io,項目名稱:lettuce-core,代碼行數:23,代碼來源:AbstractRedisClient.java

示例9: RpcServer

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
<T extends ServerSocketChannel> RpcServer(EventLoopGroup eventLoopGroup, EventExecutorGroup eventExecutor, Class<T> channel, SocketAddress address) {
    this.address = address;
    this.allChannels = new DefaultChannelGroup(eventLoopGroup.next());
    this.handler = new ServerHandler(allChannels);
    this.bootstrap = new ServerBootstrap();
    bootstrap.channel(channel);
    bootstrap.childHandler(new ServerInitializer(eventExecutor, handler));
    bootstrap.group(eventLoopGroup);
    bootstrap.option(ChannelOption.TCP_NODELAY, true);
}
 
開發者ID:lemonJun,項目名稱:TakinRPC,代碼行數:11,代碼來源:RpcServer.java

示例10: WebSocketServerThread

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public WebSocketServerThread(Settings settings) {
    this.PORT = settings.httpPort;
    this.SSL = false; // TODO: support ssl?

    this.blockBridge = null;
    this.playersBridge = null;
    this.webPlayerBridge = null;

    this.allUsersGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);

    this.settings = settings;
}
 
開發者ID:satoshinm,項目名稱:WebSandboxMC,代碼行數:13,代碼來源:WebSocketServerThread.java

示例11: WebImageViewer

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public WebImageViewer(InetSocketAddress address) {
  this.address = address;
  this.bossGroup = new NioEventLoopGroup();
  this.workerGroup = new NioEventLoopGroup();
  this.allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
  this.bootstrap = new ServerBootstrap()
    .group(bossGroup, workerGroup)
    .channel(NioServerSocketChannel.class);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:WebImageViewer.java

示例12: startUp

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
@Override
protected void startUp() throws Exception {
  channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
  EventLoopGroup bossGroup = new NioEventLoopGroup(NUM_BOSS_THREADS,
                                                   new ThreadFactoryBuilder()
                                                     .setDaemon(true).setNameFormat("boss-thread").build());
  EventLoopGroup workerGroup = new NioEventLoopGroup(NUM_WORKER_THREADS,
                                                     new ThreadFactoryBuilder()
                                                       .setDaemon(true).setNameFormat("worker-thread#%d").build());

  bootstrap = new ServerBootstrap()
    .group(bossGroup, workerGroup)
    .channel(NioServerSocketChannel.class)
    .childHandler(new ChannelInitializer<SocketChannel>() {
      @Override
      protected void initChannel(SocketChannel ch) throws Exception {
        channelGroup.add(ch);
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast("codec", new HttpServerCodec());
        pipeline.addLast("compressor", new HttpContentCompressor());
        pipeline.addLast("aggregator", new HttpObjectAggregator(MAX_INPUT_SIZE));
        pipeline.addLast("handler", new ReportHandler());
      }
    });

  Channel serverChannel = bootstrap.bind(new InetSocketAddress(host, 0)).sync().channel();
  channelGroup.add(serverChannel);

  bindAddress = (InetSocketAddress) serverChannel.localAddress();
  url = URI.create(String.format("http://%s:%d", host, bindAddress.getPort())).toURL();

  LOG.info("Tracker service started at {}", url);
}
 
開發者ID:apache,項目名稱:twill,代碼行數:34,代碼來源:TrackerService.java

示例13: configure

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
/**
 * {@inheritDoc}
 * @see com.heliosapm.streams.tracing.AbstractMetricWriter#configure(java.util.Properties)
 */
@Override
public void configure(final Properties config) {	
	super.configure(config);
	remotes = ConfigurationHelper.getArraySystemThenEnvProperty(CONFIG_REMOTE_URIS, DEFAULT_REMOTE_URIS, config);
	Collections.addAll(remoteUris,  remotes);
	channelGroupThreads = ConfigurationHelper.getIntSystemThenEnvProperty(CONFIG_EXEC_THREADS, DEFAULT_EXEC_THREADS, config);
	this.config.put("channelGroupThreads", channelGroupThreads);
	eventLoopThreads = ConfigurationHelper.getIntSystemThenEnvProperty(CONFIG_ELOOP_THREADS, DEFAULT_ELOOP_THREADS, config);
	this.config.put("eventLoopThreads", eventLoopThreads);
	eventExecutor = new UnorderedThreadPoolEventExecutor(channelGroupThreads, groupThreadFactory, this);		
	channels = new DefaultChannelGroup(getClass().getSimpleName() + "Channels", eventExecutor);
	group = new NioEventLoopGroup(eventLoopThreads, eventLoopThreadFactory);
	bootstrap			
		.group(group)
		.channel(channelType)
		.handler(getChannelInitializer())
	;
	bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000);  // FIXME: config
	bootstrap.option(ChannelOption.ALLOCATOR, BufferManager.getInstance());
	this.config.put("connectTimeout", 5000);
	
			
		
	// FIXME: Tweaks for channel configuration
		
}
 
開發者ID:nickman,項目名稱:HeliosStreams,代碼行數:31,代碼來源:NetWriter.java

示例14: startServer

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
/**
 * Scotty, start me up!
 * Initializes the netty data pipeline and starts the IO server
 *
 * @throws InterruptedException  if interrupted while waiting for the startup
 * @throws IllegalStateException is the Server is already running
 */
private void startServer() throws InterruptedException {
    if (isChannelOpen()) {
        throw new IllegalStateException("Server already running");
    }

    //Setup the Executor and Connection Pool
    final ExecutionServiceComponent eventLoop = requireComponent(ExecutionServiceComponent.KEY);
    connections = new DefaultChannelGroup(eventLoop.next());

    ServerBootstrap b = new ServerBootstrap()
            .group(eventLoop)
            .channel(NioServerSocketChannel.class)
            .childHandler(getHandshakeHandler())
            .childOption(ChannelOption.SO_KEEPALIVE, true);

    //Bind to ports and wait for the start of the server
    final int localPort = getLocalPort();
    if (localPort < 0 || localPort > 65535) {
        throw new StartupException("Illegal localPort " + localPort);
    }
    localChannel = b.bind(localPort).sync();

    final int publicPort = getPublicPort();
    if (publicPort >= 0 && publicPort <= 65535 && localPort != publicPort) {
        publicChannel = b.bind(publicPort).sync();
    }
    Log.i(getClass().getSimpleName(), "Server bound to port " + localChannel.channel() + (publicChannel != null ? " and " + publicChannel.channel() : ""));
}
 
開發者ID:SecureSmartHome,項目名稱:SecureSmartHome,代碼行數:36,代碼來源:Server.java

示例15: init

import io.netty.channel.group.DefaultChannelGroup; //導入依賴的package包/類
public void init(CamelContext camelContext, NettyServerBootstrapConfiguration configuration, ChannelInitializer<Channel> pipelineFactory) {
    this.camelContext = camelContext;
    this.configuration = configuration;
    this.pipelineFactory = pipelineFactory;

    this.allChannels = configuration.getChannelGroup() != null
        ? configuration.getChannelGroup()
        : new DefaultChannelGroup(SingleTCPNettyServerBootstrapFactory.class.getName(), ImmediateEventExecutor.INSTANCE);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:10,代碼來源:SingleTCPNettyServerBootstrapFactory.java


注:本文中的io.netty.channel.group.DefaultChannelGroup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。