当前位置: 首页>>代码示例>>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;未经允许,请勿转载。