当前位置: 首页>>代码示例>>Java>>正文


Java ServerSocketChannelFactory类代码示例

本文整理汇总了Java中org.jboss.netty.channel.socket.ServerSocketChannelFactory的典型用法代码示例。如果您正苦于以下问题:Java ServerSocketChannelFactory类的具体用法?Java ServerSocketChannelFactory怎么用?Java ServerSocketChannelFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerSocketChannelFactory类属于org.jboss.netty.channel.socket包,在下文中一共展示了ServerSocketChannelFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createServerChannelFactory

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
public static synchronized ServerSocketChannelFactory createServerChannelFactory(String name, int workerNum) {
  name = name + "-" + serverCount.incrementAndGet();
  if(LOG.isInfoEnabled()){
    LOG.info("Create " + name + " ServerSocketChannelFactory. Worker:" + workerNum);
  }
  ThreadFactoryBuilder builder = new ThreadFactoryBuilder();
  ThreadFactory bossFactory = builder.setNameFormat(name + " Server Boss #%d").build();
  ThreadFactory workerFactory = builder.setNameFormat(name + " Server Worker #%d").build();

  NioServerBossPool bossPool =
      new NioServerBossPool(Executors.newCachedThreadPool(bossFactory), 1, ThreadNameDeterminer.CURRENT);
  NioWorkerPool workerPool =
      new NioWorkerPool(Executors.newCachedThreadPool(workerFactory), workerNum, ThreadNameDeterminer.CURRENT);

  return new NioServerSocketChannelFactory(bossPool, workerPool);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:17,代码来源:RpcChannelFactory.java

示例2: HttpTunnelServerChannel

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
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);
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:18,代码来源:HttpTunnelServerChannel.java

