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;
}
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()]);
}
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));
}
}
}
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);
}
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;
}
Aggregations