当前位置: 首页>>代码示例>>Java>>正文


Java HostPort类代码示例

本文整理汇总了Java中com.jivesoftware.os.routing.bird.shared.HostPort的典型用法代码示例。如果您正苦于以下问题:Java HostPort类的具体用法?Java HostPort怎么用?Java HostPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HostPort类属于com.jivesoftware.os.routing.bird.shared包,在下文中一共展示了HostPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTenantPartitionRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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);
    });
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:17,代码来源:AmzaHttpWALClient.java

示例2: getTenantPartitionRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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);
    });
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:17,代码来源:RCVSHttpWALClient.java

示例3: getTenantStreamRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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);
    });
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:17,代码来源:RCVSHttpWALClient.java

示例4: getActivityRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
public HostPort[] getActivityRoutingGroup(MiruTenantId tenantId,
    MiruPartitionId partitionId,
    Optional<PartitionProperties> partitionProperties,
    boolean createIfAbsent) throws Exception {

    PartitionName partitionName = getActivityPartitionName(tenantId, partitionId);
    if (createIfAbsent) {
        amzaService.getRingWriter().ensureSubRing(partitionName.getRingName(), activityRingSize, activityRoutingTimeoutMillis);
        amzaService.createPartitionIfAbsent(partitionName, partitionProperties.or(activityProperties));
    } else if (!amzaService.hasPartition(partitionName)) {
        return new HostPort[0];
    }

    AmzaService.AmzaPartitionRoute partitionRoute = amzaService.getPartitionRoute(partitionName, activityRoutingTimeoutMillis);
    if (!partitionRoute.disposed && partitionRoute.leader != null) {
        return new HostPort[]{new HostPort(partitionRoute.leader.ringHost.getHost(), partitionRoute.leader.ringHost.getPort())};
    } else {
        return partitionRoute.orderedMembers.stream()
            .map(ringMemberAndHost -> new HostPort(ringMemberAndHost.ringHost.getHost(), ringMemberAndHost.ringHost.getPort()))
            .toArray(HostPort[]::new);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:23,代码来源:AmzaWALUtil.java

示例5: getReadTrackingRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
public HostPort[] getReadTrackingRoutingGroup(MiruTenantId tenantId,
    Optional<PartitionProperties> partitionProperties,
    boolean createIfAbsent) throws Exception {

    PartitionName partitionName = getReadTrackingPartitionName(tenantId);
    if (createIfAbsent) {
        amzaService.getRingWriter().ensureSubRing(partitionName.getRingName(), readTrackingRingSize, readTrackingRoutingTimeoutMillis);
        amzaService.createPartitionIfAbsent(partitionName, partitionProperties.or(readTrackingProperties));
    } else if (!amzaService.hasPartition(partitionName)) {
        return new HostPort[0];
    }

    AmzaService.AmzaPartitionRoute partitionRoute = amzaService.getPartitionRoute(partitionName, readTrackingRoutingTimeoutMillis);
    if (!partitionRoute.disposed && partitionRoute.leader != null) {
        return new HostPort[]{new HostPort(partitionRoute.leader.ringHost.getHost(), partitionRoute.leader.ringHost.getPort())};
    } else {
        return partitionRoute.orderedMembers.stream()
            .map(ringMemberAndHost -> new HostPort(ringMemberAndHost.ringHost.getHost(), ringMemberAndHost.ringHost.getPort()))
            .toArray(HostPort[]::new);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:22,代码来源:AmzaWALUtil.java

示例6: getClients

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@Override
public int[] getClients(ConnectionDescriptor[] connectionDescriptors) {
    int len = connectionDescriptors.length;
    int[] indexes = new int[len];
    int pos = 0;
    int preferredIndex = -1;
    for (int i = 0; i < connectionDescriptors.length; i++) {
        HostPort hostPort = connectionDescriptors[i].getHostPort();
        InstanceDescriptor instanceDescriptor = connectionDescriptors[i].getInstanceDescriptor();
        if (MiruHostProvider.checkEquals(host,
            instanceDescriptor.instanceName, instanceDescriptor.instanceKey,
            hostPort.getHost(), hostPort.getPort())) {
            indexes[0] = i;
            pos = 1;
            preferredIndex = i;
            break;
        }
    }
    for (int i = 0; i < connectionDescriptors.length; i++) {
        if (i != preferredIndex) {
            indexes[pos] = i;
            pos++;
        }
    }
    return indexes;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:27,代码来源:MiruQueryRouting.java

示例7: getLazyTenantRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@GET
@Path("/routing/lazyTenant/{type}/{tenantId}/{createIfAbsent}")
@Produces(MediaType.APPLICATION_JSON)
public Response getLazyTenantRoutingGroup(@PathParam("type") RoutingGroupType routingGroupType,
    @PathParam("tenantId") String tenantId,
    @PathParam("createIfAbsent") boolean createIfAbsent) {
    try {
        long start = System.currentTimeMillis();
        HostPort[] routingGroup = walDirector.getTenantRoutingGroup(routingGroupType, new MiruTenantId(tenantId.getBytes(Charsets.UTF_8)), createIfAbsent);
        stats.ingressed("/routing/lazyTenant/" + routingGroupType.name() + "/" + tenantId, 1, System.currentTimeMillis() - start);
        return responseHelper.jsonResponse(routingGroup);
    } catch (Exception x) {
        log.error("Failed calling getLazyTenantRoutingGroup({},{})", new Object[] { routingGroupType, tenantId }, x);
        return responseHelper.errorResponse("Server error", x);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:17,代码来源:AmzaWALEndpoints.java

示例8: getTenantPartitionRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@GET
@Path("/routing/tenantPartition/{type}/{tenantId}/{partitionId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTenantPartitionRoutingGroup(@PathParam("type") RoutingGroupType routingGroupType,
    @PathParam("tenantId") String tenantId,
    @PathParam("partitionId") int partitionId) {
    try {
        long start = System.currentTimeMillis();
        HostPort[] routingGroup = walDirector.getTenantPartitionRoutingGroup(routingGroupType, new MiruTenantId(tenantId.getBytes(Charsets.UTF_8)),
            MiruPartitionId.of(partitionId), true);
        stats.ingressed("/routing/tenantPartition/" + routingGroupType.name() + "/" + tenantId, 1, System.currentTimeMillis() - start);
        return responseHelper.jsonResponse(routingGroup);
    } catch (Exception x) {
        log.error("Failed calling getTenantPartitionRoutingGroup({},{},{})", new Object[] { routingGroupType, tenantId, partitionId }, x);
        return responseHelper.errorResponse("Server error", x);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:18,代码来源:AmzaWALEndpoints.java

示例9: getLazyTenantPartitionRoutingGroupV2

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@GET
@Path("/routing/lazyTenantPartition/{type}/{tenantId}/{partitionId}/{createIfAbsent}")
@Produces(MediaType.APPLICATION_JSON)
public Response getLazyTenantPartitionRoutingGroupV2(@PathParam("type") RoutingGroupType routingGroupType,
    @PathParam("tenantId") String tenantId,
    @PathParam("partitionId") int partitionId,
    @PathParam("createIfAbsent") boolean createIfAbsent) {
    try {
        long start = System.currentTimeMillis();
        HostPort[] routingGroup = walDirector.getTenantPartitionRoutingGroup(routingGroupType, new MiruTenantId(tenantId.getBytes(Charsets.UTF_8)),
            MiruPartitionId.of(partitionId), createIfAbsent);
        stats.ingressed("/routing/lazyTenantPartition/" + routingGroupType.name() + "/" + tenantId, 1, System.currentTimeMillis() - start);
        return responseHelper.jsonResponse(routingGroup);
    } catch (Exception x) {
        log.error("Failed calling getLazyTenantPartitionRoutingGroup({},{},{},{})",
            new Object[] { routingGroupType, tenantId, partitionId, createIfAbsent }, x);
        return responseHelper.errorResponse("Server error", x);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:20,代码来源:AmzaWALEndpoints.java

示例10: getTenantStreamRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@GET
@Path("/routing/tenantStream/{type}/{tenantId}/{streamId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTenantStreamRoutingGroup(@PathParam("type") RoutingGroupType routingGroupType,
    @PathParam("tenantId") String tenantId,
    @PathParam("streamId") String streamId) {
    try {
        long start = System.currentTimeMillis();
        HostPort[] routingGroup = walDirector.getTenantStreamRoutingGroup(routingGroupType, new MiruTenantId(tenantId.getBytes(Charsets.UTF_8)),
            new MiruStreamId(streamId.getBytes(Charsets.UTF_8)), true);
        stats.ingressed("/routing/tenantStream/" + routingGroupType.name() + "/" + tenantId, 1, System.currentTimeMillis() - start);
        return responseHelper.jsonResponse(routingGroup);
    } catch (Exception x) {
        log.error("Failed calling getTenantStreamRoutingGroup({},{},{})", new Object[] { routingGroupType, tenantId, streamId }, x);
        return responseHelper.errorResponse("Server error", x);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:18,代码来源:RCVSWALEndpoints.java

示例11: getLazyTenantStreamRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
@GET
@Path("/routing/lazyTenantStream/{type}/{tenantId}/{streamId}/{createIfAbsent}")
@Produces(MediaType.APPLICATION_JSON)
public Response getLazyTenantStreamRoutingGroup(@PathParam("type") RoutingGroupType routingGroupType,
    @PathParam("tenantId") String tenantId,
    @PathParam("streamId") String streamId,
    @PathParam("createIfAbsent") boolean createIfAbsent) {
    try {
        long start = System.currentTimeMillis();
        HostPort[] routingGroup = walDirector.getTenantStreamRoutingGroup(routingGroupType, new MiruTenantId(tenantId.getBytes(Charsets.UTF_8)),
            new MiruStreamId(streamId.getBytes(Charsets.UTF_8)), createIfAbsent);
        stats.ingressed("/routing/lazyTenantStream/" + routingGroupType.name() + "/" + tenantId, 1, System.currentTimeMillis() - start);
        return responseHelper.jsonResponse(routingGroup);
    } catch (Exception x) {
        log.error("Failed calling getLazyTenantStreamRoutingGroup({},{},{},{})",
            new Object[] { routingGroupType, tenantId, streamId, createIfAbsent }, x);
        return responseHelper.errorResponse("Server error", x);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:20,代码来源:RCVSWALEndpoints.java

示例12: call

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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);
    });
}
 
开发者ID:jivesoftware,项目名称:amza,代码行数:17,代码来源:RingHostHttpClientProvider.java

示例13: getTenantRoutingGroup

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的package包/类
private HostPort[] getTenantRoutingGroup(RoutingGroupType routingGroupType, MiruTenantId tenantId, boolean createIfAbsent) throws Exception {
    return send(tenantId, "getTenantRoutingGroup", httpClient -> {
        HttpResponse httpResponse = httpClient.get(
            "/miru/wal/amza/routing/lazyTenant" +
                "/" + routingGroupType.name() +
                "/" + tenantId.toString() +
                "/" + createIfAbsent,
            null);
        HostPort[] response = responseMapper.extractResultFromResponse(httpResponse, HostPort[].class, null);
        return new ClientResponse<>(response, true);
    });
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:13,代码来源:AmzaHttpWALClient.java

示例14: sendWithTenantPartition

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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

示例15: sendWithTenant

import com.jivesoftware.os.routing.bird.shared.HostPort; //导入依赖的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


注:本文中的com.jivesoftware.os.routing.bird.shared.HostPort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。