assertTrue(sampler.isSamplingEnabled()); assertTrue(sampler.isAlive()); assertEquals(new File(pubArchives[pubVM]), sampler.getArchiveFileName()); waitForCriterion(waitForSampleCollector, 4*1000, 10, true); final SampleCollector sampleCollector = sampler.getSampleCollector(); assertNotNull(sampleCollector);
assertTrue(statSampler.waitForInitialization(5000)); final File archiveFile = statSampler.getArchiveFileName(); assertNotNull(archiveFile); assertEquals(archiveFile1, archiveFile);
public boolean done() { int i=0; synchronized (list) { for (Object obj : list) { statSampler.getLogger().convertToLogWriter().info("List:"+(++i)+":"+obj); if (obj instanceof StatisticsImpl) { StatisticsImpl si = (StatisticsImpl)obj; statSampler.getLogger().convertToLogWriter().info("stat:"+si.getTextId()); if (si.getTextId().contains(tenuredPoolName)) { statSampler.addLocalStatListener(listener, si, "currentUsedMemory"); return true; } } } } return false; } public String description() {
@Override protected final void initProcessStats(long id) { if (PureJavaMode.osStatsAreAvailable()) { if (osStatsDisabled()) { getLogger().info(LocalizedStrings.GemFireStatSampler_OS_STATISTIC_COLLECTION_DISABLED_BY_OSSTATSDISABLED_SYSTEM_PROPERTY); } else { int retVal = HostStatHelper.initOSStats(); if ( retVal != 0 ) { getLogger().error(LocalizedStrings.GemFireStatSampler_OS_STATISTICS_FAILED_TO_INITIALIZE_PROPERLY_SOME_STATS_MAY_BE_MISSING_SEE_BUGNOTE_37160); } HostStatHelper.newSystem(getOsStatisticsFactory()); String statName = getStatisticsManager().getName(); if (statName == null || statName.length() == 0) { statName = "javaApp" + getStatisticsManager().getId(); } Statistics stats = HostStatHelper.newProcess(getOsStatisticsFactory(), id, statName + "-proc"); this.processStats = HostStatHelper.newProcessStats(stats); } } }
@Override protected final void sampleProcessStats(boolean prepareOnly) { if (prepareOnly || osStatsDisabled() || !PureJavaMode.osStatsAreAvailable()) { return; } List<Statistics> l = getStatisticsManager().getStatsList(); if (l == null) { return; } if (stopRequested()) return; HostStatHelper.readyRefreshOSStats(); synchronized (l) { Iterator<Statistics> it = l.iterator(); while (it.hasNext()) { if (stopRequested()) return; StatisticsImpl s = (StatisticsImpl)it.next(); if (s.usesSystemCalls()) { HostStatHelper.refresh((LocalStatisticsImpl)s); } } } }
assertTrue(statSampler.waitForInitialization(5000)); assertEquals(0, statSampler.getArchiveFileSizeLimit()); assertEquals(0, statSampler.getArchiveDiskSpaceLimit()); assertEquals(STAT_SAMPLE_RATE, statSampler.getSampleRate()); assertEquals(true, statSampler.isSamplingEnabled()); int statsCount = statSampler.getStatisticsManager().getStatisticsCount(); assertEquals(statsCount, statSampler.getStatisticsModCount()); assertEquals(statsCount, statSampler.getStatisticsManager().getStatisticsCount()); assertEquals(statsCount, statSampler.getStatistics().length); assertEquals(getStatisticsManager().getId(), statSampler.getSystemId()); assertTrue(statSampler.getSystemStartTime() < System.currentTimeMillis()); assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), statSampler.getSystemDirectoryPath()); VMStats vmStats = statSampler.getVMStats(); assertNotNull(vmStats); ProcessStats processStats = statSampler.getProcessStats(); String osName = System.getProperty("os.name", "unknown"); if (osName.equals("SunOS")) { String productDesc = statSampler.getProductDescription(); assertTrue(productDesc.contains(GemFireVersion.getGemFireVersion())); assertTrue(productDesc.contains(GemFireVersion.getBuildId()));
assertTrue(statSampler.waitForInitialization(5000)); assertTrue(statSampler.getLocalListeners().isEmpty()); statSampler.addLocalStatListener(listener, statSamplerStats, statName); assertTrue(statSampler.getLocalListeners().size() == 1); statSampler.getLocalListeners().iterator().next(); assertEquals("sampleCount", lsli.stat.getName()); statSampler.removeLocalStatListener(listener); final int expectedSampleCountValue = sampleCountValue.get(); final int expectedSampleCountChanged = sampleCountChanged.get(); assertTrue(statSampler.getLocalListeners().isEmpty());
sampler.waitForInitialization(); String tenuredPoolName = getTenuredMemoryPoolMXBean().getName(); List list = this.cache.getDistributedSystem().getStatsList(); StatisticsImpl si = (StatisticsImpl) o; if (si.getTextId().contains(tenuredPoolName) && si.getType().getName().contains("PoolStats")) { sampler.addLocalStatListener(this.statListener, si, "currentUsedMemory"); if (this.cache.getLoggerI18n().fineEnabled()) { this.cache.getLoggerI18n().fine("Registered stat listener for " + si.getTextId());
assertNotNull(sampler); sampler.waitForInitialization(10000); // fix: remove infinite wait ProcessStats stats = sampler.getProcessStats(); assertNotNull(stats);
@Override protected void checkListeners() { checkLocalListeners(); synchronized (listeners) { if (listeners.size() == 0) { recipientToListeners.entrySet().iterator(); while (it1.hasNext()) { if (stopRequested()) return; Map.Entry<InternalDistributedMember, List<RemoteStatListenerImpl>> me = it1.next(); msg.setRecipient(recipient); for (RemoteStatListenerImpl statListener : l) { if (getStatisticsManager().statisticsExists(statListener.getStatId())) { statListener.checkForChange(msg); } else {
statSampler.waitForInitialization(5000); statSampler.getLocalListeners().size(), statSampler.getLocalListeners().size() > 0);
@Override protected final void initProcessStats(long id) { if (PureJavaMode.osStatsAreAvailable()) { if (osStatsDisabled()) { logger.info(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.GemFireStatSampler_OS_STATISTIC_COLLECTION_DISABLED_BY_OSSTATSDISABLED_SYSTEM_PROPERTY)); } else { int retVal = HostStatHelper.initOSStats(); if ( retVal != 0 ) { logger.error(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.GemFireStatSampler_OS_STATISTICS_FAILED_TO_INITIALIZE_PROPERLY_SOME_STATS_MAY_BE_MISSING_SEE_BUGNOTE_37160)); } HostStatHelper.newSystem(getOsStatisticsFactory()); String statName = getStatisticsManager().getName(); if (statName == null || statName.length() == 0) { statName = "javaApp" + getStatisticsManager().getId(); } Statistics stats = HostStatHelper.newProcess(getOsStatisticsFactory(), id, statName + "-proc"); this.processStats = HostStatHelper.newProcessStats(stats); } } }
assertTrue(statSampler.waitForInitialization(5000)); statSampler.stop();
public static void waitForSamplerInitialization() { InternalDistributedSystem system = getDistributedSystem(); final GemFireStatSampler sampler = system.getStatSampler(); if (sampler != null) { try { sampler.waitForInitialization(system.getConfig().getAckWaitThreshold() * 1000L); } catch (InterruptedException ie) { checkIfCacheClosing(ie); Thread.currentThread().interrupt(); } } }
public ConnectionStats(StatisticsFactory factory, String name) { stats = factory.createAtomicStatistics(type, name); InternalDistributedSystem sys = (InternalDistributedSystem)factory; GemFireStatSampler sampler = sys.getStatSampler(); samplingEnabled = sampler != null && sampler.isSamplingEnabled(); setClockStats(sys.getConfig().getEnableTimeStatistics(), false); }
public void addSystemStats() { GemFireStatSampler sampler = system.getStatSampler(); ProcessStats processStats = sampler.getProcessStats(); StatSamplerStats samplerStats = sampler.getStatSamplerStats(); if (processStats != null) { systemStatsMonitor.addStatisticsToMonitor(processStats.getStatistics()); } if(samplerStats != null){ systemStatsMonitor.addStatisticsToMonitor(samplerStats.getStats()); } }
public void addVMStats(){ VMStats vmStats = system.getStatSampler().getVMStats(); if (vmStats != null) { Statistics stats = vmStats.getVMStats(); if (stats != null) { vmStatsMonitor.addStatisticsToMonitor(stats); } Statistics vmHeapStats = vmStats.getVMHeapStats(); if (vmHeapStats != null) { vmStatsMonitor.addStatisticsToMonitor(vmHeapStats); } //vmStatsMonitor.addStatisticsToMonitor(vm50.getVMNonHeapStats()); StatisticsType gcType = VMStats.getGCType(); if (gcType != null) { Statistics[] gcStats = system.findStatisticsByType(gcType); if (gcStats != null && gcStats.length > 0){ for (Statistics gcStat : gcStats) { if (gcStat != null) { gcMonitor.addStatisticsToMonitor(gcStat); } } } } } }
/** * Tests the statistics sample rate within an acceptable margin of error. */ public void testSampleRate() throws Exception { connect(createGemFireProperties()); GemFireStatSampler statSampler = getGemFireStatSampler(); assertTrue(statSampler.waitForInitialization(5000)); assertEquals(STAT_SAMPLE_RATE, statSampler.getSampleRate()); assertTrue(getStatisticsManager().getStatListModCount() > 0); @SuppressWarnings("unchecked") List<Statistics> statistics = getStatisticsManager().getStatsList(); assertNotNull(statistics); assertTrue(statistics.size() > 0); StatisticsType statSamplerType = getStatisticsManager().findType("StatSampler"); Statistics[] statsArray = getStatisticsManager().findStatisticsByType(statSamplerType); assertEquals(1, statsArray.length); final Statistics statSamplerStats = statsArray[0]; final int initialSampleCount = statSamplerStats.getInt("sampleCount"); final int expectedSampleCount = initialSampleCount + 2; WaitCriterion wc = new WaitCriterion() { public boolean done() { return statSamplerStats.getInt("sampleCount") >= expectedSampleCount; } public String description() { return "Waiting for sampleCount >= " + expectedSampleCount; } }; DistributedTestBase.waitForCriterion(wc, 5000, 10, true); }
@Override protected final long getSpecialStatsId() { long statId = OSProcess.getId(); if (statId == 0 || statId == -1) { statId = getStatisticsManager().getId(); } return statId; }
/** * Creates a new <code>MemberHealthEvaluator</code> */ MemberHealthEvaluator(GemFireHealthConfig config, DM dm) { super(config, dm); this.config = config; InternalDistributedSystem system = dm.getSystem(); GemFireStatSampler sampler = system.getStatSampler(); if (sampler != null) { // Sampling is enabled // this.vmStats = sampler.getVMStats(); this.processStats = sampler.getProcessStats(); } this.dmStats = dm.getStats(); StringBuffer sb = new StringBuffer(); sb.append("Application VM member "); sb.append(dm.getId()); int pid = OSProcess.getId(); if (pid != 0) { sb.append(" with pid "); sb.append(pid); } this.description = sb.toString(); }