• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpClientBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.dropwizard.client.HttpClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java HttpClientBuilder类的具体用法?Java HttpClientBuilder怎么用?Java HttpClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpClientBuilder类属于io.dropwizard.client包,在下文中一共展示了HttpClientBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildHttpClient

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
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;
}
 
开发者ID:soabase,项目名称:soabase,代码行数:26,代码来源:ClientBuilder.java


示例2: build

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
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;
}
 
开发者ID:ufried,项目名称:resilience-tutorial,代码行数:22,代码来源:AnalysisServiceFactory.java


示例3: configure

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
@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();
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:37,代码来源:TestModule.java


示例4: createDefaultJerseyClient

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
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);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:BlobStoreClientFactory.java


示例5: createDefaultJerseyClient

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
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);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:UserAccessControlClientFactory.java


示例6: createDefaultJerseyClient

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
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);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:QueueClientFactory.java


示例7: buildJerseyClient

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
public Client buildJerseyClient(JerseyClientConfiguration configuration, String clientName)
{
    ConnectorProvider localConnectorProvider;
    if ( connectorProvider != null )
    {
        localConnectorProvider = connectorProvider;
    }
    else
    {
        HttpClientBuilder apacheHttpClientBuilder = new HttpClientBuilder(environment).using(configuration);
        CloseableHttpClient closeableHttpClient = apacheHttpClientBuilder.build(clientName);
        localConnectorProvider = new JerseyRetryConnectorProvider(retryComponents, closeableHttpClient, configuration.isChunkedEncodingEnabled());
    }
    JerseyClientBuilder builder = new JerseyClientBuilder(environment)
        .using(configuration)
        .using(localConnectorProvider);
    for ( Class<?> klass : providerClasses )
    {
        builder = builder.withProvider(klass);
    }
    for ( Object provider : providers )
    {
        builder = builder.withProvider(provider);
    }
    Client client = builder
        .build(clientName);

    SoaBundle.getFeatures(environment).putNamed(client, Client.class, clientName);

    return client;
}
 
开发者ID:soabase,项目名称:soabase,代码行数:32,代码来源:ClientBuilder.java


示例8: getWebHook

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
public Webhooks getWebHook(Environment environment) {
  if (vreAdded != null || dataSetUpdated != null) {
    final HttpClient httpClient = new HttpClientBuilder(environment)
      .using(httpClientConfig)
      .build("solr-webhook-client");

    return new CallingWebhooks(vreAdded, dataSetUpdated, httpClient);
  } else {
    return new NoOpWebhooks();
  }
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:12,代码来源:WebhookFactory.java


示例9: run

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
@Override
public void run(ThirdEyeDashboardConfiguration config, Environment environment) throws Exception {

  LOG.error("running the Dashboard application with configs, {}", config.toString());

  final HttpClient httpClient =
      new HttpClientBuilder(environment)
          .using(config.getHttpClient())
          .build(getName());

  ExecutorService queryExecutor = environment.lifecycle().executorService("query_executor").build();

  ConfigCache configCache = new ConfigCache();
  DataCache dataCache = new DataCache(httpClient, environment.getObjectMapper());
  QueryCache queryCache = new QueryCache(httpClient, environment.getObjectMapper(), queryExecutor);

  CustomDashboardResource customDashboardResource = null;
  if (config.getCustomDashboardRoot() != null) {
    File customDashboardDir = new File(config.getCustomDashboardRoot());
    configCache.setCustomDashboardRoot(customDashboardDir);
    customDashboardResource = new CustomDashboardResource(customDashboardDir, config.getServerUri(), queryCache, dataCache, configCache);
    environment.jersey().register(customDashboardResource);
  }

  FunnelsDataProvider funnelsResource = null;
  if (config.getFunnelConfigRoot() != null) {
    funnelsResource = new FunnelsDataProvider(new File(config.getFunnelConfigRoot()), config.getServerUri(), queryCache, dataCache);
    environment.jersey().register(funnelsResource);
  }

  if (config.getCollectionConfigRoot() != null) {
    File collectionConfigDir = new File(config.getCollectionConfigRoot());
    configCache.setCollectionConfigRoot(collectionConfigDir);
    CollectionConfigResource collectionConfigResource = new CollectionConfigResource(collectionConfigDir, configCache);
    environment.jersey().register(collectionConfigResource);
  }

  environment.jersey().register(new DashboardResource(
      config.getServerUri(),
      dataCache,
      config.getFeedbackEmailAddress(),
      queryCache,
      environment.getObjectMapper(),
      customDashboardResource,
      configCache, funnelsResource));

  environment.jersey().register(new FlotTimeSeriesResource(
      config.getServerUri(),
      dataCache,
      queryCache,
      environment.getObjectMapper(),
      configCache,
      config.getAnomalyDatabaseConfig()));

  environment.jersey().register(new MetadataResource(config.getServerUri(), dataCache));

  environment.admin().addTask(new ClearCachesTask(dataCache, queryCache, configCache));
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:59,代码来源:ThirdEyeDashboard.java


示例10: run

import io.dropwizard.client.HttpClientBuilder; //导入依赖的package包/类
@Override
public void run(DjConfiguration configuration,
                Environment environment) {

    final HttpClient client = new HttpClientBuilder(environment).using(configuration.getHttpClientConfiguration())
            .build("http-client");

    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");
    final DbMetaDAO meta = jdbi.onDemand(DbMetaDAO.class);
    int currentDbVersion = 1; //if this is ever incremented, you need to fix the below code to be a "real" migration system!

    if(!meta.songqueueTableExists()) {
        //we are creating a fresh new db
        meta.createSongqueueTable();
        meta.createMetaTable();
        meta.insertDbVersion(currentDbVersion);
    }
    
    if(!meta.metaTableExists()) {
        //we are updating from version 0 of the db when there was no meta table
        meta.createMetaTable();
        meta.insertDbVersion(currentDbVersion);
        meta.addSiteColumn();
        
        meta.populateLegacySoundcloudIds();
        meta.populateLegacyYoutubeIds();
    }
    
    jdbi.close(meta);

    final SongQueueDAO dao = jdbi.onDemand(SongQueueDAO.class);
    DjResource resource = new DjResource(configuration, client, dao);
    environment.jersey().register(resource);

    final ChannelCheck channelCheck = new ChannelCheck(resource);

    if(configuration.isDjbotPublic()) {
        String adminUsername = configuration.getAdminUsername();
        String adminPassword = configuration.getAdminPassword();
        if(StringUtils.isBlank(adminUsername) || StringUtils.isBlank(adminPassword)) {
            throw new RuntimeException("Djbot is set to public, so it needs an adminUsername and adminPassword");
        }

        environment.jersey().register(AuthFactory.binder(
                new BasicAuthFactory<User>(
                        new ConfiguredUserAuthenticator(adminUsername, adminPassword),
                        "djBotRealm",
                        User.class )));

    }

    environment.healthChecks().register("currentSong", channelCheck);
}
 
开发者ID:Hyphen-ated,项目名称:DJBot,代码行数:55,代码来源:DjApplication.java



注:本文中的io.dropwizard.client.HttpClientBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Truffle类代码示例发布时间:2022-05-22
下一篇:
Java PartEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap