本文整理汇总了Java中com.hubspot.baragon.models.BaragonRequest.getLoadBalancerService方法的典型用法代码示例。如果您正苦于以下问题:Java BaragonRequest.getLoadBalancerService方法的具体用法?Java BaragonRequest.getLoadBalancerService怎么用?Java BaragonRequest.getLoadBalancerService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hubspot.baragon.models.BaragonRequest
的用法示例。
在下文中一共展示了BaragonRequest.getLoadBalancerService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: revert
import com.hubspot.baragon.models.BaragonRequest; //导入方法依赖的package包/类
private Response revert(BaragonRequest request, Optional<BaragonService> maybeOldService, boolean delayReload, Optional<Integer> batchItemNumber) throws Exception {
final ServiceContext update;
if (movedOffLoadBalancer(maybeOldService)) {
update = new ServiceContext(request.getLoadBalancerService(), Collections.<UpstreamInfo>emptyList(), System.currentTimeMillis(), false);
} else {
update = new ServiceContext(maybeOldService.get(), stateDatastore.getUpstreams(maybeOldService.get().getServiceId()), System.currentTimeMillis(), true);
}
triggerTesting();
LOG.info("Reverting to {}", update);
try {
configHelper.apply(update, Optional.<BaragonService>absent(), false, request.isNoReload(), request.isNoValidate(), delayReload, batchItemNumber);
} catch (MissingTemplateException e) {
if (serviceDidNotPreviouslyExist(maybeOldService)) {
return Response.ok().build();
} else {
throw e;
}
}
return Response.ok().build();
}
示例2: getApplyContext
import com.hubspot.baragon.models.BaragonRequest; //导入方法依赖的package包/类
private ServiceContext getApplyContext(BaragonRequest request) throws Exception {
if (movedOffLoadBalancer(request)) {
return new ServiceContext(request.getLoadBalancerService(), Collections.<UpstreamInfo>emptyList(), System.currentTimeMillis(), false);
} else if (!request.getReplaceUpstreams().isEmpty()) {
return new ServiceContext(request.getLoadBalancerService(), request.getReplaceUpstreams(), System.currentTimeMillis(), true);
} else {
List<UpstreamInfo> upstreams = new ArrayList<>();
upstreams.addAll(request.getAddUpstreams());
for (UpstreamInfo existingUpstream : stateDatastore.getUpstreams(request.getLoadBalancerService().getServiceId())) {
boolean present = false;
boolean toRemove = false;
for (UpstreamInfo currentUpstream : upstreams) {
if (UpstreamInfo.upstreamAndGroupMatches(currentUpstream, existingUpstream)) {
present = true;
break;
}
}
for (UpstreamInfo upstreamToRemove : request.getRemoveUpstreams()) {
if (UpstreamInfo.upstreamAndGroupMatches(upstreamToRemove, existingUpstream)) {
toRemove = true;
break;
}
}
if (!present && !toRemove) {
upstreams.add(existingUpstream);
}
}
return new ServiceContext(request.getLoadBalancerService(), upstreams, System.currentTimeMillis(), true);
}
}
示例3: getBasePathConflicts
import com.hubspot.baragon.models.BaragonRequest; //导入方法依赖的package包/类
public Map<String, String> getBasePathConflicts(BaragonRequest request) {
final BaragonService service = request.getLoadBalancerService();
final Map<String, String> loadBalancerServiceIds = Maps.newHashMap();
for (String loadBalancerGroup : service.getLoadBalancerGroups()) {
Optional<BaragonGroup> maybeGroup = loadBalancerDatastore.getLoadBalancerGroup(loadBalancerGroup);
for (String path : service.getAllPaths()) {
final Optional<String> maybeServiceIdForPath = loadBalancerDatastore.getBasePathServiceId(loadBalancerGroup, path);
if (maybeServiceIdForPath.isPresent() && !maybeServiceIdForPath.get().equals(service.getServiceId())) {
if (!request.getReplaceServiceId().isPresent() || (request.getReplaceServiceId().isPresent() && !request.getReplaceServiceId().get().equals(maybeServiceIdForPath.get()))) {
loadBalancerServiceIds.put(loadBalancerGroup, maybeServiceIdForPath.get());
continue;
}
}
if (!path.startsWith("/")) {
if (maybeGroup.isPresent() && maybeGroup.get().getDefaultDomain().isPresent() && path.startsWith(maybeGroup.get().getDefaultDomain().get())) {
Optional<String> maybeServiceForDefaultDomainPath = loadBalancerDatastore.getBasePathServiceId(loadBalancerGroup, path.replace(maybeGroup.get().getDefaultDomain().get(), ""));
if (maybeServiceForDefaultDomainPath.isPresent() && !maybeServiceForDefaultDomainPath.get().equals(service.getServiceId())) {
if (!request.getReplaceServiceId().isPresent() || (request.getReplaceServiceId().isPresent() && !request.getReplaceServiceId().get().equals(maybeServiceForDefaultDomainPath.get()))) {
loadBalancerServiceIds.put(loadBalancerGroup, maybeServiceForDefaultDomainPath.get());
}
}
}
}
}
}
return loadBalancerServiceIds;
}