Package com.alu.e3.rate.model

Examples of com.alu.e3.rate.model.LimitCheckResult


    RateLimitProcessor rateProcessor = new RateLimitProcessor();
    rateProcessor.setGatewayRateMger(new IGatewayRateManager() {

      @Override
      public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
        LimitCheckResult result = new LimitCheckResult();
        return result;
      }

    });
View Full Code Here


    RateLimitProcessor rateProcessor = new RateLimitProcessor();
    rateProcessor.setGatewayRateMger(new IGatewayRateManager() {

      @Override
      public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
        LimitCheckResult result = new LimitCheckResult();
        result.setActionType(ActionType.REJECT);
        return result;
      }
    });

    checkRate.whenAnyExchangeReceived(rateProcessor);
View Full Code Here

  class AlwaysAllowed implements IGatewayRateManager {

    @Override
    public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
      LimitCheckResult result = new LimitCheckResult();
      return result;
    }
View Full Code Here

  class NeverAllowed implements IGatewayRateManager {

    @Override

    public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
      LimitCheckResult result = new LimitCheckResult();
      result.setActionType(ActionType.REJECT);
      return result;
    }
View Full Code Here

    apiCallStatus.apiCallIsSuccess = true;
    apiCallStatus.apiCallAction = null;
   
    RateLimitParams params = new RateLimitParams();
    params.isTDREnabled = isTDREnabled;
    params.result = new LimitCheckResult();
    params.authIdentity = authIdentity;
   
    boolean mustResetRateLimit = gatewayRateValidator.isRateLimitInvalid(currentTime);
   
    // contain the id of the lock to unlocks locks in case of throw exception
View Full Code Here

      throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "The property " + ExchangeConstantKeys.E3_AUTH_IDENTITY.toString() + " is required to check the rate limits.");
    }

    boolean isTDREnabled = exchange.getProperty(ExchangeConstantKeys.E3_TDR_ENABLED.toString(), boolean.class);
    AuthIdentity authIdentity = (AuthIdentity) property;
    LimitCheckResult limitCheckResult = rateManager.isAllowed(authIdentity, isTDREnabled);

    if(isTDREnabled){
      /**
       * Put some TDR data into into service
       */
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA, limitCheckResult.isOverQuota());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_SEC, limitCheckResult.isOverSecond());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MIN, limitCheckResult.isOverMinute());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_DAY, limitCheckResult.isOverDay());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_WEEK, limitCheckResult.isOverWeek());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MONTH, limitCheckResult.isOverMonth());

      for(String tdrName : limitCheckResult.getTdrValues().keySet()){
        List<TdrGenerationRule> genRules = limitCheckResult.getTdrValues().get(tdrName);
        for(TdrGenerationRule genRule : genRules){
          TDRDataService.addNewTdrGenerationRule(exchange, genRule, tdrName);
        }
      }
    }


    // Route allowed if null - no action error defined
    if (limitCheckResult != null && limitCheckResult.getActionType() != null) {
      if(isTDREnabled) {
        exchange.setProperty(ExchangeConstantKeys.E3_RATELIMIT_ACTION.toString(), limitCheckResult.getActionType().toString());
        TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_ACTION, limitCheckResult.getActionType().toString());
      }

      // Log - Will be based on the Logging Framework developed internally
      //log.debug("Route rate limit for API " + (authIdentity.getApi()==null ? "(no API)" : authIdentity.getApi().getId()) + " exeeded" + ((authIdentity.getAuth()==null) ? "": "by " + authIdentity.getAuth().getId()));
      // TDR Notification - not yet implemented
      // HTTP Status Code 429 - to be return by the error processor of the route

      if(limitCheckResult.getActionType().equals(ActionType.REJECT)) {
        throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "Rate limit exceeded. " + limitCheckResult.getActionTypeMessage(), limitCheckResult.getActionType().toString());
      }
    }

  }
View Full Code Here

   
    return perfWatch;
  }
 
  public TdrStreamWriter(File dir) throws TransformerConfigurationException {
    this(new RotatableFileWriterProvider(dir, TDR_FILE_SIZE, TDR_FILE_AGE) {
      @Override
      protected String getFileName() {
        return "tdrs." + System.currentTimeMillis() + ".xml";   // TDR file name
      }
View Full Code Here

   
    topologyWatcher.setPollingInterval(POLLING_INTERVAL);
   
    topologyClient = new DummyTopologyClient();
   
    healthCheckFactory = new DummyHealthCheckFactory();
   
    setHealthCheckGateways(gatewayList);
    setHealthCheckGatewaysActive(gatewayActiveList);
    setHealthCheckSpeakers(activeSpeakerList);
   
View Full Code Here

  private void createTestResources(String[] gatewayList, String[] gatewayActiveList, String[] activeSpeakerList) {
    topologyWatcher = new TopologyWatcher();
   
    topologyWatcher.setPollingInterval(POLLING_INTERVAL);
   
    topologyClient = new DummyTopologyClient();
   
    healthCheckFactory = new DummyHealthCheckFactory();
   
    setHealthCheckGateways(gatewayList);
    setHealthCheckGatewaysActive(gatewayActiveList);
View Full Code Here

   
    return instance;
  }
 
  private void createTestResources(String[] gatewayList, String[] gatewayActiveList, String[] activeSpeakerList) {
    topologyWatcher = new TopologyWatcher();
   
    topologyWatcher.setPollingInterval(POLLING_INTERVAL);
   
    topologyClient = new DummyTopologyClient();
   
View Full Code Here

TOP

Related Classes of com.alu.e3.rate.model.LimitCheckResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.