本文整理汇总了Java中com.jivesoftware.os.routing.bird.http.client.HttpResponse类的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponse类属于com.jivesoftware.os.routing.bird.http.client包,在下文中一共展示了HttpResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyStorePassword
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
private String keyStorePassword(String routesHost, Integer routesPort) throws Exception {
HttpClientConfig httpClientConfig = HttpClientConfig.newBuilder().build();
String password = keyStorePassword.get();
if (password == null) {
HttpClient httpClient = new HttpClientFactoryProvider()
.createHttpClientFactory(Collections.singletonList(httpClientConfig), false)
.createClient(null, routesHost, routesPort);
HttpResponse response = httpClient.get(instanceConfig.getKeyStorePasswordsPath() + "/" + instanceConfig.getInstanceKey(), null);
if (response.getStatusCode() >= 200 && response.getStatusCode() < 300) {
password = new String(response.getResponseBody(), StandardCharsets.UTF_8);
keyStorePassword.compareAndSet(null, password);
} else {
throw new Exception("Failed to access required keystore password. " + response.getStatusCode());
}
}
return password;
}
示例2: removeTopology
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public void removeTopology(final MiruHost host, final MiruTenantId tenantId, final MiruPartitionId partitionId) {
send("removeTopology", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.postJson("/miru/topology/remove/"
+ host.getLogicalName() + "/"
+ tenantId + "/"
+ partitionId.getId(), "null", null);
String r = responseMapper.extractResultFromResponse(response, String.class, null);
miruStats.egressed("/miru/topology/remove/"
+ host.getLogicalName() + "/"
+ tenantId + "/"
+ partitionId.getId(), 1, System.currentTimeMillis() - start);
return new ClientResponse<>(r, true);
});
}
示例3: getTenantPartitionRoutingGroup
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
private HostPort[] getTenantPartitionRoutingGroup(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
MiruPartitionId partitionId,
boolean createIfAbsent) throws Exception {
return send(tenantId, "getTenantPartitionRoutingGroup", httpClient -> {
HttpResponse httpResponse = httpClient.get(
"/miru/wal/amza/routing/lazyTenantPartition" +
"/" + routingGroupType.name() +
"/" + tenantId.toString() +
"/" + partitionId.getId() +
"/" + createIfAbsent,
null);
HostPort[] response = responseMapper.extractResultFromResponse(httpResponse, HostPort[].class, null);
return new ClientResponse<>(response, true);
});
}
示例4: getTenantPartitionRoutingGroup
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
private HostPort[] getTenantPartitionRoutingGroup(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
MiruPartitionId partitionId,
boolean createIfAbsent) throws Exception {
return send(tenantId, "getTenantPartitionRoutingGroup", httpClient -> {
HttpResponse httpResponse = httpClient.get(
"/miru/wal/rcvs/routing/lazyTenantPartition" +
"/" + routingGroupType.name() +
"/" + tenantId.toString() +
"/" + partitionId.getId() +
"/" + createIfAbsent,
null);
HostPort[] response = responseMapper.extractResultFromResponse(httpResponse, HostPort[].class, null);
return new ClientResponse<>(response, true);
});
}
示例5: getTenantStreamRoutingGroup
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
private HostPort[] getTenantStreamRoutingGroup(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
MiruStreamId streamId,
boolean createIfAbsent) throws Exception {
return send(tenantId, "getTenantStreamRoutingGroup", httpClient -> {
HttpResponse httpResponse = httpClient.get(
"/miru/wal/rcvs/routing/lazyTenantStream" +
"/" + routingGroupType.name() +
"/" + tenantId.toString() +
"/" + streamId.toString() +
"/" + createIfAbsent,
null);
HostPort[] response = responseMapper.extractResultFromResponse(httpResponse, HostPort[].class, null);
return new ClientResponse<>(response, true);
});
}
示例6: query
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的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;
}
}
示例7: query
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的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;
}
}
示例8: ingress
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
private void ingress(List<MiruActivity> activities) throws JsonProcessingException {
ingressLatency.startTimer();
try {
String jsonActivities = activityMapper.writeValueAsString(activities);
while (true) {
try {
// TODO expose "" tenant to config?
HttpResponse response = miruWriter.call("", roundRobinStrategy, "ingress",
client -> new ClientCall.ClientResponse<>(client.postJson(miruIngressEndpoint, jsonActivities, null), true));
if (response.getStatusCode() < 200 || response.getStatusCode() >= 300) {
throw new RuntimeException("Failed to post " + activities.size() + " to " + miruIngressEndpoint);
}
log.inc("ingressed");
break;
} catch (Exception x) {
try {
log.error("Failed to forward ingress. Will retry shortly....", x);
Thread.sleep(5000);
} catch (InterruptedException ex) {
Thread.interrupted();
return;
}
}
}
} finally {
ingressLatency.stopTimer("Ingress " + activities.size(), "Add more stumptown services or fix down stream issue.");
}
}
示例9: routingTopology
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public MiruTopologyResponse routingTopology(final MiruTenantId tenantId) throws Exception {
return send("routingTopology", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.get("/miru/topology/routing/" + tenantId.toString(), null);
MiruTopologyResponse miruTopologyResponse = responseMapper.extractResultFromResponse(response, MiruTopologyResponse.class, null);
miruStats.egressed("/miru/topology/routing/" + tenantId.toString(), 1, System.currentTimeMillis() - start);
return new ClientResponse<>(miruTopologyResponse, true);
});
}
示例10: updateIngress
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public void updateIngress(MiruIngressUpdate ingressUpdate) throws Exception {
String jsonWarmIngress = requestMapper.writeValueAsString(ingressUpdate);
send("updateIngress", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.postJson("/miru/topology/update/ingress", jsonWarmIngress, null);
String r = responseMapper.extractResultFromResponse(response, String.class, null);
miruStats.egressed("/miru/topology/update/ingress", 1, System.currentTimeMillis() - start);
return new ClientResponse<>(r, true);
});
}
示例11: removeIngress
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public void removeIngress(MiruTenantId tenantId, MiruPartitionId partitionId) throws Exception {
send("removeIngress", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.postJson("/miru/topology/remove/ingress/" + tenantId.toString() + "/" + partitionId.toString(), "null", null);
String r = responseMapper.extractResultFromResponse(response, String.class, null);
miruStats.egressed("/miru/topology/remove/ingress/" + tenantId.toString() + "/" + partitionId.toString(), 1, System.currentTimeMillis() - start);
return new ClientResponse<>(r, true);
});
}
示例12: updateLastTimestamp
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public void updateLastTimestamp(MiruPartitionCoord coord, long lastTimestamp) throws Exception {
send("updateLastTimestamp", client -> {
long start = System.currentTimeMillis();
String endpointPrefix = "/miru/topology/update/lastTimestamp" +
"/" + coord.tenantId.toString() +
"/" + coord.partitionId.toString() +
"/" + coord.host.toString();
HttpResponse response = client.postJson(endpointPrefix + "/" + lastTimestamp, "null", null);
String r = responseMapper.extractResultFromResponse(response, String.class, null);
miruStats.egressed(endpointPrefix, 1, System.currentTimeMillis() - start);
return new ClientResponse<>(r, true);
});
}
示例13: destroyPartition
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public void destroyPartition(MiruTenantId tenantId, MiruPartitionId partitionId) throws Exception {
send("destroyPartition", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.postJson("/miru/topology/destroy/partition/" + tenantId.toString() + "/" + partitionId.toString(), "null", null);
String r = responseMapper.extractResultFromResponse(response, String.class, null);
miruStats.egressed("/miru/topology/destroy/partition/" + tenantId.toString() + "/" + partitionId.toString(), 1, System.currentTimeMillis() - start);
return new ClientResponse<>(r, true);
});
}
示例14: getPartitionStatus
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public List<MiruPartitionStatus> getPartitionStatus(MiruTenantId tenantId, MiruPartitionId largestPartitionId) throws Exception {
return send("getPartitionStatus", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.get("/miru/topology/partition/status/" + tenantId.toString() + "/" + largestPartitionId.toString(), null);
MiruPartitionStatus[] statuses = responseMapper.extractResultFromResponse(response, MiruPartitionStatus[].class, null);
miruStats.egressed("/miru/topology/partition/status/" + tenantId.toString() + "/" + largestPartitionId.toString(), 1,
System.currentTimeMillis() - start);
return new ClientResponse<>(Arrays.asList(statuses), true);
});
}
示例15: thumpthump
import com.jivesoftware.os.routing.bird.http.client.HttpResponse; //导入依赖的package包/类
@Override
public MiruHeartbeatResponse thumpthump(final MiruHost host, final MiruHeartbeatRequest heartbeatRequest) throws Exception {
String jsonHeartbeatRequest = requestMapper.writeValueAsString(heartbeatRequest);
return send("thumpthump", client -> {
long start = System.currentTimeMillis();
HttpResponse response = client.postJson("/miru/topology/thumpthump/" + host.getLogicalName(), jsonHeartbeatRequest, null);
MiruHeartbeatResponse heartbeatResponse = responseMapper.extractResultFromResponse(response, MiruHeartbeatResponse.class, null);
miruStats.egressed("/miru/topology/thumpthump/" + host.getLogicalName(), 1, System.currentTimeMillis() - start);
return new ClientResponse<>(heartbeatResponse, true);
});
}