Package com.alu.e3.gateway.targethealthcheck

Examples of com.alu.e3.gateway.targethealthcheck.ITargetHealthCheckService


    if(allowedHttpMethods==null || allowedHttpMethods.isEmpty())
      return;

    Object methodheader = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
    if(methodheader == null){
      throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "No HTTP Method");
    }
   
    for(String m : allowedHttpMethods){
      if(m.equals(methodheader.toString().toLowerCase())){
        return;
      }
    }
   
    throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "Method "+methodheader.toString()+" not allowed");
  }
View Full Code Here


    this.apiId = apiId;
  }

  @Override
  public Producer createProducer() throws Exception {
    return new IpWhiteListProducer(this, dataManager, apiId);
  }
View Full Code Here

  {
    ServletContextHandler context = new ServletContextHandler(server, "/",
        ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    context.setConnectorNames(new String[] {connector.getName()});

    DispatchingContinuationServlet servlet = new DispatchingContinuationServlet();
    servlet.setDispatcher(new TreeDispatcher<HttpConsumer>());
    Long timeout = endpoint.getContinuationTimeout() != null ? endpoint
        .getContinuationTimeout() : getContinuationTimeout();
    if (timeout != null) {
      servlet.setContinuationTimeout(timeout);
    }

    ServletHolder holder = new ServletHolder();
    holder.setServlet(servlet);
    context.addServlet(holder, "/*");
 
View Full Code Here

        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");
              }
View Full Code Here

      if(usage == 0) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("Usage == 0, removing target #{}", targetHostReference);
        }
        // Unregistering it from the HealthCheck service
        ITargetHealthCheckService healthCheckService = target.getHealthCheckService();
        if(healthCheckService != null) {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Unregistering target #{} from HealthCheckService {}", targetHostReference, healthCheckService.getName());
          }
          healthCheckService.unregisterTarget(target);
          target.setHealthCheckService(null);
        }

        // Removing it from the local targets map
        targets.remove(targetHostReference);
View Full Code Here

    if (LOG.isDebugEnabled())
      LOG.debug("Update API ID: {}", apiId);

    // check API ID same in Pay-load/URL
    if (api == null || api.getId() == null)
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_NOT_PROVIDED, "API ID missing in the body for Update operation"));

    if (!api.getId().equals(apiId))
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_MISMATCH, "API ID not the same in URL vs Body for Update operation: +" + apiId + "/" + apiId));

    Action action = new Action() {
      protected Object doAction(Object... params) {
        try {
          apiService.update(api);
View Full Code Here

    Action action = new Action() {

      protected Object doAction(Object... params) {
        try {
          Api api = apiService.get(apiId);
          return new ApiResponse(ApiResponse.SUCCESS, api);

        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
View Full Code Here

    provisionData.setValidation(fromDataModel(api.getValidation()));
    provisionData.setHeaderTransEnabled(api.getHeaderTransEnabled());
    provisionData.setInternal(api.getInternal());
   
    ApiProxySettings proxySettings = null;
   
    if(api.isUseGlobalProxy()){
      proxySettings = new ApiProxySettings();
      proxySettings.setGlobalProxy(new ApiProxySettings.GlobalProxy());
    }else if(api.getForwardProxy() != null){
      proxySettings = new ApiProxySettings();
      proxySettings.setLocalProxy(fromDataModel(api.getForwardProxy()));
    }
    provisionData.setProxySettings(proxySettings);
   
    return provisionData;
  }
View Full Code Here

        try {
          apiService.create(api);
        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
        return new ApiResponse(ApiResponse.SUCCESS, api.getId());
      }
    };

    return execute(action, (Object) null);
   
View Full Code Here

    Action action = new Action() {
      protected Object doAction(Object... params) {
        try {
          apiService.update(api);
          return new ApiResponse(ApiResponse.SUCCESS, apiId);

        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
      }
View Full Code Here

TOP

Related Classes of com.alu.e3.gateway.targethealthcheck.ITargetHealthCheckService

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.