{"action":"created","comment":{"url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/comments/44733068","id":44733068,"diff_hunk":"@@ -170,11 +117,55 @@ private static void _main(final String[] args) throws InterruptedException {\n         final Subscription sink = client.sink(calls);\n         Thread.sleep(Integer.MAX_VALUE); //TODO: Figure out something better than this\n         sink.unsubscribe();\n-        setFrameworkIdSubscription.unsubscribe();\n         errorLoggerSubscription.unsubscribe();\n     }\n \n     @NotNull\n+    private static SinkOperation<Call> handleOffer(@NotNull final Tuple2<Offer, State> t) {\n+        final Offer offer = t._1;\n+        final State state = t._2;\n+        final int offerCount = state.getOfferCounter().incrementAndGet();\n+\n+        final FrameworkID frameworkId = state.getFwId();\n+        final AgentID agentId = offer.getAgentId();\n+        final List<OfferID> ids = newArrayList(offer.getId());\n+\n+        final Map<String, List<Resource>> resources = offer.getResourcesList()\n+            .stream()\n+            .collect(groupingBy(Resource::getName));\n+        final List<Resource> cpuList = resources.get(\"cpus\");\n+        final List<Resource> memList = resources.get(\"mem\");\n+        if (cpuList != null && !cpuList.isEmpty() && memList != null && !memList.isEmpty()) {\n+            final Resource cpus = cpuList.iterator().next();\n+            final Resource mem = memList.iterator().next();\n+            final List<TaskInfo> tasks = newArrayList();\n+\n+            double availableCpu = cpus.getScalar().getValue();\n+            double availableMem = mem.getScalar().getValue();\n+            final double cpusPerTask = state.getCpusPerTask();\n+            final double memMbPerTask = state.getMemMbPerTask();\n+            while (availableCpu >= cpusPerTask && availableMem >= memMbPerTask) { // .foldLeft((newArrayList(), cpu, mem))","path":"mesos-rxjava-example/mesos-rxjava-example-framework/src/main/java/org/apache/mesos/rx/java/example/framework/sleepy/Main.java","position":171,"original_position":171,"commit_id":"e8902b97e92382cabad25541dc898d66221eeb31","original_commit_id":"e8902b97e92382cabad25541dc898d66221eeb31","user":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"body":"Not dead code, a comment for me to easily remember what that `while` look was doing. (I've gotten too used to functional stuff and find manual loops harder to read now). I'll remove it since it looks like dead code.","created_at":"2015-11-12T23:49:06Z","updated_at":"2015-11-12T23:49:06Z","html_url":"https://github.com/mesos/mesos-rxjava/pull/21#discussion_r44733068","pull_request_url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/comments/44733068"},"html":{"href":"https://github.com/mesos/mesos-rxjava/pull/21#discussion_r44733068"},"pull_request":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21","id":50461315,"html_url":"https://github.com/mesos/mesos-rxjava/pull/21","diff_url":"https://github.com/mesos/mesos-rxjava/pull/21.diff","patch_url":"https://github.com/mesos/mesos-rxjava/pull/21.patch","issue_url":"https://api.github.com/repos/mesos/mesos-rxjava/issues/21","number":21,"state":"open","locked":false,"title":"Refactor all state handling","user":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"body":"All state reads and writes now go through the state object so that the streams aren't closing over anything.","created_at":"2015-11-12T01:33:22Z","updated_at":"2015-11-12T23:49:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fb384118847a636c4d86d732e8006d9a341cbc4","assignee":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mesos/mesos-rxjava/milestones/1","html_url":"https://github.com/mesos/mesos-rxjava/milestones/0.1.0","labels_url":"https://api.github.com/repos/mesos/mesos-rxjava/milestones/1/labels","id":1407158,"number":1,"title":"0.1.0","description":null,"creator":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2015-11-11T18:50:01Z","updated_at":"2015-11-12T01:33:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21/commits","review_comments_url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21/comments","review_comment_url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesos/mesos-rxjava/issues/21/comments","statuses_url":"https://api.github.com/repos/mesos/mesos-rxjava/statuses/e8902b97e92382cabad25541dc898d66221eeb31","head":{"label":"BenWhitehead:state-refactor","ref":"state-refactor","sha":"e8902b97e92382cabad25541dc898d66221eeb31","user":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"repo":{"id":44843346,"name":"mesos-rxjava","full_name":"BenWhitehead/mesos-rxjava","owner":{"login":"BenWhitehead","id":1754037,"avatar_url":"https://avatars.githubusercontent.com/u/1754037?v=3","gravatar_id":"","url":"https://api.github.com/users/BenWhitehead","html_url":"https://github.com/BenWhitehead","followers_url":"https://api.github.com/users/BenWhitehead/followers","following_url":"https://api.github.com/users/BenWhitehead/following{/other_user}","gists_url":"https://api.github.com/users/BenWhitehead/gists{/gist_id}","starred_url":"https://api.github.com/users/BenWhitehead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenWhitehead/subscriptions","organizations_url":"https://api.github.com/users/BenWhitehead/orgs","repos_url":"https://api.github.com/users/BenWhitehead/repos","events_url":"https://api.github.com/users/BenWhitehead/events{/privacy}","received_events_url":"https://api.github.com/users/BenWhitehead/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BenWhitehead/mesos-rxjava","description":"RxJava client for Apache Mesos HTTP APIs","fork":true,"url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava","forks_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/forks","keys_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/teams","hooks_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/hooks","issue_events_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/issues/events{/number}","events_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/events","assignees_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/assignees{/user}","branches_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/branches{/branch}","tags_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/tags","blobs_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/git/refs{/sha}","trees_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/statuses/{sha}","languages_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/languages","stargazers_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/stargazers","contributors_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/contributors","subscribers_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/subscribers","subscription_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/subscription","commits_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/commits{/sha}","git_commits_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/git/commits{/sha}","comments_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/comments{/number}","issue_comment_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/issues/comments{/number}","contents_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/contents/{+path}","compare_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/merges","archive_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/downloads","issues_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/issues{/number}","pulls_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/pulls{/number}","milestones_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/milestones{/number}","notifications_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/labels{/name}","releases_url":"https://api.github.com/repos/BenWhitehead/mesos-rxjava/releases{/id}","created_at":"2015-10-23T23:14:37Z","updated_at":"2015-10-23T23:14:38Z","pushed_at":"2015-11-12T01:32:59Z","git_url":"git://github.com/BenWhitehead/mesos-rxjava.git","ssh_url":"git@github.com:BenWhitehead/mesos-rxjava.git","clone_url":"https://github.com/BenWhitehead/mesos-rxjava.git","svn_url":"https://github.com/BenWhitehead/mesos-rxjava","homepage":"","size":139,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"mesos:master","ref":"master","sha":"c770d3c628e2788a7d8f0e84644a9ab292701708","user":{"login":"mesos","id":229272,"avatar_url":"https://avatars.githubusercontent.com/u/229272?v=3","gravatar_id":"","url":"https://api.github.com/users/mesos","html_url":"https://github.com/mesos","followers_url":"https://api.github.com/users/mesos/followers","following_url":"https://api.github.com/users/mesos/following{/other_user}","gists_url":"https://api.github.com/users/mesos/gists{/gist_id}","starred_url":"https://api.github.com/users/mesos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesos/subscriptions","organizations_url":"https://api.github.com/users/mesos/orgs","repos_url":"https://api.github.com/users/mesos/repos","events_url":"https://api.github.com/users/mesos/events{/privacy}","received_events_url":"https://api.github.com/users/mesos/received_events","type":"Organization","site_admin":false},"repo":{"id":44835755,"name":"mesos-rxjava","full_name":"mesos/mesos-rxjava","owner":{"login":"mesos","id":229272,"avatar_url":"https://avatars.githubusercontent.com/u/229272?v=3","gravatar_id":"","url":"https://api.github.com/users/mesos","html_url":"https://github.com/mesos","followers_url":"https://api.github.com/users/mesos/followers","following_url":"https://api.github.com/users/mesos/following{/other_user}","gists_url":"https://api.github.com/users/mesos/gists{/gist_id}","starred_url":"https://api.github.com/users/mesos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesos/subscriptions","organizations_url":"https://api.github.com/users/mesos/orgs","repos_url":"https://api.github.com/users/mesos/repos","events_url":"https://api.github.com/users/mesos/events{/privacy}","received_events_url":"https://api.github.com/users/mesos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesos/mesos-rxjava","description":"RxJava client for Apache Mesos HTTP APIs","fork":false,"url":"https://api.github.com/repos/mesos/mesos-rxjava","forks_url":"https://api.github.com/repos/mesos/mesos-rxjava/forks","keys_url":"https://api.github.com/repos/mesos/mesos-rxjava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesos/mesos-rxjava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesos/mesos-rxjava/teams","hooks_url":"https://api.github.com/repos/mesos/mesos-rxjava/hooks","issue_events_url":"https://api.github.com/repos/mesos/mesos-rxjava/issues/events{/number}","events_url":"https://api.github.com/repos/mesos/mesos-rxjava/events","assignees_url":"https://api.github.com/repos/mesos/mesos-rxjava/assignees{/user}","branches_url":"https://api.github.com/repos/mesos/mesos-rxjava/branches{/branch}","tags_url":"https://api.github.com/repos/mesos/mesos-rxjava/tags","blobs_url":"https://api.github.com/repos/mesos/mesos-rxjava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesos/mesos-rxjava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesos/mesos-rxjava/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesos/mesos-rxjava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesos/mesos-rxjava/statuses/{sha}","languages_url":"https://api.github.com/repos/mesos/mesos-rxjava/languages","stargazers_url":"https://api.github.com/repos/mesos/mesos-rxjava/stargazers","contributors_url":"https://api.github.com/repos/mesos/mesos-rxjava/contributors","subscribers_url":"https://api.github.com/repos/mesos/mesos-rxjava/subscribers","subscription_url":"https://api.github.com/repos/mesos/mesos-rxjava/subscription","commits_url":"https://api.github.com/repos/mesos/mesos-rxjava/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesos/mesos-rxjava/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesos/mesos-rxjava/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesos/mesos-rxjava/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesos/mesos-rxjava/contents/{+path}","compare_url":"https://api.github.com/repos/mesos/mesos-rxjava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesos/mesos-rxjava/merges","archive_url":"https://api.github.com/repos/mesos/mesos-rxjava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesos/mesos-rxjava/downloads","issues_url":"https://api.github.com/repos/mesos/mesos-rxjava/issues{/number}","pulls_url":"https://api.github.com/repos/mesos/mesos-rxjava/pulls{/number}","milestones_url":"https://api.github.com/repos/mesos/mesos-rxjava/milestones{/number}","notifications_url":"https://api.github.com/repos/mesos/mesos-rxjava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesos/mesos-rxjava/labels{/name}","releases_url":"https://api.github.com/repos/mesos/mesos-rxjava/releases{/id}","created_at":"2015-10-23T20:04:55Z","updated_at":"2015-11-12T22:19:12Z","pushed_at":"2015-11-12T22:27:43Z","git_url":"git://github.com/mesos/mesos-rxjava.git","ssh_url":"git@github.com:mesos/mesos-rxjava.git","clone_url":"https://github.com/mesos/mesos-rxjava.git","svn_url":"https://github.com/mesos/mesos-rxjava","homepage":"","size":355,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":12,"forks":2,"open_issues":12,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21"},"html":{"href":"https://github.com/mesos/mesos-rxjava/pull/21"},"issue":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/issues/21"},"comments":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/mesos/mesos-rxjava/statuses/e8902b97e92382cabad25541dc898d66221eeb31"}}}}