本文整理了Java中com.ning.http.client.RequestBuilder.setPerRequestConfig
方法的一些代码示例,展示了RequestBuilder.setPerRequestConfig
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestBuilder.setPerRequestConfig
方法的具体详情如下:
包路径:com.ning.http.client.RequestBuilder
类名称:RequestBuilder
方法名:setPerRequestConfig
暂无
代码示例来源:origin: HubSpot/Singularity
private void asyncHealthcheck(final SingularityTask task) {
final SingularityHealthcheckAsyncHandler handler = new SingularityHealthcheckAsyncHandler(exceptionNotifier, configuration, this, newTaskChecker, taskManager, task);
final Optional<String> uri = getHealthcheckUri(task);
if (!uri.isPresent()) {
saveFailure(handler, "Invalid healthcheck uri or ports not present");
return;
}
final Integer timeoutSeconds = task.getTaskRequest().getDeploy().getHealthcheck().isPresent() ?
task.getTaskRequest().getDeploy().getHealthcheck().get().getResponseTimeoutSeconds().or(configuration.getHealthcheckTimeoutSeconds()) : configuration.getHealthcheckTimeoutSeconds();
try {
PerRequestConfig prc = new PerRequestConfig();
prc.setRequestTimeoutInMs((int) TimeUnit.SECONDS.toMillis(timeoutSeconds));
RequestBuilder builder = new RequestBuilder("GET");
builder.setFollowRedirects(true);
builder.setUrl(uri.get());
builder.setPerRequestConfig(prc);
LOG.trace("Issuing a healthcheck ({}) for task {} with timeout {}s", uri.get(), task.getTaskId(), timeoutSeconds);
http.prepareRequest(builder.build()).execute(handler);
} catch (Throwable t) {
LOG.debug("Exception while preparing healthcheck ({}) for task ({})", uri, task.getTaskId(), t);
exceptionNotifier.notify(String.format("Error preparing healthcheck (%s)", t.getMessage()), t, ImmutableMap.of("taskId", task.getTaskId().toString()));
saveFailure(handler, String.format("Healthcheck failed due to exception: %s", t.getMessage()));
}
}
代码示例来源:origin: com.hubspot/SingularityService
private void asyncHealthcheck(final SingularityTask task) {
final SingularityHealthcheckAsyncHandler handler = new SingularityHealthcheckAsyncHandler(exceptionNotifier, configuration, this, newTaskChecker, taskManager, task);
final Optional<String> uri = getHealthcheckUri(task);
if (!uri.isPresent()) {
saveFailure(handler, "Invalid healthcheck uri or ports not present");
return;
}
final Integer timeoutSeconds = task.getTaskRequest().getDeploy().getHealthcheck().isPresent() ?
task.getTaskRequest().getDeploy().getHealthcheck().get().getResponseTimeoutSeconds().or(configuration.getHealthcheckTimeoutSeconds()) : configuration.getHealthcheckTimeoutSeconds();
try {
PerRequestConfig prc = new PerRequestConfig();
prc.setRequestTimeoutInMs((int) TimeUnit.SECONDS.toMillis(timeoutSeconds));
RequestBuilder builder = new RequestBuilder("GET");
builder.setFollowRedirects(true);
builder.setUrl(uri.get());
builder.setPerRequestConfig(prc);
LOG.trace("Issuing a healthcheck ({}) for task {} with timeout {}s", uri.get(), task.getTaskId(), timeoutSeconds);
http.prepareRequest(builder.build()).execute(handler);
} catch (Throwable t) {
LOG.debug("Exception while preparing healthcheck ({}) for task ({})", uri, task.getTaskId(), t);
exceptionNotifier.notify(String.format("Error preparing healthcheck (%s)", t.getMessage()), t, ImmutableMap.of("taskId", task.getTaskId().toString()));
saveFailure(handler, String.format("Healthcheck failed due to exception: %s", t.getMessage()));
}
}
代码示例来源:origin: org.sonatype.spice/jersey-ahc-client
PerRequestConfig c = new PerRequestConfig();
c.setRequestTimeoutInMs(readTimeout);
requestBuilder.setPerRequestConfig(c);
代码示例来源:origin: sonia.net.ahc/jersey-ahc-client
PerRequestConfig c = new PerRequestConfig();
c.setRequestTimeoutInMs(readTimeout);
requestBuilder.setPerRequestConfig(c);
内容来源于网络,如有侵权,请联系作者删除!