Tabnine Logo
ThriftServerConfig.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.facebook.swift.service.ThriftServerConfig
constructor

Best Java code snippets using com.facebook.swift.service.ThriftServerConfig.<init> (Showing top 18 results out of 315)

origin: com.facebook.swift/swift-service

public SuiteBase(
    Class<? extends ServiceInterface> handlerClass,
    Class<? extends ClientInterface> clientClass,
    ThriftServerConfig serverConfig) {
  this(handlerClass, clientClass, serverConfig, ImmutableList.<ThriftEventHandler>of());
}
origin: io.zipkin.zipkin2/zipkin-collector-scribe

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));
}
origin: io.zipkin.java/zipkin-transport-scribe

ScribeCollector(Builder builder, Lazy<AsyncSpanConsumer> consumer) {
 ScribeSpanConsumer scribe = new ScribeSpanConsumer(builder.category, consumer, builder.metrics);
 ThriftServiceProcessor processor =
   new ThriftServiceProcessor(new ThriftCodecManager(), emptyList(), scribe);
 server = new ThriftServer(processor, new ThriftServerConfig().setPort(builder.port)).start();
}
origin: com.facebook.swift/swift-service

public ExceptionTest() {
  super(ExceptionServiceHandler.class,
     ExceptionServiceClient.class,
     new ThriftServerConfig(),
     ImmutableList.<ThriftEventHandler>of(new ExceptionThrowingEventHandler()));
}
origin: com.facebook.swift/swift-service

protected ThriftServer createServerFromHandler(Object handler)
    throws InstantiationException, IllegalAccessException
{
  return createServerFromHandler(new ThriftServerConfig(), handler);
}
origin: com.facebook.swift/swift-service

public TestThriftClientManager()
{
  super(DelayedMapSyncHandler.class, DelayedMap.Client.class, new ThriftServerConfig().setBindAddress(LOCALHOST_IP_ADDRESS));
}
origin: org.apache.giraph/giraph-core

/**
 * Create and start the Thrift server.
 *
 * @param conf Giraph conf to set the host and ports for.
 * @param services Services to start
 */
public ClientThriftServer(GiraphConfiguration conf,
             List<?> services) {
 checkNotNull(conf, "conf is null");
 checkNotNull(services, "services is null");
 ThriftServiceProcessor processor =
   new ThriftServiceProcessor(new ThriftCodecManager(),
                 new ArrayList<ThriftEventHandler>(),
                 services);
 clientThriftServer =
   new ThriftServer(processor, new ThriftServerConfig());
 clientThriftServer.start();
 try {
  CLIENT_THRIFT_SERVER_HOST.set(
    conf,
    conf.getLocalHostname());
 } catch (UnknownHostException e) {
  throw new IllegalStateException("Unable to get host information", e);
 }
 CLIENT_THRIFT_SERVER_PORT.set(conf, clientThriftServer.getPort());
}
origin: melin/dubbo-rpc-swift

@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url)
    throws RpcException {
  TProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), impl);
  final ThriftServer server = new ThriftServer(processor, new ThriftServerConfig().setPort(url.getPort()));
  server.start();
  return new Runnable() {
    public void run() {
      try {
        server.close();
      } catch (Throwable e) {
        logger.warn(e.getMessage(), e);
      }
    }
  };
}
origin: com.facebook.swift/swift-service

  @Override
  protected void configure()
  {
    bind(ThriftServerConfig.class).toInstance(
        new ThriftServerConfig().setWorkerExecutor(myExecutor)
    );
  }
}
origin: com.facebook.swift/swift-service

protected ThriftServer createTargetServer(int numThreads)
    throws TException, InstantiationException, IllegalAccessException
{
  DelayedMapSyncHandler handler = new DelayedMapSyncHandler();
  return createServerFromHandler(new ThriftServerConfig().setWorkerThreads(numThreads), handler);
}
origin: com.facebook.swift/swift-service

protected ThriftServer createAsyncServer(int numThreads, ThriftClientManager clientManager, ThriftServer targetServer) throws Exception
{
  DelayedMapAsyncProxyHandler handler = new DelayedMapAsyncProxyHandler(clientManager, targetServer);
  return createServerFromHandler(new ThriftServerConfig().setWorkerThreads(numThreads), handler);
}
origin: com.facebook.swift/swift-service

/**
 * Creates a {@link com.facebook.swift.service.guice.ThriftServerModule} with the binding
 * for {@link com.facebook.swift.service.ThriftServerConfig} overridden to specify a specific
 * instance of {@link java.util.concurrent.ExecutorService} for the worker executor.
 */
private Module overrideThriftServerModuleWithWorkerExecutorInstance(final ExecutorService myExecutor)
{
  return Modules.override(new ThriftServerModule()).with(
      new AbstractModule()
      {
        @Override
        protected void configure()
        {
          bind(ThriftServerConfig.class).toInstance(
              new ThriftServerConfig().setWorkerExecutor(myExecutor)
          );
        }
      }
  );
}
origin: com.facebook.swift/swift-service

private void testProcessor(NiftyProcessor processor)
    throws Exception
{
  DummyTransportAttachObserver dummyTransportAttachObserver = new DummyTransportAttachObserver();
  try (ThriftServer server = new ThriftServer(
      processor,
      new ThriftServerConfig(),
      new NiftyTimer("timer"),
      ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES,
      ThriftServer.DEFAULT_PROTOCOL_FACTORIES,
      ThriftServer.DEFAULT_WORKER_EXECUTORS,
      ThriftServer.DEFAULT_SECURITY_FACTORY,
      ThriftServer.DEFAULT_SSL_SERVER_CONFIGURATION,
      new ThriftServer.TransportAttachObserverHolder(dummyTransportAttachObserver)).start()) {
    assertTrue(dummyTransportAttachObserver.getState());
    server.close();
    assertFalse(dummyTransportAttachObserver.getState());
  }
}
origin: com.facebook.swift/swift-service

