{"action":"created","comment":{"url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/comments/64896517","id":64896517,"diff_hunk":"@@ -155,23 +176,89 @@ public Object getMessage() {\n                     public int getStatus() {\n                         return Response.Status.FORBIDDEN.getStatusCode();\n                     }\n+\n                     @Override\n                     public Object getMessage() {\n                         return \"Could not change the number of instances. The number of desired instances is lower than the number of replicas + 1.\";\n                     }\n                 }).build();\n             }\n         }\n+\n+        int mesosAgentCount = getMesosAgentCount();\n+\n+        if(desired > mesosAgentCount && mesosAgentCount != -1) {\n+            return Response.status(Response.Status.FORBIDDEN).entity(new GenericAPIResponse() {\n+                @Override\n+                public int getStatus() {\n+                    return Response.Status.FORBIDDEN.getStatusCode();\n+                }\n+\n+                @Override\n+                public Object getMessage() {\n+                    return \"Could not initialize more Crate nodes than existing number of mesos agents\";\n+                }\n+            }).build();\n+        }\n+\n         store.state().desiredInstances(desired);\n-        return Response.ok(new GenericAPIResponse() {}).build();\n+        return Response.ok(new GenericAPIResponse() {\n+        }).build();\n+\n+    }\n+\n+    @Nullable\n+    private String getMesosMasterIp() {\n+        try {\n+            CuratorFramework cf = zkClient();\n+            cf.start();\n+            String data = \"\";\n+            List<String> childrenList = cf.getChildren().forPath(\"/mesos\");\n+\n+            for(String child: childrenList){\n+                if(child.contains(\"json.info\")){\n+                    data = new String(cf.getData().forPath(\"/mesos/\" + child));\n+                }\n+            }\n+            JSONObject clusterState = new JSONObject(data);\n+            JSONObject address = clusterState.getJSONObject(\"address\");","path":"src/main/java/io/crate/frameworks/mesos/api/CrateRestResource.java","position":150,"original_position":150,"commit_id":"147f2e2ab65b5150ac00ab1d9a3a4491fe7323ef","original_commit_id":"147f2e2ab65b5150ac00ab1d9a3a4491fe7323ef","user":{"login":"bogensberger","id":1038966,"avatar_url":"https://avatars.githubusercontent.com/u/1038966?v=3","gravatar_id":"","url":"https://api.github.com/users/bogensberger","html_url":"https://github.com/bogensberger","followers_url":"https://api.github.com/users/bogensberger/followers","following_url":"https://api.github.com/users/bogensberger/following{/other_user}","gists_url":"https://api.github.com/users/bogensberger/gists{/gist_id}","starred_url":"https://api.github.com/users/bogensberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogensberger/subscriptions","organizations_url":"https://api.github.com/users/bogensberger/orgs","repos_url":"https://api.github.com/users/bogensberger/repos","events_url":"https://api.github.com/users/bogensberger/events{/privacy}","received_events_url":"https://api.github.com/users/bogensberger/received_events","type":"User","site_admin":false},"body":"i think i your implementation the JSONObject may miss the address field, which causes a NPE in the next line","created_at":"2016-05-27T12:21:24Z","updated_at":"2016-05-27T12:21:24Z","html_url":"https://github.com/crate/crate-mesos-framework/pull/100#discussion_r64896517","pull_request_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/comments/64896517"},"html":{"href":"https://github.com/crate/crate-mesos-framework/pull/100#discussion_r64896517"},"pull_request":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100","id":71553659,"html_url":"https://github.com/crate/crate-mesos-framework/pull/100","diff_url":"https://github.com/crate/crate-mesos-framework/pull/100.diff","patch_url":"https://github.com/crate/crate-mesos-framework/pull/100.patch","issue_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/100","number":100,"state":"open","locked":false,"title":"Added desired instance vs active mesos agent control","user":{"login":"aslanbekirov","id":254398,"avatar_url":"https://avatars.githubusercontent.com/u/254398?v=3","gravatar_id":"","url":"https://api.github.com/users/aslanbekirov","html_url":"https://github.com/aslanbekirov","followers_url":"https://api.github.com/users/aslanbekirov/followers","following_url":"https://api.github.com/users/aslanbekirov/following{/other_user}","gists_url":"https://api.github.com/users/aslanbekirov/gists{/gist_id}","starred_url":"https://api.github.com/users/aslanbekirov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslanbekirov/subscriptions","organizations_url":"https://api.github.com/users/aslanbekirov/orgs","repos_url":"https://api.github.com/users/aslanbekirov/repos","events_url":"https://api.github.com/users/aslanbekirov/events{/privacy}","received_events_url":"https://api.github.com/users/aslanbekirov/received_events","type":"User","site_admin":false},"body":"Steps : \r\n1- Create ZK client\r\n2- Get Mesos Master IP from ZK znode \"/mesos\"\r\n3- Get active agent count using mesos master HTTP API\r\n4- control in /cluster/resize API of crate-framework","created_at":"2016-05-26T13:17:38Z","updated_at":"2016-05-27T12:21:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3a5323203e11f0be177c34c621764f32695c9ba","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100/commits","review_comments_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100/comments","review_comment_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/100/comments","statuses_url":"https://api.github.com/repos/crate/crate-mesos-framework/statuses/147f2e2ab65b5150ac00ab1d9a3a4491fe7323ef","head":{"label":"crate:ab/check-desired-instances-in-api","ref":"ab/check-desired-instances-in-api","sha":"147f2e2ab65b5150ac00ab1d9a3a4491fe7323ef","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":32357403,"name":"crate-mesos-framework","full_name":"crate/crate-mesos-framework","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate-mesos-framework","description":"Crate Mesos Framework","fork":false,"url":"https://api.github.com/repos/crate/crate-mesos-framework","forks_url":"https://api.github.com/repos/crate/crate-mesos-framework/forks","keys_url":"https://api.github.com/repos/crate/crate-mesos-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate-mesos-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate-mesos-framework/teams","hooks_url":"https://api.github.com/repos/crate/crate-mesos-framework/hooks","issue_events_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate-mesos-framework/events","assignees_url":"https://api.github.com/repos/crate/crate-mesos-framework/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate-mesos-framework/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate-mesos-framework/tags","blobs_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate-mesos-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate-mesos-framework/languages","stargazers_url":"https://api.github.com/repos/crate/crate-mesos-framework/stargazers","contributors_url":"https://api.github.com/repos/crate/crate-mesos-framework/contributors","subscribers_url":"https://api.github.com/repos/crate/crate-mesos-framework/subscribers","subscription_url":"https://api.github.com/repos/crate/crate-mesos-framework/subscription","commits_url":"https://api.github.com/repos/crate/crate-mesos-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate-mesos-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate-mesos-framework/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate-mesos-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate-mesos-framework/merges","archive_url":"https://api.github.com/repos/crate/crate-mesos-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate-mesos-framework/downloads","issues_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate-mesos-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate-mesos-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate-mesos-framework/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate-mesos-framework/releases{/id}","deployments_url":"https://api.github.com/repos/crate/crate-mesos-framework/deployments","created_at":"2015-03-16T22:43:59Z","updated_at":"2016-05-13T14:17:07Z","pushed_at":"2016-05-26T13:19:35Z","git_url":"git://github.com/crate/crate-mesos-framework.git","ssh_url":"git@github.com:crate/crate-mesos-framework.git","clone_url":"https://github.com/crate/crate-mesos-framework.git","svn_url":"https://github.com/crate/crate-mesos-framework","homepage":null,"size":394,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":19,"default_branch":"master"}},"base":{"label":"crate:update-mesos","ref":"update-mesos","sha":"508ff5557840fdb1a09fea9bd4c5c0716b6799a8","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":32357403,"name":"crate-mesos-framework","full_name":"crate/crate-mesos-framework","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate-mesos-framework","description":"Crate Mesos Framework","fork":false,"url":"https://api.github.com/repos/crate/crate-mesos-framework","forks_url":"https://api.github.com/repos/crate/crate-mesos-framework/forks","keys_url":"https://api.github.com/repos/crate/crate-mesos-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate-mesos-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate-mesos-framework/teams","hooks_url":"https://api.github.com/repos/crate/crate-mesos-framework/hooks","issue_events_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate-mesos-framework/events","assignees_url":"https://api.github.com/repos/crate/crate-mesos-framework/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate-mesos-framework/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate-mesos-framework/tags","blobs_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate-mesos-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate-mesos-framework/languages","stargazers_url":"https://api.github.com/repos/crate/crate-mesos-framework/stargazers","contributors_url":"https://api.github.com/repos/crate/crate-mesos-framework/contributors","subscribers_url":"https://api.github.com/repos/crate/crate-mesos-framework/subscribers","subscription_url":"https://api.github.com/repos/crate/crate-mesos-framework/subscription","commits_url":"https://api.github.com/repos/crate/crate-mesos-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate-mesos-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate-mesos-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate-mesos-framework/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate-mesos-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate-mesos-framework/merges","archive_url":"https://api.github.com/repos/crate/crate-mesos-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate-mesos-framework/downloads","issues_url":"https://api.github.com/repos/crate/crate-mesos-framework/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate-mesos-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate-mesos-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate-mesos-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate-mesos-framework/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate-mesos-framework/releases{/id}","deployments_url":"https://api.github.com/repos/crate/crate-mesos-framework/deployments","created_at":"2015-03-16T22:43:59Z","updated_at":"2016-05-13T14:17:07Z","pushed_at":"2016-05-26T13:19:35Z","git_url":"git://github.com/crate/crate-mesos-framework.git","ssh_url":"git@github.com:crate/crate-mesos-framework.git","clone_url":"https://github.com/crate/crate-mesos-framework.git","svn_url":"https://github.com/crate/crate-mesos-framework","homepage":null,"size":394,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100"},"html":{"href":"https://github.com/crate/crate-mesos-framework/pull/100"},"issue":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/issues/100"},"comments":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/crate/crate-mesos-framework/statuses/147f2e2ab65b5150ac00ab1d9a3a4491fe7323ef"}}}}
{"actor":{"display_login":"bogensberger"}}