Java源码示例:com.twitter.finagle.thrift.ThriftClientFramedCodec
示例1
@SuppressWarnings("unchecked")
private ClientBuilder configureThriftMux(ClientBuilder builder,
ClientId clientId,
ClientConfig clientConfig) {
if (clientConfig.getThriftMux()) {
return builder.stack(ThriftMux.client().withClientId(clientId));
} else {
return builder.codec(ThriftClientFramedCodec.apply(Option.apply(clientId)));
}
}
示例2
@SuppressWarnings("unchecked")
private ClientBuilder setDefaultSettings(ClientBuilder builder) {
return builder.name(clientName)
.codec(ThriftClientFramedCodec.apply(Option.apply(clientId)))
.failFast(false)
.noFailureAccrual()
// disable retries on finagle client builder, as there is only one host per finagle client
// we should throw exception immediately on first failure, so DL client could quickly detect
// failures and retry other proxies.
.retries(1)
.keepAlive(true);
}
示例3
public PinLaterClient(String host, int port, int concurrency) {
this.service = ClientBuilder.safeBuild(
ClientBuilder.get()
.hosts(new InetSocketAddress(host, port))
.codec(ThriftClientFramedCodec.apply(Option.apply(new ClientId("pinlaterclient"))))
.hostConnectionLimit(concurrency)
.tcpConnectTimeout(Duration.apply(2, TimeUnit.SECONDS))
.requestTimeout(Duration.apply(10, TimeUnit.SECONDS))
.retries(1));
this.iface = new PinLater.ServiceToClient(service, new TBinaryProtocol.Factory());
}
示例4
public PinLaterClient(ServerSet serverSet, int concurrency) {
ZookeeperServerSetCluster cluster = new ZookeeperServerSetCluster(serverSet);
ClientBuilder builder = ClientBuilder.get().cluster(cluster);
this.service = ClientBuilder.safeBuild(
builder.codec(ThriftClientFramedCodec.get())
.tcpConnectTimeout(Duration.apply(2, TimeUnit.SECONDS))
.requestTimeout(Duration.apply(10, TimeUnit.SECONDS))
.hostConnectionLimit(concurrency));
this.iface = new PinLater.ServiceToClient(service, new TBinaryProtocol.Factory());
}