rabbah commented on a change in pull request #2360: Choose target invoker based 
on specific invoker load.
URL: 
https://github.com/apache/incubator-openwhisk/pull/2360#discussion_r122568304
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
 ##########
 @@ -299,26 +329,32 @@ class LoadBalancerService(config: WhiskConfig, 
entityStore: EntityStore)(implici
      * Invoker is currently using and which is better avoid if/until
      * these are moved to some common place (like a subclass of Message?)
      */
-    private val activationCountMap = TrieMap[(String, String), AtomicInteger]()
-    private def hashAndCountSubjectAction(msg: ActivationMessage): (Int, Int) 
= {
+    private def hashSubjectAction(msg: ActivationMessage): Int = {
         val subject = msg.user.subject.asString
         val path = msg.action.toString
-        val hash = subject.hashCode() ^ path.hashCode()
-        val key = (subject, path)
-        val count = activationCountMap.get(key) match {
-            case Some(counter) => counter.getAndIncrement()
-            case None => {
-                activationCountMap.put(key, new AtomicInteger(0))
-                0
-            }
-        }
-        return (hash, count)
+        subject.hashCode() ^ path.hashCode()
+    }
+
+    /** Memoizes the result of `f` for later use. */
+    private def memoize[I, O](f: I => O): I => O = new 
scala.collection.mutable.HashMap[I, O]() {
 
 Review comment:
   I would also pre-compute these lists for the number of invokers in a 
deployment rather than on demand where you might up doing computing the same 
list multiple times in `chooseInvoker` for overlapping first selections. It 
seems we don't have that value in the whisk config but perhaps we should to 
facilitate this. You could also fold this into the invoker health protocol so 
as new invokers are online the lists are computed.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to