Search in sources :

Example 1 with ITupleOpenTsdbDatapointMapper

use of org.apache.storm.opentsdb.bolt.ITupleOpenTsdbDatapointMapper in project storm by apache.

the class OpenTsdbState method update.

public void update(List<TridentTuple> tridentTuples, TridentCollector collector) {
    try {
        List<OpenTsdbMetricDatapoint> metricDataPoints = new ArrayList<>();
        for (TridentTuple tridentTuple : tridentTuples) {
            for (ITupleOpenTsdbDatapointMapper tupleOpenTsdbDatapointMapper : tupleMetricPointMappers) {
                metricDataPoints.add(tupleOpenTsdbDatapointMapper.getMetricPoint(tridentTuple));
            }
        }
        final ClientResponse.Details details = openTsdbClient.writeMetricPoints(metricDataPoints);
        if (details != null && (details.getFailed() > 0)) {
            final String errorMsg = "Failed in writing metrics to TSDB with details: " + details;
            LOG.error(errorMsg);
            throw new RuntimeException(errorMsg);
        }
    } catch (Exception e) {
        collector.reportError(e);
        throw new FailedException(e);
    }
}
Also used : ClientResponse(org.apache.storm.opentsdb.client.ClientResponse) OpenTsdbMetricDatapoint(org.apache.storm.opentsdb.OpenTsdbMetricDatapoint) FailedException(org.apache.storm.topology.FailedException) ArrayList(java.util.ArrayList) ITupleOpenTsdbDatapointMapper(org.apache.storm.opentsdb.bolt.ITupleOpenTsdbDatapointMapper) FailedException(org.apache.storm.topology.FailedException) TridentTuple(org.apache.storm.trident.tuple.TridentTuple)

Aggregations

ArrayList (java.util.ArrayList)1 OpenTsdbMetricDatapoint (org.apache.storm.opentsdb.OpenTsdbMetricDatapoint)1 ITupleOpenTsdbDatapointMapper (org.apache.storm.opentsdb.bolt.ITupleOpenTsdbDatapointMapper)1 ClientResponse (org.apache.storm.opentsdb.client.ClientResponse)1 FailedException (org.apache.storm.topology.FailedException)1 TridentTuple (org.apache.storm.trident.tuple.TridentTuple)1