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_r127775074
##########
File path:
core/controller/src/main/scala/whisk/core/loadBalancer/LoadBalancerData.scala
##########
@@ -44,22 +44,32 @@ class LoadBalancerData {
activationByInvoker.getOrElseUpdate(invokerName, new
TrieSet[ActivationEntry])
}
+ def activationById(activationId: ActivationId) = {
+ activationsById.get(activationId)
+ }
+
def activationsByNamespaceId(namespaceId: UUID) = {
activationByNamespaceId.getOrElseUpdate(namespaceId, new
TrieSet[ActivationEntry])
}
- def putActivation(entry: ActivationEntry) = {
+ def putActivation(entry: ActivationEntry): Any= {
+ activationsById.put(entry.id, entry)
activationByNamespaceId.getOrElseUpdate(entry.namespaceId, new
TrieSet[ActivationEntry]).put(entry, {})
activationByInvoker.getOrElseUpdate(entry.invokerName, new
TrieSet[ActivationEntry]).put(entry, {})
}
- def removeActivation(entry: ActivationEntry) = {
+ def removeActivation(entry: ActivationEntry): ActivationEntry = {
+ activationsById.remove(entry.id)
activationByNamespaceId.getOrElseUpdate(entry.namespaceId, new
TrieSet[ActivationEntry]).remove(entry)
activationByInvoker.getOrElseUpdate(entry.invokerName, new
TrieSet[ActivationEntry]).remove(entry)
+ entry
}
- def removeActivation(aid: ActivationId): Option[ActivationEntry] =
activationById.remove(aid)
-
- def getActivationByIdOrUpdate(aid: ActivationId, func: () =>
ActivationEntry): ActivationEntry = activationById
- .getOrElseUpdate(aid, func())
+ def removeActivation(aid: ActivationId): Option[ActivationEntry]= {
+ activationsById.get(aid) match {
+ case Some(entry @ ActivationEntry(_, _, _, _, _)) =>
Review comment:
This case is not needed:
```scala
activationsById.get(aid).map(removeActivation)
```
Should be equivalent in this case.
----------------------------------------------------------------
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