本文整理匯總了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);
});
}
示例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);
});
}
示例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);
});
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
});
}
示例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);
});
}
示例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();
}
}
示例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();
}
}