Example #1
0
 public void sendUpdateApplicationAndInstancesToWotaskds(
     MApplication changedApplication, NSArray wotaskdArray) {
   WOResponse[] responses =
       sendRequest(
           createUpdateRequestDictionary(
               null, null, changedApplication, changedApplication.instanceArray(), "configure"),
           wotaskdArray,
           true);
   NSDictionary[] responseDicts = generateResponseDictionaries(responses);
   getUpdateErrors(responseDicts, "configure", false, true, true, false);
 }
Example #2
0
  private String _generateModProxyConfig() {
    StringBuilder result = new StringBuilder();

    result.append("#\n");
    result.append("# Common configuration (if not already set)\n");
    result.append("#\n");
    result.append("ProxyRequests Off\nProxyVia Full\n");
    result.append("#\n");
    result.append("# Give us a name\n");
    result.append("#\n");
    result.append("RequestHeader append x-webobjects-adaptor-version \"mod_proxy\"\n\n\n");

    result.append("#\n");
    result.append("# Balancer routes\n");
    result.append("#\n");

    for (Enumeration<MApplication> e = siteConfig().applicationArray().objectEnumerator();
        e.hasMoreElements(); ) {
      MApplication anApp = e.nextElement();
      anApp.extractAdaptorValuesFromSiteConfig();

      String tmpAdaptor = siteConfig().woAdaptor();
      tmpAdaptor = StringUtils.removeEnd(tmpAdaptor, "/");

      NSArray<String> tmpPath = NSArray.componentsSeparatedByString(tmpAdaptor, "/");

      int count = tmpPath.count();
      String adaptorPath = "/" + tmpPath.get(count - 2) + "/" + tmpPath.get(count - 1) + "/";

      result.append("<Proxy balancer://" + anApp.name() + ".woa>\n");

      NSMutableArray<String> reversePathes = new NSMutableArray<String>();

      for (Enumeration<MInstance> e2 = anApp.instanceArray().objectEnumerator();
          e2.hasMoreElements(); ) {
        MInstance anInst = e2.nextElement();

        anInst.extractAdaptorValuesFromApplication();

        String host = anInst.values().valueForKey("hostName").toString();
        String port = anInst.values().valueForKey("port").toString();

        String url = "http://" + host + ":" + port + adaptorPath + anApp.name() + ".woa";

        result.append("\tBalancerMember ");
        result.append(url);
        result.append(" route=");
        result.append(_proxyBalancerRoute(anApp.name(), host, port));
        result.append('\n');

        reversePathes.add(url);
      }

      result.append("</Proxy>\n");
      result.append("ProxyPass ");
      result.append(adaptorPath);
      result.append(anApp.name());
      result.append(".woa balancer://");
      result.append(anApp.name());
      result.append(".woa stickysession=");
      result.append(_proxyBalancerCookieName(anApp.name()));
      result.append(" nofailover=On\n");

      for (int i = 0; i < reversePathes.count(); i++) {
        String url = reversePathes.objectAtIndex(i);
        result.append("ProxyPassReverse / ");
        result.append(url);
        result.append('\n');
      }
      result.append('\n');
    }

    result.append("#\n");
    result.append("# Balancer configuration\n");
    result.append("#\n");
    for (Enumeration<MApplication> e = siteConfig().applicationArray().objectEnumerator();
        e.hasMoreElements(); ) {
      MApplication anApp = e.nextElement();
      anApp.extractAdaptorValuesFromSiteConfig();
      String name = anApp.name();
      result.append("ProxySet balancer://" + name + ".woa");
      if (timeout != null && timeout.intValue() > 0) {
        result.append(" timeout=");
        result.append(timeout);
      }
      if (loadBalancer != null) {
        result.append(" lbmethod=");
        result.append(loadBalancer);
      } else {
        result.append(" lbmethod=byrequests");
      }
      result.append('\n');
    }

    result.append("#\n");
    result.append("#\n");
    result.append("#\n");

    result.append('\n');
    return result.toString();
  }