当前位置: 首页>>代码示例>>Java>>正文


Java HttpClientException类代码示例

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


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

示例1: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <C, R> R call(String family,
    ClientCall<C, R, HttpClientException> httpCall,
    ConnectionDescriptor[] connectionDescriptors,
    long connectionDescriptorsVersion,
    C[] clients,
    ClientHealth[] clientHealths,
    int deadAfterNErrors,
    long checkDeadEveryNMillis,
    AtomicInteger[] clientsErrors,
    AtomicLong[] clientsDeathTimestamp,
    Favored favored) throws HttpClientException {
    return returnFirstNonFailure.call(this,
        family,
        httpCall,
        connectionDescriptors,
        connectionDescriptorsVersion,
        clients,
        clientHealths,
        deadAfterNErrors,
        checkDeadEveryNMillis,
        clientsErrors,
        clientsDeathTimestamp,
        favored);
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:26,代码来源:StableShuffleStrategy.java

示例2: executePostJsonStreamingResponse

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
private HttpStreamResponse executePostJsonStreamingResponse(HttpEntityEnclosingRequestBase requestBase,
    String jsonBody,
    Map<String, String> headers) throws HttpClientException {
    try {
        setRequestHeaders(headers, requestBase);
        requestBase.setEntity(new StringEntity(jsonBody, ContentType.APPLICATION_JSON));
        requestBase.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
        return executeStream(requestBase);
    } catch (IOException | UnsupportedCharsetException | OAuthCommunicationException | OAuthExpectationFailedException |
        OAuthMessageSignerException e) {
        String trimmedMethodBody = (jsonBody.length() > JSON_POST_LOG_LENGTH_LIMIT)
            ? jsonBody.substring(0, JSON_POST_LOG_LENGTH_LIMIT) : jsonBody;
        throw new HttpClientException("Error executing " + requestBase.getMethod() + " request " +
            "to " + clientPathToString(requestBase.getURI().getPath()) + " body:" + trimmedMethodBody, e);
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:17,代码来源:ApacheHttpClient441BackedHttpClient.java

示例3: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <C, R> R call(String family,
    ClientCall<C, R, HttpClientException> httpCall,
    ConnectionDescriptor[] connectionDescriptors,
    long connectionDescriptorsVersion,
    C[] clients,
    ClientHealth[] clientHealths,
    int deadAfterNErrors,
    long checkDeadEveryNMillis,
    AtomicInteger[] clientsErrors,
    AtomicLong[] clientsDeathTimestamp,
    Favored favored) throws HttpClientException {

    return returnFirstNonFailure.call(this,
        family,
        httpCall,
        connectionDescriptors,
        connectionDescriptorsVersion,
        clients,
        clientHealths,
        deadAfterNErrors,
        checkDeadEveryNMillis,
        clientsErrors,
        clientsDeathTimestamp,
        favored);
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:27,代码来源:RoundRobinStrategy.java

示例4: executeGet

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
public byte[] executeGet(HttpClient httpClient, String endpointUrl) {
    HttpResponse response;
    try {
        response = httpClient.get(endpointUrl, null);
    } catch (HttpClientException e) {
        throw new RuntimeException("Error posting query request to server.  The endpoint posted to was \"" + endpointUrl + "\".", e);
    }

    byte[] responseBody = response.getResponseBody();

    if (responseBody == null) {
        responseBody = EMPTY_RESPONSE;
    }

    if (!isSuccessStatusCode(response.getStatusCode())) {
        throw new NonSuccessStatusCodeException(response.getStatusCode(), "Received non success status code (" + response.getStatusCode() + ") "
            + "from the server.  The reason phrase on the response was \"" + response.getStatusReasonPhrase() + "\" "
            + "and the body of the response was \"" + new String(responseBody, UTF_8) + "\".");
    }

    return responseBody;
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:23,代码来源:HttpRequestHelper.java

示例5: executeDeleteJson

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
private byte[] executeDeleteJson(HttpClient httpClient, String endpointUrl) {
    HttpResponse response;
    try {
        response = httpClient.delete(endpointUrl, null);
    } catch (HttpClientException var5) {
        throw new RuntimeException("Error posting query request to server.  The endpoint posted to was \"" + endpointUrl + "\".", var5);
    }

    byte[] responseBody = response.getResponseBody();
    if (responseBody == null) {
        responseBody = EMPTY_RESPONSE;
    }

    if (!this.isSuccessStatusCode(response.getStatusCode())) {
        throw new NonSuccessStatusCodeException(response.getStatusCode(),
            "Received non success status code (" + response.getStatusCode() + ") " + "from the server.  The reason phrase on the response was \""
            + response.getStatusReasonPhrase() + "\" " + "and the body of the response was \"" + new String(
            responseBody, UTF_8) + "\".");
    } else {
        return responseBody;
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:23,代码来源:HttpRequestHelper.java

示例6: executePostJson

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
private byte[] executePostJson(HttpClient httpClient, String endpointUrl, String postEntity) {
    HttpResponse response;
    try {
        response = httpClient.postJson(endpointUrl, postEntity, null);
    } catch (HttpClientException e) {
        throw new RuntimeException("Error posting query request to server.  The entity posted "
            + "was length \"" + postEntity.length() + "\" and the endpoint posted to was \"" + endpointUrl + "\".", e);
    }

    byte[] responseBody = response.getResponseBody();

    if (responseBody == null) {
        responseBody = EMPTY_RESPONSE;
    }

    if (!isSuccessStatusCode(response.getStatusCode())) {
        throw new NonSuccessStatusCodeException(response.getStatusCode(), "Received non success status code (" + response.getStatusCode() + ") "
            + "from the server.  The reason phrase on the response was \"" + response.getStatusReasonPhrase() + "\" "
            + "and the body of the response was length \"" + responseBody.length + "\".");
    }

    return responseBody;
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:24,代码来源:HttpRequestHelper.java

示例7: query

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <Q, A> MiruResponse<A> query(String routingTenant,
    String family,
    MiruRequest<Q> request,
    String path,
    Class<A> answerClass) throws Exception {

    MiruTenantIdAndFamily tenantAndFamily = new MiruTenantIdAndFamily(request.tenantId, family);
    long start = System.currentTimeMillis();
    try {
        String json = requestMapper.writeValueAsString(request);
        TailAtScaleStrategy tenantStrategy = getTenantStrategy(tenantAndFamily);
        InterceptingNextClientStrategy interceptingNextClientStrategy = new InterceptingNextClientStrategy(tenantStrategy);
        HttpResponse httpResponse = readerClient.call(routingTenant,
            interceptingNextClientStrategy,
            family,
            (c) -> new ClientCall.ClientResponse<>(c.postJson(path, json, null), true)
        );
        MiruResponse<A> answer = responseMapper.extractResultFromResponse(httpResponse, MiruResponse.class, new Class[] { answerClass }, null);
        recordTenantStrategy(tenantAndFamily, request.actorId, interceptingNextClientStrategy, answer);
        return answer;
    } catch (HttpClientException x) {
        queryEvent.event(tenantAndFamily.miruTenantId, request.actorId, tenantAndFamily.family, "nil", System.currentTimeMillis() - start, "failure");
        throw x;
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:27,代码来源:MiruQueryTASRouting.java

示例8: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <C, R> R call(String family,
    ClientCall<C, R, HttpClientException> httpCall,
    ConnectionDescriptor[] connectionDescriptors,
    long connectionDescriptorsVersion,
    C[] clients,
    ClientHealth[] clientHealths,
    int deadAfterNErrors,
    long checkDeadEveryNMillis,
    AtomicInteger[] clientsErrors,
    AtomicLong[] clientsDeathTimestamp,
    Favored favored) throws HttpClientException {

    this.connectionDescriptors = connectionDescriptors;

    return delegate.call(family, httpCall, connectionDescriptors, connectionDescriptorsVersion, clients, clientHealths, deadAfterNErrors,
        checkDeadEveryNMillis, clientsErrors, clientsDeathTimestamp, (attempt, totalAttempts, favoredConnectionDescriptor, latency) -> {
            this.attempt = attempt;
            this.totalAttempts = totalAttempts;
            this.favoredConnectionDescriptor = favoredConnectionDescriptor;
            this.latency = latency;
        });
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:24,代码来源:InterceptingNextClientStrategy.java

示例9: query

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <Q, A> MiruResponse<A> query(String routingTenant,
    String family,
    MiruRequest<Q> request,
    String path,
    Class<A> answerClass) throws Exception {

    MiruTenantIdAndFamily tenantAndFamily = new MiruTenantIdAndFamily(request.tenantId, family);
    long start = System.currentTimeMillis();
    try {
        String json = requestMapper.writeValueAsString(request);
        NextClientStrategy tenantStrategy = getTenantStrategy(tenantAndFamily);
        InterceptingNextClientStrategy interceptingNextClientStrategy = new InterceptingNextClientStrategy(tenantStrategy);
        HttpResponse httpResponse = readerClient.call(routingTenant,
            tenantStrategy,
            family,
            (c) -> new ClientCall.ClientResponse<>(c.postJson(path, json, null), true)
        );
        MiruResponse<A> answer = responseMapper.extractResultFromResponse(httpResponse, MiruResponse.class, new Class[] { answerClass }, null);
        recordTenantStrategy(tenantAndFamily, request.actorId, interceptingNextClientStrategy, answer);
        return answer;
    } catch (HttpClientException x) {
        queryEvent.event(tenantAndFamily.miruTenantId, request.actorId, tenantAndFamily.family, "nil", System.currentTimeMillis() - start, "failure");
        throw x;
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:27,代码来源:MiruQueryRouting.java

示例10: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <C, R> R call(String family,
    ClientCall<C, R, HttpClientException> httpCall,
    ConnectionDescriptor[] connectionDescriptors,
    long connectionDescriptorsVersion, C[] clients,
    ClientHealth[] clientHealths,
    int deadAfterNErrors,
    long checkDeadEveryNMillis,
    AtomicInteger[] clientsErrors,
    AtomicLong[] clientsDeathTimestamp,
    Favored favored) throws HttpClientException {
    return returnFirstNonFailure.call(this,
        family,
        httpCall,
        connectionDescriptors,
        connectionDescriptorsVersion,
        clients,
        clientHealths,
        deadAfterNErrors,
        checkDeadEveryNMillis,
        clientsErrors,
        clientsDeathTimestamp,
        favored);
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:25,代码来源:MiruHostSelectiveStrategy.java

示例11: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <R> R call(PartitionName partitionName,
    RingMember leader,
    RingMemberAndHost ringMemberAndHost,
    String family,
    PartitionCall<HttpClient, R, HttpClientException> clientCall) throws HttpClientException {

    ConnectionDescriptorSelectiveStrategy strategy = new ConnectionDescriptorSelectiveStrategy(new HostPort[]{
        new HostPort(ringMemberAndHost.ringHost.getHost(), ringMemberAndHost.ringHost.getPort())
    });

    return tenantAwareHttpClient.call("", strategy, family, (client) -> {
        PartitionResponse<R> response = clientCall.call(leader, ringMemberAndHost.ringMember, client);
        return new ClientResponse<R>(response.response, response.responseComplete);
    });
}
 
开发者ID:jivesoftware,项目名称:amza,代码行数:17,代码来源:RingHostHttpClientProvider.java

示例12: takeFromTransactionId

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public PartitionResponse<CloseableStreamResponse> takeFromTransactionId(RingMember leader,
    RingMember ringMember,
    HttpClient client,
    Map<RingMember, Long> membersTxId,
    int limit) throws HttpClientException {

    long transactionId = membersTxId.getOrDefault(ringMember, -1L);
    HttpStreamResponse got = client.streamingPostStreamableRequest(
        "/amza/v1/takeFromTransactionId/" + base64PartitionName + '/' + limit,
        (out) -> {
            try {
                FilerOutputStream fos = new FilerOutputStream(out);
                UIO.writeLong(fos, transactionId, "transactionId", new byte[8]);
            } finally {
                out.close();
            }
        }, null);

    return new PartitionResponse<>(new CloseableHttpStreamResponse(got), got.getStatusCode() >= 200 && got.getStatusCode() < 300);
}
 
开发者ID:jivesoftware,项目名称:amza,代码行数:22,代码来源:HttpRemotePartitionCaller.java

示例13: takePrefixFromTransactionId

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public PartitionResponse<CloseableStreamResponse> takePrefixFromTransactionId(RingMember leader,
    RingMember ringMember,
    HttpClient client,
    byte[] prefix,
    Map<RingMember, Long> membersTxId,
    int limit) throws HttpClientException {

    byte[] intLongBuffer = new byte[8];

    long transactionId = membersTxId.getOrDefault(ringMember, -1L);
    HttpStreamResponse got = client.streamingPostStreamableRequest(
        "/amza/v1/takePrefixFromTransactionId/" + base64PartitionName + '/' + limit,
        (out) -> {
            try {
                FilerOutputStream fos = new FilerOutputStream(out);
                UIO.writeByteArray(fos, prefix, "prefix", intLongBuffer);
                UIO.writeLong(fos, transactionId, "transactionId", intLongBuffer);
            } finally {
                out.close();
            }
        }, null);

    return new PartitionResponse<>(new CloseableHttpStreamResponse(got), got.getStatusCode() >= 200 && got.getStatusCode() < 300);
}
 
开发者ID:jivesoftware,项目名称:amza,代码行数:26,代码来源:HttpRemotePartitionCaller.java

示例14: call

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public <R> R call(NextClientStrategy strategy, String family, ClientCall<C, R, HttpClientException> httpCall) throws HttpClientException {

    return strategy.call(family,
        httpCall,
        connectionDescriptors,
        timestamp,
        clients,
        clientHealths,
        deadAfterNErrors,
        checkDeadEveryNMillis,
        clientsErrors,
        clientsDeathTimestamp,
        null);
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:16,代码来源:ErrorCheckingTimestampedClients.java

示例15: streamingPostStreamableRequest

import com.jivesoftware.os.routing.bird.shared.HttpClientException; //导入依赖的package包/类
@Override
public HttpStreamResponse streamingPostStreamableRequest(String path,
    HttpClient.StreamableRequest streamableRequest,
    Map<String, String> headers) throws HttpClientException {
    randSleep();
    return delegate.streamingPostStreamableRequest(path, streamableRequest, headers);
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:8,代码来源:LatentHttpClient.java


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