markusthoemmes commented on a change in pull request #2477: Move load balancer
data into a separate class
URL:
https://github.com/apache/incubator-openwhisk/pull/2477#discussion_r127673885
##########
File path:
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerService.scala
##########
@@ -163,32 +157,38 @@ class LoadBalancerService(
processCompletion(Left(activationId), transid, forced = true)
}
- ActivationEntry(activationId, namespaceId, invokerName,
Instant.now(Clock.systemUTC()), Promise[Either[ActivationId,
WhiskActivation]]())
- })
+ ActivationEntry(activationId, namespaceId, invokerName,
Instant.now(Clock.systemUTC()),
+ Promise[Either[ActivationId, WhiskActivation]]())
+
+ }
+
+ /**
+ * Creates an activation entry and insert into various maps.
+ */
+ private def setupActivation(action: ExecutableWhiskAction, activationId:
ActivationId, namespaceId: UUID, invokerName: String, transid: TransactionId):
ActivationEntry = {
+ // either create a new promise or reuse a previous one for this
activation if it exists
+ val entry = loadBalancerData.getActivationByIdOrUpdate(activationId,
() => setTimeout(action, activationId,
+ namespaceId, invokerName, transid))
// add the entry to our maps, for bookkeeping
- activationByInvoker.getOrElseUpdate(invokerName, new
TrieSet[ActivationEntry]).put(entry, {})
- activationByNamespaceId.getOrElseUpdate(namespaceId, new
TrieSet[ActivationEntry]).put(entry, {})
+ loadBalancerData.putActivation(entry)
entry
}
/**
- * When invoker health detects a new invoker has come up, this callback is
called.
- */
+ * When invoker health detects a new invoker has come up, this callback
is called.
+ */
private def clearInvokerState(invokerName: String) = {
- val actSet = activationByInvoker.getOrElseUpdate(invokerName, new
TrieSet[ActivationEntry])
+ val actSet = loadBalancerData.activationsByInvoker(invokerName)
actSet.keySet map {
case actEntry @ ActivationEntry(activationId, namespaceId,
invokerIndex, _, promise) =>
promise.tryFailure(new LoadBalancerException(s"Invoker
$invokerIndex restarted"))
- activationById.remove(activationId)
- activationByNamespaceId.get(namespaceId) map {
_.remove(actEntry) }
+ loadBalancerData.removeActivationById(activationId)
+ loadBalancerData.removeActivation(actEntry)
Review comment:
Why duplicate? `removeActivation` can just update the third map as well, no?
----------------------------------------------------------------
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