Package com.alu.e3.data.model.sub

Examples of com.alu.e3.data.model.sub.APIContext


  }


  private static final APIContext toDataModel(com.alu.e3.prov.restapi.model.ApiContext context) {
    if (context==null) throw new IllegalArgumentException("environment must not be null");
    APIContext apiContext = new APIContext();

    apiContext.setId            (context.getId());
    apiContext.setDefaultContext      (context.isDefaultContext());
    apiContext.setStatus          (toDataModel(context.getStatus()));
    apiContext.setMaxRateLimitTPMThreshold  (context.getMaxRateLimitTPMThreshold());
    apiContext.setMaxRateLimitTPMWarning  (context.getMaxRateLimitTPMWarning());
    apiContext.setMaxRateLimitTPSThreshold  (context.getMaxRateLimitTPSThreshold());
    apiContext.setMaxRateLimitTPSWarning  (context.getMaxRateLimitTPSWarning());
    if (context.getLoadBalancing() != null)
      apiContext.setLoadBalancing        (toDataModel(context.getLoadBalancing()));

    // Since the addition of MO call support
    // We can have no TargetHosts
    if (context.getTargetHosts()!=null)
      apiContext.getTargetHosts().addAll    (BeanConverterUtil.<TargetHost, com.alu.e3.prov.restapi.model.TargetHost>toDataModels(context.getTargetHosts()));

    return apiContext;
  }
View Full Code Here


    if(healthCheckService != null) {
      targetHealthCheck = new TargetHealthCheck();
      targetHealthCheck.setType(healthCheckService.getName());
    }
   
    APIContext context1 = new APIContext();
    context1.setId("test");
    context1.setDefaultContext(true);
    context1.getTargetHosts().add(targetHostWithUrlAndSite("http://www.google.fr", "LOCAL"));
    context1.getTargetHosts().add(targetHostWithUrlAndSite("http://www.google.com", "US"));
    context1.getTargetHosts().add(targetHostWithUrlAndSite("http://www.google.co.uk", "UK"));
   
    if(targetHealthCheck != null)
      context1.getLoadBalancing().setTargetHealthCheck(targetHealthCheck);
   
   
   
    APIContext context2 = new APIContext();
    context2.setId("production");
    context2.setDefaultContext(false);
    context2.getTargetHosts().add(targetHostWithUrlAndSite("http://www.apple.fr", "LOCAL"));
    context2.getTargetHosts().add(targetHostWithUrlAndSite("http://www.apple.com", "US"));
    context2.getTargetHosts().add(targetHostWithUrlAndSite("http://www.apple.co.uk", "UK"));
   
    if(targetHealthCheck != null)
      context2.getLoadBalancing().setTargetHealthCheck(targetHealthCheck);
   
    Api api = new Api();
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("/endpoint");
    api.getApiDetail().getContexts().add(context1);
