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

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

Introduction

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

Prototype

public static Map getMap(Map map, Object key, Map defaultValue) 

Source Link

Document

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

Usage

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

/**
 * Check if the given perfTest has too many errors. (20%)
 *
 * @param perfTest perftest//  w w  w  . j a  v a 2  s . 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//w  ww.ja v a 2 s  . c  om
 */
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());

}