Search in sources :

Example 11 with EurekaHttpResponse

use of com.netflix.discovery.shared.transport.EurekaHttpResponse in project eureka by Netflix.

the class AbstractJersey2EurekaHttpClient method getInstanceInternal.

private EurekaHttpResponse<InstanceInfo> getInstanceInternal(String urlPath) {
    Response response = null;
    try {
        Builder requestBuilder = jerseyClient.target(serviceUrl).path(urlPath).request();
        addExtraProperties(requestBuilder);
        addExtraHeaders(requestBuilder);
        response = requestBuilder.accept(MediaType.APPLICATION_JSON_TYPE).get();
        InstanceInfo infoFromPeer = null;
        if (response.getStatus() == Status.OK.getStatusCode() && response.hasEntity()) {
            infoFromPeer = response.readEntity(InstanceInfo.class);
        }
        return anEurekaHttpResponse(response.getStatus(), infoFromPeer).headers(headersOf(response)).build();
    } finally {
        if (logger.isDebugEnabled()) {
            logger.debug("Jersey2 HTTP GET {}/{}; statusCode={}", serviceUrl, urlPath, response == null ? "N/A" : response.getStatus());
        }
        if (response != null) {
            response.close();
        }
    }
}
Also used : EurekaHttpResponse(com.netflix.discovery.shared.transport.EurekaHttpResponse) EurekaHttpResponse.anEurekaHttpResponse(com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse) Response(javax.ws.rs.core.Response) EurekaHttpResponseBuilder(com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder) Builder(javax.ws.rs.client.Invocation.Builder) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Aggregations

EurekaHttpResponse (com.netflix.discovery.shared.transport.EurekaHttpResponse)11 EurekaHttpResponse.anEurekaHttpResponse (com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse)11 Response (javax.ws.rs.core.Response)11 Builder (javax.ws.rs.client.Invocation.Builder)9 EurekaHttpResponseBuilder (com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder)8 InstanceInfo (com.netflix.appinfo.InstanceInfo)3 ReplicationListResponse (com.netflix.eureka.cluster.protocol.ReplicationListResponse)3 WebTarget (javax.ws.rs.client.WebTarget)3 Application (com.netflix.discovery.shared.Application)1 Applications (com.netflix.discovery.shared.Applications)1