Search in sources :

Example 1 with DistributedLogClientImpl

use of com.twitter.distributedlog.client.DistributedLogClientImpl in project distributedlog by twitter.

the class DistributedLogClientBuilder method buildClient.

DistributedLogClientImpl buildClient() {
    Preconditions.checkNotNull(_name, "No name provided.");
    Preconditions.checkNotNull(_clientId, "No client id provided.");
    Preconditions.checkNotNull(_routingServiceBuilder, "No routing service builder provided.");
    Preconditions.checkNotNull(_statsReceiver, "No stats receiver provided.");
    if (null == _streamStatsReceiver) {
        _streamStatsReceiver = new NullStatsReceiver();
    }
    RoutingService routingService = _routingServiceBuilder.statsReceiver(_statsReceiver.scope("routing")).build();
    DistributedLogClientImpl clientImpl = new DistributedLogClientImpl(_name, _clientId, routingService, _clientBuilder, _clientConfig, _statsReceiver, _streamStatsReceiver, _regionResolver, _enableRegionStats);
    routingService.startService();
    clientImpl.handshake();
    return clientImpl;
}
Also used : RegionsRoutingService(com.twitter.distributedlog.client.routing.RegionsRoutingService) RoutingService(com.twitter.distributedlog.client.routing.RoutingService) NullStatsReceiver(com.twitter.finagle.stats.NullStatsReceiver) DistributedLogClientImpl(com.twitter.distributedlog.client.DistributedLogClientImpl)

Example 2 with DistributedLogClientImpl

use of com.twitter.distributedlog.client.DistributedLogClientImpl in project distributedlog by twitter.

the class TestDistributedLogServer method testChecksumFlag.

/**
     * Sanity check to make sure both checksum flag values work.
     */
@Test(timeout = 60000)
public void testChecksumFlag() throws Exception {
    String name = "dlserver-basic-write";
    LocalRoutingService routingService = LocalRoutingService.newBuilder().build();
    routingService.addHost(name, dlServer.getAddress());
    DistributedLogClientBuilder dlClientBuilder = DistributedLogClientBuilder.newBuilder().name(name).clientId(ClientId$.MODULE$.apply("test")).routingService(routingService).handshakeWithClientInfo(true).clientBuilder(ClientBuilder.get().hostConnectionLimit(1).connectionTimeout(Duration.fromSeconds(1)).requestTimeout(Duration.fromSeconds(60))).checksum(false);
    DistributedLogClient dlClient = (DistributedLogClientImpl) dlClientBuilder.build();
    Await.result(dlClient.write(name, ByteBuffer.wrap(("1").getBytes())));
    dlClient.close();
    dlClient = dlClientBuilder.checksum(true).build();
    Await.result(dlClient.write(name, ByteBuffer.wrap(("2").getBytes())));
    dlClient.close();
}
Also used : DistributedLogClientImpl(com.twitter.distributedlog.client.DistributedLogClientImpl) LocalRoutingService(com.twitter.distributedlog.client.routing.LocalRoutingService) Test(org.junit.Test)

Aggregations

DistributedLogClientImpl (com.twitter.distributedlog.client.DistributedLogClientImpl)2 LocalRoutingService (com.twitter.distributedlog.client.routing.LocalRoutingService)1 RegionsRoutingService (com.twitter.distributedlog.client.routing.RegionsRoutingService)1 RoutingService (com.twitter.distributedlog.client.routing.RoutingService)1 NullStatsReceiver (com.twitter.finagle.stats.NullStatsReceiver)1 Test (org.junit.Test)1