markusthoemmes 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_r122627143
 
 

 ##########
 File path: 
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
 ##########
 @@ -277,14 +277,44 @@ class LoadBalancerService(config: WhiskConfig, 
entityStore: EntityStore)(implici
             case _              => false
         }
         val invokers = if (isBlackbox) blackboxInvokers else managedInvokers
-        val (hash, count) = hashAndCountSubjectAction(msg)
+        val hash = hashSubjectAction(msg).abs
 
         invokers.flatMap { invokers =>
             val numInvokers = invokers.length
             if (numInvokers > 0) {
-                val hashCount = math.abs(hash + count / 
activationCountBeforeNextInvoker)
-                val invokerIndex = hashCount % numInvokers
-                Future.successful(invokers(invokerIndex))
+                val nextInvokerThreshold = 
config.loadbalancerInvokerBusyThreshold
+                val homeInvoker = hash % numInvokers
+
+                val stepSizes = coprimePrimeNumbersUntil(numInvokers)
+                val step = stepSizes(hash % stepSizes.size)
+
+                /*
+                 * Scans through all invokers and searches for an invoker, 
which's queue is below
+                 * the defined threshold. Iff no "underloaded" container was 
found it will default
+                 * to the least loaded invoker in the list.
+                 *
+                 * @param targetInvoker index of the invoker-candidate.
+                 * @return name of the target invoker
+                 */
+                @tailrec
+                def search(targetInvoker: Int): String = {
 
 Review comment:
   I'd rather get the whole `chooseInvoker` out then. There's more benefit in 
testing the whole decision rather than testing only this little part of it.
 
----------------------------------------------------------------
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