{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/heron/pulls/comments/82303593","pull_request_review_id":3221961,"id":82303593,"diff_hunk":"@@ -219,4 +222,142 @@ public static int allocateNewContainer(ArrayList<Container> containers, Resource\n     return componentsToScaleUp;\n   }\n \n+  /**\n+   * Identifies the resources reclaimed by the components that will be scaled down\n+   *\n+   * @return Total resources reclaimed\n+   */\n+  public static Resource getScaleDownResource(TopologyAPI.Topology topology, Map<String, Integer>\n+      componentChanges, Resource defaultInstanceResources) {\n+    double cpu = 0;\n+    long ram = 0;\n+    long disk = 0;\n+    Map<String, Long> ramMap = TopologyUtils.getComponentRamMapConfig(topology);\n+    Map<String, Integer> componentsToScaleDown = PackingUtils.getComponentsToScaleDown(\n+        componentChanges);\n+    for (String component : componentsToScaleDown.keySet()) {\n+      int parallelismChange = -componentChanges.get(component);\n+      cpu += parallelismChange * defaultInstanceResources.getCpu();\n+      disk += parallelismChange * defaultInstanceResources.getDisk();\n+      if (ramMap.containsKey(component)) {\n+        ram += parallelismChange * ramMap.get(component);\n+      } else {\n+        ram += parallelismChange * defaultInstanceResources.getRam();\n+      }\n+    }\n+    return new Resource(cpu, ram, disk);\n+  }\n+\n+  /**\n+   * Identifies the resources needed for the components that will be scaled up\n+   *\n+   * @return Total resources needed\n+   */\n+  public static Resource getScaleUpResource(TopologyAPI.Topology topology, Map<String, Integer>\n+      componentChanges, Resource defaultInstanceResources) {\n+    double cpu = 0;\n+    long ram = 0;\n+    long disk = 0;\n+    Map<String, Long> ramMap = TopologyUtils.getComponentRamMapConfig(topology);\n+    Map<String, Integer> componentsToScaleUp = PackingUtils.getComponentsToScaleUp(\n+        componentChanges);\n+    for (String component : componentsToScaleUp.keySet()) {\n+      int parallelismChange = componentChanges.get(component);\n+      cpu += parallelismChange * defaultInstanceResources.getCpu();\n+      disk += parallelismChange * defaultInstanceResources.getDisk();\n+      if (ramMap.containsKey(component)) {\n+        ram += parallelismChange * ramMap.get(component);\n+      } else {\n+        ram += parallelismChange * defaultInstanceResources.getRam();\n+      }\n+    }\n+    return new Resource(cpu, ram, disk);\n+  }\n+\n+  /**\n+   * Computes the additional resources needed to accommodate a scale up and down operation\n+   *\n+   * @return Additional resources needed\n+   */\n+  public static Resource getAdditionalResources(Resource scaleupResource,\n+                                                Resource scaledownResource) {\n+    double cpuDifference =  scaleupResource.getCpu() - scaledownResource.getCpu();\n+    double cpu = cpuDifference < 0 ? 0 : cpuDifference;\n+    long ramDifference =  scaleupResource.getRam() - scaledownResource.getRam();\n+    long ram =  ramDifference < 0 ? 0 : ramDifference;\n+    long diskDifference = scaleupResource.getDisk() - scaledownResource.getDisk();\n+    long disk = diskDifference < 0 ? 0 : diskDifference;\n+    return new Resource(cpu, ram, disk);\n+  }\n+\n+\n+  /**\n+   * Computes number of containers needed to accommodate a specific resource request given the container size\n+   *\n+   * @return Number of containers needed\n+   */\n+  public static double getRequiredNumContainers(Resource resourceRequest, Resource capacity) {","path":"heron/packing/src/java/com/twitter/heron/packing/PackingUtils.java","position":97,"original_position":97,"commit_id":"a4a1684e1d04ff616caf9064589c67350ee52105","original_commit_id":"a4a1684e1d04ff616caf9064589c67350ee52105","user":{"login":"billonahill","id":23758,"avatar_url":"https://avatars.githubusercontent.com/u/23758?v=3","gravatar_id":"","url":"https://api.github.com/users/billonahill","html_url":"https://github.com/billonahill","followers_url":"https://api.github.com/users/billonahill/followers","following_url":"https://api.github.com/users/billonahill/following{/other_user}","gists_url":"https://api.github.com/users/billonahill/gists{/gist_id}","starred_url":"https://api.github.com/users/billonahill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billonahill/subscriptions","organizations_url":"https://api.github.com/users/billonahill/orgs","repos_url":"https://api.github.com/users/billonahill/repos","events_url":"https://api.github.com/users/billonahill/events{/privacy}","received_events_url":"https://api.github.com/users/billonahill/received_events","type":"User","site_admin":false},"body":"This could also be a method on `Resource`:\r\n```\r\nResource divideBy(Resource other);\r\n```","created_at":"2016-10-06T23:05:38Z","updated_at":"2016-10-06T23:05:38Z","html_url":"https://github.com/twitter/heron/pull/1471#discussion_r82303593","pull_request_url":"https://api.github.com/repos/twitter/heron/pulls/1471","_links":{"self":{"href":"https://api.github.com/repos/twitter/heron/pulls/comments/82303593"},"html":{"href":"https://github.com/twitter/heron/pull/1471#discussion_r82303593"},"pull_request":{"href":"https://api.github.com/repos/twitter/heron/pulls/1471"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/heron/pulls/1471","id":88116496,"html_url":"https://github.com/twitter/heron/pull/1471","diff_url":"https://github.com/twitter/heron/pull/1471.diff","patch_url":"https://github.com/twitter/heron/pull/1471.patch","issue_url":"https://api.github.com/repos/twitter/heron/issues/1471","number":1471,"state":"open","locked":false,"title":"Repack implementation for the Resource Compliant RR algorithm","user":{"login":"avflor","id":18666312,"avatar_url":"https://avatars.githubusercontent.com/u/18666312?v=3","gravatar_id":"","url":"https://api.github.com/users/avflor","html_url":"https://github.com/avflor","followers_url":"https://api.github.com/users/avflor/followers","following_url":"https://api.github.com/users/avflor/following{/other_user}","gists_url":"https://api.github.com/users/avflor/gists{/gist_id}","starred_url":"https://api.github.com/users/avflor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avflor/subscriptions","organizations_url":"https://api.github.com/users/avflor/orgs","repos_url":"https://api.github.com/users/avflor/repos","events_url":"https://api.github.com/users/avflor/events{/privacy}","received_events_url":"https://api.github.com/users/avflor/received_events","type":"User","site_admin":false},"body":"Fixes #1439 ","created_at":"2016-10-05T16:55:42Z","updated_at":"2016-10-06T23:05:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c413109aad024982058e8da299a4a7bbf30570c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/twitter/heron/pulls/1471/commits","review_comments_url":"https://api.github.com/repos/twitter/heron/pulls/1471/comments","review_comment_url":"https://api.github.com/repos/twitter/heron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/heron/issues/1471/comments","statuses_url":"https://api.github.com/repos/twitter/heron/statuses/a4a1684e1d04ff616caf9064589c67350ee52105","head":{"label":"avflor:roundrobinrepack","ref":"roundrobinrepack","sha":"a4a1684e1d04ff616caf9064589c67350ee52105","user":{"login":"avflor","id":18666312,"avatar_url":"https://avatars.githubusercontent.com/u/18666312?v=3","gravatar_id":"","url":"https://api.github.com/users/avflor","html_url":"https://github.com/avflor","followers_url":"https://api.github.com/users/avflor/followers","following_url":"https://api.github.com/users/avflor/following{/other_user}","gists_url":"https://api.github.com/users/avflor/gists{/gist_id}","starred_url":"https://api.github.com/users/avflor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avflor/subscriptions","organizations_url":"https://api.github.com/users/avflor/orgs","repos_url":"https://api.github.com/users/avflor/repos","events_url":"https://api.github.com/users/avflor/events{/privacy}","received_events_url":"https://api.github.com/users/avflor/received_events","type":"User","site_admin":false},"repo":{"id":61583089,"name":"heron","full_name":"avflor/heron","owner":{"login":"avflor","id":18666312,"avatar_url":"https://avatars.githubusercontent.com/u/18666312?v=3","gravatar_id":"","url":"https://api.github.com/users/avflor","html_url":"https://github.com/avflor","followers_url":"https://api.github.com/users/avflor/followers","following_url":"https://api.github.com/users/avflor/following{/other_user}","gists_url":"https://api.github.com/users/avflor/gists{/gist_id}","starred_url":"https://api.github.com/users/avflor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avflor/subscriptions","organizations_url":"https://api.github.com/users/avflor/orgs","repos_url":"https://api.github.com/users/avflor/repos","events_url":"https://api.github.com/users/avflor/events{/privacy}","received_events_url":"https://api.github.com/users/avflor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/avflor/heron","description":"Heron is a realtime, distributed, fault-tolerant stream processing engine from Twitter","fork":true,"url":"https://api.github.com/repos/avflor/heron","forks_url":"https://api.github.com/repos/avflor/heron/forks","keys_url":"https://api.github.com/repos/avflor/heron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avflor/heron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avflor/heron/teams","hooks_url":"https://api.github.com/repos/avflor/heron/hooks","issue_events_url":"https://api.github.com/repos/avflor/heron/issues/events{/number}","events_url":"https://api.github.com/repos/avflor/heron/events","assignees_url":"https://api.github.com/repos/avflor/heron/assignees{/user}","branches_url":"https://api.github.com/repos/avflor/heron/branches{/branch}","tags_url":"https://api.github.com/repos/avflor/heron/tags","blobs_url":"https://api.github.com/repos/avflor/heron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avflor/heron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avflor/heron/git/refs{/sha}","trees_url":"https://api.github.com/repos/avflor/heron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avflor/heron/statuses/{sha}","languages_url":"https://api.github.com/repos/avflor/heron/languages","stargazers_url":"https://api.github.com/repos/avflor/heron/stargazers","contributors_url":"https://api.github.com/repos/avflor/heron/contributors","subscribers_url":"https://api.github.com/repos/avflor/heron/subscribers","subscription_url":"https://api.github.com/repos/avflor/heron/subscription","commits_url":"https://api.github.com/repos/avflor/heron/commits{/sha}","git_commits_url":"https://api.github.com/repos/avflor/heron/git/commits{/sha}","comments_url":"https://api.github.com/repos/avflor/heron/comments{/number}","issue_comment_url":"https://api.github.com/repos/avflor/heron/issues/comments{/number}","contents_url":"https://api.github.com/repos/avflor/heron/contents/{+path}","compare_url":"https://api.github.com/repos/avflor/heron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avflor/heron/merges","archive_url":"https://api.github.com/repos/avflor/heron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avflor/heron/downloads","issues_url":"https://api.github.com/repos/avflor/heron/issues{/number}","pulls_url":"https://api.github.com/repos/avflor/heron/pulls{/number}","milestones_url":"https://api.github.com/repos/avflor/heron/milestones{/number}","notifications_url":"https://api.github.com/repos/avflor/heron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avflor/heron/labels{/name}","releases_url":"https://api.github.com/repos/avflor/heron/releases{/id}","deployments_url":"https://api.github.com/repos/avflor/heron/deployments","created_at":"2016-06-20T21:57:11Z","updated_at":"2016-06-20T21:57:15Z","pushed_at":"2016-10-05T18:27:57Z","git_url":"git://github.com/avflor/heron.git","ssh_url":"git@github.com:avflor/heron.git","clone_url":"https://github.com/avflor/heron.git","svn_url":"https://github.com/avflor/heron","homepage":"http://heronstreaming.io","size":113674,"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":"twitter:master","ref":"master","sha":"8a4c482fd30077707f3e4cdd2f8e3ece90160af2","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":43158694,"name":"heron","full_name":"twitter/heron","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/heron","description":"Heron is a realtime, distributed, fault-tolerant stream processing engine from Twitter","fork":false,"url":"https://api.github.com/repos/twitter/heron","forks_url":"https://api.github.com/repos/twitter/heron/forks","keys_url":"https://api.github.com/repos/twitter/heron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/heron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/heron/teams","hooks_url":"https://api.github.com/repos/twitter/heron/hooks","issue_events_url":"https://api.github.com/repos/twitter/heron/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/heron/events","assignees_url":"https://api.github.com/repos/twitter/heron/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/heron/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/heron/tags","blobs_url":"https://api.github.com/repos/twitter/heron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/heron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/heron/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/heron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/heron/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/heron/languages","stargazers_url":"https://api.github.com/repos/twitter/heron/stargazers","contributors_url":"https://api.github.com/repos/twitter/heron/contributors","subscribers_url":"https://api.github.com/repos/twitter/heron/subscribers","subscription_url":"https://api.github.com/repos/twitter/heron/subscription","commits_url":"https://api.github.com/repos/twitter/heron/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/heron/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/heron/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/heron/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/heron/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/heron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/heron/merges","archive_url":"https://api.github.com/repos/twitter/heron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/heron/downloads","issues_url":"https://api.github.com/repos/twitter/heron/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/heron/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/heron/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/heron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/heron/labels{/name}","releases_url":"https://api.github.com/repos/twitter/heron/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/heron/deployments","created_at":"2015-09-25T16:09:24Z","updated_at":"2016-10-06T16:26:28Z","pushed_at":"2016-10-06T22:36:30Z","git_url":"git://github.com/twitter/heron.git","ssh_url":"git@github.com:twitter/heron.git","clone_url":"https://github.com/twitter/heron.git","svn_url":"https://github.com/twitter/heron","homepage":"http://heronstreaming.io","size":147652,"stargazers_count":2406,"watchers_count":2406,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":401,"mirror_url":null,"open_issues_count":201,"forks":401,"open_issues":201,"watchers":2406,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/heron/pulls/1471"},"html":{"href":"https://github.com/twitter/heron/pull/1471"},"issue":{"href":"https://api.github.com/repos/twitter/heron/issues/1471"},"comments":{"href":"https://api.github.com/repos/twitter/heron/issues/1471/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/heron/pulls/1471/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/heron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/heron/pulls/1471/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/heron/statuses/a4a1684e1d04ff616caf9064589c67350ee52105"}}}}
{"actor":{"display_login":"billonahill"}}