@Override protected void configure() { ObjectMapper objectMapper = JavaUtils.newObjectMapper(); Builder httpConfigBuilder = HttpConfig.newBuilder().setObjectMapper(objectMapper); bind(ObjectMapper.class).annotatedWith(Names.named(MESOS_CLIENT_OBJECT_MAPPER)).toInstance(objectMapper); bind(HttpClient.class).annotatedWith(Names.named(SingularityMesosClient.DEFAULT_HTTP_CLIENT_NAME)) .toInstance(new NingHttpClient(httpConfigBuilder.build())); bind(HttpClient.class).annotatedWith(Names.named(SingularityMesosClient.SHORT_TIMEOUT_HTTP_CLIENT_NAME)) .toInstance(new NingHttpClient(httpConfigBuilder.setRequestTimeoutSeconds(MESOS_CLIENT_HTTP_SHORT_TIMEOUT_SECONDS).build())); bind(MesosClient.class).to(SingularityMesosClient.class).in(Scopes.SINGLETON); }
@Override public HttpResponse execute(HttpRequest request) throws HttpRuntimeException { return execute(Preconditions.checkNotNull(request), Options.DEFAULT); }
@Override protected void configure() { ObjectMapper objectMapper = JavaUtils.newObjectMapper(); objectMapper.registerModule(new GuavaModule()); objectMapper.registerModule(new Jdk8Module()); HttpClient httpClient = new NingHttpClient(httpConfig.or(HttpConfig.newBuilder().setObjectMapper(objectMapper).build())); bind(HttpClient.class).annotatedWith(Names.named(HTTP_CLIENT_NAME)).toInstance(httpClient); bind(SingularityClient.class).toProvider(SingularityClientProvider.class).in(Scopes.SINGLETON); if (hosts != null) { bindHosts(binder()).toInstance(hosts); } }
@Override protected void configure() { HttpClient httpClient = new NingHttpClient(HttpConfig.newBuilder() .setObjectMapper(buildObjectMapper()) .build()); bind(HttpClient.class).annotatedWith(Names.named(HTTP_CLIENT_NAME)).toInstance(httpClient); bind(BaragonServiceClient.class).toProvider(BaragonClientProvider.class).in(Scopes.SINGLETON); if (hosts != null) { bindHosts(binder()).toInstance(hosts); } }