@@ -61,6 +61,8 @@ abstract class CommonLoadBalancer(config: WhiskConfig,
61
61
protected [loadBalancer] val activationPromises =
62
62
TrieMap [ActivationId , Promise [Either [ActivationId , WhiskActivation ]]]()
63
63
protected val activationsPerNamespace = TrieMap [UUID , LongAdder ]()
64
+ protected val activationsPerController = TrieMap [ControllerInstanceId , LongAdder ]()
65
+ protected val activationsPerInvoker = TrieMap [InvokerInstanceId , LongAdder ]()
64
66
protected val totalActivations = new LongAdder ()
65
67
protected val totalBlackBoxActivationMemory = new LongAdder ()
66
68
protected val totalManagedActivationMemory = new LongAdder ()
@@ -83,6 +85,14 @@ abstract class CommonLoadBalancer(config: WhiskConfig,
83
85
override def activeActivationsFor (namespace : UUID ): Future [Int ] =
84
86
Future .successful(activationsPerNamespace.get(namespace).map(_.intValue).getOrElse(0 ))
85
87
override def totalActiveActivations : Future [Int ] = Future .successful(totalActivations.intValue)
88
+ override def activeActivationsByController (controller : String ): Future [Int ] =
89
+ Future .successful(activationsPerController.get(ControllerInstanceId (controller)).map(_.intValue()).getOrElse(0 ))
90
+ override def activeActivationsByController : Future [List [ActivationId ]] =
91
+ Future .successful(activationSlots.keySet.toList)
92
+ override def activeActivationsByInvoker (invoker : String ): Future [Int ] =
93
+ Future .successful(
94
+ activationsPerInvoker.get(InvokerInstanceId (invoker.toInt, userMemory = 0 .MB )).map(_.intValue()).getOrElse(0 ))
95
+ override def close : Unit = activationFeed ! GracefulShutdown
86
96
87
97
/**
88
98
* Calculate the duration within which a completion ack must be received for an activation.
@@ -125,6 +135,10 @@ abstract class CommonLoadBalancer(config: WhiskConfig,
125
135
totalActivationMemory.add(action.limits.memory.megabytes)
126
136
127
137
activationsPerNamespace.getOrElseUpdate(msg.user.namespace.uuid, new LongAdder ()).increment()
138
+ activationsPerController.getOrElseUpdate(controllerInstance, new LongAdder ()).increment()
139
+ activationsPerInvoker
140
+ .getOrElseUpdate(InvokerInstanceId (instance.instance, userMemory = 0 .MB ), new LongAdder ())
141
+ .increment()
128
142
129
143
// Completion Ack must be received within the calculated time.
130
144
val completionAckTimeout = calculateCompletionAckTimeout(action.limits.timeout.duration)
@@ -162,7 +176,8 @@ abstract class CommonLoadBalancer(config: WhiskConfig,
162
176
action.fullyQualifiedName(true ),
163
177
timeoutHandler,
164
178
isBlackboxInvocation,
165
- msg.blocking)
179
+ msg.blocking,
180
+ controllerInstance)
166
181
})
167
182
168
183
resultPromise
@@ -287,6 +302,10 @@ abstract class CommonLoadBalancer(config: WhiskConfig,
287
302
if (entry.isBlackbox) totalBlackBoxActivationMemory else totalManagedActivationMemory
288
303
totalActivationMemory.add(entry.memoryLimit.toMB * (- 1 ))
289
304
activationsPerNamespace.get(entry.namespaceId).foreach(_.decrement())
305
+ activationsPerController.get(entry.controllerId).foreach(_.decrement())
306
+ activationsPerInvoker
307
+ .get(InvokerInstanceId (entry.invokerName.instance, userMemory = 0 .MB ))
308
+ .foreach(_.decrement())
290
309
291
310
invoker.foreach(releaseInvoker(_, entry))
292
311
0 commit comments