{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/serenity/pulls/comments/34667093","id":34667093,"diff_hunk":"@@ -0,0 +1,132 @@\n+#ifndef SERENITY_QOS_CORRECTION_HPP\n+#define SERENITY_QOS_CORRECTION_HPP\n+\n+#include <list>\n+#include <vector>\n+\n+#include \"glog/logging.h\"\n+\n+#include \"mesos/mesos.hpp\"\n+#include \"mesos/resources.hpp\"\n+\n+#include \"mesos/slave/oversubscription.hpp\"\n+\n+#include \"messages/serenity.hpp\"\n+\n+#include \"serenity/serenity.hpp\"\n+\n+namespace mesos {\n+namespace serenity {\n+\n+inline std::list<ResourceUsage_Executor> filterPrExecutors(\n+    ResourceUsage usage) {\n+  std::list<ResourceUsage_Executor> beExecutors;\n+  for (ResourceUsage_Executor inExec : usage.executors()) {\n+    if (!inExec.has_executor_info()) {\n+      LOG(ERROR) << \"Executor <unknown>\"\n+      << \" does not include executor_info\";\n+      // Filter out these executors.\n+      continue;\n+    }\n+    if (inExec.allocated().size() == 0) {\n+      LOG(ERROR) << \"Executor \"\n+      << inExec.executor_info().executor_id().value()\n+      << \" does not include allocated resources.\";\n+      // Filter out these executors.\n+      continue;\n+    }\n+\n+    Resources allocated(inExec.allocated());\n+    // Check if task uses revocable resources.\n+    if (!allocated.revocable().empty())\n+      beExecutors.push_back(inExec);\n+  }\n+\n+  return beExecutors;\n+}\n+\n+\n+using ContentionInterpreterFunction = Try<QoSCorrections>\n+    (Contentions currentContentions,\n+    ResourceUsage currentUsage);\n+\n+\n+/**\n+ * Class including all algorithms for contention interpretations.\n+ * They converts contentions & usage to QoSCorrections.\n+ *\n+ * Convenient for debuging and testing different algorithms.\n+ */\n+class ContentionInterpreters {\n+ public:\n+  static ContentionInterpreterFunction severityBasedCpuContention;\n+};\n+\n+\n+/**\n+ * QoSCorrectionObserver observes incoming Contentions and\n+ * ResourceUsage and produces QoSCorrections.\n+ *\n+ * Currently Slave understand only kill correction action.\n+ */\n+class QoSCorrectionObserver : public MultiConsumer<Contentions>,\n+                              public Consumer<ResourceUsage>,\n+                              public Producer<QoSCorrections> {\n+ public:\n+  explicit QoSCorrectionObserver(\n+      Consumer<QoSCorrections>* _consumer,\n+      uint64_t _contentionProducents,","path":"observers/qos_correction.hpp","position":78,"original_position":78,"commit_id":"9f99b411ea1b982d3eb885b76d71f25ee2c4a283","original_commit_id":"9f99b411ea1b982d3eb885b76d71f25ee2c4a283","user":{"login":"Bplotka","id":6950331,"avatar_url":"https://avatars.githubusercontent.com/u/6950331?v=3","gravatar_id":"","url":"https://api.github.com/users/Bplotka","html_url":"https://github.com/Bplotka","followers_url":"https://api.github.com/users/Bplotka/followers","following_url":"https://api.github.com/users/Bplotka/following{/other_user}","gists_url":"https://api.github.com/users/Bplotka/gists{/gist_id}","starred_url":"https://api.github.com/users/Bplotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bplotka/subscriptions","organizations_url":"https://api.github.com/users/Bplotka/orgs","repos_url":"https://api.github.com/users/Bplotka/repos","events_url":"https://api.github.com/users/Bplotka/events{/privacy}","received_events_url":"https://api.github.com/users/Bplotka/received_events","type":"User","site_admin":false},"body":"Number of contentions products we are expecting in our consumer. (It's filling MultiConsumer(..) constructor)","created_at":"2015-07-15T10:53:13Z","updated_at":"2015-07-15T10:53:13Z","html_url":"https://github.com/mesosphere/serenity/pull/48#discussion_r34667093","pull_request_url":"https://api.github.com/repos/mesosphere/serenity/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/comments/34667093"},"html":{"href":"https://github.com/mesosphere/serenity/pull/48#discussion_r34667093"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/mesosphere/serenity/pulls/48","id":39899660,"html_url":"https://github.com/mesosphere/serenity/pull/48","diff_url":"https://github.com/mesosphere/serenity/pull/48.diff","patch_url":"https://github.com/mesosphere/serenity/pull/48.patch","issue_url":"https://api.github.com/repos/mesosphere/serenity/issues/48","number":48,"state":"open","locked":false,"title":"QoSCorrectionObserver which interprets contentions and creates corrections","user":{"login":"Bplotka","id":6950331,"avatar_url":"https://avatars.githubusercontent.com/u/6950331?v=3","gravatar_id":"","url":"https://api.github.com/users/Bplotka","html_url":"https://github.com/Bplotka","followers_url":"https://api.github.com/users/Bplotka/followers","following_url":"https://api.github.com/users/Bplotka/following{/other_user}","gists_url":"https://api.github.com/users/Bplotka/gists{/gist_id}","starred_url":"https://api.github.com/users/Bplotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bplotka/subscriptions","organizations_url":"https://api.github.com/users/Bplotka/orgs","repos_url":"https://api.github.com/users/Bplotka/repos","events_url":"https://api.github.com/users/Bplotka/events{/privacy}","received_events_url":"https://api.github.com/users/Bplotka/received_events","type":"User","site_admin":false},"body":"\r\nSigned-off-by: bplotka <bwplotka@gmail.com>","created_at":"2015-07-14T09:58:07Z","updated_at":"2015-07-15T10:53:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3488b3e4dea9184fd603a3174e2e16b64049355","assignee":{"login":"nqn","id":897374,"avatar_url":"https://avatars.githubusercontent.com/u/897374?v=3","gravatar_id":"","url":"https://api.github.com/users/nqn","html_url":"https://github.com/nqn","followers_url":"https://api.github.com/users/nqn/followers","following_url":"https://api.github.com/users/nqn/following{/other_user}","gists_url":"https://api.github.com/users/nqn/gists{/gist_id}","starred_url":"https://api.github.com/users/nqn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nqn/subscriptions","organizations_url":"https://api.github.com/users/nqn/orgs","repos_url":"https://api.github.com/users/nqn/repos","events_url":"https://api.github.com/users/nqn/events{/privacy}","received_events_url":"https://api.github.com/users/nqn/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mesosphere/serenity/pulls/48/commits","review_comments_url":"https://api.github.com/repos/mesosphere/serenity/pulls/48/comments","review_comment_url":"https://api.github.com/repos/mesosphere/serenity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/serenity/issues/48/comments","statuses_url":"https://api.github.com/repos/mesosphere/serenity/statuses/9f99b411ea1b982d3eb885b76d71f25ee2c4a283","head":{"label":"Bplotka:qos-correction-observer","ref":"qos-correction-observer","sha":"9f99b411ea1b982d3eb885b76d71f25ee2c4a283","user":{"login":"Bplotka","id":6950331,"avatar_url":"https://avatars.githubusercontent.com/u/6950331?v=3","gravatar_id":"","url":"https://api.github.com/users/Bplotka","html_url":"https://github.com/Bplotka","followers_url":"https://api.github.com/users/Bplotka/followers","following_url":"https://api.github.com/users/Bplotka/following{/other_user}","gists_url":"https://api.github.com/users/Bplotka/gists{/gist_id}","starred_url":"https://api.github.com/users/Bplotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bplotka/subscriptions","organizations_url":"https://api.github.com/users/Bplotka/orgs","repos_url":"https://api.github.com/users/Bplotka/repos","events_url":"https://api.github.com/users/Bplotka/events{/privacy}","received_events_url":"https://api.github.com/users/Bplotka/received_events","type":"User","site_admin":false},"repo":{"id":37205434,"name":"serenity","full_name":"Bplotka/serenity","owner":{"login":"Bplotka","id":6950331,"avatar_url":"https://avatars.githubusercontent.com/u/6950331?v=3","gravatar_id":"","url":"https://api.github.com/users/Bplotka","html_url":"https://github.com/Bplotka","followers_url":"https://api.github.com/users/Bplotka/followers","following_url":"https://api.github.com/users/Bplotka/following{/other_user}","gists_url":"https://api.github.com/users/Bplotka/gists{/gist_id}","starred_url":"https://api.github.com/users/Bplotka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bplotka/subscriptions","organizations_url":"https://api.github.com/users/Bplotka/orgs","repos_url":"https://api.github.com/users/Bplotka/repos","events_url":"https://api.github.com/users/Bplotka/events{/privacy}","received_events_url":"https://api.github.com/users/Bplotka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Bplotka/serenity","description":"Repo for Intel:Mesosphere Oversubscription Technologies","fork":true,"url":"https://api.github.com/repos/Bplotka/serenity","forks_url":"https://api.github.com/repos/Bplotka/serenity/forks","keys_url":"https://api.github.com/repos/Bplotka/serenity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Bplotka/serenity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Bplotka/serenity/teams","hooks_url":"https://api.github.com/repos/Bplotka/serenity/hooks","issue_events_url":"https://api.github.com/repos/Bplotka/serenity/issues/events{/number}","events_url":"https://api.github.com/repos/Bplotka/serenity/events","assignees_url":"https://api.github.com/repos/Bplotka/serenity/assignees{/user}","branches_url":"https://api.github.com/repos/Bplotka/serenity/branches{/branch}","tags_url":"https://api.github.com/repos/Bplotka/serenity/tags","blobs_url":"https://api.github.com/repos/Bplotka/serenity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Bplotka/serenity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Bplotka/serenity/git/refs{/sha}","trees_url":"https://api.github.com/repos/Bplotka/serenity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Bplotka/serenity/statuses/{sha}","languages_url":"https://api.github.com/repos/Bplotka/serenity/languages","stargazers_url":"https://api.github.com/repos/Bplotka/serenity/stargazers","contributors_url":"https://api.github.com/repos/Bplotka/serenity/contributors","subscribers_url":"https://api.github.com/repos/Bplotka/serenity/subscribers","subscription_url":"https://api.github.com/repos/Bplotka/serenity/subscription","commits_url":"https://api.github.com/repos/Bplotka/serenity/commits{/sha}","git_commits_url":"https://api.github.com/repos/Bplotka/serenity/git/commits{/sha}","comments_url":"https://api.github.com/repos/Bplotka/serenity/comments{/number}","issue_comment_url":"https://api.github.com/repos/Bplotka/serenity/issues/comments{/number}","contents_url":"https://api.github.com/repos/Bplotka/serenity/contents/{+path}","compare_url":"https://api.github.com/repos/Bplotka/serenity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Bplotka/serenity/merges","archive_url":"https://api.github.com/repos/Bplotka/serenity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Bplotka/serenity/downloads","issues_url":"https://api.github.com/repos/Bplotka/serenity/issues{/number}","pulls_url":"https://api.github.com/repos/Bplotka/serenity/pulls{/number}","milestones_url":"https://api.github.com/repos/Bplotka/serenity/milestones{/number}","notifications_url":"https://api.github.com/repos/Bplotka/serenity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Bplotka/serenity/labels{/name}","releases_url":"https://api.github.com/repos/Bplotka/serenity/releases{/id}","created_at":"2015-06-10T15:26:39Z","updated_at":"2015-06-10T15:26:39Z","pushed_at":"2015-07-14T10:02:25Z","git_url":"git://github.com/Bplotka/serenity.git","ssh_url":"git@github.com:Bplotka/serenity.git","clone_url":"https://github.com/Bplotka/serenity.git","svn_url":"https://github.com/Bplotka/serenity","homepage":null,"size":4482,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"mesosphere:master","ref":"master","sha":"965993016306dbc3dd4183d12dafe3695c81feaf","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":35688047,"name":"serenity","full_name":"mesosphere/serenity","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars.githubusercontent.com/u/3458585?v=3","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/serenity","description":"Repo for Intel:Mesosphere Oversubscription Technologies","fork":false,"url":"https://api.github.com/repos/mesosphere/serenity","forks_url":"https://api.github.com/repos/mesosphere/serenity/forks","keys_url":"https://api.github.com/repos/mesosphere/serenity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/serenity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/serenity/teams","hooks_url":"https://api.github.com/repos/mesosphere/serenity/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/serenity/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/serenity/events","assignees_url":"https://api.github.com/repos/mesosphere/serenity/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/serenity/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/serenity/tags","blobs_url":"https://api.github.com/repos/mesosphere/serenity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/serenity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/serenity/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/serenity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/serenity/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/serenity/languages","stargazers_url":"https://api.github.com/repos/mesosphere/serenity/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/serenity/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/serenity/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/serenity/subscription","commits_url":"https://api.github.com/repos/mesosphere/serenity/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/serenity/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/serenity/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/serenity/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/serenity/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/serenity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/serenity/merges","archive_url":"https://api.github.com/repos/mesosphere/serenity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/serenity/downloads","issues_url":"https://api.github.com/repos/mesosphere/serenity/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/serenity/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/serenity/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/serenity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/serenity/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/serenity/releases{/id}","created_at":"2015-05-15T17:46:54Z","updated_at":"2015-06-24T23:31:07Z","pushed_at":"2015-07-14T18:14:48Z","git_url":"git://github.com/mesosphere/serenity.git","ssh_url":"git@github.com:mesosphere/serenity.git","clone_url":"https://github.com/mesosphere/serenity.git","svn_url":"https://github.com/mesosphere/serenity","homepage":null,"size":4853,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/48"},"html":{"href":"https://github.com/mesosphere/serenity/pull/48"},"issue":{"href":"https://api.github.com/repos/mesosphere/serenity/issues/48"},"comments":{"href":"https://api.github.com/repos/mesosphere/serenity/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/serenity/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/serenity/statuses/9f99b411ea1b982d3eb885b76d71f25ee2c4a283"}}}}