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_r122568239
##########
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 put memoize and coprime in the companion object which would make it
easier to unit test just that function.
----------------------------------------------------------------
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