示例#1
0
  public static void resetData() {

    try {

      AgentDataProvider adp = AgentDataProvider.getInstance();

      adp.resetData();

      renderJSON("Successful resetData " + DateUtils.getNowDateTimeStr());
    } catch (Throwable t) {

      renderJSON("Error occured in resetData");
    }
  }
示例#2
0
  public static void aggregateMetaDataNodeList(
      String nodeGroupType,
      String agentCommandType,
      String value,
      String timeStamp,
      String rawDataSourceType,
      String aggrRule) {
    try {

      AgentDataProvider adp = AgentDataProvider.getInstance();
      Map<String, String> rulesMap = adp.aggregationMetadatas;
      String patternStr =
          rulesMap.get(
              (aggrRule == null || aggrRule.length() == 0)
                  ? VarUtils.AGGREGATION_DEFAULT_METRIC
                  : aggrRule);

      AgentDataAggregator ada = AgentDataAggregator.getInstance();

      AggregateData aggregateData =
          ada.aggregateMetricsWithGroupingNew(
              nodeGroupType, agentCommandType, timeStamp, rawDataSourceType, patternStr);

      String nodeListDetails =
          aggregateData.getResponseToMetadataMap().get(value).nodeListDetailsStr();

      renderText(nodeListDetails);
    } catch (Throwable t) {

      renderJSON(
          new JsonResult(
              "Error in aggregateMetaDataNodeList for nodeGroupType"
                  + nodeGroupType
                  + " error: "
                  + t.getLocalizedMessage()
                  + "  at time: "
                  + DateUtils.getNowDateTimeStrSdsm()));
    }
  }
示例#3
0
  public static void aggregatePieChart(
      String nodeGroupType,
      String agentCommandType,
      String timeStamp,
      String rawDataSourceType,
      String aggrRule,
      Boolean textOnly) {
    String page = "aggregatePieChart";
    String topnav = "agent";
    String lastRefreshed = DateUtils.getNowDateTimeStrSdsm();

    String patternStr = "N/A";

    // 20130805: add option to see text only
    if (textOnly == null) {
      textOnly = false;
    }

    try {

      AgentDataAggregator ada = AgentDataAggregator.getInstance();
      AgentDataProvider adp = AgentDataProvider.getInstance();
      Map<String, String> rulesMap = adp.aggregationMetadatas;
      // 20130610: fix null

      if (aggrRule == null) {
        aggrRule = VarUtils.AGGREGATION_DEFAULT_METRIC;
      }
      patternStr =
          rulesMap.get(
              (aggrRule == null || aggrRule.length() == 0)
                  ? VarUtils.AGGREGATION_DEFAULT_METRIC
                  : aggrRule);
      AggregateData aggregateData =
          ada.aggregateMetricsWithGroupingNew(
              nodeGroupType, agentCommandType, timeStamp, rawDataSourceType, patternStr);

      String pieDataStr = null;

      boolean humanReadFriendly = false;

      List<AggregationValueMetadata> avmList = aggregateData.getResponseToMetadataList();

      if (!textOnly) {

        pieDataStr = aggregateData.getValueCountJSNumber2D(humanReadFriendly);

        render(
            page,
            topnav,
            pieDataStr,
            avmList,
            agentCommandType,
            nodeGroupType,
            lastRefreshed,
            patternStr,
            timeStamp,
            rawDataSourceType,
            rulesMap,
            aggrRule);
      } else {

        String avmListString = AgentUtils.renderJson(avmList);
        humanReadFriendly = true;
        pieDataStr = aggregateData.getValueCountJSNumber2D(humanReadFriendly);

        StringBuilder finalResponse =
            new StringBuilder(
                "//SUPERMAN*****OVERVIEW -- AGGREGATION SUMMARY - START *************\n\n");
        finalResponse.append(pieDataStr);
        finalResponse.append(
            "\n\n//SUPERMAN*****OVERVIEW -- AGGREGATION SUMMARY - END *************\n\n");

        finalResponse.append("//SUPERMAN*****DETAILS (SORTED BY KEY) - START *************\n\n");
        finalResponse.append(avmListString);
        finalResponse.append("\n\n//SUPERMAN*****DETAILS (SORTED BY KEY) - END *************\n\n");
        renderText(finalResponse.toString());
      }
    } catch (Throwable t) {

      renderJSON(
          new JsonResult(
              "Error in aggregatePieChart for nodeGroupType"
                  + nodeGroupType
                  + " error: "
                  + t.getLocalizedMessage()
                  + "  at time: "
                  + DateUtils.getNowDateTimeStrSdsm()));
    }
  }