List of usage examples for com.amazonaws.util.json Jackson toJsonString
public static String toJsonString(Object value)
From source file:com.github.gregwhitaker.awspolly.example.PollyVoicesHandler.java
License:Apache License
@Override public void handle(Context ctx) throws Exception { String token = null;/*from w w w. j a v a 2 s.c om*/ List<Voice> voices = new ArrayList<>(); while (true) { DescribeVoicesResult result; if (token == null) { result = polly.describeVoices(new DescribeVoicesRequest()); } else { result = polly.describeVoices(new DescribeVoicesRequest().withNextToken(token)); } voices.addAll(result.getVoices()); if (result.getNextToken() != null) { token = result.getNextToken(); } else { ctx.render(Jackson.toJsonString(voices)); break; } } }
From source file:com.github.lpezet.antiope.metrics.aws.BlockingRequestBuilder.java
License:Open Source License
/** * Summarizes the given datum into the statistics of the respective unique metric. *//* w ww .j a va2 s . c om*/ private void summarize(MetricDatum pDatum, Map<String, MetricDatum> pUniqueMetrics) { Double pValue = pDatum.getValue(); if (pValue == null) { return; } List<Dimension> oDims = pDatum.getDimensions(); Collections.sort(oDims, DimensionComparator.INSTANCE); String oMetricName = pDatum.getMetricName(); String k = oMetricName + Jackson.toJsonString(oDims); MetricDatum oStatDatum = pUniqueMetrics.get(k); if (oStatDatum == null) { oStatDatum = new MetricDatum().withDimensions(pDatum.getDimensions()).withMetricName(oMetricName) .withUnit(pDatum.getUnit()).withStatisticValues(new StatisticSet().withMaximum(pValue) .withMinimum(pValue).withSampleCount(0.0).withSum(0.0)); pUniqueMetrics.put(k, oStatDatum); } StatisticSet oStat = oStatDatum.getStatisticValues(); oStat.setSampleCount(oStat.getSampleCount() + 1.0); oStat.setSum(oStat.getSum() + pValue); if (pValue > oStat.getMaximum()) { oStat.setMaximum(pValue); } else if (pValue < oStat.getMinimum()) { oStat.setMinimum(pValue); } }