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;
}
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();
}
Aggregations