Пример #1
0
  static {
    if (!Boolean.getBoolean(GridSystemProperties.GG_JETTY_LOG_NO_OVERRIDE)) {
      String ctgrJetty = "org.eclipse.jetty"; // WARN for this category.
      String ctgrJettyUtil = "org.eclipse.jetty.util.log"; // ERROR for this...
      String ctgrJettyUtilComp = "org.eclipse.jetty.util.component"; // ...and this.

      try {
        Class<?> logCls = Class.forName("org.apache.log4j.Logger");

        Object logJetty = logCls.getMethod("getLogger", String.class).invoke(logCls, ctgrJetty);
        Object logJettyUtil =
            logCls.getMethod("getLogger", String.class).invoke(logCls, ctgrJettyUtil);
        Object logJettyUtilComp =
            logCls.getMethod("getLogger", String.class).invoke(logCls, ctgrJettyUtilComp);

        Class<?> lvlCls = Class.forName("org.apache.log4j.Level");

        Object warnLvl = lvlCls.getField("WARN").get(null);
        Object errLvl = lvlCls.getField("ERROR").get(null);

        logJetty.getClass().getMethod("setLevel", lvlCls).invoke(logJetty, warnLvl);
        logJettyUtil.getClass().getMethod("setLevel", lvlCls).invoke(logJetty, errLvl);
        logJettyUtilComp.getClass().getMethod("setLevel", lvlCls).invoke(logJetty, errLvl);
      } catch (Exception ignored) {
        // No-op.
      }
    }
  }
Пример #2
0
  public void prepare(String path, String tx_log_dir) {
    try {
      asadmin("create-cluster", CLUSTER_NAME);
      asadmin(
          "set",
          "configs.config."
              + CLUSTER_NAME
              + "-config.transaction-service.property.delegated-recovery=true");
      asadmin(
          "set",
          "configs.config."
              + CLUSTER_NAME
              + "-config.transaction-service.property.add-wait-point-during-recovery=20");
      asadmin("create-system-properties", "--target", CLUSTER_NAME, "TX-LOG-DIR=" + tx_log_dir);
      asadmin("create-local-instance", "--cluster", CLUSTER_NAME, INSTANCE1_NAME);
      asadmin("create-local-instance", "--cluster", CLUSTER_NAME, INSTANCE2_NAME);
      asadmin("create-local-instance", "--cluster", CLUSTER_NAME, INSTANCE3_NAME);
      if (Boolean.getBoolean("enableShoalLogger")) {
        asadmin("set-log-levels", "ShoalLogger=FINER");
        asadmin("set-log-levels", "--target", CLUSTER_NAME, "ShoalLogger=FINER");
      }
      asadmin("start-cluster", CLUSTER_NAME);
      System.out.println("Started cluster. Setting up resources.");

      asadmin("create-resource-ref", "--target", CLUSTER_NAME, DEF_RESOURCE);
      asadmin("create-resource-ref", "--target", CLUSTER_NAME, XA_RESOURCE);
      asadmin("deploy", "--target", CLUSTER_NAME, path);
      System.out.println("Deployed " + path);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #3
0
  /**
   * Returns boolean value from system property or provided function.
   *
   * @param propName System property host.
   * @param dflt Function that returns {@code Boolean}.
   * @return {@code Boolean} value
   */
  public static boolean boolValue(String propName, boolean dflt) {
    String sysProp = getProperty(propName);

    return (sysProp != null && !sysProp.isEmpty()) ? Boolean.getBoolean(sysProp) : dflt;
  }