ningyougang commented on a change in pull request #5098:
URL: https://github.com/apache/openwhisk/pull/5098#discussion_r604543216
##########
File path:
core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/InvokerReactive.scala
##########
@@ -293,10 +295,52 @@ class InvokerReactive(
}
private val healthProducer = msgProvider.getProducer(config)
- Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+ var scheduler: Option[ActorRef] =
Some(Scheduler.scheduleWaitAtMost(1.seconds)(() => {
healthProducer.send("health", PingMessage(instance)).andThen {
case Failure(t) => logging.error(this, s"failed to ping the controller:
$t")
}
- })
+ }))
+
+ override def enable(): Route = {
+ scheduler match {
+ case Some(_) => complete("Can't enable invoker again");
+ case None =>
+ scheduler = Some(Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+ healthProducer
+ .send("health", PingMessage(instance))
+ .andThen {
+ case Failure(t) => logging.error(this, s"enable invoker, failed
to ping the controller: $t")
+ }
+ }))
+ complete("Success enable invoker");
+ }
+ }
+
+ override def disable(): Route = {
+ scheduler match {
+ case Some(schedulerActor) =>
+ // Through negative number of invoker to pass unhealthy message
+ healthProducer
+ .send(
+ "health",
+ PingMessage(
+ InvokerInstanceId(
+ -1 - instance.instance,
Review comment:
Use the same topic name `health` to send unhealthy message via negative
number of invoker.
In controller side(e.g. InvokerSupervision), get the message from kafka and
make the invoker to `unhealthy` and `down` finally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]