private void startSampler() { if (statsDisabled) { return; } sampler = loggingSession.getLogFile() .map(logFile -> new GemFireStatSampler(this, logFile)) .orElseGet(() -> new GemFireStatSampler(this)); this.sampler.start(); }
public int addListener(InternalDistributedMember recipient, long resourceId, String statName) { int result = getNextListenerId(); synchronized (listeners) { while (listeners.get(result) != null) { // previous one was still being used result = getNextListenerId(); } RemoteStatListenerImpl sl = RemoteStatListenerImpl.create(result, recipient, resourceId, statName, this); listeners.put(result, sl); List<RemoteStatListenerImpl> l = recipientToListeners.get(recipient); if (l == null) { l = new ArrayList<RemoteStatListenerImpl>(); recipientToListeners.put(recipient, l); } l.add(sl); } return result; }
@Override protected void initProcessStats(long id) { if (PureJavaMode.osStatsAreAvailable()) { if (osStatsDisabled()) { logger.info(LogMarker.STATISTICS_MARKER, "OS statistic collection disabled by setting the osStatsDisabled system property to true."); } else { int retVal = HostStatHelper.initOSStats(); if (retVal != 0) { logger.error(LogMarker.STATISTICS_MARKER, "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" + getSystemId(); } Statistics stats = HostStatHelper.newProcess(getOsStatisticsFactory(), id, statName + "-proc"); this.processStats = HostStatHelper.newProcessStats(stats); } } }
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()); } }
@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 {
/** * Start a listener on the cache stats to monitor memory usage. * * @return True of the listener was correctly started, false otherwise. */ private boolean startCacheStatListener() { final GemFireStatSampler sampler = this.cache.getInternalDistributedSystem().getStatSampler(); if (sampler == null) { return false; } try { sampler.waitForInitialization(); Statistics si = getTenuredPoolStatistics( this.cache.getInternalDistributedSystem().getStatisticsManager()); if (si != null) { sampler.addLocalStatListener(this.statListener, si, "currentUsedMemory"); if (logger.isDebugEnabled()) { logger.debug("Registered stat listener for " + si.getTextId()); } return true; } } catch (InterruptedException iex) { Thread.currentThread().interrupt(); this.cache.getCancelCriterion().checkCancelInProgress(iex); } return false; }
@Override public long getArchiveDiskSpaceLimit() { if (fileSizeLimitInKB()) { // use KB instead of MB to speed up removal for testing return ((long) this.con.getConfig().getArchiveDiskSpaceLimit()) * (1024); } else { return ((long) this.con.getConfig().getArchiveDiskSpaceLimit()) * (1024 * 1024); } }
protected void sample() throws InterruptedException { this.system.getStatSampler().getSampleCollector().sample(NanoTimer.getTime()); Thread.sleep(SLEEP); }
/** * Creates a new <code>MemberHealthEvaluator</code> */ MemberHealthEvaluator(GemFireHealthConfig config, DistributionManager dm) { super(config, dm); this.config = config; InternalDistributedSystem system = dm.getSystem(); GemFireStatSampler sampler = system.getStatSampler(); if (sampler != null) { // Sampling is enabled this.processStats = sampler.getProcessStats(); } this.dmStats = dm.getStats(); StringBuilder sb = new StringBuilder(); 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(); }
@Override public void setStatisticArchiveFile(File value) { value = (File) checkAttribute(STATISTIC_ARCHIVE_FILE, value); if (value == null) { value = new File(""); } try { system.getStatSampler().changeArchive(value); } catch (GemFireIOException ex) { throw new IllegalArgumentException(ex.getMessage()); } statisticArchiveFile = value; getAttSourceMap().put(STATISTIC_ARCHIVE_FILE, ConfigSource.runtime()); }
/** * Returns a <code>AddStatListenerResponse</code> that will be returned to the specified * recipient. The message will contains a copy of the local manager's system config. */ public static AddStatListenerResponse create(DistributionManager dm, InternalDistributedMember recipient, long resourceId, String statName) { AddStatListenerResponse m = new AddStatListenerResponse(); m.setRecipient(recipient); GemFireStatSampler sampler = null; sampler = dm.getSystem().getStatSampler(); if (sampler != null) { m.listenerId = sampler.addListener(recipient, resourceId, statName); } return m; }
@Override public long getArchiveFileSizeLimit() { if (fileSizeLimitInKB()) { // use KB instead of MB to speed up rolling for testing return ((long) this.con.getConfig().getArchiveFileSizeLimit()) * (1024); } else { return ((long) this.con.getConfig().getArchiveFileSizeLimit()) * (1024 * 1024); } }