Skip to content

Commit

Permalink
Skip scheduling for empty cold creation. (apache#5316)
Browse files Browse the repository at this point in the history
  • Loading branch information
style95 authored and michele-sciabarra committed Nov 23, 2022
1 parent d531769 commit 6da24a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,22 @@ class ContainerManager(jobManagerFactory: ActorRefFactory => ActorRef,
}

// handle cold creations
ContainerManager
.schedule(updatedInvokers, coldCreations.map(_._1), memory)
.map { pair =>
pair.invokerId match {
// an invoker is assigned for the msg
case Some(instanceId) =>
creationJobManager ! RegisterCreationJob(pair.msg)
sendCreationContainerToInvoker(messagingProducer, instanceId.instance, pair.msg)

// if a chosen invoker does not exist, it means it failed to find a matching invoker for the msg.
case _ =>
pair.err.foreach(error => sendState(pair.msg, error, error))
if (coldCreations.nonEmpty) {
ContainerManager
.schedule(updatedInvokers, coldCreations.map(_._1), memory)
.map { pair =>
pair.invokerId match {
// an invoker is assigned for the msg
case Some(instanceId) =>
creationJobManager ! RegisterCreationJob(pair.msg)
sendCreationContainerToInvoker(messagingProducer, instanceId.instance, pair.msg)

// if a chosen invoker does not exist, it means it failed to find a matching invoker for the msg.
case _ =>
pair.err.foreach(error => sendState(pair.msg, error, error))
}
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ContainerManagerTests

def mockMessaging(receiver: Option[ActorRef] = None): MessagingProvider = {
val messaging = stub[MessagingProvider]
val producer = receiver.map(fakeProducer(_)).getOrElse(stub[MessageProducer])
val producer = receiver.map(fakeProducer).getOrElse(stub[MessageProducer])
val consumer = stub[MessageConsumer]
(messaging
.getProducer(_: WhiskConfig, _: Option[ByteSize])(_: Logging, _: ActorSystem))
Expand Down

0 comments on commit 6da24a2

Please sign in to comment.