private List<LogEntry> testProcessor(NiftyProcessor processor, boolean plaintext)
    throws Exception
{
  ImmutableList<LogEntry> messages = ImmutableList.of(
      new LogEntry("hello", "world"),
      new LogEntry("bye", "world")
  );
  SslServerConfiguration sslConfiguration = OpenSslServerConfiguration.newBuilder()
      .certFile(new File(getClass().getResource("/rsa.crt").getFile()))
      .keyFile(new File(getClass().getResource("/rsa.key").getFile()))
      .allowPlaintext(plaintext)
      .build();
  try (ThriftServer server = new ThriftServer(
      processor,
      new ThriftServerConfig(),
      new NiftyTimer("timer"),
      ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES,
      ThriftServer.DEFAULT_PROTOCOL_FACTORIES,
      ThriftServer.DEFAULT_WORKER_EXECUTORS,
      ThriftServer.DEFAULT_SECURITY_FACTORY,
      new ThriftServer.SslServerConfigurationHolder(sslConfiguration),
      ThriftServer.DEFAULT_TRANSPORT_ATTACH_OBSERVER).start()) {
    assertEquals(logThrift(server.getPort(), messages), ResultCode.OK);
    assertEquals(logSwift(server.getPort(), toSwiftLogEntry(messages)), com.facebook.swift.service.ResultCode.OK);
  }
  return messages;
}
origin: com.facebook.swift/swift-service

  @Test
  public void testGenericProcessor()
      throws ExecutionException, InterruptedException
  {
    ThriftCodecManager codecManager = new ThriftCodecManager();
    ThriftServiceProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.<ThriftEventHandler>of(), new GenericService());

    try (ThriftServer server = new ThriftServer(processor, new ThriftServerConfig()).start();
       ThriftClientManager clientManager = new ThriftClientManager(codecManager)) {
      ThriftClient<GenericInterface.Client> clientOpener = new ThriftClient<>(clientManager, GenericInterface.Client.class);
      try (GenericInterface.Client client = clientOpener.open(new FramedClientConnector(HostAndPort.fromParts("localhost", server.getPort()))).get()) {
        GenericStruct<String> original = new GenericStruct<>();
        original.genericField = "original.genericField";
        GenericStruct<String> copy = client.echo(original);
        assertEquals(original, copy);
      }
    }
  }
}
origin: com.facebook.swift/swift-service

    .build();
ThriftServerConfig expected = new ThriftServerConfig()
    .setPort(12345)
    .setMaxFrameSize(DataSize.valueOf("333kB"))
origin: com.gitee.l0km/facelog-service

/**
 * 从配置文件中读取参数创建{@link ThriftServerConfig}实例
 * @return
 */
public static ThriftServerConfig makeThriftServerConfig(){
  ThriftServerConfig thriftServerConfig = new ThriftServerConfig();
  CombinedConfiguration config = GlobalConfig.getConfig();
  int intValue ;
  thriftServerConfig.setPort(config.getInt(SERVER_PORT,DEFAULT_PORT));
  if((intValue  = config.getInt(SERVER_CONNECTION_LIMIT,0)) >0){
    thriftServerConfig.setConnectionLimit(intValue);
  }
  if((intValue = config.getInt(SERVER_IDLE_CONNECTION_TIMEMOUT,0))>0){
    Duration timeout = new Duration(intValue,TimeUnit.SECONDS);
    thriftServerConfig.setIdleConnectionTimeout(timeout);
  }
  if((intValue = config.getInt(SERVER_WORKER_THREAD_COUNT,0))>0){
    thriftServerConfig.setWorkerThreads(intValue);
  }
  return thriftServerConfig;
}
/**
origin: com.gitee.l0km/faceapi-thriftservice

public static void main(String ...args){
  serviceConfig.parseCommandLine(args);
  // 设置slf4j记录日志,否则会有警告
  InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
  ThriftServerConfig config = new ThriftServerConfig()
      .setPort(serviceConfig.getServicePort())
      .setWorkerThreads(serviceConfig.getWorkThreads())
      .setConnectionLimit(serviceConfig.getConnectionLimit())
      .setIdleConnectionTimeout(new Duration(serviceConfig.getIdleConnectionTimeout(),TimeUnit.SECONDS));
  FaceApi faceapi = serviceConfig.getFaceapi();
  ThriftServerService service = ThriftServerService.bulider()
      .withServices(new FaceApiThriftDecorator(faceapi))
      .setThriftServerConfig(config)
      .build();
  logger.info("FaceApi instance:{}",faceapi);
  service.startAsync();
}
 
com.facebook.swift.serviceThriftServerConfig<init>

Popular methods of ThriftServerConfig

  • setPort
  • setConnectionLimit
  • setIdleConnectionTimeout
  • setWorkerThreads
  • getBindAddress
  • getConnectionLimit
  • getIdleConnectionTimeout
  • getPort
  • getWorkerThreads
  • setAcceptBacklog
  • setAcceptorThreadCount
  • setBindAddress
  • setAcceptorThreadCount,
  • setBindAddress,
  • setIoThreadCount,
  • setMaxFrameSize,
  • setMaxQueuedRequests,
  • setMaxQueuedResponsesPerConnection,
  • setProtocolName,
  • setQueueTimeout,
  • setTaskExpirationTimeout

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • requestLocationUpdates (LocationManager)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Join (org.hibernate.mapping)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now