Exemplo n.º 1
0
  private boolean updateStats() {
    // enkel opvragen als statistieken ouder dan een seconde zijn
    if (latestStatsRequest == null
        || Calendar.getInstance().getTime().getTime() - latestStatsRequest.getTime() > 1000) {

      try {
        XmlRpcClient client = SPClientFactory.getPrivateClient();
        Object result = client.execute("System.Backend.Stats", new Object[] {});

        HashMap ht = (HashMap) result;

        // users ophalen
        onlineUsers = (Integer) ht.get("users");
        processedRequests = (Integer) ht.get("req");
        uptime = Long.parseLong((String) ht.get("uptime"));

        latestStatsRequest = Calendar.getInstance().getTime();
        return true;

      } catch (Exception ex) {
        logger.error("Error while fetching statistics", ex);
        return false;
      }
    } else {
      return true;
    }
  }
Exemplo n.º 2
0
  public BackendStatus getStatus() throws StockPlayException {

    try {
      XmlRpcClient client = SPClientFactory.getPrivateClient();
      Integer result = (Integer) client.execute("System.Backend.Status", new Object[] {});

      if (result == 0) {
        return BackendStatus.MAINTANANCE;

      } else if (result == 1) {
        return BackendStatus.ONLINE;
      } else {
        return BackendStatus.UNKNOWN;
      }

    } catch (XmlRpcException ex) {
      logger.error("Error while fetching backend status", ex);
      return BackendStatus.UNKNOWN;
    }
  }