io.rainfall.statistics.StatisticsPeekHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rainfall-core Show documentation
Show all versions of rainfall-core Show documentation
Rainfall-core is the core of the Rainfall framework
/*
* Copyright (c) 2014-2022 Aurélien Broszniowski
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.rainfall.statistics;
import io.rainfall.statistics.collector.StatisticsCollector;
import io.rainfall.statistics.exporter.Exporter;
import org.HdrHistogram.Histogram;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Aurelien Broszniowski
*/
public class StatisticsPeekHolder> {
public final static String ALL = "ALL";
private final Enum[] resultsReported;
private final ConcurrentHashMap assertionsErrors;
private final RainfallHistogramSink histograms;
private final long startTime;
private Map> statisticsPeeks = new ConcurrentHashMap>();
private Map extraCollectedStatistics = new ConcurrentHashMap();
private StatisticsPeek totalStatisticsPeeks = null;
private long timestamp;
public StatisticsPeekHolder(final Enum[] resultsReported, final Map> statisticsMap,
final Set statisticsCollectors,
final ConcurrentHashMap assertionsErrors, RainfallHistogramSink histograms,
long startTime) {
this.resultsReported = resultsReported;
this.assertionsErrors = assertionsErrors;
this.histograms = histograms;
this.startTime = startTime;
this.timestamp = System.currentTimeMillis();
for (String name : statisticsMap.keySet()) {
statisticsPeeks.put(name, statisticsMap.get(name).peek(timestamp));
}
this.totalStatisticsPeeks = new StatisticsPeek(ALL, this.resultsReported, this.timestamp);
totalStatisticsPeeks.addAll(statisticsPeeks);
for (StatisticsCollector statisticsCollector : statisticsCollectors) {
extraCollectedStatistics.put(statisticsCollector.getName(), statisticsCollector.peek());
}
}
public StatisticsPeek getStatisticsPeeks(String name) {
return statisticsPeeks.get(name);
}
public Long getAssertionsErrorsCount(String name) {return assertionsErrors.get(name).longValue();}
public Set getStatisticsPeeksNames() {
return statisticsPeeks.keySet();
}
public StatisticsPeek getTotalStatisticsPeeks() {
return totalStatisticsPeeks;
}
public long getTimestamp() {
return timestamp;
}
public long getStartTime() {
return startTime;
}
public Enum[] getResultsReported() {
return resultsReported;
}
public Map getExtraCollectedStatistics() {
return extraCollectedStatistics;
}
public Long getTotalAssertionsErrorsCount() {
Long totalAssertionsErrorsCount = 0L;
for (LongAdder count : assertionsErrors.values()) {
totalAssertionsErrorsCount += count.longValue();
}
return totalAssertionsErrorsCount;
}
public Histogram fetchHistogram(final Enum result) {
return histograms.fetchHistogram(result);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy