{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/tranquility/pulls/comments/49651719","id":49651719,"diff_hunk":"@@ -0,0 +1,161 @@\n+/*\n+ * Licensed to Metamarkets Group Inc. (Metamarkets) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  Metamarkets licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package com.metamx.tranquility.kafka.writer;\n+\n+import com.fasterxml.jackson.core.type.TypeReference;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.google.common.base.Throwables;\n+import com.google.common.primitives.Ints;\n+import com.metamx.common.logger.Logger;\n+import com.metamx.common.scala.net.curator.Disco;\n+import com.metamx.tranquility.config.ConfigHelper;\n+import com.metamx.tranquility.config.DataSourceConfig;\n+import com.metamx.tranquility.druid.DruidLocation;\n+import com.metamx.tranquility.finagle.FinagleRegistry;\n+import com.metamx.tranquility.finagle.FinagleRegistryConfig;\n+import com.metamx.tranquility.kafka.model.MessageCounters;\n+import com.metamx.tranquility.kafka.model.TranquilityKafkaConfig;\n+import com.metamx.tranquility.tranquilizer.SimpleTranquilizerAdapter;\n+import com.metamx.tranquility.tranquilizer.Tranquilizer;\n+import org.apache.curator.RetryPolicy;\n+import org.apache.curator.framework.CuratorFramework;\n+import org.apache.curator.framework.CuratorFrameworkFactory;\n+import org.apache.curator.retry.ExponentialBackoffRetry;\n+import scala.Predef;\n+import scala.Tuple2;\n+import scala.collection.JavaConverters;\n+\n+import java.io.IOException;\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+/**\n+ * Pushes events to Druid through Tranquility using the SimpleTranquilizerAdapter.\n+ */\n+public class TranquilityEventWriter\n+{\n+  private static final Logger log = new Logger(TranquilityEventWriter.class);\n+  private static final ObjectMapper MAPPER = new ObjectMapper();\n+  private static final RetryPolicy RETRY_POLICY = new ExponentialBackoffRetry(1000, 500, 30000);\n+\n+  private final CuratorFramework curator;\n+  private final DataSourceConfig<TranquilityKafkaConfig> dataSourceConfig;\n+  private final SimpleTranquilizerAdapter<scala.collection.immutable.Map<String, Object>> simpleTranquilizerAdapter;\n+\n+  private long rejectedLogCount = 0;\n+\n+  public TranquilityEventWriter(String topic, DataSourceConfig<TranquilityKafkaConfig> dataSourceConfig)\n+  {\n+    this.dataSourceConfig = dataSourceConfig;\n+\n+    final int zkTimeout = Ints.checkedCast(\n+        dataSourceConfig.config()\n+                        .zookeeperTimeout()\n+                        .toStandardDuration()\n+                        .getMillis()\n+    );\n+\n+    curator = CuratorFrameworkFactory.builder()","path":"kafka/src/main/java/com/metamx/tranquility/kafka/writer/TranquilityEventWriter.java","position":74,"original_position":74,"commit_id":"ebc60b117103d738fb072d9d683f1031fa340ea6","original_commit_id":"ebc60b117103d738fb072d9d683f1031fa340ea6","user":{"login":"gianm","id":1214075,"avatar_url":"https://avatars.githubusercontent.com/u/1214075?v=3","gravatar_id":"","url":"https://api.github.com/users/gianm","html_url":"https://github.com/gianm","followers_url":"https://api.github.com/users/gianm/followers","following_url":"https://api.github.com/users/gianm/following{/other_user}","gists_url":"https://api.github.com/users/gianm/gists{/gist_id}","starred_url":"https://api.github.com/users/gianm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gianm/subscriptions","organizations_url":"https://api.github.com/users/gianm/orgs","repos_url":"https://api.github.com/users/gianm/repos","events_url":"https://api.github.com/users/gianm/events{/privacy}","received_events_url":"https://api.github.com/users/gianm/received_events","type":"User","site_admin":false},"body":"That'll allow scaling to more data sources without overloading things.","created_at":"2016-01-13T21:16:27Z","updated_at":"2016-01-13T21:16:27Z","html_url":"https://github.com/druid-io/tranquility/pull/65#discussion_r49651719","pull_request_url":"https://api.github.com/repos/druid-io/tranquility/pulls/65","_links":{"self":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/comments/49651719"},"html":{"href":"https://github.com/druid-io/tranquility/pull/65#discussion_r49651719"},"pull_request":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/tranquility/pulls/65","id":53069777,"html_url":"https://github.com/druid-io/tranquility/pull/65","diff_url":"https://github.com/druid-io/tranquility/pull/65.diff","patch_url":"https://github.com/druid-io/tranquility/pull/65.patch","issue_url":"https://api.github.com/repos/druid-io/tranquility/issues/65","number":65,"state":"open","locked":false,"title":"tranquility-kafka module","user":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"body":"This PR adds a module to Tranquility to help push data from Kafka into the indexing service through Tranquility. Multiple instances of tranquility-kafka can be run at the same time to provide scalability and high availability, and an instance can read from multiple Kafka topics and write to multiple Druid datasources. Tranquility-kafka supports regex pattern based mapping of Kafka topic to a Druid ingestion spec, thus allowing indexing tasks for new datasources to be automatically created when a new Kafka topic is created that matches the regex. If additional Kafka topic -> ingestion spec mappings need to be added, tranquility-kafka supports rolling updates without data loss.\r\n\r\nTo build, run: `sbt universal:packageZipTarball`\r\n\r\nUnpack the tgz in `/kafka/target/universal/tranquility-kafka-x.x.x.tgz` and run `bin/tranquility-kafka -f conf/config.properties` to start. You'll need to modify config.properties and add some ingestion specs to do anything useful.\r\n\r\nI'll be adding unit tests and documentation, but wanted to put this out to get some feedback.","created_at":"2015-12-09T02:41:48Z","updated_at":"2016-01-13T21:16:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e35676f529bbfe00e580779ed90743b59e4146f6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/tranquility/pulls/65/commits","review_comments_url":"https://api.github.com/repos/druid-io/tranquility/pulls/65/comments","review_comment_url":"https://api.github.com/repos/druid-io/tranquility/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/tranquility/issues/65/comments","statuses_url":"https://api.github.com/repos/druid-io/tranquility/statuses/ebc60b117103d738fb072d9d683f1031fa340ea6","head":{"label":"dclim:tranquility-kafka","ref":"tranquility-kafka","sha":"ebc60b117103d738fb072d9d683f1031fa340ea6","user":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"repo":{"id":47656693,"name":"tranquility","full_name":"dclim/tranquility","owner":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dclim/tranquility","description":"Tranquility helps you send real-time event streams to Druid and handles partitioning, replication, service discovery, and schema rollover, seamlessly and without downtime.","fork":true,"url":"https://api.github.com/repos/dclim/tranquility","forks_url":"https://api.github.com/repos/dclim/tranquility/forks","keys_url":"https://api.github.com/repos/dclim/tranquility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dclim/tranquility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dclim/tranquility/teams","hooks_url":"https://api.github.com/repos/dclim/tranquility/hooks","issue_events_url":"https://api.github.com/repos/dclim/tranquility/issues/events{/number}","events_url":"https://api.github.com/repos/dclim/tranquility/events","assignees_url":"https://api.github.com/repos/dclim/tranquility/assignees{/user}","branches_url":"https://api.github.com/repos/dclim/tranquility/branches{/branch}","tags_url":"https://api.github.com/repos/dclim/tranquility/tags","blobs_url":"https://api.github.com/repos/dclim/tranquility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dclim/tranquility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dclim/tranquility/git/refs{/sha}","trees_url":"https://api.github.com/repos/dclim/tranquility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dclim/tranquility/statuses/{sha}","languages_url":"https://api.github.com/repos/dclim/tranquility/languages","stargazers_url":"https://api.github.com/repos/dclim/tranquility/stargazers","contributors_url":"https://api.github.com/repos/dclim/tranquility/contributors","subscribers_url":"https://api.github.com/repos/dclim/tranquility/subscribers","subscription_url":"https://api.github.com/repos/dclim/tranquility/subscription","commits_url":"https://api.github.com/repos/dclim/tranquility/commits{/sha}","git_commits_url":"https://api.github.com/repos/dclim/tranquility/git/commits{/sha}","comments_url":"https://api.github.com/repos/dclim/tranquility/comments{/number}","issue_comment_url":"https://api.github.com/repos/dclim/tranquility/issues/comments{/number}","contents_url":"https://api.github.com/repos/dclim/tranquility/contents/{+path}","compare_url":"https://api.github.com/repos/dclim/tranquility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dclim/tranquility/merges","archive_url":"https://api.github.com/repos/dclim/tranquility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dclim/tranquility/downloads","issues_url":"https://api.github.com/repos/dclim/tranquility/issues{/number}","pulls_url":"https://api.github.com/repos/dclim/tranquility/pulls{/number}","milestones_url":"https://api.github.com/repos/dclim/tranquility/milestones{/number}","notifications_url":"https://api.github.com/repos/dclim/tranquility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dclim/tranquility/labels{/name}","releases_url":"https://api.github.com/repos/dclim/tranquility/releases{/id}","created_at":"2015-12-08T23:48:56Z","updated_at":"2015-12-08T23:48:57Z","pushed_at":"2016-01-13T03:09:33Z","git_url":"git://github.com/dclim/tranquility.git","ssh_url":"git@github.com:dclim/tranquility.git","clone_url":"https://github.com/dclim/tranquility.git","svn_url":"https://github.com/dclim/tranquility","homepage":"","size":673,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"4a78c1699346d5cd4b0fbc3e965a6b948470e10f","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":16817857,"name":"tranquility","full_name":"druid-io/tranquility","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/tranquility","description":"Tranquility helps you send real-time event streams to Druid and handles partitioning, replication, service discovery, and schema rollover, seamlessly and without downtime.","fork":false,"url":"https://api.github.com/repos/druid-io/tranquility","forks_url":"https://api.github.com/repos/druid-io/tranquility/forks","keys_url":"https://api.github.com/repos/druid-io/tranquility/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/tranquility/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/tranquility/teams","hooks_url":"https://api.github.com/repos/druid-io/tranquility/hooks","issue_events_url":"https://api.github.com/repos/druid-io/tranquility/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/tranquility/events","assignees_url":"https://api.github.com/repos/druid-io/tranquility/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/tranquility/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/tranquility/tags","blobs_url":"https://api.github.com/repos/druid-io/tranquility/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/tranquility/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/tranquility/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/tranquility/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/tranquility/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/tranquility/languages","stargazers_url":"https://api.github.com/repos/druid-io/tranquility/stargazers","contributors_url":"https://api.github.com/repos/druid-io/tranquility/contributors","subscribers_url":"https://api.github.com/repos/druid-io/tranquility/subscribers","subscription_url":"https://api.github.com/repos/druid-io/tranquility/subscription","commits_url":"https://api.github.com/repos/druid-io/tranquility/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/tranquility/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/tranquility/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/tranquility/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/tranquility/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/tranquility/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/tranquility/merges","archive_url":"https://api.github.com/repos/druid-io/tranquility/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/tranquility/downloads","issues_url":"https://api.github.com/repos/druid-io/tranquility/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/tranquility/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/tranquility/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/tranquility/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/tranquility/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/tranquility/releases{/id}","created_at":"2014-02-13T21:30:05Z","updated_at":"2016-01-13T09:44:01Z","pushed_at":"2016-01-13T03:09:33Z","git_url":"git://github.com/druid-io/tranquility.git","ssh_url":"git@github.com:druid-io/tranquility.git","clone_url":"https://github.com/druid-io/tranquility.git","svn_url":"https://github.com/druid-io/tranquility","homepage":"","size":692,"stargazers_count":106,"watchers_count":106,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":15,"forks":41,"open_issues":15,"watchers":106,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/65"},"html":{"href":"https://github.com/druid-io/tranquility/pull/65"},"issue":{"href":"https://api.github.com/repos/druid-io/tranquility/issues/65"},"comments":{"href":"https://api.github.com/repos/druid-io/tranquility/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/tranquility/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/tranquility/statuses/ebc60b117103d738fb072d9d683f1031fa340ea6"}}}}