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


Java BaragonRequest类代码示例

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


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

示例1: sendBaragonRequest

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private SingularityLoadBalancerUpdate sendBaragonRequest(LoadBalancerRequestId loadBalancerRequestId, BaragonRequest loadBalancerRequest, LoadBalancerMethod method) {
  try {
    LOG.trace("Preparing to send request {}", loadBalancerRequest);

    final BoundRequestBuilder requestBuilder = httpClient.preparePost(loadBalancerUri)
      .addHeader(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON)
      .setBody(objectMapper.writeValueAsBytes(loadBalancerRequest));

    if (loadBalancerQueryParams.isPresent()) {
      addAllQueryParams(requestBuilder, loadBalancerQueryParams.get());
    }

    return sendRequestWrapper(loadBalancerRequestId, method, requestBuilder.build(), BaragonRequestState.FAILED);
  } catch (IOException e) {
    return new SingularityLoadBalancerUpdate(BaragonRequestState.UNKNOWN, loadBalancerRequestId, Optional.of(e.getMessage()), System.currentTimeMillis(), method, Optional.of(loadBalancerUri));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:LoadBalancerClientImpl.java

示例2: enqueue

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
@Override
public SingularityLoadBalancerUpdate enqueue(LoadBalancerRequestId loadBalancerRequestId, SingularityRequest request, SingularityDeploy deploy, List<SingularityTask> add,
    List<SingularityTask> remove) {
  final List<String> serviceOwners = request.getOwners().or(Collections.<String> emptyList());
  final Set<String> loadBalancerGroups = deploy.getLoadBalancerGroups().or(Collections.<String>emptySet());
  final BaragonService lbService = new BaragonService(request.getId(), serviceOwners, deploy.getServiceBasePath().get(),
    deploy.getLoadBalancerAdditionalRoutes().or(Collections.<String>emptyList()), loadBalancerGroups, deploy.getLoadBalancerOptions().orNull(),
    deploy.getLoadBalancerTemplate(), deploy.getLoadBalancerDomains().or(Collections.<String>emptySet()));

  final List<UpstreamInfo> addUpstreams = tasksToUpstreams(add, loadBalancerRequestId.toString());
  final List<UpstreamInfo> removeUpstreams = tasksToUpstreams(remove, loadBalancerRequestId.toString());

  final BaragonRequest loadBalancerRequest = new BaragonRequest(loadBalancerRequestId.toString(), lbService, addUpstreams, removeUpstreams);

  return sendBaragonRequest(loadBalancerRequestId, loadBalancerRequest, LoadBalancerMethod.ENQUEUE);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:LoadBalancerClientImpl.java

示例3: enqueue

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
@Override
public SingularityLoadBalancerUpdate enqueue(LoadBalancerRequestId loadBalancerRequestId, SingularityRequest request, SingularityDeploy deploy, List<SingularityTask> add,
    List<SingularityTask> remove) {
  final List<String> serviceOwners = request.getOwners().or(Collections.<String> emptyList());
  final Set<String> loadBalancerGroups = deploy.getLoadBalancerGroups().or(Collections.<String>emptySet());
  final BaragonService lbService = new BaragonService(deploy.getLoadBalancerServiceIdOverride().or(request.getId()), serviceOwners, deploy.getServiceBasePath().get(),
    deploy.getLoadBalancerAdditionalRoutes().or(Collections.<String>emptyList()), loadBalancerGroups, deploy.getLoadBalancerOptions().orNull(),
    deploy.getLoadBalancerTemplate(), deploy.getLoadBalancerDomains().or(Collections.<String>emptySet()));

  final List<UpstreamInfo> addUpstreams = tasksToUpstreams(add, loadBalancerRequestId.toString(), deploy.getLoadBalancerUpstreamGroup());
  final List<UpstreamInfo> removeUpstreams = tasksToUpstreams(remove, loadBalancerRequestId.toString(), deploy.getLoadBalancerUpstreamGroup());

  final BaragonRequest loadBalancerRequest = new BaragonRequest(loadBalancerRequestId.toString(), lbService, addUpstreams, removeUpstreams);

  return sendBaragonRequest(loadBalancerRequestId, loadBalancerRequest, LoadBalancerMethod.ENQUEUE);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:17,代码来源:LoadBalancerClientImpl.java

示例4: 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

示例5: getResponseFromActiveRequests

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private Optional<BaragonResponse> getResponseFromActiveRequests(String requestId) {
  if (requestDatastore.activeRequestExists(requestId)) {
    final Optional<InternalRequestStates> maybeStatus = requestDatastore.getRequestState(requestId);

    if (!maybeStatus.isPresent()) {
      return Optional.absent();
    }

    final Optional<BaragonRequest> maybeRequest = requestDatastore.getRequest(requestId);
    if (!maybeRequest.isPresent()) {
      return Optional.absent();
    }

    return Optional.of(new BaragonResponse(requestId, InternalStatesMap.getRequestState(maybeStatus.get()), requestDatastore.getRequestMessage(requestId), Optional.of(agentResponseDatastore.getLastResponses(requestId)), maybeRequest));
  } else {
    return Optional.absent();
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:19,代码来源:RequestManager.java

示例6: revertBasePath

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
public void revertBasePath(BaragonRequest request) {
  Optional<BaragonService> maybeOriginalService = Optional.absent();
  if (request.getReplaceServiceId().isPresent()) {
    maybeOriginalService = stateDatastore.getService(request.getReplaceServiceId().get());
  }
  if (!maybeOriginalService.isPresent()) {
    maybeOriginalService = stateDatastore.getService(request.getLoadBalancerService().getServiceId());
  }
  // if the request is not in the state datastore (ie. no previous request) clear the base path lock
  if (!maybeOriginalService.isPresent()) {
    for (String loadBalancerGroup : request.getLoadBalancerService().getLoadBalancerGroups()) {
      for (String path : request.getLoadBalancerService().getAllPaths()) {
        loadBalancerDatastore.clearBasePath(loadBalancerGroup, path);
      }
    }
  }

  // if we changed the base path, revert it to the old one
  if (maybeOriginalService.isPresent() && request.getReplaceServiceId().isPresent() && maybeOriginalService.get().getServiceId().equals(request.getReplaceServiceId().get())) {
    lockBasePaths(request.getLoadBalancerService().getLoadBalancerGroups(), request.getLoadBalancerService().getAllPaths(), maybeOriginalService.get().getServiceId());
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:23,代码来源:RequestManager.java

示例7: commitRequest

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
public synchronized void commitRequest(BaragonRequest request) throws Exception {
  RequestAction action = request.getAction().or(RequestAction.UPDATE);
  Optional<BaragonService> maybeOriginalService = getOriginalService(request);

  switch(action) {
    case UPDATE:
    case REVERT:
      updateStateDatastore(request);
      clearChangedBasePaths(request, maybeOriginalService);
      clearBasePathsFromUnusedLbs(request, maybeOriginalService);
      removeOldService(request, maybeOriginalService);
      clearBasePathsWithNoUpstreams(request);
      break;
    case DELETE:
      clearChangedBasePaths(request, maybeOriginalService);
      clearBasePathsFromUnusedLbs(request, maybeOriginalService);
      deleteRemovedServices(request);
      clearBasePathsWithNoUpstreams(request);
      break;
    default:
      LOG.debug(String.format("No updates to commit for request action %s", action));
      break;
  }
  updateLastRequestForGroups(request);
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:26,代码来源:RequestManager.java

示例8: clearChangedBasePaths

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private void clearChangedBasePaths(BaragonRequest request, Optional<BaragonService> maybeOriginalService) {
  if (maybeOriginalService.isPresent()) {
    try {
      List<String> newPaths = request.getLoadBalancerService().getAllPaths();
      for (String oldPath : maybeOriginalService.get().getAllPaths()) {
        if (!newPaths.contains(oldPath)) {
          for (String loadBalancerGroup : maybeOriginalService.get().getLoadBalancerGroups()) {
            if (loadBalancerDatastore.getBasePathServiceId(loadBalancerGroup, oldPath).or("").equals(maybeOriginalService.get().getServiceId())) {
              loadBalancerDatastore.clearBasePath(loadBalancerGroup, oldPath);
            }
          }
        }
      }
    } catch (Exception e) {
      LOG.error("Error clearing base path", e);
    }
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:19,代码来源:RequestManager.java

示例9: clearBasePathsFromUnusedLbs

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private void clearBasePathsFromUnusedLbs(BaragonRequest request, Optional<BaragonService> maybeOriginalService) {
  if (maybeOriginalService.isPresent()) {
    Set<String> removedLbGroups = maybeOriginalService.get().getLoadBalancerGroups();
    removedLbGroups.removeAll(request.getLoadBalancerService().getLoadBalancerGroups());
    if (!removedLbGroups.isEmpty()) {
      try {
        for (String loadBalancerGroup : removedLbGroups) {
          for (String path : maybeOriginalService.get().getAllPaths()) {
            if (loadBalancerDatastore.getBasePathServiceId(loadBalancerGroup, path).or("").equals(maybeOriginalService.get().getServiceId())) {
              loadBalancerDatastore.clearBasePath(loadBalancerGroup, path);
            }
          }
        }
      } catch (Exception e) {
        LOG.error("Error clearing base path", e);
      }
    }
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:20,代码来源:RequestManager.java

示例10: handleCheckRevertResponse

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private InternalRequestStates handleCheckRevertResponse(BaragonRequest request, InternalRequestStates currentState) {
  final Map<String, Collection<AgentResponse>> agentResponses;

  switch (agentManager.getRequestsStatus(request, InternalStatesMap.getRequestType(currentState))) {
    case FAILURE:
      agentResponses = agentManager.getAgentResponses(request.getLoadBalancerRequestId());
      requestManager.setRequestMessage(request.getLoadBalancerRequestId(), String.format("Apply failed {%s}, %s failed {%s}", buildResponseString(agentResponses, AgentRequestType.APPLY), InternalStatesMap.getRequestType(currentState).name(), buildResponseString(agentResponses, InternalStatesMap.getRequestType(currentState))));
      return InternalStatesMap.getFailureState(currentState);
    case SUCCESS:
      agentResponses = agentManager.getAgentResponses(request.getLoadBalancerRequestId());
      requestManager.setRequestMessage(request.getLoadBalancerRequestId(), String.format("Apply failed {%s}, %s OK.", buildResponseString(agentResponses, AgentRequestType.APPLY), InternalStatesMap.getRequestType(currentState).name()));
      requestManager.revertBasePath(request);
      return InternalStatesMap.getSuccessState(currentState);
    case RETRY:
      return InternalStatesMap.getRetryState(currentState);
    default:
      return InternalStatesMap.getWaitingState(currentState);
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:20,代码来源:BaragonRequestWorker.java

示例11: testNonExistentLoadBalancerGroup

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
@Test
public void testNonExistentLoadBalancerGroup(RequestManager requestManager, BaragonRequestWorker requestWorker) {
  final String requestId = "test-126";
  Set<String> lbGroup = new HashSet<>();
  lbGroup.add(FAKE_LB_GROUP);
  final BaragonService service = new BaragonService("testservice1", Collections.<String>emptyList(), "/test", lbGroup, Collections.<String, Object>emptyMap());

  final UpstreamInfo upstream = new UpstreamInfo("testhost:8080", Optional.of(requestId), Optional.<String>absent());

  final BaragonRequest request = new BaragonRequest(requestId, service, ImmutableList.of(upstream), ImmutableList.<UpstreamInfo>of(), Optional.<String>absent());

  try {
    assertResponseStateAbsent(requestManager, requestId);

    LOG.info("Going to enqueue request: {}", request);
    requestManager.enqueueRequest(request);

    assertResponseStateExists(requestManager, requestId, BaragonRequestState.WAITING);

    requestWorker.run();

    assertResponseStateExists(requestManager, requestId, BaragonRequestState.INVALID_REQUEST_NOOP);
  } catch (Exception e) {
    throw Throwables.propagate(e);
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:27,代码来源:RequestTest.java

示例12: delete

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
@Override
public SingularityLoadBalancerUpdate delete(LoadBalancerRequestId loadBalancerRequestId, String requestId, Set<String> loadBalancerGroups, String serviceBasePath) {
  final BaragonService lbService = new BaragonService(requestId, Collections.<String> emptyList(), serviceBasePath, loadBalancerGroups, Collections.<String, Object>emptyMap());
  final BaragonRequest loadBalancerRequest = new BaragonRequest(loadBalancerRequestId.toString(), lbService, Collections.<UpstreamInfo>emptyList(), Collections.<UpstreamInfo>emptyList(), Collections.<UpstreamInfo>emptyList(), Optional.<String>absent(), Optional.of(RequestAction.DELETE));

  return sendBaragonRequest(loadBalancerRequestId, loadBalancerRequest, LoadBalancerMethod.DELETE);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:LoadBalancerClientImpl.java

示例13: setupTestService

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private void setupTestService(String requestId, String serviceId, String basePath, List<String> additionalPaths, Optional<String> replaceServiceId, Optional<Map<String, Object>> options, Optional<String> template) {
  UpstreamInfo upstream = new UpstreamInfo(UPSTREAM, Optional.<String>absent(), Optional.<String>absent());
  BaragonService lbService = new BaragonService(serviceId, new ArrayList<String>(), basePath, additionalPaths,
      new HashSet<String>(Arrays.asList(LOAD_BALANCER_GROUP)), options.isPresent() ? options.get() : new HashMap<String, Object>(), template, Collections.<String>emptySet(), Optional.absent());
  
  BaragonRequest request = new BaragonRequest(requestId, lbService, Arrays.asList(upstream), new ArrayList<UpstreamInfo>(), replaceServiceId);
  baragonServiceClient.enqueueRequest(request);
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:9,代码来源:BaragonServiceTestIT.java

示例14: reload

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private Response reload(BaragonRequest request, boolean delayReload) throws Exception {
  if (!delayReload) {
    configHelper.checkAndReload();
  }
  mostRecentRequestId.set(request.getLoadBalancerRequestId());
  return Response.ok().build();
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:8,代码来源:AgentRequestManager.java

示例15: apply

import com.hubspot.baragon.models.BaragonRequest; //导入依赖的package包/类
private Response apply(BaragonRequest request, Optional<BaragonService> maybeOldService, boolean delayReload, Optional<Integer> batchItemNumber) throws Exception {
  final ServiceContext update = getApplyContext(request);
  triggerTesting();
  configHelper.apply(update, maybeOldService, true, request.isNoReload(), request.isNoValidate(), delayReload, batchItemNumber);
  mostRecentRequestId.set(request.getLoadBalancerRequestId());
  return Response.ok().build();
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:8,代码来源:AgentRequestManager.java


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