{"action":"created","comment":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/66312905","id":66312905,"diff_hunk":"@@ -0,0 +1,652 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF 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.datatorrent.lib.db.jdbc;\n+\n+import java.io.IOException;\n+import java.sql.PreparedStatement;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+import java.util.ArrayList;\n+import java.util.Collection;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.concurrent.ArrayBlockingQueue;\n+import java.util.concurrent.atomic.AtomicReference;\n+\n+import javax.validation.constraints.Min;\n+\n+import org.slf4j.LoggerFactory;\n+\n+import org.apache.apex.malhar.lib.wal.FSWindowDataManager;\n+import org.apache.apex.malhar.lib.wal.WindowDataManager;\n+import org.apache.commons.lang3.tuple.MutablePair;\n+\n+import com.datatorrent.api.Context;\n+import com.datatorrent.api.Context.OperatorContext;\n+import com.datatorrent.api.DefaultPartition;\n+import com.datatorrent.api.Operator.ActivationListener;\n+import com.datatorrent.api.Operator.IdleTimeHandler;\n+import com.datatorrent.api.Partitioner;\n+import com.datatorrent.api.annotation.Stateless;\n+import com.datatorrent.lib.db.AbstractStoreInputOperator;\n+import com.datatorrent.lib.util.KeyValPair;\n+import com.datatorrent.lib.util.KryoCloneUtils;\n+import com.datatorrent.netlet.util.DTThrowable;\n+\n+/**\n+ * Abstract operator for for consuming data using JDBC interface<br>\n+ * User needs User needs to provide\n+ * tableName,dbConnection,setEmitColumnList,look-up key <br>\n+ * Optionally batchSize,pollInterval,Look-up key and a where clause can be given\n+ * <br>\n+ * This operator uses static partitioning to arrive at range queries for exactly\n+ * once reads<br>\n+ * Assumption is that there is an ordered column using which range queries can\n+ * be formed<br>\n+ * If an emitColumnList is provided, please ensure that the keyColumn is the\n+ * first column in the list<br>\n+ * Range queries are formed using the {@link JdbcMetaDataUtility}} Output -\n+ * comma separated list of the emit columns eg columnA,columnB,columnC\n+ * \n+ * @displayName Jdbc Polling Input Operator\n+ * @category Input\n+ * @tags database, sql, jdbc, partitionable,exactlyOnce\n+ */\n+public abstract class AbstractJdbcPollInputOperator<T> extends AbstractStoreInputOperator<T, JdbcStore>\n+    implements ActivationListener<Context>, IdleTimeHandler, Partitioner<AbstractJdbcPollInputOperator<T>>\n+{\n+  /*\n+   * poll interval in milliseconds\n+   */\n+  private int pollInterval;\n+\n+  @Min(1)\n+  private int partitionCount = 1;\n+  protected transient int operatorId;\n+  protected transient boolean isReplayed;\n+  protected transient boolean isPollable;\n+  protected int batchSize;\n+  protected int fetchSize;\n+  /**\n+   * Map of windowId to <lower bound,upper bound> of the range key\n+   */\n+  protected transient MutablePair<String, String> currentWindowRecoveryState;\n+\n+  /**\n+   * size of the emit queue used to hold polled records before emit\n+   */\n+  private int queueCapacity = 4 * 1024 * 1024;\n+  private transient volatile boolean execute;\n+  private transient AtomicReference<Throwable> cause;\n+  protected transient int spinMillis;\n+  private transient OperatorContext context;\n+  protected String tableName;\n+  protected String key;\n+  protected long currentWindowId;\n+  protected KeyValPair<String, String> rangeQueryPair;","path":"library/src/main/java/com/datatorrent/lib/db/jdbc/AbstractJdbcPollInputOperator.java","position":103,"original_position":103,"commit_id":"a96c06d6f4a3d1c5f4a69340ca1c9dce3d45a7e1","original_commit_id":"a96c06d6f4a3d1c5f4a69340ca1c9dce3d45a7e1","user":{"login":"bhupeshchawda","id":8895284,"avatar_url":"https://avatars.githubusercontent.com/u/8895284?v=3","gravatar_id":"","url":"https://api.github.com/users/bhupeshchawda","html_url":"https://github.com/bhupeshchawda","followers_url":"https://api.github.com/users/bhupeshchawda/followers","following_url":"https://api.github.com/users/bhupeshchawda/following{/other_user}","gists_url":"https://api.github.com/users/bhupeshchawda/gists{/gist_id}","starred_url":"https://api.github.com/users/bhupeshchawda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhupeshchawda/subscriptions","organizations_url":"https://api.github.com/users/bhupeshchawda/orgs","repos_url":"https://api.github.com/users/bhupeshchawda/repos","events_url":"https://api.github.com/users/bhupeshchawda/events{/privacy}","received_events_url":"https://api.github.com/users/bhupeshchawda/received_events","type":"User","site_admin":false},"body":"@NotNull?","created_at":"2016-06-08T18:31:42Z","updated_at":"2016-06-08T18:31:42Z","html_url":"https://github.com/apache/apex-malhar/pull/282#discussion_r66312905","pull_request_url":"https://api.github.com/repos/apache/apex-malhar/pulls/282","_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/66312905"},"html":{"href":"https://github.com/apache/apex-malhar/pull/282#discussion_r66312905"},"pull_request":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/282"}}},"pull_request":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/282","id":70610073,"html_url":"https://github.com/apache/apex-malhar/pull/282","diff_url":"https://github.com/apache/apex-malhar/pull/282.diff","patch_url":"https://github.com/apache/apex-malhar/pull/282.patch","issue_url":"https://api.github.com/repos/apache/apex-malhar/issues/282","number":282,"state":"open","locked":false,"title":"APEXMALHAR-2066 JdbcPolling,idempotent,partitionable","user":{"login":"devtagare","id":7666415,"avatar_url":"https://avatars.githubusercontent.com/u/7666415?v=3","gravatar_id":"","url":"https://api.github.com/users/devtagare","html_url":"https://github.com/devtagare","followers_url":"https://api.github.com/users/devtagare/followers","following_url":"https://api.github.com/users/devtagare/following{/other_user}","gists_url":"https://api.github.com/users/devtagare/gists{/gist_id}","starred_url":"https://api.github.com/users/devtagare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devtagare/subscriptions","organizations_url":"https://api.github.com/users/devtagare/orgs","repos_url":"https://api.github.com/users/devtagare/repos","events_url":"https://api.github.com/users/devtagare/events{/privacy}","received_events_url":"https://api.github.com/users/devtagare/received_events","type":"User","site_admin":false},"body":"JdbcPolling,idempotent,partitionable #282","created_at":"2016-05-18T22:28:38Z","updated_at":"2016-06-08T18:31:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0622e4ad72849530806f6042d742d213f6fa195e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/apex-malhar/pulls/282/commits","review_comments_url":"https://api.github.com/repos/apache/apex-malhar/pulls/282/comments","review_comment_url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/apex-malhar/issues/282/comments","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/a96c06d6f4a3d1c5f4a69340ca1c9dce3d45a7e1","head":{"label":"devtagare:APEXMALHAR-2066-JdbcPolling","ref":"APEXMALHAR-2066-JdbcPolling","sha":"a96c06d6f4a3d1c5f4a69340ca1c9dce3d45a7e1","user":{"login":"devtagare","id":7666415,"avatar_url":"https://avatars.githubusercontent.com/u/7666415?v=3","gravatar_id":"","url":"https://api.github.com/users/devtagare","html_url":"https://github.com/devtagare","followers_url":"https://api.github.com/users/devtagare/followers","following_url":"https://api.github.com/users/devtagare/following{/other_user}","gists_url":"https://api.github.com/users/devtagare/gists{/gist_id}","starred_url":"https://api.github.com/users/devtagare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devtagare/subscriptions","organizations_url":"https://api.github.com/users/devtagare/orgs","repos_url":"https://api.github.com/users/devtagare/repos","events_url":"https://api.github.com/users/devtagare/events{/privacy}","received_events_url":"https://api.github.com/users/devtagare/received_events","type":"User","site_admin":false},"repo":{"id":53950635,"name":"incubator-apex-malhar","full_name":"devtagare/incubator-apex-malhar","owner":{"login":"devtagare","id":7666415,"avatar_url":"https://avatars.githubusercontent.com/u/7666415?v=3","gravatar_id":"","url":"https://api.github.com/users/devtagare","html_url":"https://github.com/devtagare","followers_url":"https://api.github.com/users/devtagare/followers","following_url":"https://api.github.com/users/devtagare/following{/other_user}","gists_url":"https://api.github.com/users/devtagare/gists{/gist_id}","starred_url":"https://api.github.com/users/devtagare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devtagare/subscriptions","organizations_url":"https://api.github.com/users/devtagare/orgs","repos_url":"https://api.github.com/users/devtagare/repos","events_url":"https://api.github.com/users/devtagare/events{/privacy}","received_events_url":"https://api.github.com/users/devtagare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/devtagare/incubator-apex-malhar","description":"Mirror of Apache Apex malhar (Incubating)","fork":true,"url":"https://api.github.com/repos/devtagare/incubator-apex-malhar","forks_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/forks","keys_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/teams","hooks_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/events","assignees_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/tags","blobs_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/languages","stargazers_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/subscription","commits_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/merges","archive_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/downloads","issues_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/devtagare/incubator-apex-malhar/deployments","created_at":"2016-03-15T14:20:54Z","updated_at":"2016-03-15T14:20:59Z","pushed_at":"2016-06-07T22:11:28Z","git_url":"git://github.com/devtagare/incubator-apex-malhar.git","ssh_url":"git@github.com:devtagare/incubator-apex-malhar.git","clone_url":"https://github.com/devtagare/incubator-apex-malhar.git","svn_url":"https://github.com/devtagare/incubator-apex-malhar","homepage":null,"size":85516,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"a91287ce7652f3f0000498ebfa33c16315f44e45","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":41348334,"name":"apex-malhar","full_name":"apache/apex-malhar","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/apex-malhar","description":"Mirror of Apache Apex malhar","fork":false,"url":"https://api.github.com/repos/apache/apex-malhar","forks_url":"https://api.github.com/repos/apache/apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/apache/apex-malhar/deployments","created_at":"2015-08-25T07:00:05Z","updated_at":"2016-06-04T00:58:12Z","pushed_at":"2016-06-08T06:47:58Z","git_url":"git://github.com/apache/apex-malhar.git","ssh_url":"git@github.com:apache/apex-malhar.git","clone_url":"https://github.com/apache/apex-malhar.git","svn_url":"https://github.com/apache/apex-malhar","homepage":"","size":96260,"stargazers_count":36,"watchers_count":36,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":76,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":16,"forks":76,"open_issues":16,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/282"},"html":{"href":"https://github.com/apache/apex-malhar/pull/282"},"issue":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/282"},"comments":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/282/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/282/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/282/commits"},"statuses":{"href":"https://api.github.com/repos/apache/apex-malhar/statuses/a96c06d6f4a3d1c5f4a69340ca1c9dce3d45a7e1"}}}}
{"actor":{"display_login":"bhupeshchawda"}}