{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments/138259497","pull_request_review_id":62024974,"id":138259497,"diff_hunk":"@@ -0,0 +1,77 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * 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, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package whisk.core.loadBalancer\n+\n+import java.util.concurrent.atomic.AtomicInteger\n+\n+import scala.collection.concurrent.TrieMap\n+import scala.concurrent.Future\n+import whisk.core.entity.{ActivationId, UUID}\n+import whisk.core.entity.InstanceId\n+\n+/**\n+ * Loadbalancer bookkeeping data which are stored locally,\n+ * e.g. not shared with other controller instances.\n+ *\n+ * Note: The state keeping is backed by concurrent data-structures. As such,\n+ * concurrent reads can return stale values (especially the counters returned).\n+ */\n+class LoadBalancerDataLocal() extends BookkeepingData {\n+\n+  private val activationByInvoker = TrieMap[InstanceId, AtomicInteger]()\n+  private val activationByNamespaceId = TrieMap[UUID, AtomicInteger]()\n+  private val activationsById = TrieMap[ActivationId, ActivationEntry]()\n+  private val totalActivations = new AtomicInteger(0)\n+\n+  override def totalActivationCount: Future[Int] = Future.successful(totalActivations.get)\n+\n+  override def activationCountOn(namespace: UUID): Future[Int] = {\n+    Future.successful(activationByNamespaceId.get(namespace).map(_.get).getOrElse(0))\n+  }\n+\n+  override def activationCountPerInvoker: Future[Map[String, Int]] = {\n+    Future.successful(activationByInvoker.map(x => (x._1.toString, x._2.get)).toMap)","path":"core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerDataLocal.scala","position":48,"original_position":48,"commit_id":"1b362b20092e5db50455a6ea3a3695d3999a1169","original_commit_id":"1b362b20092e5db50455a6ea3a3695d3999a1169","user":{"login":"markusthoemmes","id":1289147,"avatar_url":"https://avatars3.githubusercontent.com/u/1289147?v=4","gravatar_id":"","url":"https://api.github.com/users/markusthoemmes","html_url":"https://github.com/markusthoemmes","followers_url":"https://api.github.com/users/markusthoemmes/followers","following_url":"https://api.github.com/users/markusthoemmes/following{/other_user}","gists_url":"https://api.github.com/users/markusthoemmes/gists{/gist_id}","starred_url":"https://api.github.com/users/markusthoemmes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markusthoemmes/subscriptions","organizations_url":"https://api.github.com/users/markusthoemmes/orgs","repos_url":"https://api.github.com/users/markusthoemmes/repos","events_url":"https://api.github.com/users/markusthoemmes/events{/privacy}","received_events_url":"https://api.github.com/users/markusthoemmes/received_events","type":"User","site_admin":false},"body":"If we can switch back to not using `String` we can use the lazy `mapValues` here so we don't update the whole map everytime it's gotten (once per invocation).","created_at":"2017-09-12T06:11:59Z","updated_at":"2017-09-12T06:21:57Z","html_url":"https://github.com/apache/incubator-openwhisk/pull/2531#discussion_r138259497","pull_request_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments/138259497"},"html":{"href":"https://github.com/apache/incubator-openwhisk/pull/2531#discussion_r138259497"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531","id":132526395,"html_url":"https://github.com/apache/incubator-openwhisk/pull/2531","diff_url":"https://github.com/apache/incubator-openwhisk/pull/2531.diff","patch_url":"https://github.com/apache/incubator-openwhisk/pull/2531.patch","issue_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2531","number":2531,"state":"open","locked":false,"title":"Share bookkeeping data across controllers","user":{"login":"vvraskin","id":7526585,"avatar_url":"https://avatars3.githubusercontent.com/u/7526585?v=4","gravatar_id":"","url":"https://api.github.com/users/vvraskin","html_url":"https://github.com/vvraskin","followers_url":"https://api.github.com/users/vvraskin/followers","following_url":"https://api.github.com/users/vvraskin/following{/other_user}","gists_url":"https://api.github.com/users/vvraskin/gists{/gist_id}","starred_url":"https://api.github.com/users/vvraskin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvraskin/subscriptions","organizations_url":"https://api.github.com/users/vvraskin/orgs","repos_url":"https://api.github.com/users/vvraskin/repos","events_url":"https://api.github.com/users/vvraskin/events{/privacy}","received_events_url":"https://api.github.com/users/vvraskin/received_events","type":"User","site_admin":false},"body":"Hello, \r\n\r\nthis PR is a WIP to share the state across multiple controllers to scale out the controllers in OpenWhisk. \r\nIt will allow us to share Activations per namespaces and invokers across several controllers using [Akka Distributed framework](http://doc.akka.io/docs/akka/snapshot/scala/distributed-data.html). The TrieMaps were replaced by PNCounterMaps, which are updated locally without waiting for the replication across other nodes in the cluster. \r\n\r\nUPDATED.\r\nI have a couple of things to mention:\r\n* Parsing of the seed-nodes is defined in a separate method due to a well known akka config issue https://github.com/akka/akka/issues/23600. \r\n* The old LoadBalancerData implementation is still in place, so in case of emergency we can turn off akka replication across Controllers. \r\n\r\nAny other todos and comments are welcome. \r\n\r\n@cbickel @markusthoemmes @rabbah \r\n\r\nregards, \r\nVadim. ","created_at":"2017-07-26T14:15:33Z","updated_at":"2017-09-12T06:21:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c815aaf4ab051d0bedd1dd88ec6a4a9cf7af524","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2531/comments","statuses_url":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/1b362b20092e5db50455a6ea3a3695d3999a1169","head":{"label":"vvraskin:shared-state-akka","ref":"shared-state-akka","sha":"1b362b20092e5db50455a6ea3a3695d3999a1169","user":{"login":"vvraskin","id":7526585,"avatar_url":"https://avatars3.githubusercontent.com/u/7526585?v=4","gravatar_id":"","url":"https://api.github.com/users/vvraskin","html_url":"https://github.com/vvraskin","followers_url":"https://api.github.com/users/vvraskin/followers","following_url":"https://api.github.com/users/vvraskin/following{/other_user}","gists_url":"https://api.github.com/users/vvraskin/gists{/gist_id}","starred_url":"https://api.github.com/users/vvraskin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvraskin/subscriptions","organizations_url":"https://api.github.com/users/vvraskin/orgs","repos_url":"https://api.github.com/users/vvraskin/repos","events_url":"https://api.github.com/users/vvraskin/events{/privacy}","received_events_url":"https://api.github.com/users/vvraskin/received_events","type":"User","site_admin":false},"repo":{"id":94328164,"name":"incubator-openwhisk","full_name":"vvraskin/incubator-openwhisk","owner":{"login":"vvraskin","id":7526585,"avatar_url":"https://avatars3.githubusercontent.com/u/7526585?v=4","gravatar_id":"","url":"https://api.github.com/users/vvraskin","html_url":"https://github.com/vvraskin","followers_url":"https://api.github.com/users/vvraskin/followers","following_url":"https://api.github.com/users/vvraskin/following{/other_user}","gists_url":"https://api.github.com/users/vvraskin/gists{/gist_id}","starred_url":"https://api.github.com/users/vvraskin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvraskin/subscriptions","organizations_url":"https://api.github.com/users/vvraskin/orgs","repos_url":"https://api.github.com/users/vvraskin/repos","events_url":"https://api.github.com/users/vvraskin/events{/privacy}","received_events_url":"https://api.github.com/users/vvraskin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vvraskin/incubator-openwhisk","description":"Apache OpenWhisk is a serverless event-based programming service and an Apache Incubator project.","fork":true,"url":"https://api.github.com/repos/vvraskin/incubator-openwhisk","forks_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/forks","keys_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/teams","hooks_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/hooks","issue_events_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/issues/events{/number}","events_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/events","assignees_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/assignees{/user}","branches_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/branches{/branch}","tags_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/tags","blobs_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/statuses/{sha}","languages_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/languages","stargazers_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/stargazers","contributors_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/contributors","subscribers_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/subscribers","subscription_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/subscription","commits_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/contents/{+path}","compare_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/merges","archive_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/downloads","issues_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/issues{/number}","pulls_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/pulls{/number}","milestones_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/milestones{/number}","notifications_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/labels{/name}","releases_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/releases{/id}","deployments_url":"https://api.github.com/repos/vvraskin/incubator-openwhisk/deployments","created_at":"2017-06-14T12:23:35Z","updated_at":"2017-06-20T09:56:30Z","pushed_at":"2017-09-11T13:06:14Z","git_url":"git://github.com/vvraskin/incubator-openwhisk.git","ssh_url":"git@github.com:vvraskin/incubator-openwhisk.git","clone_url":"https://github.com/vvraskin/incubator-openwhisk.git","svn_url":"https://github.com/vvraskin/incubator-openwhisk","homepage":"http://openwhisk.org","size":56882,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_projects":true,"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":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"d86c415a1d9a4eaa2061eac3a6ce99f24ba390f9","user":{"login":"apache","id":47359,"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":52039373,"name":"incubator-openwhisk","full_name":"apache/incubator-openwhisk","owner":{"login":"apache","id":47359,"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},"private":false,"html_url":"https://github.com/apache/incubator-openwhisk","description":"Apache OpenWhisk is a serverless event-based programming service and an Apache Incubator project.","fork":false,"url":"https://api.github.com/repos/apache/incubator-openwhisk","forks_url":"https://api.github.com/repos/apache/incubator-openwhisk/forks","keys_url":"https://api.github.com/repos/apache/incubator-openwhisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-openwhisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-openwhisk/teams","hooks_url":"https://api.github.com/repos/apache/incubator-openwhisk/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-openwhisk/events","assignees_url":"https://api.github.com/repos/apache/incubator-openwhisk/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-openwhisk/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-openwhisk/tags","blobs_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-openwhisk/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-openwhisk/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-openwhisk/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-openwhisk/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-openwhisk/subscription","commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-openwhisk/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-openwhisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-openwhisk/merges","archive_url":"https://api.github.com/repos/apache/incubator-openwhisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-openwhisk/downloads","issues_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-openwhisk/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-openwhisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-openwhisk/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-openwhisk/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-openwhisk/deployments","created_at":"2016-02-18T21:16:19Z","updated_at":"2017-09-11T23:44:45Z","pushed_at":"2017-09-12T05:36:46Z","git_url":"git://github.com/apache/incubator-openwhisk.git","ssh_url":"git@github.com:apache/incubator-openwhisk.git","clone_url":"https://github.com/apache/incubator-openwhisk.git","svn_url":"https://github.com/apache/incubator-openwhisk","homepage":"http://openwhisk.org","size":56823,"stargazers_count":1929,"watchers_count":1929,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":418,"mirror_url":null,"open_issues_count":401,"forks":418,"open_issues":401,"watchers":1929,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531"},"html":{"href":"https://github.com/apache/incubator-openwhisk/pull/2531"},"issue":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2531"},"comments":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2531/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2531/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/1b362b20092e5db50455a6ea3a3695d3999a1169"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"markusthoemmes"}}