@Override
 public Object getValue(Context context, CommonSettingInfo info) {
   if (mStatusCb != null) {
     return mStatusCb.getStatus(context, info);
   }
   return "";
 }
Example #2
0
  /**
   * status
   *
   * @return a int.
   */
  public int status() {
    Authenticator.setDefault(getAuthenticator());

    StatusGetter statusGetter = new StatusGetter();
    statusGetter.setVerbose(isVerbose());

    String url = getInvokeUrl() + "&operation=status";
    try {
      statusGetter.setInvokeURL(new URL(url));
    } catch (MalformedURLException e) {
      String message = "Error creating URL object for invoke URL: '" + url + "'";
      System.err.println(message);
      LOG.error(message, e);
    }

    try {
      statusGetter.queryStatus();
    } catch (Throwable t) {
      String message = "Error invoking status command";
      System.err.println(message);
      LOG.error(message, t);
      return 1;
    }

    switch (statusGetter.getStatus()) {
      case NOT_RUNNING:
      case CONNECTION_REFUSED:
        return 3; // According to LSB: 3 - service not running

      case PARTIALLY_RUNNING:
        /*
         * According to LSB: reserved for application So, I say
         * 160 - partially running
         */
        return 160;

      case RUNNING:
        return 0; // everything should be good and running

      default:
        LOG.error(
            "Unknown status returned from statusGetter.getStatus(): {}", statusGetter.getStatus());
        return 1;
    }
  }