本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
});
}
示例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;
}
}
示例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);
}
示例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);
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}