{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/24252952","id":24252952,"diff_hunk":"@@ -179,121 +182,190 @@ object KafkaUtils {\n       errs => throw new SparkException(errs.mkString(\"\\n\")),\n       ok => ok\n     )\n-    new KafkaRDD[K, V, U, T, (K, V)](sc, kafkaParams, offsetRanges, leaders, messageHandler)\n+    new KafkaRDD[K, V, KD, VD, (K, V)](sc, kafkaParams, offsetRanges, leaders, messageHandler)\n   }\n \n-  /** A batch-oriented interface for consuming from Kafka.\n-   * Starting and ending offsets are specified in advance,\n-   * so that you can control exactly-once semantics.\n+  /**\n+   * :: Experimental ::\n+   * Create a RDD from Kafka using offset ranges for each topic and partition. This allows you\n+   * specify the Kafka leader to connect to (to optimize fetching) and access the message as well\n+   * as the metadata.\n+   *\n    * @param sc SparkContext object\n    * @param kafkaParams Kafka <a href=\"http://kafka.apache.org/documentation.html#configuration\">\n-   * configuration parameters</a>.\n-   *   Requires \"metadata.broker.list\" or \"bootstrap.servers\" to be set with Kafka broker(s),\n-   *   NOT zookeeper servers, specified in host1:port1,host2:port2 form.\n+   *    configuration parameters</a>. Requires \"metadata.broker.list\" or \"bootstrap.servers\"\n+   *    to be set with Kafka broker(s) (NOT zookeeper servers) specified in\n+   *    host1:port1,host2:port2 form.\n    * @param offsetRanges Each OffsetRange in the batch corresponds to a\n    *   range of offsets for a given Kafka topic/partition\n    * @param leaders Kafka leaders for each offset range in batch\n-   * @param messageHandler function for translating each message into the desired type\n+   * @param messageHandler function for translating each message and metadata into the desired type\n    */\n   @Experimental\n   def createRDD[\n     K: ClassTag,\n     V: ClassTag,\n-    U <: Decoder[_]: ClassTag,\n-    T <: Decoder[_]: ClassTag,\n-    R: ClassTag] (\n+    KD <: Decoder[K]: ClassTag,\n+    VD <: Decoder[V]: ClassTag,\n+    R: ClassTag](\n       sc: SparkContext,\n       kafkaParams: Map[String, String],\n       offsetRanges: Array[OffsetRange],\n       leaders: Array[Leader],\n       messageHandler: MessageAndMetadata[K, V] => R\n-  ): RDD[R] = {\n-\n+    ): RDD[R] = {\n     val leaderMap = leaders\n       .map(l => TopicAndPartition(l.topic, l.partition) -> (l.host, l.port))\n       .toMap\n-    new KafkaRDD[K, V, U, T, R](sc, kafkaParams, offsetRanges, leaderMap, messageHandler)\n+    new KafkaRDD[K, V, KD, VD, R](sc, kafkaParams, offsetRanges, leaderMap, messageHandler)\n   }\n \n+\n   /**\n-   * This stream can guarantee that each message from Kafka is included in transformations\n-   * (as opposed to output actions) exactly once, even in most failure situations.\n+   * Create a RDD from Kafka using offset ranges for each topic and partition.\n    *\n-   * Points to note:\n-   *\n-   * Failure Recovery - You must checkpoint this stream, or save offsets yourself and provide them\n-   * as the fromOffsets parameter on restart.\n-   * Kafka must have sufficient log retention to obtain messages after failure.\n-   *\n-   * Getting offsets from the stream - see programming guide\n+   * @param jsc JavaSparkContext object\n+   * @param kafkaParams Kafka <a href=\"http://kafka.apache.org/documentation.html#configuration\">\n+   *    configuration parameters</a>. Requires \"metadata.broker.list\" or \"bootstrap.servers\"\n+   *    to be set with Kafka broker(s) (NOT zookeeper servers) specified in\n+   *    host1:port1,host2:port2 form.\n+   * @param offsetRanges Each OffsetRange in the batch corresponds to a\n+   *   range of offsets for a given Kafka topic/partition\n+   */\n+  @Experimental\n+  def createRDD[K, V, KD <: Decoder[K], VD <: Decoder[V]](\n+      jsc: JavaSparkContext,\n+      keyClass: Class[K],\n+      valueClass: Class[V],\n+      keyDecoderClass: Class[KD],\n+      valueDecoderClass: Class[VD],\n+      kafkaParams: JMap[String, String],\n+      offsetRanges: Array[OffsetRange]\n+    ): JavaPairRDD[K, V] = {\n+    implicit val keyCmt: ClassTag[K] = ClassTag(keyClass)\n+    implicit val valueCmt: ClassTag[V] = ClassTag(valueClass)\n+    implicit val keyDecoderCmt: ClassTag[KD] = ClassTag(keyDecoderClass)\n+    implicit val valueDecoderCmt: ClassTag[VD] = ClassTag(valueDecoderClass)\n+    new JavaPairRDD(createRDD[K, V, KD, VD](\n+      jsc.sc, Map(kafkaParams.toSeq: _*), offsetRanges))\n+  }\n+\n+  /**\n+   * :: Experimental ::\n+   * Create a RDD from Kafka using offset ranges for each topic and partition. This allows you\n+   * specify the Kafka leader to connect to (to optimize fetching) and access the message as well\n+   * as the metadata.\n    *\n-.  * Zookeeper - This does not use Zookeeper to store offsets.  For interop with Kafka monitors\n-   * that depend on Zookeeper, you must store offsets in ZK yourself.\n+   * @param jsc JavaSparkContext object\n+   * @param kafkaParams Kafka <a href=\"http://kafka.apache.org/documentation.html#configuration\">\n+   *    configuration parameters</a>. Requires \"metadata.broker.list\" or \"bootstrap.servers\"\n+   *    to be set with Kafka broker(s) (NOT zookeeper servers) specified in\n+   *    host1:port1,host2:port2 form.\n+   * @param offsetRanges Each OffsetRange in the batch corresponds to a\n+   *   range of offsets for a given Kafka topic/partition\n+   * @param leaders Kafka leaders for each offset range in batch\n+   * @param messageHandler function for translating each message and metadata into the desired type\n+   */\n+  @Experimental\n+  def createRDD[K, V, KD <: Decoder[K], VD <: Decoder[V], R](\n+      jsc: JavaSparkContext,\n+      keyClass: Class[K],\n+      valueClass: Class[V],\n+      keyDecoderClass: Class[KD],\n+      valueDecoderClass: Class[VD],\n+      recordClass: Class[R],\n+      kafkaParams: JMap[String, String],\n+      offsetRanges: Array[OffsetRange],\n+      leaders: Array[Leader],\n+      messageHandler: JFunction[MessageAndMetadata[K, V], R]\n+    ): JavaRDD[R] = {\n+    implicit val keyCmt: ClassTag[K] = ClassTag(keyClass)\n+    implicit val valueCmt: ClassTag[V] = ClassTag(valueClass)\n+    implicit val keyDecoderCmt: ClassTag[KD] = ClassTag(keyDecoderClass)\n+    implicit val valueDecoderCmt: ClassTag[VD] = ClassTag(valueDecoderClass)\n+    implicit val recordCmt: ClassTag[R] = ClassTag(recordClass)\n+    createRDD[K, V, KD, VD, R](\n+      jsc.sc, Map(kafkaParams.toSeq: _*), offsetRanges, leaders, messageHandler.call _)\n+  }\n+\n+  /**\n+   * :: Experimental ::\n+   * Create an input stream that pulls messages from a Kafka Broker. This stream can guarantee\n+   * that each message from Kafka is included in transformations exactly once (see points below).\n    *\n-   * End-to-end semantics - This does not guarantee that any output operation will push each record\n-   * exactly once. To ensure end-to-end exactly-once semantics (that is, receiving exactly once and\n-   * outputting exactly once), you have to either ensure that the output operation is\n-   * idempotent, or transactionally store offsets with the output. See the programming guide for\n-   * more details.\n+   * Points to note:\n+   *  - No receivers: This stream does not use any receiver. It directly queries Kafka\n+   *  - Offsets: This does not use Zookeeper to store offsets. The consumed offsets are tracked\n+   *    by the stream itself. For interoperability with Kafka monitoring tools that depend on \n+   *    Zookeeper, you have to update Kafka/Zookeeper yourself from the streaming application.\n+   *  - Failure Recovery: To recover from driver failures, you have to enable checkpointing","path":"external/kafka/src/main/scala/org/apache/spark/streaming/kafka/KafkaUtils.scala","position":226,"original_position":226,"commit_id":"e4abf69b63bb6bfa94823bcefd27bcbe821b1f2e","original_commit_id":"e4abf69b63bb6bfa94823bcefd27bcbe821b1f2e","user":{"login":"koeninger","id":98311,"avatar_url":"https://avatars.githubusercontent.com/u/98311?v=3","gravatar_id":"","url":"https://api.github.com/users/koeninger","html_url":"https://github.com/koeninger","followers_url":"https://api.github.com/users/koeninger/followers","following_url":"https://api.github.com/users/koeninger/following{/other_user}","gists_url":"https://api.github.com/users/koeninger/gists{/gist_id}","starred_url":"https://api.github.com/users/koeninger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koeninger/subscriptions","organizations_url":"https://api.github.com/users/koeninger/orgs","repos_url":"https://api.github.com/users/koeninger/repos","events_url":"https://api.github.com/users/koeninger/events{/privacy}","received_events_url":"https://api.github.com/users/koeninger/received_events","type":"User","site_admin":false},"body":"The methods that take fromOffsets don't actually require checkpointing to recover from driver failure, you can save offsets yourself and provide them as the fromOffsets parameter on restart, as the docs originally noted.","created_at":"2015-02-06T16:42:57Z","updated_at":"2015-02-06T16:42:57Z","html_url":"https://github.com/apache/spark/pull/4384#discussion_r24252952","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/4384","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/24252952"},"html":{"href":"https://github.com/apache/spark/pull/4384#discussion_r24252952"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/4384"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4384","id":28697957,"html_url":"https://github.com/apache/spark/pull/4384","diff_url":"https://github.com/apache/spark/pull/4384.diff","patch_url":"https://github.com/apache/spark/pull/4384.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/4384","number":4384,"state":"open","locked":false,"title":"[SPARK-4964][Streaming][Kafka] More updates to Exactly-once Kafka stream","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"body":"Changes\r\n- Added example\r\n- Added a critical unit test that verifies that offset ranges can be recovered through checkpoints\r\n\r\nMight add more changes.","created_at":"2015-02-05T04:07:54Z","updated_at":"2015-02-06T16:42:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9c4a22e13edee8132cfb0d5b9f88ac376bbb7bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/4384/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/4384/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/4384/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/e4abf69b63bb6bfa94823bcefd27bcbe821b1f2e","head":{"label":"tdas:new-kafka-fixes","ref":"new-kafka-fixes","sha":"e4abf69b63bb6bfa94823bcefd27bcbe821b1f2e","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"repo":{"id":17603343,"name":"spark","full_name":"tdas/spark","owner":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdas/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/tdas/spark","forks_url":"https://api.github.com/repos/tdas/spark/forks","keys_url":"https://api.github.com/repos/tdas/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdas/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdas/spark/teams","hooks_url":"https://api.github.com/repos/tdas/spark/hooks","issue_events_url":"https://api.github.com/repos/tdas/spark/issues/events{/number}","events_url":"https://api.github.com/repos/tdas/spark/events","assignees_url":"https://api.github.com/repos/tdas/spark/assignees{/user}","branches_url":"https://api.github.com/repos/tdas/spark/branches{/branch}","tags_url":"https://api.github.com/repos/tdas/spark/tags","blobs_url":"https://api.github.com/repos/tdas/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdas/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdas/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdas/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdas/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/tdas/spark/languages","stargazers_url":"https://api.github.com/repos/tdas/spark/stargazers","contributors_url":"https://api.github.com/repos/tdas/spark/contributors","subscribers_url":"https://api.github.com/repos/tdas/spark/subscribers","subscription_url":"https://api.github.com/repos/tdas/spark/subscription","commits_url":"https://api.github.com/repos/tdas/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdas/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdas/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdas/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/tdas/spark/contents/{+path}","compare_url":"https://api.github.com/repos/tdas/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdas/spark/merges","archive_url":"https://api.github.com/repos/tdas/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdas/spark/downloads","issues_url":"https://api.github.com/repos/tdas/spark/issues{/number}","pulls_url":"https://api.github.com/repos/tdas/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/tdas/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/tdas/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdas/spark/labels{/name}","releases_url":"https://api.github.com/repos/tdas/spark/releases{/id}","created_at":"2014-03-10T18:19:48Z","updated_at":"2014-10-09T07:43:39Z","pushed_at":"2015-02-06T03:34:39Z","git_url":"git://github.com/tdas/spark.git","ssh_url":"git@github.com:tdas/spark.git","clone_url":"https://github.com/tdas/spark.git","svn_url":"https://github.com/tdas/spark","homepage":null,"size":92109,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"84acd08e0886aa23195f35837c15c09aa7804aff","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-02-06T15:15:12Z","pushed_at":"2015-02-06T12:22:42Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1233200,"stargazers_count":2801,"watchers_count":2801,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2451,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":304,"forks":2451,"open_issues":304,"watchers":2801,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/4384"},"html":{"href":"https://github.com/apache/spark/pull/4384"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/4384"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/4384/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/4384/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/4384/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/e4abf69b63bb6bfa94823bcefd27bcbe821b1f2e"}}}}