Example #1
0
  public long getUserId() {
    if (userId != null) return userId.longValue();

    if (!apiServer) s_logger.warn("Null user id in UserContext " + ProcessUtil.dumpStack());

    return 0;
  }
Example #2
0
  public void start() {
    try {
      /* By default we only search for log4j.xml */
      LogUtils.initLog4j("log4j-cloud.xml");

      System.setProperty("java.net.preferIPv4Stack", "true");

      String instance = getProperty(null, "instance");
      if (instance == null) {
        if (Boolean.parseBoolean(getProperty(null, "developer"))) {
          instance = UUID.randomUUID().toString();
        } else {
          instance = "";
        }
      } else {
        instance += ".";
      }

      String pidDir = getProperty(null, "piddir");

      final String run = "agent." + instance + "pid";
      s_logger.debug("Checking to see if " + run + " exists.");
      ProcessUtil.pidCheck(pidDir, run);

      launchAgent();

      try {
        while (!_exit) Thread.sleep(1000);
      } catch (InterruptedException e) {
      }

    } catch (final ConfigurationException e) {
      s_logger.error("Unable to start agent: " + e.getMessage());
      System.out.println("Unable to start agent: " + e.getMessage());
      System.exit(ExitStatus.Configuration.value());
    } catch (final Exception e) {
      s_logger.error("Unable to start agent: ", e);
      System.out.println("Unable to start agent: " + e.getMessage());
      System.exit(ExitStatus.Error.value());
    }
  }
Example #3
0
  public long getAccountId() {
    if (accountId != null) return accountId.longValue();

    if (!apiServer) s_logger.warn("Null account id in UserContext " + ProcessUtil.dumpStack());
    return 0;
  }