[
https://issues.apache.org/jira/browse/STORM-1893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15329012#comment-15329012
]
ASF GitHub Bot commented on STORM-1893:
---------------------------------------
Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/1484#discussion_r66920336
--- Diff:
external/storm-opentsdb/src/main/java/org/apache/stom/opentsdb/bolt/OpenTsdbBolt.java
---
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stom.opentsdb.bolt;
+
+import org.apache.stom.opentsdb.OpenTsdbMetricDatapoint;
+import org.apache.stom.opentsdb.client.ClientResponse;
+import org.apache.stom.opentsdb.client.OpenTsdbClient;
+import org.apache.storm.task.OutputCollector;
+import org.apache.storm.task.TopologyContext;
+import org.apache.storm.topology.OutputFieldsDeclarer;
+import org.apache.storm.topology.base.BaseRichBolt;
+import org.apache.storm.tuple.Tuple;
+import org.apache.storm.utils.BatchHelper;
+import org.apache.storm.utils.TupleUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Basic bolt implementation for storing timeseries datapoints to OpenTSDB.
+ *
+ * List of {@link OpenTsdbMetricDatapoint} is generated for each tuple
with the configured {@code tupleOpenTsdbDatapointMappers}.
+ * All these datapoints are batched till the given {@code batchSize} or
{@code flushIntervalInSeconds} is reached.
+ *
+ * Example topology:
+ *
+ */
+public class OpenTsdbBolt extends BaseRichBolt {
+ private static final Logger LOG =
LoggerFactory.getLogger(OpenTsdbBolt.class);
+
+ private final OpenTsdbClient.Builder openTsdbClientBuilder;
+ private final List<TupleOpenTsdbDatapointMapper>
tupleOpenTsdbDatapointMappers;
+ private int batchSize;
+ private int flushIntervalInSeconds;
+ private boolean failTupleForFailedMetrics;
+
+ private BatchHelper batchHelper;
+ private OpenTsdbClient openTsdbClient;
+ private Map<OpenTsdbMetricDatapoint, Tuple> metricPointsWithTuple =
new HashMap<>();
+ private OutputCollector collector;
+
+ public OpenTsdbBolt(OpenTsdbClient.Builder openTsdbClientBuilder,
List<TupleOpenTsdbDatapointMapper> tupleOpenTsdbDatapointMappers) {
+ this.openTsdbClientBuilder = openTsdbClientBuilder;
+ this.tupleOpenTsdbDatapointMappers = tupleOpenTsdbDatapointMappers;
+ }
+
+ public OpenTsdbBolt withFlushInterval(int flushIntervalInSeconds) {
+ this.flushIntervalInSeconds = flushIntervalInSeconds;
+ return this;
+ }
+
+ public OpenTsdbBolt withBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ return this;
+ }
+
+ /**
+ * When it is invoked, this bolt acks only the tuples which have
successful metrics stored into OpenTSDB and fails
+ * the respective tuples of the failed metrics.
+ *
+ * @return same insatcne by setting {@code failTupleForFailedMetrics}
to true
--- End diff --
insatcne -> instance
> Support OpenTSDB for storing timeseries data.
> ---------------------------------------------
>
> Key: STORM-1893
> URL: https://issues.apache.org/jira/browse/STORM-1893
> Project: Apache Storm
> Issue Type: New Feature
> Reporter: Satish Duggana
> Assignee: Satish Duggana
>
> - Implement openTSDB bolt to store timeseries data.
> - Trident implementation to store timeseries data in openTSDB.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)