use of com.linecorp.armeria.common.AggregatedHttpResponse in project zipkin by openzipkin.
the class ITZipkinServerSsl method callHealthEndpoint.
void callHealthEndpoint(SessionProtocol http) {
AggregatedHttpResponse response = WebClient.builder(baseUrl(server, http)).factory(clientFactory).build().get("/health").aggregate().join();
assertThat(response.status()).isEqualTo(HttpStatus.OK);
}
use of com.linecorp.armeria.common.AggregatedHttpResponse in project zipkin by openzipkin.
the class HttpCall method sendRequest.
CompletableFuture<AggregatedHttpResponse> sendRequest() {
final HttpResponse response;
try (SafeCloseable ignored = Clients.withContextCustomizer(ctx -> ctx.logBuilder().name(name))) {
HttpRequestWriter httpRequest = HttpRequest.streaming(request.headers());
response = httpClient.execute(httpRequest);
request.writeBody(httpRequest::tryWrite);
httpRequest.close();
}
CompletableFuture<AggregatedHttpResponse> responseFuture = RequestContext.mapCurrent(ctx -> response.aggregateWithPooledObjects(ctx.eventLoop(), ctx.alloc()), // This should never be used in practice since the module runs in an Armeria server.
response::aggregate);
responseFuture = responseFuture.exceptionally(t -> {
if (t instanceof UnprocessedRequestException) {
Throwable cause = t.getCause();
// Go ahead and reduce the output in logs since this is usually a configuration or
// infrastructure issue and the Armeria stack trace won't help debugging that.
Exceptions.clearTrace(cause);
String message = cause.getMessage();
if (message == null)
message = cause.getClass().getSimpleName();
throw new RejectedExecutionException(message, cause);
} else {
Exceptions.throwUnsafely(t);
}
return null;
});
this.responseFuture = responseFuture;
return responseFuture;
}
use of com.linecorp.armeria.common.AggregatedHttpResponse in project zipkin by openzipkin.
the class ITElasticsearchStorage method testUsageOfDeprecatedFeatures.
@Test
void testUsageOfDeprecatedFeatures() {
WebClient webClient = WebClient.builder(elasticsearch().baseUrl()).factory(ClientFactory.builder().useHttp2Preface(false).build()).build();
final AggregatedHttpResponse response = webClient.execute(HttpRequest.of(RequestHeaders.of(HttpMethod.GET, "/_migration/deprecations"))).aggregate().join();
if (!response.contentAscii().isEmpty()) {
LOGGER.warn("The ElasticSearch instance used during IT's is using deprecated features or " + "configuration. This is likely nothing to be really worried about (for example 'xpack.monitoring.enabled' " + "setting), but nevertheless it should be looked at to see if our docker image used during " + "integration tests needs updating for the next version of ElasticSearch. " + "See https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html" + "for more information. This is the deprecation warning we received:\n\n" + response.contentAscii());
}
}
use of com.linecorp.armeria.common.AggregatedHttpResponse in project zipkin by openzipkin.
the class HttpCallTest method releasesAllReferencesToByteBuf.
@Test
void releasesAllReferencesToByteBuf() {
// Force this to be a ref-counted response
byte[] message = "{\"Message\":\"error\"}".getBytes(UTF_8);
ByteBuf encodedBuf = PooledByteBufAllocator.DEFAULT.buffer(message.length);
encodedBuf.writeBytes(message);
AggregatedHttpResponse response = AggregatedHttpResponse.of(ResponseHeaders.of(HttpStatus.FORBIDDEN), HttpData.wrap(encodedBuf));
HttpCall<Object> call = http.newCall(REQUEST, NULL, "test");
// Invoke the parser directly because using the fake server will not result in ref-counted
assertThatThrownBy(() -> call.parseResponse(response, NULL)).hasMessage("error");
assertThat(encodedBuf.refCnt()).isEqualTo(0);
}
Aggregations