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


Java BaragonRequest.getLoadBalancerService方法代码示例

本文整理汇总了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();
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:24,代码来源:AgentRequestManager.java

示例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);
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:32,代码来源:AgentRequestManager.java

示例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;
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:30,代码来源:RequestManager.java


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