All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.pivotal.services.dataTx.geode.office.ParNewCollectionTimeThresholdChartStatsVisitor Maven / Gradle / Ivy

Go to download

APIs to convert Apache Geode/GemFire data points to office documents such as CSVs or graphic reports

The newest version!
package io.pivotal.services.dataTx.geode.office;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import io.pivotal.services.dataTx.geode.operations.stats.ResourceInst;
import io.pivotal.services.dataTx.geode.operations.stats.ResourceType;
import io.pivotal.services.dataTx.geode.operations.stats.StatDescriptor;
import io.pivotal.services.dataTx.geode.operations.stats.StatValue;
import nyla.solutions.core.data.Property;
import nyla.solutions.core.data.clock.Day;
import nyla.solutions.core.util.Text;
import nyla.solutions.office.chart.Chart;
import nyla.solutions.office.chart.JFreeChartFacade;

/**
 * 
 *  
 *  The class will generate a bar graph of all ParNew collection times greater 
 *  than a given millisecond threshold.
 *  
 * 
* @author Gregory Green * */ public class ParNewCollectionTimeThresholdChartStatsVisitor extends AbstractChartVisitor { private String appName = null; private String resourceResourceNameFilter = "ParNew"; private String filterTypeName = "VMGCStats".toUpperCase(); private String filterStatName = "collectionTime"; private Map maxMap = new HashMap<>(); private final Double threshold; private final Day dayFilter; public ParNewCollectionTimeThresholdChartStatsVisitor(Day dayFilter) { this(dayFilter, 50.1); }//---------------------------------------------s public ParNewCollectionTimeThresholdChartStatsVisitor(Day dayFilter, double threshold) { this.threshold = Double.valueOf(threshold); this.dayFilter = dayFilter; this.chart.setTitle("Max Par New collection time per second on "+this.dayFilter); this.chart.setGraphType(Chart.BAR_GRAPH_TYPE); } @Override public void visitResourceInsts(ResourceInst[] resourceInsts) { this.appName = StatsUtil.getAppName(resourceInsts); } @Override public void visitResourceInst(ResourceInst resourceInst) { String name = resourceInst.getName(); ResourceType resourceType= resourceInst.getType(); boolean skip = !this.resourceResourceNameFilter.equals(name) || resourceType == null || resourceType.getName() == null || (this.filterTypeName != null && !resourceType.getName().toUpperCase().contains(this.filterTypeName)); if(skip) { return; } StatValue[] statValues = resourceInst.getStatValues(); if(statValues == null) return; for (StatValue statValue : statValues) { String statName = statValue.getDescriptor().getName(); if(filterStatName != null && !filterStatName.equalsIgnoreCase(statName)) { continue; //skip; } if(statValue.getSnapshotsMaximum() < threshold) return; StatDescriptor statDescriptor = resourceInst.getType().getStat(statName); long [] times = statValue.getRawAbsoluteTimeStamps(); double [] values = statValue.getSnapshots(); String timeFormat = "HH:mm:ss"; for (int i = 0; i < values.length; i++) { Date date = new Date(times[i]); Day day = new Day(date); if (!dayFilter.isSameDay(day)) continue; String timeValueText = Text.formatDate(timeFormat, date); Property timeValue = new Property(this.appName, timeValueText); //get previous Max Double max = this.maxMap.get(timeValue); if (max == null) max = Double.valueOf(values[i]); else max = Double.valueOf(Math.max(values[i], max.doubleValue())); if (max.doubleValue() > statValue.getSnapshotsMaximum()) throw new IllegalArgumentException(max.doubleValue() + ">" + statValue.getSnapshotsMaximum() + " statValue:" + statValue); if (values[i] >= threshold) this.maxMap.put(timeValue, max); } } for (Map.Entry entry : maxMap.entrySet()) { this.chart.plotValue(entry.getValue(), entry.getKey().getName(), entry.getKey().getValue().toString()); } }//------------------------------------------------ }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy