Search in sources :

Example 1 with ClientBuilder

use of com.twitter.finagle.builder.ClientBuilder in project distributedlog by twitter.

the class WriterWorker method buildDlogClient.

private DistributedLogClient buildDlogClient() {
    ClientBuilder clientBuilder = ClientBuilder.get().hostConnectionLimit(hostConnectionLimit).hostConnectionCoresize(hostConnectionCoreSize).tcpConnectTimeout(Duration$.MODULE$.fromMilliseconds(200)).connectTimeout(Duration$.MODULE$.fromMilliseconds(200)).requestTimeout(Duration$.MODULE$.fromSeconds(10)).sendBufferSize(sendBufferSize).recvBufferSize(recvBufferSize);
    ClientId clientId = ClientId$.MODULE$.apply("dlog_loadtest_writer");
    DistributedLogClientBuilder builder = DistributedLogClientBuilder.newBuilder().clientId(clientId).clientBuilder(clientBuilder).thriftmux(thriftmux).redirectBackoffStartMs(100).redirectBackoffMaxMs(500).requestTimeoutMs(10000).statsReceiver(statsReceiver).streamNameRegex("^" + streamPrefix + "_[0-9]+$").handshakeWithClientInfo(handshakeWithClientInfo).periodicHandshakeIntervalMs(TimeUnit.SECONDS.toMillis(30)).periodicOwnershipSyncIntervalMs(TimeUnit.MINUTES.toMillis(5)).periodicDumpOwnershipCache(true).handshakeTracing(true).name("writer");
    if (!finagleNames.isEmpty()) {
        String local = finagleNames.get(0);
        String[] remotes = new String[finagleNames.size() - 1];
        finagleNames.subList(1, finagleNames.size()).toArray(remotes);
        builder = builder.finagleNameStrs(local, remotes);
    } else if (serverSets.length != 0) {
        ServerSet local = serverSets[0].getServerSet();
        ServerSet[] remotes = new ServerSet[serverSets.length - 1];
        for (int i = 1; i < serverSets.length; i++) {
            remotes[i - 1] = serverSets[i].getServerSet();
        }
        builder = builder.serverSets(local, remotes);
    } else {
        builder = builder.uri(dlUri);
    }
    return builder.build();
}
Also used : ServerSet(com.twitter.common.zookeeper.ServerSet) DLZkServerSet(com.twitter.distributedlog.client.serverset.DLZkServerSet) ClientId(com.twitter.finagle.thrift.ClientId) DistributedLogClientBuilder(com.twitter.distributedlog.service.DistributedLogClientBuilder) ClientBuilder(com.twitter.finagle.builder.ClientBuilder) DistributedLogClientBuilder(com.twitter.distributedlog.service.DistributedLogClientBuilder)

Aggregations

ServerSet (com.twitter.common.zookeeper.ServerSet)1 DLZkServerSet (com.twitter.distributedlog.client.serverset.DLZkServerSet)1 DistributedLogClientBuilder (com.twitter.distributedlog.service.DistributedLogClientBuilder)1 ClientBuilder (com.twitter.finagle.builder.ClientBuilder)1 ClientId (com.twitter.finagle.thrift.ClientId)1