Example usage for org.apache.commons.collections MapUtils getDouble

List of usage examples for org.apache.commons.collections MapUtils getDouble

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getDouble.

Prototype

public static Double getDouble(Map map, Object key, Double defaultValue) 

Source Link

Document

Looks up the given key in the given map, converting the result into a double, using the default value if the the conversion fails.

Usage

From source file:com.iyonger.apm.web.service.PerfTestService.java

double parseDoubleWithSafety(Map<?, ?> map, Object key, Double defaultValue) {
    Double doubleValue = MapUtils.getDouble(map, key, defaultValue);
    return Math.round(doubleValue * 100D) / 100D;
}

From source file:com.iyonger.apm.web.service.PerfTestService.java

/**
 * Check if the given perfTest has too many errors. (20%)
 *
 * @param perfTest perftest/*from   www  .java2s .  c o  m*/
 * @return true if too many errors.
 */
@SuppressWarnings("unchecked")
public boolean hasTooManyError(PerfTest perfTest) {
    Map<String, Object> result = getStatistics(perfTest);
    Map<String, Object> totalStatistics = MapUtils.getMap(result, "totalStatistics", MapUtils.EMPTY_MAP);
    long tests = MapUtils.getDouble(totalStatistics, "Tests", 0D).longValue();
    long errors = MapUtils.getDouble(totalStatistics, "Errors", 0D).longValue();
    return ((((double) errors) / (tests + errors)) > 0.3d);
}

From source file:com.iyonger.apm.web.service.PerfTestService.java

/**
 * Update the given {@link PerfTest} properties after test finished.
 *
 * @param perfTest perfTest/*from ww  w.j  a  va 2s. com*/
 */
public void updatePerfTestAfterTestFinish(PerfTest perfTest) {
    checkNotNull(perfTest);
    Map<String, Object> result = consoleManager.getConsoleUsingPort(perfTest.getPort()).getStatisticsData();
    @SuppressWarnings("unchecked")
    Map<String, Object> totalStatistics = MapUtils.getMap(result, "totalStatistics", MapUtils.EMPTY_MAP);
    LOGGER.info("Total Statistics for test {}  is {}", perfTest.getId(), totalStatistics);
    perfTest.setTps(parseDoubleWithSafety(totalStatistics, "TPS", 0D));
    perfTest.setMeanTestTime(parseDoubleWithSafety(totalStatistics, "Mean_Test_Time_(ms)", 0D));
    perfTest.setPeakTps(parseDoubleWithSafety(totalStatistics, "Peak_TPS", 0D));
    perfTest.setTests(MapUtils.getDouble(totalStatistics, "Tests", 0D).longValue());
    perfTest.setErrors(MapUtils.getDouble(totalStatistics, "Errors", 0D).longValue());

}