{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-heron/pulls/comments/245382853","pull_request_review_id":189478531,"id":245382853,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NTM4Mjg1Mw==","diff_hunk":"@@ -0,0 +1,90 @@\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+\n+package org.apache.heron.common.basics;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+public final class CPUShare extends ResourceMeasure<Double> {\n+\n+  private CPUShare(Double value) {\n+    super(value);\n+  }\n+\n+  public static CPUShare fromDouble(double value) {\n+    return new CPUShare(value);\n+  }\n+\n+  @Override\n+  public CPUShare minus(ResourceMeasure<Double> other) {\n+    return new CPUShare(value - other.value);\n+  }\n+\n+  @Override\n+  public CPUShare plus(ResourceMeasure<Double> other) {\n+    return new CPUShare(value + other.value);\n+  }\n+\n+  @Override\n+  public CPUShare multiply(int factor) {\n+    return new CPUShare(value * factor);\n+  }\n+\n+  @Override\n+  public CPUShare divide(int factor) {\n+    return new CPUShare(value / factor);\n+  }\n+\n+  @Override\n+  public CPUShare increaseBy(int percentage) {\n+    return new CPUShare(value * (1.0 + percentage / 100.0));\n+  }\n+\n+  public static Map<String, CPUShare> convertDoubleMapToCpuShareMap(Map<String, Double> doubleMap) {\n+    Map<String, CPUShare> retval = new HashMap<>();\n+    for (Map.Entry<String, Double> entry : doubleMap.entrySet()) {\n+      retval.put(entry.getKey(), new CPUShare(entry.getValue()));\n+    }\n+    return retval;\n+  }\n+\n+  @Override\n+  public int hashCode() {\n+    return value.hashCode();\n+  }\n+\n+  @Override","path":"heron/common/src/java/org/apache/heron/common/basics/CPUShare.java","position":73,"original_position":73,"commit_id":"b5e23fbbabd4926717b088eaef9a3215d234533c","original_commit_id":"b5e23fbbabd4926717b088eaef9a3215d234533c","user":{"login":"nwangtw","id":6353055,"node_id":"MDQ6VXNlcjYzNTMwNTU=","avatar_url":"https://avatars0.githubusercontent.com/u/6353055?v=4","gravatar_id":"","url":"https://api.github.com/users/nwangtw","html_url":"https://github.com/nwangtw","followers_url":"https://api.github.com/users/nwangtw/followers","following_url":"https://api.github.com/users/nwangtw/following{/other_user}","gists_url":"https://api.github.com/users/nwangtw/gists{/gist_id}","starred_url":"https://api.github.com/users/nwangtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwangtw/subscriptions","organizations_url":"https://api.github.com/users/nwangtw/orgs","repos_url":"https://api.github.com/users/nwangtw/repos","events_url":"https://api.github.com/users/nwangtw/events{/privacy}","received_events_url":"https://api.github.com/users/nwangtw/received_events","type":"User","site_admin":false},"body":"can this function be implemented in base class?","created_at":"2019-01-04T18:36:09Z","updated_at":"2019-01-04T18:46:43Z","html_url":"https://github.com/apache/incubator-heron/pull/3142#discussion_r245382853","pull_request_url":"https://api.github.com/repos/apache/incubator-heron/pulls/3142","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/comments/245382853"},"html":{"href":"https://github.com/apache/incubator-heron/pull/3142#discussion_r245382853"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/3142"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-heron/pulls/3142","id":241876363,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxODc2MzYz","html_url":"https://github.com/apache/incubator-heron/pull/3142","diff_url":"https://github.com/apache/incubator-heron/pull/3142.diff","patch_url":"https://github.com/apache/incubator-heron/pull/3142.patch","issue_url":"https://api.github.com/repos/apache/incubator-heron/issues/3142","number":3142,"state":"open","locked":false,"title":"Validate resource constraint (RAM and CPU) in RoundRobinPacking","user":{"login":"xiaoyao1991","id":674277,"node_id":"MDQ6VXNlcjY3NDI3Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/674277?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaoyao1991","html_url":"https://github.com/xiaoyao1991","followers_url":"https://api.github.com/users/xiaoyao1991/followers","following_url":"https://api.github.com/users/xiaoyao1991/following{/other_user}","gists_url":"https://api.github.com/users/xiaoyao1991/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaoyao1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaoyao1991/subscriptions","organizations_url":"https://api.github.com/users/xiaoyao1991/orgs","repos_url":"https://api.github.com/users/xiaoyao1991/repos","events_url":"https://api.github.com/users/xiaoyao1991/events{/privacy}","received_events_url":"https://api.github.com/users/xiaoyao1991/received_events","type":"User","site_admin":false},"body":"**This PR might break some mis-configured topologies in production**\r\n\r\nThis PR addresses some issues raised previously in the slack chat that the packing algorithm did not honor container-level and instance-level constraints on CPU resource. Additionally, we added resource constraint validation in RoundRobinPacking. Specifically:\r\n- `topology.container.cpu` and `topology.container.ram` are honored and considered as the **hard cap** constraint for the corresponding resource in **one** container. \r\n- `topology.component.cpumap` and `topology.component.rammap` are honored and considered as the instance resource mapping in **one** container.\r\n- The sum of instance resources in one container, plus padding, should not exceed the container-level constraint, otherwise the scheduling would fail. ","created_at":"2019-01-02T23:46:40Z","updated_at":"2019-01-04T18:46:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"434ae4c960e9601e4835c797d83b5ce0e034e033","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-heron/pulls/3142/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-heron/pulls/3142/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-heron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-heron/issues/3142/comments","statuses_url":"https://api.github.com/repos/apache/incubator-heron/statuses/b5e23fbbabd4926717b088eaef9a3215d234533c","head":{"label":"xiaoyao1991:validate_resource_constraint_in_RRPacking","ref":"validate_resource_constraint_in_RRPacking","sha":"b5e23fbbabd4926717b088eaef9a3215d234533c","user":{"login":"xiaoyao1991","id":674277,"node_id":"MDQ6VXNlcjY3NDI3Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/674277?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaoyao1991","html_url":"https://github.com/xiaoyao1991","followers_url":"https://api.github.com/users/xiaoyao1991/followers","following_url":"https://api.github.com/users/xiaoyao1991/following{/other_user}","gists_url":"https://api.github.com/users/xiaoyao1991/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaoyao1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaoyao1991/subscriptions","organizations_url":"https://api.github.com/users/xiaoyao1991/orgs","repos_url":"https://api.github.com/users/xiaoyao1991/repos","events_url":"https://api.github.com/users/xiaoyao1991/events{/privacy}","received_events_url":"https://api.github.com/users/xiaoyao1991/received_events","type":"User","site_admin":false},"repo":{"id":65680872,"node_id":"MDEwOlJlcG9zaXRvcnk2NTY4MDg3Mg==","name":"heron","full_name":"xiaoyao1991/heron","private":false,"owner":{"login":"xiaoyao1991","id":674277,"node_id":"MDQ6VXNlcjY3NDI3Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/674277?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaoyao1991","html_url":"https://github.com/xiaoyao1991","followers_url":"https://api.github.com/users/xiaoyao1991/followers","following_url":"https://api.github.com/users/xiaoyao1991/following{/other_user}","gists_url":"https://api.github.com/users/xiaoyao1991/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaoyao1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaoyao1991/subscriptions","organizations_url":"https://api.github.com/users/xiaoyao1991/orgs","repos_url":"https://api.github.com/users/xiaoyao1991/repos","events_url":"https://api.github.com/users/xiaoyao1991/events{/privacy}","received_events_url":"https://api.github.com/users/xiaoyao1991/received_events","type":"User","site_admin":false},"html_url":"https://github.com/xiaoyao1991/heron","description":"Heron is a realtime, distributed, fault-tolerant stream processing engine from Twitter","fork":true,"url":"https://api.github.com/repos/xiaoyao1991/heron","forks_url":"https://api.github.com/repos/xiaoyao1991/heron/forks","keys_url":"https://api.github.com/repos/xiaoyao1991/heron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xiaoyao1991/heron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xiaoyao1991/heron/teams","hooks_url":"https://api.github.com/repos/xiaoyao1991/heron/hooks","issue_events_url":"https://api.github.com/repos/xiaoyao1991/heron/issues/events{/number}","events_url":"https://api.github.com/repos/xiaoyao1991/heron/events","assignees_url":"https://api.github.com/repos/xiaoyao1991/heron/assignees{/user}","branches_url":"https://api.github.com/repos/xiaoyao1991/heron/branches{/branch}","tags_url":"https://api.github.com/repos/xiaoyao1991/heron/tags","blobs_url":"https://api.github.com/repos/xiaoyao1991/heron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xiaoyao1991/heron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xiaoyao1991/heron/git/refs{/sha}","trees_url":"https://api.github.com/repos/xiaoyao1991/heron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xiaoyao1991/heron/statuses/{sha}","languages_url":"https://api.github.com/repos/xiaoyao1991/heron/languages","stargazers_url":"https://api.github.com/repos/xiaoyao1991/heron/stargazers","contributors_url":"https://api.github.com/repos/xiaoyao1991/heron/contributors","subscribers_url":"https://api.github.com/repos/xiaoyao1991/heron/subscribers","subscription_url":"https://api.github.com/repos/xiaoyao1991/heron/subscription","commits_url":"https://api.github.com/repos/xiaoyao1991/heron/commits{/sha}","git_commits_url":"https://api.github.com/repos/xiaoyao1991/heron/git/commits{/sha}","comments_url":"https://api.github.com/repos/xiaoyao1991/heron/comments{/number}","issue_comment_url":"https://api.github.com/repos/xiaoyao1991/heron/issues/comments{/number}","contents_url":"https://api.github.com/repos/xiaoyao1991/heron/contents/{+path}","compare_url":"https://api.github.com/repos/xiaoyao1991/heron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xiaoyao1991/heron/merges","archive_url":"https://api.github.com/repos/xiaoyao1991/heron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xiaoyao1991/heron/downloads","issues_url":"https://api.github.com/repos/xiaoyao1991/heron/issues{/number}","pulls_url":"https://api.github.com/repos/xiaoyao1991/heron/pulls{/number}","milestones_url":"https://api.github.com/repos/xiaoyao1991/heron/milestones{/number}","notifications_url":"https://api.github.com/repos/xiaoyao1991/heron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xiaoyao1991/heron/labels{/name}","releases_url":"https://api.github.com/repos/xiaoyao1991/heron/releases{/id}","deployments_url":"https://api.github.com/repos/xiaoyao1991/heron/deployments","created_at":"2016-08-14T18:35:31Z","updated_at":"2019-01-02T22:56:36Z","pushed_at":"2019-01-03T23:33:37Z","git_url":"git://github.com/xiaoyao1991/heron.git","ssh_url":"git@github.com:xiaoyao1991/heron.git","clone_url":"https://github.com/xiaoyao1991/heron.git","svn_url":"https://github.com/xiaoyao1991/heron","homepage":"http://heronstreaming.io","size":170785,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"d0141cbfe3d549d1e597882a81a02c4e41688ef3","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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":43158694,"node_id":"MDEwOlJlcG9zaXRvcnk0MzE1ODY5NA==","name":"incubator-heron","full_name":"apache/incubator-heron","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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},"html_url":"https://github.com/apache/incubator-heron","description":"Apache Heron (Incubating) is a realtime, distributed, fault-tolerant stream processing engine from Twitter","fork":false,"url":"https://api.github.com/repos/apache/incubator-heron","forks_url":"https://api.github.com/repos/apache/incubator-heron/forks","keys_url":"https://api.github.com/repos/apache/incubator-heron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-heron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-heron/teams","hooks_url":"https://api.github.com/repos/apache/incubator-heron/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-heron/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-heron/events","assignees_url":"https://api.github.com/repos/apache/incubator-heron/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-heron/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-heron/tags","blobs_url":"https://api.github.com/repos/apache/incubator-heron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-heron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-heron/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-heron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-heron/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-heron/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-heron/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-heron/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-heron/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-heron/subscription","commits_url":"https://api.github.com/repos/apache/incubator-heron/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-heron/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-heron/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-heron/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-heron/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-heron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-heron/merges","archive_url":"https://api.github.com/repos/apache/incubator-heron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-heron/downloads","issues_url":"https://api.github.com/repos/apache/incubator-heron/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-heron/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-heron/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-heron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-heron/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-heron/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-heron/deployments","created_at":"2015-09-25T16:09:24Z","updated_at":"2019-01-04T07:53:08Z","pushed_at":"2019-01-04T07:52:57Z","git_url":"git://github.com/apache/incubator-heron.git","ssh_url":"git@github.com:apache/incubator-heron.git","clone_url":"https://github.com/apache/incubator-heron.git","svn_url":"https://github.com/apache/incubator-heron","homepage":"http://heronstreaming.io","size":223070,"stargazers_count":3299,"watchers_count":3299,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":601,"mirror_url":null,"archived":false,"open_issues_count":389,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":601,"open_issues":389,"watchers":3299,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/3142"},"html":{"href":"https://github.com/apache/incubator-heron/pull/3142"},"issue":{"href":"https://api.github.com/repos/apache/incubator-heron/issues/3142"},"comments":{"href":"https://api.github.com/repos/apache/incubator-heron/issues/3142/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/3142/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-heron/pulls/3142/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-heron/statuses/b5e23fbbabd4926717b088eaef9a3215d234533c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nwangtw"}}