當前位置: 首頁>>代碼示例>>Java>>正文


Java NextClientStrategy類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:27,代碼來源:MiruQueryRouting.java

示例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;
    }
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:26,代碼來源:StrutModelCache.java

示例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);
}
 
開發者ID:jivesoftware,項目名稱:routing-bird,代碼行數:16,代碼來源:ErrorCheckingTimestampedClients.java

示例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);
}
 
開發者ID:jivesoftware,項目名稱:routing-bird,代碼行數:9,代碼來源:TenantRoutingHttpClient.java

示例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;
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:15,代碼來源:MiruHttpClusterClient.java

示例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);
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:12,代碼來源:AmzaHttpWALClient.java

示例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();
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:37,代碼來源:AmzaHttpWALClient.java

示例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();
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:35,代碼來源:AmzaHttpWALClient.java

示例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();
    }
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:36,代碼來源:RCVSHttpWALClient.java

示例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());
        }
    }
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:16,代碼來源:StrutModelCache.java

示例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;
 
開發者ID:jivesoftware,項目名稱:routing-bird,代碼行數:6,代碼來源:TenantAwareHttpClient.java

示例12: InterceptingNextClientStrategy

import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //導入依賴的package包/類
InterceptingNextClientStrategy(NextClientStrategy delegate) {
    this.delegate = delegate;
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:4,代碼來源:InterceptingNextClientStrategy.java

示例13: getTenantStrategy

import com.jivesoftware.os.routing.bird.shared.NextClientStrategy; //導入依賴的package包/類
private NextClientStrategy getTenantStrategy(MiruTenantIdAndFamily tenantAndFamily) {
    return strategyCache.getOrDefault(tenantAndFamily, new RoundRobinStrategy());
}
 
開發者ID:jivesoftware,項目名稱:miru,代碼行數:4,代碼來源:MiruQueryRouting.java


注:本文中的com.jivesoftware.os.routing.bird.shared.NextClientStrategy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。