Search in sources :

Example 1 with DummyStatisticInfoImpl

use of org.apache.geode.internal.admin.statalerts.DummyStatisticInfoImpl in project geode by apache.

the class StatAlertsManager method createMemberStatAlertDefinition.

/**
   * Convert {@link StatAlertDefinition }(Created by client like GFMon2.0) with
   * {@link DummyStatisticInfoImpl} to StatAlertDefinition with {@link StatisticInfoImpl}
   */
private StatAlertDefinition[] createMemberStatAlertDefinition(DistributionManager dm, StatAlertDefinition[] defns) {
    dm.getCancelCriterion().checkCancelInProgress(null);
    Statistics[] statistics;
    StatisticsType type;
    StatisticDescriptor desc;
    String textId;
    boolean skipDefinition = false;
    List result = new ArrayList();
    for (int i = 0; i < defns.length; i++) {
        skipDefinition = false;
        StatAlertDefinition defn = defns[i];
        StatisticInfo[] statInfos = defn.getStatisticInfo();
        for (int ii = 0; ii < statInfos.length && !skipDefinition; ii++) {
            textId = statInfos[ii].getStatisticsTextId();
            // TODO If none by TextID, use StatType and getAll.
            statistics = dm.getSystem().findStatisticsByTextId(textId);
            if (statistics.length == 0) {
                logger.error(LocalizedMessage.create(LocalizedStrings.StatAlertsManager_STATALERTSMANAGER_CREATEMEMBERSTATALERTDEFINITION_STATISTICS_WITH_GIVEN_TEXTID_0_NOT_FOUND, textId));
                skipDefinition = true;
                // To print all errors
                continue;
            }
            type = statistics[0].getType();
            desc = type.nameToDescriptor(statInfos[ii].getStatisticName());
            // Replace the actual StatInfo object
            statInfos[ii] = new StatisticInfoImpl(statistics[0], desc);
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition: created statInfo {}", statInfos[ii]);
            }
        }
        if (!skipDefinition) {
            defn.setStatisticInfo(statInfos);
            result.add(defn);
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: {}", defns[i].getStringRepresentation());
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: StatAlertDefinition {} is excluded", defn.getName());
            }
        }
    }
    return (StatAlertDefinition[]) result.toArray(new StatAlertDefinition[result.size()]);
}
Also used : StatisticsType(org.apache.geode.StatisticsType) ArrayList(java.util.ArrayList) StatisticInfo(org.apache.geode.internal.admin.statalerts.StatisticInfo) Statistics(org.apache.geode.Statistics) StatisticDescriptor(org.apache.geode.StatisticDescriptor) ArrayList(java.util.ArrayList) List(java.util.List) StatisticInfoImpl(org.apache.geode.internal.admin.statalerts.StatisticInfoImpl) DummyStatisticInfoImpl(org.apache.geode.internal.admin.statalerts.DummyStatisticInfoImpl)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 StatisticDescriptor (org.apache.geode.StatisticDescriptor)1 Statistics (org.apache.geode.Statistics)1 StatisticsType (org.apache.geode.StatisticsType)1 DummyStatisticInfoImpl (org.apache.geode.internal.admin.statalerts.DummyStatisticInfoImpl)1 StatisticInfo (org.apache.geode.internal.admin.statalerts.StatisticInfo)1 StatisticInfoImpl (org.apache.geode.internal.admin.statalerts.StatisticInfoImpl)1