本文整理汇总了Java中com.jivesoftware.os.routing.bird.shared.NextClientStrategy类的典型用法代码示例。如果您正苦于以下问题:Java NextClientStrategy类的具体用法?Java NextClientStrategy怎么用?Java NextClientStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NextClientStrategy类属于com.jivesoftware.os.routing.bird.shared包,在下文中一共展示了NextClientStrategy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的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;
}
}
示例2: fetchModel
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private CatwalkModel fetchModel(NextClientStrategy nextClientStrategy, CatwalkQuery catwalkQuery, String key, int partitionId) throws Exception {
String json = requestMapper.writeValueAsString(catwalkQuery);
HttpStreamResponse response = catwalkClient.call("",
nextClientStrategy,
"strutModelCacheGet",
(c) -> new ClientResponse<>(c.streamingPost("/miru/catwalk/model/get/" + key + "/" + partitionId, json, null), true));
CatwalkModel catwalkModel = null;
try {
if (responseMapper.isSuccessStatusCode(response.getStatusCode())) {
SnappyInputStream in = new SnappyInputStream(new BufferedInputStream(response.getInputStream(), 8192));
catwalkModel = requestMapper.readValue(in, CatwalkModel.class);
}
} finally {
response.close();
}
if (catwalkModel == null) {
throw new ModelNotAvailable("Model not available,"
+ " status code: " + response.getStatusCode()
+ " reason: " + response.getStatusReasonPhrase());
}
return catwalkModel;
}
示例3: call
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的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);
}
示例4: call
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
@Override
public <R> R call(T tenant,
NextClientStrategy strategy,
String family,
ClientCall<HttpClient, R, HttpClientException> clientCall)
throws HttpClientException {
return tenantRoutingClient.tenantAwareCall(tenant, strategy, family, clientCall);
}
示例5: MiruHttpClusterClient
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
public MiruHttpClusterClient(MiruStats miruStats,
String routingTenantId,
TenantAwareHttpClient<String> clusterClient,
NextClientStrategy nextClientStrategy,
ObjectMapper requestMapper,
HttpResponseMapper responseMapper) {
this.miruStats = miruStats;
this.routingTenantId = routingTenantId;
this.clusterClient = clusterClient;
this.nextClientStrategy = nextClientStrategy;
this.requestMapper = requestMapper;
this.responseMapper = responseMapper;
}
示例6: send
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private <R> R send(MiruTenantId miruTenantId, String family, ClientCall<HttpClient, R, HttpClientException> call) {
try {
NextClientStrategy nextClientStrategy = tenantNextClientStrategy.computeIfAbsent(miruTenantId,
(t) -> new TailAtScaleStrategy(tasExecutors, tasWindowSize, tasPercentile, tasInitialSLAMillis));
return walClient.call(routingTenantId, nextClientStrategy, family, call);
} catch (Exception x) {
throw new RuntimeException("Failed to send.", x);
}
}
示例7: sendWithTenantPartition
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private <R> R sendWithTenantPartition(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
MiruPartitionId partitionId,
boolean createIfAbsent,
String family,
ClientCall<HttpClient, SendResult<R>, HttpClientException> call) throws Exception {
TenantRoutingGroup<MiruPartitionId> routingGroup = new TenantRoutingGroup<>(routingGroupType, tenantId, partitionId);
try {
while (true) {
NextClientStrategy strategy = tenantRoutingCache.get(routingGroup,
() -> {
HostPort[] hostPorts = getTenantPartitionRoutingGroup(routingGroupType, tenantId, partitionId, createIfAbsent);
if (hostPorts == null || hostPorts.length == 0) {
throw new MiruRouteUnavailableException("No route available for tenant " + tenantId + " partition " + partitionId);
}
return new ConnectionDescriptorSelectiveStrategy(hostPorts);
});
SendResult<R> sendResult = walClient.call(routingTenantId, strategy, family, call);
if (sendResult.validRoute) {
return sendResult.result;
}
tenantRoutingCache.invalidate(routingGroup);
if (sendResult.errorRoute) {
return null;
}
sickThreads.sick(new Throwable("Tenant partition route is invalid"));
}
} catch (Exception x) {
tenantRoutingCache.invalidate(routingGroup);
throw x;
} finally {
sickThreads.recovered();
}
}
示例8: sendWithTenant
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private <R> R sendWithTenant(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
boolean createIfAbsent,
String family,
ClientCall<HttpClient, SendResult<R>, HttpClientException> call) throws Exception {
TenantRoutingGroup<Void> routingGroup = new TenantRoutingGroup<>(routingGroupType, tenantId, null);
try {
while (true) {
NextClientStrategy strategy = tenantRoutingCache.get(routingGroup,
() -> {
HostPort[] hostPorts = getTenantRoutingGroup(routingGroupType, tenantId, createIfAbsent);
if (hostPorts == null || hostPorts.length == 0) {
throw new MiruRouteUnavailableException("No route available for tenant " + tenantId);
}
return new ConnectionDescriptorSelectiveStrategy(hostPorts);
});
SendResult<R> sendResult = walClient.call(routingTenantId, strategy, family, call);
if (sendResult.validRoute) {
return sendResult.result;
}
tenantRoutingCache.invalidate(routingGroup);
if (sendResult.errorRoute) {
return null;
}
sickThreads.sick(new Throwable("Tenant stream route is invalid"));
}
} catch (Exception x) {
tenantRoutingCache.invalidate(routingGroup);
throw x;
} finally {
sickThreads.recovered();
}
}
示例9: sendWithTenantStream
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private <R> R sendWithTenantStream(RoutingGroupType routingGroupType,
MiruTenantId tenantId,
MiruStreamId streamId,
boolean createIfAbsent,
String family,
ClientCall<HttpClient, SendResult<R>, HttpClientException> call) throws Exception {
TenantRoutingGroup<MiruStreamId> routingGroup = new TenantRoutingGroup<>(routingGroupType, tenantId, streamId);
try {
while (true) {
NextClientStrategy strategy = tenantRoutingCache.get(routingGroup,
() -> {
HostPort[] hostPorts = getTenantStreamRoutingGroup(routingGroupType, tenantId, streamId, createIfAbsent);
if (hostPorts == null || hostPorts.length == 0) {
throw new MiruRouteUnavailableException("No route available for tenant " + tenantId + " stream " + streamId);
}
return new ConnectionDescriptorSelectiveStrategy(hostPorts);
});
SendResult<R> sendResult = walClient.call(routingTenantId, strategy, family, call);
if (sendResult.validRoute) {
return sendResult.result;
}
tenantRoutingCache.invalidate(routingGroup);
if (sendResult.errorRoute) {
return null;
}
sickThreads.sick(new Throwable("Tenant stream route is invalid"));
}
} catch (Exception x) {
tenantRoutingCache.invalidate(routingGroup);
throw x;
} finally {
sickThreads.recovered();
}
}
示例10: fetchModelBytes
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private byte[] fetchModelBytes(NextClientStrategy nextClientStrategy, CatwalkQuery catwalkQuery, String key, int partitionId) throws Exception {
String json = requestMapper.writeValueAsString(catwalkQuery);
HttpResponse response = catwalkClient.call("",
nextClientStrategy,
"strutModelCacheGet",
(c) -> new ClientResponse<>(c.postJson("/miru/catwalk/model/get/" + key + "/" + partitionId, json, null), true));
if (responseMapper.isSuccessStatusCode(response.getStatusCode())) {
return response.getResponseBody();
} else {
throw new ModelNotAvailable("Model not available,"
+ " status code: " + response.getStatusCode()
+ " reason: " + response.getStatusReasonPhrase());
}
}
示例11: call
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
<R> R call(T tenant,
NextClientStrategy strategy,
String family,
ClientCall<HttpClient, R, HttpClientException> clientCall)
throws HttpClientException;
示例12: InterceptingNextClientStrategy
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
InterceptingNextClientStrategy(NextClientStrategy delegate) {
this.delegate = delegate;
}
示例13: getTenantStrategy
import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //导入依赖的package包/类
private NextClientStrategy getTenantStrategy(MiruTenantIdAndFamily tenantAndFamily) {
return strategyCache.getOrDefault(tenantAndFamily, new RoundRobinStrategy());
}