View Full Code Here

  }

  private void populateBucketAndAPIIds() {

    for (ContextWrapper context : cachingTableContext.getAllValues()) {
      APIContext apiContext = context.getApiContext();

      if (apiContext != null) {
        usedBucketIds.add(apiContext.getBucketId());
      }
    }

    for (Policy policy : cachingTablePolicy.getAllValues()) {
      for (QuotaRLBucket bucket : policy.getAuthIds()) {
View Full Code Here

    for(ApiIds id : ids) {
      // Get the ApiContext by its ID (this map is populated on all gateways)
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Getting api context for api id {}", apiId);
      }
      APIContext context = dataManager.getApiContextById(id.getApiContextId());
     
      // Shouldn't be null...
      if(context != null) {
        // Prepare the list of TargetReference
        List<TargetReference> targetReferences = new ArrayList<TargetReference>();
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("Registering Context {} ({} TargetHosts)", context.getId(), context.getTargetHosts().size());
        }
       
        // Store requested HealthCheck service for later use
        ITargetHealthCheckService healthCheckService = null;
        String healthCheckServiceName = null;
       
        LoadBalancing lbConfig = context.getLoadBalancing();
        if(lbConfig.getTargetHealthCheck() != null) {
          healthCheckServiceName = lbConfig.getTargetHealthCheck().getType();
        }
       
        if(healthCheckServiceName != null) {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Will use HealthCheck service ", healthCheckServiceName);
          }
           
          // Getting corresponding HealthCheck Service
          healthCheckService = targetHealthCheckServices.get(healthCheckServiceName);
          if(healthCheckService != null) {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("Found a HealthCheckService ({}) for this name: {}", healthCheckService.getClass().getName(), healthCheckServiceName);
            }
          } else {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("No HealthCheckService found for this name: {}", healthCheckServiceName);
            }
          }
        } else {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Will NOT use HealthCheck service for following targets");
          }
        }
       
       
        // For each TargetHost, check if there is already a corresponding ManagedTargetHost
        for(TargetHost targetHost : context.getTargetHosts()) {
         
          /*
           * If the api has its own proxy settings, they were automatically set by the DataManager while loading the api. Nothing to do.
           * If the api uses global proxy settings,  we have to retrieve a reference on this shared instance
           */
         
          targetHost.setForwardProxy( api.isUseGlobalProxy() ? globalForwardProxy : api.getForwardProxy() );
         
          // Using a "hash differentiation string":
          // We need to take into account the HealthCheckService associated to a TargetHost
          // Ex: API #1 (http://www.apple.com|Ping), API #2 (http://www.apple.com|Telnet), API #3 (http://www.apple.com|Ping)
          // API #1 and #3 must have the same "Managed target" and #2 another one
          // (One HealthCheck service may check for a specific functionality status)
          String hashDifferentiationString = healthCheckServiceName == null ? "" : healthCheckServiceName;
          String managedReference = ManagedTargetHost.computeTargetHostHash(targetHost, hashDifferentiationString);
                 
          ManagedTargetHost target = targets.get(managedReference);   
          if(target == null) {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("No corresponding ManagedTarget, creating a new one");
            }
           
            // Instantiating and remembering managed target
            target = new ManagedTargetHost(targetHost);
            target.setReference(managedReference);
            targets.put(managedReference, target);
           
            // Registering managed target on health check service
            if(healthCheckService != null) {
              if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Target #{} registered on HealthCheck service {}", managedReference, healthCheckService.getName());
              }
             
              healthCheckService.registerTarget(target);
              target.setHealthCheckService(healthCheckService);
            } else {
              if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Target #{} not registered on HealthCheck service");
              }
            }
          } else {
            // We already have a ManagedTarget for this protocol+host+port+healthcheck
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("There is already a corresponding ManagedTarget: #{} ", managedReference);
            }
          }
         
          // Incrementing counter of use (used for unregister method)
          target.getNumberOfUse().incrementAndGet();
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("New usage for target #{}: {}", managedReference, target.getNumberOfUse());
          }
         
          // Adding this reference to the list that will be returned to the LoadBalancer later on
          TargetReference targetReference = new TargetReference();
          targetReference.setReference(managedReference);
          targetReference.setTargetHost(targetHost);
          targetReferences.add(targetReference);
        }
       
        // Put the list of TargetReferences in the appropriate map for this Api Context.
        map.put(context.getId(), targetReferences);
       
      } else {
        // Context null
        LOGGER.warn("No APIContext with that id {}, ignoring", id.getApiContextId());
      }
View Full Code Here

 
 
  @Override
  public APIContext getApiContextById(Integer id) {
    APIContext context = contexts.get(id);
    return context;
  }
View Full Code Here

  }

  private static final LoadBalancing toDataModel(com.alu.e3.prov.restapi.model.LoadBalancing loadBalancing) {
    if (loadBalancing==null) throw new IllegalArgumentException("loadBalancing must not be null");

    LoadBalancing lb = new LoadBalancing();
    lb.setLoadBalancingType(toDataModel(loadBalancing.getLoadBalancingType()));

    if(loadBalancing.getTargetHealthCheck() != null)
      lb.setTargetHealthCheck(toDataModel(loadBalancing.getTargetHealthCheck()));

    if(loadBalancing.getFailOver() != null)
      lb.setFailOver(toDataModel(loadBalancing.getFailOver()));

    return lb;
  }
View Full Code Here

  }

  public static final QuotaRLBucket toDataModel(com.alu.e3.prov.restapi.model.AuthIdsNoIdType authIds) {
    if (authIds==null) throw new IllegalArgumentException("authIds must not be null");

    QuotaRLBucket ids = new QuotaRLBucket();
    ids.getAuthIds().addAll(authIds.getAuthIds());
    ids.setId(authIds.getId());

    return ids;
  }
View Full Code Here

  private static final QuotaRLBucket toDataModel(com.alu.e3.prov.restapi.model.AuthIdsType authIds) {
    if (authIds==null) throw new IllegalArgumentException("authIds must not be null");
    if (authIds.getId()==null) throw new IllegalArgumentException("id must not be null");

    QuotaRLBucket ids = new QuotaRLBucket();
    ids.getAuthIds().addAll(authIds.getAuthIds());
    ids.setId(authIds.getId());

    return ids;
  }
View Full Code Here

    return t;
  }

  private static final SBAuthentication toDataModel(Authentication authentication) {
    if (authentication==null) return null; // throw new IllegalArgumentException("authentication must not be null");
    SBAuthentication s = new SBAuthentication();
    s.setType(authentication.getType());
    for (Key k : authentication.getData().getKey())
      s.getKeys().put(k.getName(), k.getValue());
    return s;
  }
View Full Code Here

  }

  private static final TargetHealthCheck toDataModel(com.alu.e3.prov.restapi.model.TargetHealthCheck targetHealthCheckType) {
    if (targetHealthCheckType==null) throw new IllegalArgumentException("targetHealthCheckType must not be null");

    TargetHealthCheck thc = new TargetHealthCheck();
    thc.setType(targetHealthCheckType.getType());

    return thc;
  }
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.sub.APIContext

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.