Search in sources :

Example 36 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class InternalDistributedSystem method createAtomicStatistics.

public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) {
    if (this.statsDisabled) {
        return new DummyStatisticsImpl(type, textId, numericId);
    }
    long myUniqueId = statsListUniqueId.getAndIncrement();
    Statistics result = StatisticsImpl.createAtomicNoOS(type, textId, numericId, myUniqueId, this);
    synchronized (statsList) {
        statsList.add(result);
        statsListModCount++;
    }
    return result;
}
Also used : Statistics(org.apache.geode.Statistics) LinuxProcFsStatistics(org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics) DummyStatisticsImpl(org.apache.geode.internal.statistics.DummyStatisticsImpl)

Example 37 with Statistics

use of org.apache.geode.Statistics 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)

Example 38 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class VMStats50 method refreshThreads.

private void refreshThreads() {
    if (!THREAD_STATS_ENABLED) {
        return;
    }
    if (this.allThreadIds == null || newThreadsStarted()) {
        this.allThreadIds = threadBean.getAllThreadIds();
        this.threadStartCount = threadBean.getTotalStartedThreadCount();
    }
    ThreadInfo[] threadInfos = threadBean.getThreadInfo(this.allThreadIds, 0);
    for (int i = 0; i < threadInfos.length; i++) {
        long id = this.allThreadIds[i];
        ThreadInfo item = threadInfos[i];
        if (item != null) {
            ThreadStatInfo tsi = threadMap.get(id);
            if (tsi == null) {
                threadMap.put(id, new ThreadStatInfo(item, this.f.createStatistics(threadType, item.getThreadName() + '-' + item.getThreadId(), this.id)));
            } else {
                tsi.ti = item;
            }
        } else {
            ThreadStatInfo tsi = threadMap.remove(id);
            if (tsi != null) {
                tsi.s.close();
            }
        }
    }
    Iterator<Map.Entry<Long, ThreadStatInfo>> it = threadMap.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Long, ThreadStatInfo> me = it.next();
        long id = me.getKey();
        ThreadStatInfo tsi = me.getValue();
        ThreadInfo ti = tsi.ti;
        Statistics s = tsi.s;
        s.setLong(thread_blockedId, ti.getBlockedCount());
        s.setLong(thread_lockOwnerId, ti.getLockOwnerId());
        s.setLong(thread_waitedId, ti.getWaitedCount());
        s.setInt(thread_inNativeId, ti.isInNative() ? 1 : 0);
        s.setInt(thread_suspendedId, ti.isSuspended() ? 1 : 0);
        if (threadBean.isThreadContentionMonitoringSupported() && threadBean.isThreadContentionMonitoringEnabled()) {
            s.setLong(thread_blockedTimeId, ti.getBlockedTime());
            s.setLong(thread_waitedTimeId, ti.getWaitedTime());
        }
        if (threadBean.isThreadCpuTimeSupported() && threadBean.isThreadCpuTimeEnabled()) {
            s.setLong(thread_cpuTimeId, threadBean.getThreadCpuTime(id));
            s.setLong(thread_userTimeId, threadBean.getThreadUserTime(id));
        }
    }
}
Also used : ThreadInfo(java.lang.management.ThreadInfo) HashMap(java.util.HashMap) Map(java.util.Map) Statistics(org.apache.geode.Statistics)

Example 39 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class MemberMBeanBridge method addFunctionStats.

public void addFunctionStats(FunctionServiceStats functionServiceStats) {
    Statistics functionStatistics = functionServiceStats.getStats();
    monitor.addStatisticsToMonitor(functionStatistics);
}
Also used : Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics)

Example 40 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class MemberMBeanBridge method init.

public MemberMBeanBridge init() {
    CachePerfStats cachePerfStats = this.cache.getCachePerfStats();
    addCacheStats(cachePerfStats);
    addFunctionStats(system.getFunctionServiceStats());
    if (system.getDistributionManager().getStats() instanceof DistributionStats) {
        DistributionStats distributionStats = (DistributionStats) system.getDistributionManager().getStats();
        addDistributionStats(distributionStats);
    }
    if (PureJavaMode.osStatsAreAvailable()) {
        Statistics[] systemStats = null;
        if (HostStatHelper.isSolaris()) {
            systemStats = system.findStatisticsByType(SolarisSystemStats.getType());
        } else if (HostStatHelper.isLinux()) {
            systemStats = system.findStatisticsByType(LinuxSystemStats.getType());
        } else if (HostStatHelper.isOSX()) {
            // @TODO once OSX stats are implemented
            systemStats = null;
        } else if (HostStatHelper.isWindows()) {
            systemStats = system.findStatisticsByType(WindowsSystemStats.getType());
        }
        if (systemStats != null) {
            systemStat = systemStats[0];
        }
    }
    MemoryAllocator allocator = this.cache.getOffHeapStore();
    if ((null != allocator)) {
        OffHeapMemoryStats offHeapStats = allocator.getStats();
        if (null != offHeapStats) {
            addOffHeapStats(offHeapStats);
        }
    }
    addSystemStats();
    addVMStats();
    initializeStats();
    return this;
}
Also used : MemoryAllocator(org.apache.geode.internal.offheap.MemoryAllocator) OffHeapMemoryStats(org.apache.geode.internal.offheap.OffHeapMemoryStats) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics) DistributionStats(org.apache.geode.distributed.internal.DistributionStats)

Aggregations

Statistics (org.apache.geode.Statistics)74 StatisticsType (org.apache.geode.StatisticsType)36 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)29 StatisticDescriptor (org.apache.geode.StatisticDescriptor)18 File (java.io.File)17 ArrayList (java.util.ArrayList)12 List (java.util.List)12 StatValue (org.apache.geode.internal.statistics.StatArchiveReader.StatValue)11 TestStatArchiveWriter (org.apache.geode.internal.statistics.TestStatArchiveWriter)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)6 HashMap (java.util.HashMap)5 LinuxProcFsStatistics (org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics)5 Iterator (java.util.Iterator)4 Map (java.util.Map)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 MainWithChildrenRollingFileHandler (org.apache.geode.internal.io.MainWithChildrenRollingFileHandler)3 Before (org.junit.Before)3 IOException (java.io.IOException)2