{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-reef/pulls/comments/35304217","id":35304217,"diff_hunk":"@@ -0,0 +1,92 @@\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 org.apache.reef.vortex.driver;\n+\n+import org.apache.reef.vortex.driver.tasklet.RunningExecutors;\n+import org.apache.reef.vortex.driver.tasklet.Tasklet;\n+import org.apache.reef.vortex.driver.tasklet.TaskletExecutor;\n+\n+import javax.inject.Inject;\n+import java.io.Serializable;\n+import java.util.*;\n+import java.util.concurrent.BlockingDeque;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.LinkedBlockingDeque;\n+import java.util.logging.Level;\n+import java.util.logging.Logger;\n+\n+/**\n+ * Default implementation of VortexManager.\n+ */\n+public class DefaultVortexManager implements VortexManager {\n+  private static final Logger LOG = Logger.getLogger(DefaultVortexManager.class.getName());\n+  private final RunningExecutors runningExecutors;\n+  private final BlockingDeque<Tasklet> pendingTasklets = new LinkedBlockingDeque<>();\n+  private final ExecutorService schedulerThread = Executors.newSingleThreadExecutor();\n+\n+  @Inject\n+  public DefaultVortexManager(final RunningExecutors runningExecutors) {\n+    this.runningExecutors = runningExecutors;\n+    schedulerThread.execute(new Runnable() {\n+      @Override\n+      public void run() {\n+        while (!runningExecutors.isTerminated()) {\n+          try {\n+            final Tasklet tasklet = pendingTasklets.takeFirst(); // blocks when no tasklet exists\n+            runningExecutors.launchTasklet(tasklet); // blocks when no executor exists\n+          } catch (InterruptedException e) {\n+            LOG.log(Level.INFO, \"Interrupted upon termination\");\n+          }\n+        }\n+      }\n+    });\n+  }\n+\n+  @Override\n+  public void enqueueNewTasklet(final Tasklet tasklet) {","path":"lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/DefaultVortexManager.java","position":63,"original_position":63,"commit_id":"5ed4e8b73fd126fbb196eefa5256ab701244fae9","original_commit_id":"5ed4e8b73fd126fbb196eefa5256ab701244fae9","user":{"login":"bgchun","id":359137,"avatar_url":"https://avatars.githubusercontent.com/u/359137?v=3","gravatar_id":"","url":"https://api.github.com/users/bgchun","html_url":"https://github.com/bgchun","followers_url":"https://api.github.com/users/bgchun/followers","following_url":"https://api.github.com/users/bgchun/following{/other_user}","gists_url":"https://api.github.com/users/bgchun/gists{/gist_id}","starred_url":"https://api.github.com/users/bgchun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgchun/subscriptions","organizations_url":"https://api.github.com/users/bgchun/orgs","repos_url":"https://api.github.com/users/bgchun/repos","events_url":"https://api.github.com/users/bgchun/events{/privacy}","received_events_url":"https://api.github.com/users/bgchun/received_events","type":"User","site_admin":false},"body":"I was thinking `VortexManager`s can be accessed concurrently by multiple threads. Is this not the case? \r\nIf it's concurrently accessed, this class should be updated to be thread-safe.","created_at":"2015-07-23T09:27:57Z","updated_at":"2015-07-23T09:27:57Z","html_url":"https://github.com/apache/incubator-reef/pull/310#discussion_r35304217","pull_request_url":"https://api.github.com/repos/apache/incubator-reef/pulls/310","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/comments/35304217"},"html":{"href":"https://github.com/apache/incubator-reef/pull/310#discussion_r35304217"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/310"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-reef/pulls/310","id":40639031,"html_url":"https://github.com/apache/incubator-reef/pull/310","diff_url":"https://github.com/apache/incubator-reef/pull/310.diff","patch_url":"https://github.com/apache/incubator-reef/pull/310.patch","issue_url":"https://api.github.com/repos/apache/incubator-reef/issues/310","number":310,"state":"open","locked":false,"title":"[REEF-491] Initial Vortex implementation","user":{"login":"johnyangk","id":4114572,"avatar_url":"https://avatars.githubusercontent.com/u/4114572?v=3","gravatar_id":"","url":"https://api.github.com/users/johnyangk","html_url":"https://github.com/johnyangk","followers_url":"https://api.github.com/users/johnyangk/followers","following_url":"https://api.github.com/users/johnyangk/following{/other_user}","gists_url":"https://api.github.com/users/johnyangk/gists{/gist_id}","starred_url":"https://api.github.com/users/johnyangk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnyangk/subscriptions","organizations_url":"https://api.github.com/users/johnyangk/orgs","repos_url":"https://api.github.com/users/johnyangk/repos","events_url":"https://api.github.com/users/johnyangk/events{/privacy}","received_events_url":"https://api.github.com/users/johnyangk/received_events","type":"User","site_admin":false},"body":"![150723_architecture](https://cloud.githubusercontent.com/assets/4114572/8843561/a67b00e8-313c-11e5-922f-d034c3c1c9f4.png)\r\n\r\n## How to test\r\n* Unit test\r\n  * In the directory `reef-vortex`, run `mvn clean install`\r\n* Integration test\r\n  * You can simply test using `reef-tests` as usual, the test is included in there\r\n\r\n## Implementation\r\n* Java ThreadPool-like user interface\r\n* Distributed execution of user-submitted functions\r\n* Handling of resource preemption events\r\n* Simple Vortex Tasklet scheduling mechanisms\r\n* Simple unit/integration tests to verify correctness\r\n\r\n## Vortex-REEF component mapping\r\nHere's a brief description of how some of main Vortex components map to those of REEF\r\n* VortexManager\r\n  * Maps to REEF Driver event handlers \r\n  * Acts as the brain of the Vortex runtime, handling events from different parts of the system, scheduling/executing user tasks, and keeping track of running executors/tasks\r\n* LocalExecutor\r\n  * Maps to REEF Context\r\n  * Receives commands, executes them, and sends the results back to VortexManager\r\n\r\n\r\nJIRA\r\nhttps://issues.apache.org/jira/browse/REEF-491","created_at":"2015-07-23T05:48:37Z","updated_at":"2015-07-23T09:27:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"451700c19af326e19c513470d0ffbda3151f882e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-reef/pulls/310/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-reef/pulls/310/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-reef/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-reef/issues/310/comments","statuses_url":"https://api.github.com/repos/apache/incubator-reef/statuses/5ed4e8b73fd126fbb196eefa5256ab701244fae9","head":{"label":"johnyangk:REEF-491","ref":"REEF-491","sha":"5ed4e8b73fd126fbb196eefa5256ab701244fae9","user":{"login":"johnyangk","id":4114572,"avatar_url":"https://avatars.githubusercontent.com/u/4114572?v=3","gravatar_id":"","url":"https://api.github.com/users/johnyangk","html_url":"https://github.com/johnyangk","followers_url":"https://api.github.com/users/johnyangk/followers","following_url":"https://api.github.com/users/johnyangk/following{/other_user}","gists_url":"https://api.github.com/users/johnyangk/gists{/gist_id}","starred_url":"https://api.github.com/users/johnyangk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnyangk/subscriptions","organizations_url":"https://api.github.com/users/johnyangk/orgs","repos_url":"https://api.github.com/users/johnyangk/repos","events_url":"https://api.github.com/users/johnyangk/events{/privacy}","received_events_url":"https://api.github.com/users/johnyangk/received_events","type":"User","site_admin":false},"repo":{"id":25674390,"name":"incubator-reef","full_name":"johnyangk/incubator-reef","owner":{"login":"johnyangk","id":4114572,"avatar_url":"https://avatars.githubusercontent.com/u/4114572?v=3","gravatar_id":"","url":"https://api.github.com/users/johnyangk","html_url":"https://github.com/johnyangk","followers_url":"https://api.github.com/users/johnyangk/followers","following_url":"https://api.github.com/users/johnyangk/following{/other_user}","gists_url":"https://api.github.com/users/johnyangk/gists{/gist_id}","starred_url":"https://api.github.com/users/johnyangk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnyangk/subscriptions","organizations_url":"https://api.github.com/users/johnyangk/orgs","repos_url":"https://api.github.com/users/johnyangk/repos","events_url":"https://api.github.com/users/johnyangk/events{/privacy}","received_events_url":"https://api.github.com/users/johnyangk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnyangk/incubator-reef","description":"Mirror of Apache REEF (Incubating)","fork":true,"url":"https://api.github.com/repos/johnyangk/incubator-reef","forks_url":"https://api.github.com/repos/johnyangk/incubator-reef/forks","keys_url":"https://api.github.com/repos/johnyangk/incubator-reef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnyangk/incubator-reef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnyangk/incubator-reef/teams","hooks_url":"https://api.github.com/repos/johnyangk/incubator-reef/hooks","issue_events_url":"https://api.github.com/repos/johnyangk/incubator-reef/issues/events{/number}","events_url":"https://api.github.com/repos/johnyangk/incubator-reef/events","assignees_url":"https://api.github.com/repos/johnyangk/incubator-reef/assignees{/user}","branches_url":"https://api.github.com/repos/johnyangk/incubator-reef/branches{/branch}","tags_url":"https://api.github.com/repos/johnyangk/incubator-reef/tags","blobs_url":"https://api.github.com/repos/johnyangk/incubator-reef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnyangk/incubator-reef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnyangk/incubator-reef/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnyangk/incubator-reef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnyangk/incubator-reef/statuses/{sha}","languages_url":"https://api.github.com/repos/johnyangk/incubator-reef/languages","stargazers_url":"https://api.github.com/repos/johnyangk/incubator-reef/stargazers","contributors_url":"https://api.github.com/repos/johnyangk/incubator-reef/contributors","subscribers_url":"https://api.github.com/repos/johnyangk/incubator-reef/subscribers","subscription_url":"https://api.github.com/repos/johnyangk/incubator-reef/subscription","commits_url":"https://api.github.com/repos/johnyangk/incubator-reef/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnyangk/incubator-reef/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnyangk/incubator-reef/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnyangk/incubator-reef/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnyangk/incubator-reef/contents/{+path}","compare_url":"https://api.github.com/repos/johnyangk/incubator-reef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnyangk/incubator-reef/merges","archive_url":"https://api.github.com/repos/johnyangk/incubator-reef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnyangk/incubator-reef/downloads","issues_url":"https://api.github.com/repos/johnyangk/incubator-reef/issues{/number}","pulls_url":"https://api.github.com/repos/johnyangk/incubator-reef/pulls{/number}","milestones_url":"https://api.github.com/repos/johnyangk/incubator-reef/milestones{/number}","notifications_url":"https://api.github.com/repos/johnyangk/incubator-reef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnyangk/incubator-reef/labels{/name}","releases_url":"https://api.github.com/repos/johnyangk/incubator-reef/releases{/id}","created_at":"2014-10-24T06:15:53Z","updated_at":"2015-04-30T03:14:37Z","pushed_at":"2015-07-23T05:45:57Z","git_url":"git://github.com/johnyangk/incubator-reef.git","ssh_url":"git@github.com:johnyangk/incubator-reef.git","clone_url":"https://github.com/johnyangk/incubator-reef.git","svn_url":"https://github.com/johnyangk/incubator-reef","homepage":null,"size":30323,"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":"01a303d7810da6ba350b3e243c8f9e12e4f54af9","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":25623941,"name":"incubator-reef","full_name":"apache/incubator-reef","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-reef","description":"Mirror of Apache REEF (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-reef","forks_url":"https://api.github.com/repos/apache/incubator-reef/forks","keys_url":"https://api.github.com/repos/apache/incubator-reef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-reef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-reef/teams","hooks_url":"https://api.github.com/repos/apache/incubator-reef/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-reef/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-reef/events","assignees_url":"https://api.github.com/repos/apache/incubator-reef/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-reef/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-reef/tags","blobs_url":"https://api.github.com/repos/apache/incubator-reef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-reef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-reef/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-reef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-reef/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-reef/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-reef/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-reef/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-reef/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-reef/subscription","commits_url":"https://api.github.com/repos/apache/incubator-reef/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-reef/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-reef/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-reef/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-reef/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-reef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-reef/merges","archive_url":"https://api.github.com/repos/apache/incubator-reef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-reef/downloads","issues_url":"https://api.github.com/repos/apache/incubator-reef/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-reef/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-reef/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-reef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-reef/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-reef/releases{/id}","created_at":"2014-10-23T07:00:10Z","updated_at":"2015-07-03T08:22:28Z","pushed_at":"2015-07-23T05:48:37Z","git_url":"git://github.com/apache/incubator-reef.git","ssh_url":"git@github.com:apache/incubator-reef.git","clone_url":"https://github.com/apache/incubator-reef.git","svn_url":"https://github.com/apache/incubator-reef","homepage":null,"size":42168,"stargazers_count":23,"watchers_count":23,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":"git://git.apache.org/incubator-reef.git","open_issues_count":7,"forks":30,"open_issues":7,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/310"},"html":{"href":"https://github.com/apache/incubator-reef/pull/310"},"issue":{"href":"https://api.github.com/repos/apache/incubator-reef/issues/310"},"comments":{"href":"https://api.github.com/repos/apache/incubator-reef/issues/310/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/310/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-reef/pulls/310/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-reef/statuses/5ed4e8b73fd126fbb196eefa5256ab701244fae9"}}}}