Java 类com.facebook.swift.service.ThriftServerConfig 实例源码

项目:hadoop-EAR    文件:TClientProxyProtocolServer.java   
/** Translates Hadoop's Configuration into Thrift's server config */
private static ThriftServerConfig getServerConfig(Configuration conf) {
  ThriftServerConfig serverConfig = new ThriftServerConfig();
  serverConfig.setPort(conf.getInt(StorageServiceConfigKeys.PROXY_THRIFT_PORT_KEY,
      StorageServiceConfigKeys.PROXY_THRIFT_PORT_DEFAULT));
  return serverConfig;
}
项目:zipkin    文件:ScribeCollector.java   
ScribeCollector(Builder builder) {
  ScribeSpanConsumer scribe = new ScribeSpanConsumer(builder);
  ThriftServiceProcessor processor =
      new ThriftServiceProcessor(new ThriftCodecManager(), emptyList(), scribe);
  server = new ThriftServer(processor, new ThriftServerConfig().setPort(builder.port));
}
项目:mandrel    文件:ThriftServer.java   
public ThriftServer(NiftyProcessor processor) {
    this(processor, new ThriftServerConfig());
}
项目:mandrel    文件:ThriftServer.java   
public ThriftServer(NiftyProcessor processor, ThriftServerConfig config) {
    this(processor, config, new NiftyTimer("thrift"));
}
项目:mandrel    文件:ThriftServer.java   
public ThriftServer(NiftyProcessor processor, ThriftServerConfig config, Timer timer) {
    this(processor, config, timer, DEFAULT_FRAME_CODEC_FACTORIES, DEFAULT_PROTOCOL_FACTORIES, DEFAULT_WORKER_EXECUTORS, DEFAULT_SECURITY_FACTORY, false);
}
项目:mandrel    文件:ThriftServer.java   
public ThriftServer(final NiftyProcessor processor, ThriftServerConfig config, @ThriftServerTimer Timer timer,
        Map<String, ThriftFrameCodecFactory> availableFrameCodecFactories, Map<String, TDuplexProtocolFactory> availableProtocolFactories,
        Map<String, ExecutorService> availableWorkerExecutors, NiftySecurityFactory securityFactory, boolean local) {
    this(processor, config, timer, availableFrameCodecFactories, availableProtocolFactories, availableWorkerExecutors, new NiftySecurityFactoryHolder(
            securityFactory), local);
}
项目:mandrel    文件:ThriftServer.java   
@Inject
public ThriftServer(final NiftyProcessor processor, ThriftServerConfig config, @ThriftServerTimer Timer timer,
        Map<String, ThriftFrameCodecFactory> availableFrameCodecFactories, Map<String, TDuplexProtocolFactory> availableProtocolFactories,
        @ThriftServerWorkerExecutor Map<String, ExecutorService> availableWorkerExecutors, NiftySecurityFactoryHolder securityFactoryHolder, boolean local) {
    checkNotNull(availableFrameCodecFactories, "availableFrameCodecFactories cannot be null");
    checkNotNull(availableProtocolFactories, "availableProtocolFactories cannot be null");

    NiftyProcessorFactory processorFactory = new NiftyProcessorFactory() {
        @Override
        public NiftyProcessor getProcessor(TTransport transport) {
            return processor;
        }
    };

    String transportName = config.getTransportName();
    String protocolName = config.getProtocolName();

    checkState(availableFrameCodecFactories.containsKey(transportName), "No available server transport named " + transportName);
    checkState(availableProtocolFactories.containsKey(protocolName), "No available server protocol named " + protocolName);

    workerExecutor = config.getOrBuildWorkerExecutor(availableWorkerExecutors);
    if (local) {
        log.warn("Using local server");
        configuredPort = 0;
        ioThreads = 0;
        ioExecutor = null;
        acceptorThreads = 0;
        acceptorExecutor = null;
        serverChannelFactory = new DefaultLocalServerChannelFactory();
    } else {
        configuredPort = config.getPort();

        acceptorExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-acceptor-%s").build());
        acceptorThreads = config.getAcceptorThreadCount();
        ioExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-io-%s").build());
        ioThreads = config.getIoThreadCount();

        serverChannelFactory = new NioServerSocketChannelFactory(new NioServerBossPool(acceptorExecutor, acceptorThreads, ThreadNameDeterminer.CURRENT),
                new NioWorkerPool(ioExecutor, ioThreads, ThreadNameDeterminer.CURRENT));
    }

    ThriftServerDef thriftServerDef = ThriftServerDef.newBuilder().name("thrift").listen(configuredPort)
            .limitFrameSizeTo((int) config.getMaxFrameSize().toBytes()).clientIdleTimeout(config.getIdleConnectionTimeout())
            .withProcessorFactory(processorFactory).limitConnectionsTo(config.getConnectionLimit())
            .limitQueuedResponsesPerConnection(config.getMaxQueuedResponsesPerConnection())
            .thriftFrameCodecFactory(availableFrameCodecFactories.get(transportName)).protocol(availableProtocolFactories.get(protocolName))
            .withSecurityFactory(securityFactoryHolder.niftySecurityFactory).using(workerExecutor).taskTimeout(config.getTaskExpirationTimeout()).build();

    NettyServerConfigBuilder nettyServerConfigBuilder = NettyServerConfig.newBuilder();

    nettyServerConfigBuilder.getServerSocketChannelConfig().setBacklog(config.getAcceptBacklog());
    nettyServerConfigBuilder.setBossThreadCount(config.getAcceptorThreadCount());
    nettyServerConfigBuilder.setWorkerThreadCount(config.getIoThreadCount());
    nettyServerConfigBuilder.setTimer(timer);

    NettyServerConfig nettyServerConfig = nettyServerConfigBuilder.build();

    transport = new NettyServerTransport(thriftServerDef, nettyServerConfig, allChannels, local);
}