[
https://issues.apache.org/jira/browse/STORM-1893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15329355#comment-15329355
]
ASF GitHub Bot commented on STORM-1893:
---------------------------------------
Github user abhishekagarwal87 commented on a diff in the pull request:
https://github.com/apache/storm/pull/1484#discussion_r66953536
--- Diff:
external/storm-opentsdb/src/main/java/org/apache/stom/opentsdb/client/OpenTsdbClient.java
---
@@ -0,0 +1,151 @@
+/*
+ * 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.client;
+
+import com.google.common.base.Preconditions;
+import org.apache.stom.opentsdb.OpenTsdbMetricDatapoint;
+import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.RequestEntityProcessing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import java.io.Serializable;
+import java.util.Collection;
+
+/**
+ * Client to connect to OpenTsdb TSD for storing timeseries datapoints.
+ */
+public class OpenTsdbClient {
+ private static final String PUT_PATH = "/api/put";
+ private static Logger LOG =
LoggerFactory.getLogger(OpenTsdbClient.class);
+
+ private final String urlString;
+ private final boolean sync;
+ private final long syncTimeout;
+ private final ResponseType responseType;
+ private final boolean enableChunkedEncoding;
+
+ private WebTarget target;
+ private Client client;
+
+ public enum ResponseType {
+ None(""),
+ Summary("summary"),
+ Details("details");
+
+ private final String value;
+
+ ResponseType(String value) {
+ this.value = value;
+ }
+ }
+
+ protected OpenTsdbClient(String urlString, boolean sync, long
syncTimeOut, ResponseType responseType, boolean enableChunkedEncoding) {
+ this.urlString = urlString;
+ this.sync = sync;
+ this.syncTimeout = syncTimeOut;
+ this.responseType = responseType;
+ this.enableChunkedEncoding = enableChunkedEncoding;
+
+ init();
+ }
+
+ private void init() {
+
+ final ApacheConnectorProvider apacheConnectorProvider = new
ApacheConnectorProvider();
+ final ClientConfig clientConfig = new
ClientConfig().connectorProvider(apacheConnectorProvider);
+
+ // transfer encoding should be set as jersey sets it on by default.
+ clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING,
+ enableChunkedEncoding ? RequestEntityProcessing.CHUNKED :
RequestEntityProcessing.BUFFERED);
+
+ client = ClientBuilder.newClient(clientConfig);
+
+ target = client.target(urlString).path(PUT_PATH);
+ if(sync) {
+ target = target.queryParam("sync").queryParam("sync_timeout",
syncTimeout);
+ }
+ if(!(responseType == ResponseType.None)) {
+ target.queryParam(responseType.value);
+ }
+
+ LOG.debug("target uri [{}]", target.getUri());
--- End diff --
This can be made info.
> 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)