@JsonCreator public BenchConfiguration(@JsonProperty("metrics") List<String> metrics, @JsonProperty("tags") Map<String, List<String>> tags, @JsonProperty("sampleFrequency") @DefaultValue("1.0") double sampleFrequency, @JsonProperty("start") @DefaultValue("0") long start, @JsonProperty("end") @DefaultValue("0") long end, @JsonProperty("ktsdHost") @DefaultValue("localhost") String host, @JsonProperty("ktsdPort") @DefaultValue("4242") int port, @JsonProperty("sync") @DefaultValue("true") boolean sync, @JsonProperty("httpClient") HttpClientConfiguration httpClient) { this.metrics = metrics; this.tags = tags; this.sampleFrequency = sampleFrequency; this.start = start; this.end = end; this.ktsdHost = host; this.ktsdPort = port; this.sync = sync; this.httpClient = httpClient; }
public HttpClient buildHttpClient(HttpClientConfiguration configuration, String clientName) { Preconditions.checkState(providers.size() == 0, "HttpClient does not support providers"); Preconditions.checkState(providerClasses.size() == 0, "HttpClient does not support providers"); Preconditions.checkState(connectorProvider == null, "HttpClient does not support ConnectorProvider"); HttpRequestRetryHandler nullRetry = new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { return false; } }; HttpClient httpClient = new HttpClientBuilder(environment) .using(configuration) .using(nullRetry) // Apache's retry mechanism does not allow changing hosts. Do retries manually .build(clientName); HttpClient client = new WrappedHttpClient(httpClient, retryComponents); SoaBundle.getFeatures(environment).putNamed(client, HttpClient.class, clientName); return client; }
public AnalysisServiceClient build(Environment environment) { final HttpClientConfiguration httpConfig = new HttpClientConfiguration(); httpConfig.setTimeout(Duration.milliseconds(getTimeout())); final HttpClient httpClient = new HttpClientBuilder(environment).using(httpConfig) .build("analysis-http-client"); AnalysisServiceClient client = new AnalysisServiceClientAdapter(getHost(), getPort(), getPortFailover(), getPath(), httpClient); environment.lifecycle().manage(new Managed() { @Override public void start() { } @Override public void stop() { } }); return client; }
@JsonCreator public static CassandraSchedulerConfiguration create( @JsonProperty("executor") final ExecutorConfig executorConfig, @JsonProperty("servers") final int servers, @JsonProperty("seeds") final int seeds, @JsonProperty("placement_constraint") final String placementConstraint, @JsonProperty("cassandra") final CassandraConfig cassandraConfig, @JsonProperty("cluster_task") final ClusterTaskConfig clusterTaskConfig, @JsonProperty("api_port") final int apiPort, @JsonProperty("service") final ServiceConfig serviceConfig, @JsonProperty("external_dc_sync_ms") final long externalDcSyncMs, @JsonProperty("external_dcs") final String externalDcs, @JsonProperty("dc_url") final String dcUrl, @JsonProperty("phase_strategy") final String phaseStrategy, @JsonProperty("enable_upgrade_sstable_endpoint") final boolean enableUpgradeSSTableEndpoint, @JsonProperty("http_client") final HttpClientConfiguration httpClientConfiguration) { return new CassandraSchedulerConfiguration( executorConfig, servers, seeds, placementConstraint, cassandraConfig, clusterTaskConfig, apiPort, serviceConfig, externalDcSyncMs, externalDcs, dcUrl, phaseStrategy, enableUpgradeSSTableEndpoint, httpClientConfiguration ); }
private CassandraSchedulerConfiguration( ExecutorConfig executorConfig, int servers, int seeds, String placementConstraint, CassandraConfig cassandraConfig, ClusterTaskConfig clusterTaskConfig, int apiPort, ServiceConfig serviceConfig, long externalDcSyncMs, String externalDcs, String dcUrl, String phaseStrategy, boolean enableUpgradeSSTableEndpoint, HttpClientConfiguration httpClientConfiguration) { this.executorConfig = executorConfig; this.servers = servers; this.seeds = seeds; this.placementConstraint = placementConstraint; this.cassandraConfig = cassandraConfig; this.clusterTaskConfig = clusterTaskConfig; this.apiPort = apiPort; this.serviceConfig = serviceConfig; this.externalDcSyncMs = externalDcSyncMs; this.externalDcs = externalDcs; this.dcUrl = dcUrl; this.phaseStrategy = phaseStrategy; this.enableUpgradeSSTableEndpoint = enableUpgradeSSTableEndpoint; this.httpClientConfiguration = httpClientConfiguration; }
@Override protected void configure() { bind(CassandraSchedulerConfiguration.class).toInstance(this.configuration); bind(new TypeLiteral<Serializer<Integer>>() {}).toInstance(IntegerStringSerializer.get()); bind(new TypeLiteral<Serializer<Boolean>>() {}).toInstance(BooleanStringSerializer.get()); bind(new TypeLiteral<Serializer<CassandraTask>>() {}).toInstance(CassandraTask.PROTO_SERIALIZER); bind(MesosConfig.class).toInstance(mesosConfig); bind(ServiceConfig.class) .annotatedWith(Names.named("ConfiguredIdentity")) .toInstance(configuration.getServiceConfig()); bindConstant() .annotatedWith(Names.named("ConfiguredEnableUpgradeSSTableEndpoint")) .to(configuration.getEnableUpgradeSSTableEndpoint()); HttpClientConfiguration httpClient = new HttpClientConfiguration(); bind(HttpClient.class) .toInstance(new HttpClientBuilder(environment).using(httpClient).build("http-client-test")); bind(ExecutorService.class).toInstance(Executors.newCachedThreadPool()); bind(CuratorFrameworkConfig.class).toInstance(curatorConfig); bind(ClusterTaskConfig.class).toInstance(configuration.getClusterTaskConfig()); bind(ScheduledExecutorService.class).toInstance(Executors.newScheduledThreadPool(8)); bind(SchedulerClient.class).asEagerSingleton(); bind(IdentityManager.class).asEagerSingleton(); bind(ConfigurationManager.class).asEagerSingleton(); bind(PersistentOfferRequirementProvider.class); bind(CassandraState.class).asEagerSingleton(); bind(EventBus.class).asEagerSingleton(); bind(BackupManager.class).asEagerSingleton(); bind(ClusterTaskOfferRequirementProvider.class); bind(Reconciler.class).to(DefaultReconciler.class).asEagerSingleton(); bind(RestoreManager.class).asEagerSingleton(); bind(CleanupManager.class).asEagerSingleton(); bind(RepairManager.class).asEagerSingleton(); bind(SeedsManager.class).asEagerSingleton(); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
/** * Creates a ServiceFactory for a cluster with reasonable configurations. */ private MultiThreadedServiceFactory<AuthDataStore> createDataStoreServiceFactory(String cluster, MetricRegistry metricRegistry) { HttpClientConfiguration clientConfig = new HttpClientConfiguration(); clientConfig.setKeepAlive(Duration.seconds(1)); clientConfig.setConnectionTimeout(Duration.seconds(10)); clientConfig.setTimeout(Duration.minutes(5)); return DataStoreClientFactory.forClusterAndHttpConfiguration(cluster, clientConfig, metricRegistry); }
@Override protected void internalRun(Configuration configuration, Environment environment) { ClientBuilder builder = new ClientBuilder(environment); builder.buildJerseyClient(new JerseyClientConfiguration(), "jersey"); builder.buildHttpClient(new HttpClientConfiguration(), "apache"); environment.jersey().register(HelloResourceJersey.class); environment.jersey().register(HelloResourceApache.class); }
@JsonProperty("httpClient") public HttpClientConfiguration getHttpClientConfiguration() { return httpClient; }
@JsonProperty("httpClient") public void setHttpClientConfiguration(HttpClientConfiguration httpClient) { this.httpClient = httpClient; }
@JsonProperty("http_client") public HttpClientConfiguration getHttpClientConfiguration() { return httpClientConfiguration; }
@JsonProperty("http_client") public void setHttpClientConfiguration(HttpClientConfiguration httpClientConfiguration) { this.httpClientConfiguration = httpClientConfiguration; }
public static BlobStoreClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new BlobStoreClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, metricRegistry, getServiceName(clusterName))); }
public static BlobStoreClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new BlobStoreClientFactory(clusterName, createDefaultJerseyClient(configuration, metricRegistry, getServiceName(clusterName))); }
public static UserAccessControlClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new UserAccessControlClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, getServiceName(clusterName), metricRegistry)); }
public static UserAccessControlClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new UserAccessControlClientFactory(clusterName, createDefaultJerseyClient(configuration, getServiceName(clusterName), metricRegistry)); }
public static DataStoreClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new DataStoreClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, getServiceName(clusterName), metricRegistry)); }
public static DataStoreClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new DataStoreClientFactory(clusterName, createDefaultJerseyClient(configuration, getServiceName(clusterName), metricRegistry)); }
public static QueueClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new QueueClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, getServiceName(clusterName), metricRegistry)); }
public static QueueClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new QueueClientFactory(clusterName, createDefaultJerseyClient(configuration, getServiceName(clusterName), metricRegistry)); }
public static DedupQueueClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new DedupQueueClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, getServiceName(clusterName), metricRegistry)); }
public static DedupQueueClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new DedupQueueClientFactory(clusterName, createDefaultJerseyClient(configuration, getServiceName(clusterName), metricRegistry)); }
public static DatabusClientFactory forCluster(String clusterName, MetricRegistry metricRegistry) { HttpClientConfiguration httpClientConfiguration = new HttpClientConfiguration(); httpClientConfiguration.setKeepAlive(Duration.seconds(1)); return new DatabusClientFactory(clusterName, createDefaultJerseyClient(httpClientConfiguration, metricRegistry, getServiceName(clusterName))); }
public static DatabusClientFactory forClusterAndHttpConfiguration(String clusterName, HttpClientConfiguration configuration, MetricRegistry metricRegistry) { return new DatabusClientFactory(clusterName, createDefaultJerseyClient(configuration, metricRegistry, getServiceName(clusterName))); }
@JsonProperty public HttpClientConfiguration getHttpClient() { return httpClient; }
public HttpClientConfiguration getHttpClientConfiguration() { return httpClientConfiguration; }
public HttpClientConfiguration getHttpClient() { return httpClient; }
public HttpClientConfiguration getHttpClientConfiguration() { return httpClient; }
@JsonProperty("httpClient") @Valid @Value.Default public HttpClientConfiguration getHttpClientConfiguration() { return new HttpClientConfiguration(); }