{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/56451045","id":56451045,"diff_hunk":"@@ -0,0 +1,373 @@\n+/*\n+ * Copyright (C) 2016 Google Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * 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, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+package com.google.cloud.dataflow.sdk.runners.inprocess;\n+\n+import com.google.cloud.dataflow.sdk.Pipeline;\n+import com.google.cloud.dataflow.sdk.runners.inprocess.InMemoryWatermarkManager.FiredTimers;\n+import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessPipelineRunner.CommittedBundle;\n+import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessPipelineRunner.InProcessExecutor;\n+import com.google.cloud.dataflow.sdk.transforms.AppliedPTransform;\n+import com.google.cloud.dataflow.sdk.util.KeyedWorkItem;\n+import com.google.cloud.dataflow.sdk.util.KeyedWorkItems;\n+import com.google.cloud.dataflow.sdk.util.TimeDomain;\n+import com.google.cloud.dataflow.sdk.util.TimerInternals.TimerData;\n+import com.google.cloud.dataflow.sdk.util.WindowedValue;\n+import com.google.cloud.dataflow.sdk.values.PCollection;\n+import com.google.cloud.dataflow.sdk.values.PValue;\n+import com.google.common.base.MoreObjects;\n+import com.google.common.base.Optional;\n+import com.google.common.collect.ImmutableList;\n+\n+import org.joda.time.Instant;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.Collection;\n+import java.util.Collections;\n+import java.util.Map;\n+import java.util.Queue;\n+import java.util.concurrent.ArrayBlockingQueue;\n+import java.util.concurrent.BlockingQueue;\n+import java.util.concurrent.ConcurrentHashMap;\n+import java.util.concurrent.ConcurrentLinkedQueue;\n+import java.util.concurrent.ConcurrentMap;\n+import java.util.concurrent.ExecutorService;\n+\n+import javax.annotation.Nullable;\n+\n+/**\n+ * An {@link InProcessExecutor} that uses an underlying {@link ExecutorService} and\n+ * {@link InProcessEvaluationContext} to execute a {@link Pipeline}.\n+ */\n+final class ExecutorServiceParallelExecutor implements InProcessExecutor {\n+  private static final Logger LOG = LoggerFactory.getLogger(ExecutorServiceParallelExecutor.class);\n+\n+  private final ExecutorService executorService;\n+\n+  private final Map<PValue, Collection<AppliedPTransform<?, ?, ?>>> valueToConsumers;\n+  private final TransformEvaluatorRegistry registry;\n+  private final InProcessEvaluationContext evaluationContext;\n+\n+  private final ConcurrentMap<StepAndKey, TransformExecutorService> currentEvaluations;\n+  private final ConcurrentMap<TransformExecutor<?>, Boolean> scheduledExecutors;\n+\n+  private final Queue<ExecutorUpdate> allUpdates;\n+  private final BlockingQueue<VisibleExecutorUpdate> visibleUpdates;\n+\n+  private final CompletionCallback defaultCompletionCallback;\n+  private Collection<AppliedPTransform<?, ?, ?>> rootNodes;\n+\n+  public static ExecutorServiceParallelExecutor create(\n+      ExecutorService executorService,\n+      Map<PValue, Collection<AppliedPTransform<?, ?, ?>>> valueToConsumers,\n+      TransformEvaluatorRegistry registry,\n+      InProcessEvaluationContext context) {\n+    return new ExecutorServiceParallelExecutor(\n+        executorService, valueToConsumers, registry, context);\n+  }\n+\n+  private ExecutorServiceParallelExecutor(\n+      ExecutorService executorService,\n+      Map<PValue, Collection<AppliedPTransform<?, ?, ?>>> valueToConsumers,\n+      TransformEvaluatorRegistry registry,\n+      InProcessEvaluationContext context) {\n+    this.executorService = executorService;\n+    this.valueToConsumers = valueToConsumers;\n+    this.registry = registry;\n+    this.evaluationContext = context;\n+\n+    currentEvaluations = new ConcurrentHashMap<>();\n+    scheduledExecutors = new ConcurrentHashMap<>();\n+\n+    this.allUpdates = new ConcurrentLinkedQueue<>();\n+    this.visibleUpdates = new ArrayBlockingQueue<>(20);\n+\n+    defaultCompletionCallback = new TimerlessCompletionCallback();\n+  }\n+\n+  @Override\n+  public void start(Collection<AppliedPTransform<?, ?, ?>> roots) {\n+    rootNodes = ImmutableList.copyOf(roots);\n+    Runnable monitorRunnable = new MonitorRunnable();\n+    executorService.submit(monitorRunnable);\n+  }\n+\n+  @SuppressWarnings(\"unchecked\")\n+  public void scheduleConsumption(\n+      AppliedPTransform<?, ?, ?> consumer,\n+      CommittedBundle<?> bundle,","path":"sdk/src/main/java/com/google/cloud/dataflow/sdk/runners/inprocess/ExecutorServiceParallelExecutor.java","position":111,"original_position":111,"commit_id":"bac398b5ac8c7c29a85f9bb56886e8e9429c213c","original_commit_id":"bac398b5ac8c7c29a85f9bb56886e8e9429c213c","user":{"login":"kennknowles","id":575353,"avatar_url":"https://avatars.githubusercontent.com/u/575353?v=3","gravatar_id":"","url":"https://api.github.com/users/kennknowles","html_url":"https://github.com/kennknowles","followers_url":"https://api.github.com/users/kennknowles/followers","following_url":"https://api.github.com/users/kennknowles/following{/other_user}","gists_url":"https://api.github.com/users/kennknowles/gists{/gist_id}","starred_url":"https://api.github.com/users/kennknowles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennknowles/subscriptions","organizations_url":"https://api.github.com/users/kennknowles/orgs","repos_url":"https://api.github.com/users/kennknowles/repos","events_url":"https://api.github.com/users/kennknowles/events{/privacy}","received_events_url":"https://api.github.com/users/kennknowles/received_events","type":"User","site_admin":false},"body":"`@Nullable`","created_at":"2016-03-17T03:26:54Z","updated_at":"2016-03-17T03:26:54Z","html_url":"https://github.com/apache/incubator-beam/pull/53#discussion_r56451045","pull_request_url":"https://api.github.com/repos/apache/incubator-beam/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments/56451045"},"html":{"href":"https://github.com/apache/incubator-beam/pull/53#discussion_r56451045"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-beam/pulls/53","id":62980185,"html_url":"https://github.com/apache/incubator-beam/pull/53","diff_url":"https://github.com/apache/incubator-beam/pull/53.diff","patch_url":"https://github.com/apache/incubator-beam/pull/53.patch","issue_url":"https://api.github.com/repos/apache/incubator-beam/issues/53","number":53,"state":"open","locked":false,"title":"[BEAM-22] Add ExecutorServiceParallelExecutor as an InProcessExecutor","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"body":"This is responsible for scheduling transform evaluations and\r\ncommunicating results back to the evaluation context. The executor\r\nhandle PTransforms that block arbitarily waiting for additional input.\r\n\r\n","created_at":"2016-03-15T21:30:48Z","updated_at":"2016-03-17T03:26:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0e3587abfd57e326cd1e864e4ad0c46714fe3c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-beam/pulls/53/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-beam/pulls/53/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-beam/issues/53/comments","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/bac398b5ac8c7c29a85f9bb56886e8e9429c213c","head":{"label":"tgroh:ippr_executor","ref":"ippr_executor","sha":"bac398b5ac8c7c29a85f9bb56886e8e9429c213c","user":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"repo":{"id":52644388,"name":"incubator-beam","full_name":"tgroh/incubator-beam","owner":{"login":"tgroh","id":429866,"avatar_url":"https://avatars.githubusercontent.com/u/429866?v=3","gravatar_id":"","url":"https://api.github.com/users/tgroh","html_url":"https://github.com/tgroh","followers_url":"https://api.github.com/users/tgroh/followers","following_url":"https://api.github.com/users/tgroh/following{/other_user}","gists_url":"https://api.github.com/users/tgroh/gists{/gist_id}","starred_url":"https://api.github.com/users/tgroh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgroh/subscriptions","organizations_url":"https://api.github.com/users/tgroh/orgs","repos_url":"https://api.github.com/users/tgroh/repos","events_url":"https://api.github.com/users/tgroh/events{/privacy}","received_events_url":"https://api.github.com/users/tgroh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tgroh/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/tgroh/incubator-beam","forks_url":"https://api.github.com/repos/tgroh/incubator-beam/forks","keys_url":"https://api.github.com/repos/tgroh/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgroh/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgroh/incubator-beam/teams","hooks_url":"https://api.github.com/repos/tgroh/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/tgroh/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/tgroh/incubator-beam/events","assignees_url":"https://api.github.com/repos/tgroh/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/tgroh/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/tgroh/incubator-beam/tags","blobs_url":"https://api.github.com/repos/tgroh/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgroh/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgroh/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgroh/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgroh/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/tgroh/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/tgroh/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/tgroh/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/tgroh/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/tgroh/incubator-beam/subscription","commits_url":"https://api.github.com/repos/tgroh/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgroh/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgroh/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgroh/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgroh/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/tgroh/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgroh/incubator-beam/merges","archive_url":"https://api.github.com/repos/tgroh/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgroh/incubator-beam/downloads","issues_url":"https://api.github.com/repos/tgroh/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/tgroh/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/tgroh/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/tgroh/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgroh/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/tgroh/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/tgroh/incubator-beam/deployments","created_at":"2016-02-27T01:43:32Z","updated_at":"2016-02-27T01:43:35Z","pushed_at":"2016-03-16T21:47:30Z","git_url":"git://github.com/tgroh/incubator-beam.git","ssh_url":"git@github.com:tgroh/incubator-beam.git","clone_url":"https://github.com/tgroh/incubator-beam.git","svn_url":"https://github.com/tgroh/incubator-beam","homepage":null,"size":11558,"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":"a13dd29102fed2551a85d4ec62d36bed10101c22","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":50904245,"name":"incubator-beam","full_name":"apache/incubator-beam","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/incubator-beam","description":"Mirror of Apache Beam (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-beam","forks_url":"https://api.github.com/repos/apache/incubator-beam/forks","keys_url":"https://api.github.com/repos/apache/incubator-beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-beam/teams","hooks_url":"https://api.github.com/repos/apache/incubator-beam/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-beam/events","assignees_url":"https://api.github.com/repos/apache/incubator-beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-beam/tags","blobs_url":"https://api.github.com/repos/apache/incubator-beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-beam/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-beam/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-beam/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-beam/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-beam/subscription","commits_url":"https://api.github.com/repos/apache/incubator-beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-beam/merges","archive_url":"https://api.github.com/repos/apache/incubator-beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-beam/downloads","issues_url":"https://api.github.com/repos/apache/incubator-beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2016-03-16T12:14:54Z","pushed_at":"2016-03-17T02:32:54Z","git_url":"git://github.com/apache/incubator-beam.git","ssh_url":"git@github.com:apache/incubator-beam.git","clone_url":"https://github.com/apache/incubator-beam.git","svn_url":"https://github.com/apache/incubator-beam","homepage":null,"size":11596,"stargazers_count":72,"watchers_count":72,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":39,"mirror_url":"git://git.apache.org/incubator-beam.git","open_issues_count":13,"forks":39,"open_issues":13,"watchers":72,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/53"},"html":{"href":"https://github.com/apache/incubator-beam/pull/53"},"issue":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/53"},"comments":{"href":"https://api.github.com/repos/apache/incubator-beam/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-beam/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-beam/statuses/bac398b5ac8c7c29a85f9bb56886e8e9429c213c"}}}}