/** * Called when this sampler has spent some time working and wants it to be accounted for. */ private void accountForTimeSpentWorking(long nanosSpentWorking, long nanosSpentSleeping) { this.samplerStats.tookSample(nanosSpentWorking, getStatisticsManager().getStatisticsCount(), nanosSpentSleeping); }
protected void addTimeStamp() { if (this.loaded) { if (firstTSidx == -1) { firstTSidx = archive.getTimeStamps().getSize() - 1; } for (int i = 0; i < values.length; i++) { if (values[i] != null) { values[i].addSample(); } } } }
protected Statistics newAtomicStatistics(StatisticsType type, long uniqueId, long numericId, String textId) { Statistics statistics = atomicStatisticsFactory.create(type, textId, numericId, uniqueId, this); registerNewStatistics(statistics); return statistics; }
@Override public double[] getRawSnapshots() { int startIdx = getStartIdx(); int endIdx = getEndIdx(startIdx); int resultSize = (endIdx - startIdx) + 1; return series.getValuesEx(descriptor.getTypeCode(), startIdx, resultSize); }
/** * Initialize any special sampler stats */ private synchronized void initSpecialStats() { // add a vm resource long id = getSystemId(); this.vmStats = VMStatsContractFactory.create(getStatisticsManager(), id); initProcessStats(id); }
private ComboValue(ComboValue original, long startTime, long endTime) { this.startTime = startTime; this.endTime = endTime; this.type = original.getType(); this.descriptor = original.getDescriptor(); this.filter = original.getFilter(); this.values = new StatValue[original.values.length]; for (int i = 0; i < this.values.length; i++) { this.values[i] = original.values[i].createTrimmed(startTime, endTime); } }
protected void makeInactive() { this.active = false; lastTSidx = archive.getTimeStamps().getSize() - 1; close(); // this frees up unused memory now that no more samples }
protected Statistics newOsStatistics(StatisticsType type, long uniqueId, long numericId, String textId, int osStatFlags) { Statistics statistics = osStatisticsFactory.create(type, textId, numericId, uniqueId, osStatFlags, this); registerNewStatistics(statistics); return statistics; }
@Override public void close() { super.close(); if (this.statisticsManager != null) { statisticsManager.destroyStatistics(this); } }
protected int countMarkableSampleHandlers(SampleHandler handler) { int count = 0; List<MarkableSampleHandler> list = currentHandlers(); for (MarkableSampleHandler wrapper : list) { if (wrapper.getSampleHandler() == handler) { count++; } } return count; }
@Override protected void monitor(final long millisTimeStamp, final List<ResourceInstance> resourceInstances) { super.monitor(millisTimeStamp, resourceInstances); monitorStatistics(millisTimeStamp, resourceInstances); }
/** * Returns the difference, measured in milliseconds, between the time of the instance's first * sample and midnight, January 1, 1970 UTC. */ public long getFirstTimeMillis() { return archive.getTimeStamps().getMilliTimeStamp(firstTSidx); }
private int getMemoryUsed() { int result = 0; StatArchiveReader.StatArchiveFile[] archives = getArchives(); for (int i = 0; i < archives.length; i++) { StatArchiveFile f = archives[i]; result += f.getMemoryUsed(); } return result; }
/** * Returns an array of all the current statistic resource instances. */ @Override public Statistics[] getStatistics() { return getStatisticsManager().getStatistics(); }
/** * Returns the time this sampler's system was started. */ @Override public long getSystemStartTime() { return getStatisticsManager().getStartTime(); }
/** * Closes down anything initialied by initSpecialStats. */ private synchronized void closeSpecialStats() { if (this.vmStats != null) { this.vmStats.close(); } closeProcessStats(); }
@Override public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) { if (this.statsDisabled) { return new DummyStatisticsImpl(type, textId, numericId); } return super.createAtomicStatistics(type, textId, numericId); } }
private void dump(PrintWriter stream) { StatArchiveReader.StatArchiveFile[] archives = getArchives(); for (int i = 0; i < archives.length; i++) { StatArchiveFile f = archives[i]; f.dump(stream); } }
/** * Returns the number of times this resource instance has been sampled. */ public int getSampleCount() { if (active) { return archive.getTimeStamps().getSize() - firstTSidx; } else { return (lastTSidx + 1) - firstTSidx; } }