com.twitter.finagle.Thrift Java Examples

The following examples show how to use com.twitter.finagle.Thrift. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LindenClient.java    From linden with Apache License 2.0 5 votes vote down vote up
private LindenService.ServiceIface buildClient(String parent, String node) {
  String nodePath = FilenameUtils.separatorsToUnix(FilenameUtils.concat(parent, node));
  byte[] bytes = zkClient.readData(nodePath);
  ServiceInstance serviceInstance = JSONObject.parseObject(new String(bytes), ServiceInstance.class);
  String schema = String.format("%s:%s",
                                serviceInstance.getServiceEndpoint().getHost(),
                                serviceInstance.getServiceEndpoint().getPort());
  return Thrift.newIface(schema, LindenService.ServiceIface.class);
}
 
Example #2
Source File: LindenServer.java    From linden with Apache License 2.0 5 votes vote down vote up
public void startServer() throws Exception {
  impl = new CoreLindenServiceImpl(lindenConf);
  server = Thrift.serveIface(new InetSocketAddress(port), impl);

  LOGGER.info("LindenServer registered to cluster.");
  clusterAnnouncer = new ClusterAnnouncer(lindenConf);
  clusterAnnouncer.announce();

  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
        close();
    }
  });
  LOGGER.info("LindenServer started.");

  // start admin server.
  if (lindenConf.getAdminPort() > 0) {
    adminThread = new Thread() {
      @Override
      public void run() {
        try {
          LindenAdmin admin = new LindenAdmin(impl, lindenConf.getAdminPort(), lindenConf.getWebapp());
          admin.start();
        } catch (Exception e) {
          e.printStackTrace();
          LOGGER.error("Admin start failed : {}", Throwables.getStackTraceAsString(e));
        }
      }
    };
    adminThread.start();
  }
  Await.ready(server);
}
 
Example #3
Source File: LindenClient.java    From linden with Apache License 2.0 4 votes vote down vote up
public LindenClient(String host, int port, int timeout) {
  this.timeout = timeout;
  this.duration = Duration.apply(timeout, TimeUnit.MILLISECONDS);
  LindenService.ServiceIface iface = Thrift.newIface(String.format("%s:%d", host, port), LindenService.ServiceIface.class);
  clientIface = new SingleClient(iface);
}
 
Example #4
Source File: ScribeSender.java    From zipkin-finagle with Apache License 2.0 4 votes vote down vote up
ScribeClient(Config config) {
  delegate = Thrift.client()
      .withTracer(new NullTracer())
      .newService(config.host(), "zipkin-scribe");
}
 
Example #5
Source File: FinagleRpcApplication.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Bean
public FinagleRpcDemoService.FutureIface client() {
    return Thrift.client()
            .newIface("localhost:12220", FinagleRpcDemoService.FutureIface.class);
}
 
Example #6
Source File: FinagleRpcApplication.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Bean
public FinagleRpcDemoService.ServiceIface client() {
    return Thrift.client()
            .newIface("localhost:12220", FinagleRpcDemoService.ServiceIface.class);
}
 
Example #7
Source File: FinagleRpcApplication.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Bean
public FinagleRpcDemoService.ServiceIface client() {
    return Thrift.client()
            .newIface("localhost:12220", FinagleRpcDemoService.ServiceIface.class);
}