示例3: HttpTunnelSoakTester

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
public HttpTunnelSoakTester() {
	scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
	executor = Executors.newCachedThreadPool();
	ServerSocketChannelFactory serverChannelFactory = new NioServerSocketChannelFactory(
			executor, executor);
	HttpTunnelServerChannelFactory serverTunnelFactory = new HttpTunnelServerChannelFactory(
			serverChannelFactory);

	serverBootstrap = new ServerBootstrap(serverTunnelFactory);
	serverBootstrap.setPipelineFactory(createServerPipelineFactory());

	ClientSocketChannelFactory clientChannelFactory = new NioClientSocketChannelFactory(
			executor, executor);
	HttpTunnelClientChannelFactory clientTunnelFactory = new HttpTunnelClientChannelFactory(
			clientChannelFactory);

	clientBootstrap = new ClientBootstrap(clientTunnelFactory);
	clientBootstrap.setPipelineFactory(createClientPipelineFactory());
	configureProxy();

	channels = new DefaultChannelGroup();
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:23,代码来源:HttpTunnelSoakTester.java

示例4: create

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
/**
 * create server<br>
 * <br>
 * @param monitoredServers
 * @param serverSocketChannelFactory
 * @return
 */
public static MonitoringServer create(Set<Server> monitoredServers, ServerSocketChannelFactory serverSocketChannelFactory) {
	synchronized (LOCK) {
		if (monitoringServer != null) {
			return monitoringServer;
		}
		
		// monitoring router
		Router router = createMonitoringRouter();
		
		// create server
		monitoringServer = new MonitoringServer();
		
		// set server basic info
		monitoringServer.setBasicInfos(SERVER_NAME, 10081, router);
		
		// set monitored server
		setMonitoredServer(monitoredServers, monitoringServer);
		
		// create injector
		monitoringServer.injector = Guice.createInjector(Stage.PRODUCTION, new MonitoringServerModule(monitoringServer));
		
		// create and set serverBootstrap
		monitoringServer.serverBootstrap = new ServerBootstrap(serverSocketChannelFactory);
		monitoringServer.serverBootstrap.setPipelineFactory(monitoringServer.injector.getInstance(ChannelPipelineFactory.class));
		monitoringServer.setNettyOptions();
		logger.info("{}-serverBootstrap option is {}", monitoringServer.serverName, monitoringServer.serverBootstrap.getOptions());
		
		return monitoringServer;
	}
}
 
开发者ID:be-hase,项目名称:honoumi,代码行数:38,代码来源:MonitoringServer.java

示例5: create

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
/**
 * create server.<br>
 * <br>
 * @param serverName
 * @param router
 * @param modules
 * @param serverSocketChannelFactory
 * @return
 */
public static Server create(String serverName, Router router, List<AbstractModule> modules,
		ServerSocketChannelFactory serverSocketChannelFactory) {
	checkArgument(StringUtils.isNotBlank(serverName), "serverName is blank.");
	checkArgument(!(serverName.equals(MonitoringServer.SERVER_NAME)), "monitoring does not allow to use as serverName.");
	checkArgument(serverName.matches(SERVER_NAME_REGEX), "serverName allows only " + SERVER_NAME_REGEX);
	checkArgument(router != null, "router is null");
	
	// create server
	Server server = new Server();

	// set server basic info
	server.setBasicInfos(serverName, 10080, router);
	
	// create injector
	List<AbstractModule> modulesForCreate = Lists.newArrayList();
	modulesForCreate.add(new ServerModule(server));
	if (modules != null) {
		for (AbstractModule item: modules) {
			logger.info("{} regists guice module... {}", server.serverName, item.getClass().getSimpleName());
		}
		modulesForCreate.addAll(modules);
	}
	server.injector = Guice.createInjector(Stage.PRODUCTION, modulesForCreate);

	// create and set serverBootstrap
	server.serverBootstrap = new ServerBootstrap(serverSocketChannelFactory);
	server.serverBootstrap.setPipelineFactory(server.injector.getInstance(ChannelPipelineFactory.class));
	server.setNettyOptions();
	logger.info("{}-serverBootstrap option is {}", server.serverName, server.serverBootstrap.getOptions());
	
	return server;
}
 
开发者ID:be-hase,项目名称:honoumi,代码行数:42,代码来源:Server.java

示例6: initialize

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
/**
 * Initialize the local Raft server.
 * <p/>
 * Sets up the service implementation classes, creates database
 * tables and starts any thread pools necessary. Following this
 * call all service classes are <strong>fully initialized</strong>.
 * Even though various threads are started they <strong>will not</strong>
 * use or interact with the service implementation classes. Callers
 * still have exclusive access to the system.
 * <p/>
 * This method should <strong>only</strong> be called once before {@link RaftAgent#start()}.
 *
 * @throws StorageException if the persistence components cannot be initialized
 * @throws IllegalStateException if this method is called multiple times
 */
public synchronized void initialize() throws StorageException {
    checkState(!running);
    checkState(!initialized);
    checkState(setupConversion);

    // start up the snapshots subsystem
    snapshotStore.initialize();
    // check that the snapshot metadata and the filesystem agree
    // FIXME (AG): this _may_ be expensive, especially if the user never bothers to clean out snapshots!
    // FIXME (AG): warning, warning - this is upfront work - probably a very, very bad idea
    snapshotStore.reconcileSnapshots();

    // initialize the log and store
    jdbcLog.initialize();
    jdbcStore.initialize();

    // initialize the various thread pools
    nonIoExecutorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
    ioExecutorService = Executors.newCachedThreadPool();
    serverBossPool = new NioServerBossPool(ioExecutorService, 1);
    clientBossPool = new NioClientBossPool(ioExecutorService, 1);
    workerPool = new NioWorkerPool(ioExecutorService, 3);

    // TODO (AG): avoid creating threads in the initialize() method
    // initialize the networking subsystem
    sharedWorkerPool = new ShareableWorkerPool<NioWorker>(workerPool);
    ServerSocketChannelFactory serverChannelFactory = new NioServerSocketChannelFactory(serverBossPool, sharedWorkerPool);
    ClientSocketChannelFactory clientChannelFactory = new NioClientSocketChannelFactory(clientBossPool, sharedWorkerPool);
    raftNetworkClient.initialize(nonIoExecutorService, serverChannelFactory, clientChannelFactory, raftAlgorithm);

    raftAlgorithm.initialize();

    initialized = true;
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:50,代码来源:RaftAgent.java

示例7: setUp

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	realChannelFactory = mockContext.mock(ServerSocketChannelFactory.class);
	factory = new HttpTunnelServerChannelFactory(realChannelFactory);
	ChannelPipeline pipeline = Channels.pipeline(new SimpleChannelHandler());
	realChannel = new FakeServerSocketChannel(factory, pipeline,
			new FakeChannelSink());
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:9,代码来源:HttpTunnelServerChannelFactoryTest.java

示例8: createServerChannel

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
public static Channel createServerChannel(InetSocketAddress addr, ChannelPipelineFactory pipelineFactory) {
	// TCP socket factory
	ServerSocketChannelFactory socketFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());

	// HTTP socket factory
	socketFactory = new HttpTunnelServerChannelFactory(socketFactory);

	final ServerBootstrap bootstrap = new ServerBootstrap(socketFactory);
	bootstrap.setPipelineFactory(pipelineFactory);

	bootstrap.setOption("child.tcpNoDelay", true);
	bootstrap.setOption("reuseAddress", true);

	return bootstrap.bind(addr);
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:16,代码来源:NettyTestUtils.java

示例9: createSocketChannelFactory

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
@Override
protected ServerSocketChannelFactory createSocketChannelFactory() {
    return new OioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor());
}
 
开发者ID:twachan,项目名称:James,代码行数:5,代码来源:OioPOP3Server.java

示例10: HttpTunnelServerChannelFactory

import org.jboss.netty.channel.socket.ServerSocketChannelFactory; //导入依赖的package包/类
public HttpTunnelServerChannelFactory(ServerSocketChannelFactory factory) {
	this.factory = factory;

	realConnections = new DefaultChannelGroup();
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:6,代码来源:HttpTunnelServerChannelFactory.java


注:本文中的org.jboss.netty.channel.socket.ServerSocketChannelFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。