コード例 #1
0
 @Override
 public Long getSyncObjId() {
   StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class, getId());
   if (policy == null) {
     throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
   }
   LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
   if (lb == null) {
     throw new InvalidParameterValueException(
         "Unable to find load balancer rule for stickiness rule: " + id);
   }
   return lb.getNetworkId();
 }
コード例 #2
0
  @Override
  public void execute() throws ResourceAllocationException, ResourceUnavailableException {
    StickinessPolicy policy = null;
    boolean success = false;

    try {
      UserContext.current().setEventDetails("Rule Id: " + getEntityId());
      success = _lbService.applyLBStickinessPolicy(this);
      if (success) {
        // State might be different after the rule is applied, so get new object here
        policy = _entityMgr.findById(StickinessPolicy.class, getEntityId());
        LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
        LBStickinessResponse spResponse =
            _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
        setResponseObject(spResponse);
        spResponse.setResponseName(getCommandName());
      }
    } finally {
      if (!success || (policy == null)) {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create stickiness policy ");
      }
    }
  }