@Override public void process(Exchange exchange) throws Exception { String message = exchange.getIn().getBody(String.class); ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); List<Double> values = objectMapper.readValue( message, typeFactory.constructCollectionType(List.class, Double.class)); SummaryStatistics summaryStatistics = new SummaryStatistics(); List<Double> list = new ObjectMapper().readValue(message, List.class); for (Double value : list) { summaryStatistics.addValue(value); } String variance = Double.toString(summaryStatistics.getVariance()); exchange.getOut().setBody(variance); }
/** * Get the Variance of all the stats that are watched, for all the stats added with add() since * the last call to clear() (in JSON). * * @return The Variance of all the stats since last clear() in JSON. */ public String getVarianceJSON() { String str = String.format( FakeUserStats.jsonMediaStreamStatsTemplate, -1, // ssrc not needed here downloadJitterMs.getVariance(), downloadPercentLoss.getVariance(), downloadRateKiloBitPerSec.getVariance(), jitterBufferDelayMs.getVariance(), jitterBufferDelayPackets.getVariance(), nbDiscarded.getVariance(), nbDiscardedFull.getVariance(), nbDiscardedLate.getVariance(), nbDiscardedReset.getVariance(), nbDiscardedShrink.getVariance(), nbFec.getVariance(), nbPackets.getVariance(), nbPacketsLost.getVariance(), nbReceivedBytes.getVariance(), nbSentBytes.getVariance(), packetQueueCountPackets.getVariance(), packetQueueSize.getVariance(), percentDiscarded.getVariance(), rttMs.getVariance(), uploadJitterMs.getVariance(), uploadPercentLoss.getVariance(), uploadRateKiloBitPerSec.getVariance()); return str; }