Search in sources :

Example 11 with D2ClientBuilder

use of com.linkedin.d2.balancer.D2ClientBuilder in project incubator-gobblin by apache.

the class D2ClientProxy method buildClient.

private D2Client buildClient(D2ClientBuilder builder) {
    D2Client d2 = builder.build();
    final SettableFuture<None> d2ClientFuture = SettableFuture.create();
    d2.start(new Callback<None>() {

        @Override
        public void onError(Throwable e) {
            d2ClientFuture.setException(e);
        }

        @Override
        public void onSuccess(None none) {
            d2ClientFuture.set(none);
        }
    });
    try {
        // Synchronously wait for d2 to start
        d2ClientFuture.get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
    return d2;
}
Also used : D2Client(com.linkedin.d2.balancer.D2Client) ExecutionException(java.util.concurrent.ExecutionException) None(com.linkedin.common.util.None)

Aggregations

D2Client (com.linkedin.d2.balancer.D2Client)10 D2ClientBuilder (com.linkedin.d2.balancer.D2ClientBuilder)10 None (com.linkedin.common.util.None)6 Map (java.util.Map)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 ScheduledFuture (java.util.concurrent.ScheduledFuture)5 JSONObject (org.json.simple.JSONObject)5 IOException (java.io.IOException)4 ExecutionException (java.util.concurrent.ExecutionException)4 ParseException (org.json.simple.parser.ParseException)4 RestRequest (com.linkedin.r2.message.rest.RestRequest)3 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)3 RestResponse (com.linkedin.r2.message.rest.RestResponse)3 TimeoutException (java.util.concurrent.TimeoutException)3 Test (org.testng.annotations.Test)3 FutureCallback (com.linkedin.common.callback.FutureCallback)1 LastSeenBalancerWithFacilitiesFactory (com.linkedin.d2.balancer.LastSeenBalancerWithFacilitiesFactory)1 RestClient (com.linkedin.restli.client.RestClient)1 PrintWriter (java.io.PrintWriter)1