ningyougang commented on a change in pull request #5098:
URL: https://github.com/apache/openwhisk/pull/5098#discussion_r604545731



##########
File path: 
core/invoker/src/main/scala/org/apache/openwhisk/core/invoker/FPCInvokerServer.scala
##########
@@ -0,0 +1,51 @@
+package org.apache.openwhisk.core.invoker
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.model.StatusCodes
+import akka.http.scaladsl.model.headers.BasicHttpCredentials
+import akka.http.scaladsl.server.Route
+import org.apache.openwhisk.common.{Logging, TransactionId}
+import org.apache.openwhisk.core.containerpool.v2.InvokerHealthManager
+import org.apache.openwhisk.http.BasicRasService
+import org.apache.openwhisk.http.ErrorResponse.terminate
+import spray.json.PrettyPrinter
+
+import scala.concurrent.ExecutionContext
+
+/**
+ * Implements web server to handle certain REST API calls.
+ */
+class FPCInvokerServer(val invoker: InvokerCore, systemUsername: String, 
systemPassword: String)(
+  implicit val ec: ExecutionContext,
+  val actorSystem: ActorSystem,
+  val logger: Logging)
+    extends BasicRasService {
+
+  /** Pretty print JSON response. */
+  implicit val jsonPrettyResponsePrinter = PrettyPrinter
+
+  override def routes(implicit transid: TransactionId): Route = {
+    super.routes ~ extractCredentials {
+      case Some(BasicHttpCredentials(username, password)) if username == 
systemUsername && password == systemPassword =>
+        (path("enable") & post) {
+          invoker.enable()
+        } ~ (path("disable") & post) {
+          invoker.disable()
+        } ~ (path("memory") & get) {

Review comment:
       Regarding `/memory`, this is for FPCInvokerServer only, this is used for 
`judge whether the invoker is idle`, if the result(busyMemory + 
inProgressMemory) > 0, it shows the invoker is executing activations, so it is 
busy, if the result == 0, it shows the invoker is idle.
   
   For DefaultInvokerServer, can't use /memory to judge whether the invoker is 
idle, this is another topic for this. btw, we judge it like this, get every 
controller slot of the invoker, and do `sum`. if the result > 0, the invoker is 
busy, otherwise, it is idle.




-- 
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]


Reply via email to