You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ty...@apache.org on 2017/11/08 22:53:26 UTC
[incubator-openwhisk] branch master updated: invoker cmd line
support for dyanamicId assignment (#2939)
This is an automated email from the ASF dual-hosted git repository.
tysonnorris pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 902c669 invoker cmd line support for dyanamicId assignment (#2939)
902c669 is described below
commit 902c669f61028457db9a0b3312ece65e123ff75f
Author: David Grove <dg...@users.noreply.github.com>
AuthorDate: Wed Nov 8 17:53:24 2017 -0500
invoker cmd line support for dyanamicId assignment (#2939)
* invoker cmd line support for dyanamicId assignment
Add optional command line argument for invoker name
and invoker proposed id to support Mesos deployment
(see issue 2872).
* replace scopt usage by list pattern matching as requested by Markus
---
.../main/scala/whisk/core/invoker/Invoker.scala | 25 +++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala b/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
index 788fbe8..8c57206 100644
--- a/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
+++ b/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
@@ -21,6 +21,7 @@ import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.util.Failure
+import scala.util.Try
import kamon.Kamon
@@ -47,6 +48,8 @@ import whisk.spi.SpiLoader
import whisk.utils.ExecutionContextFactory
import whisk.common.TransactionId
+case class CmdLineArgs(name: Option[String] = None, id: Option[Int] = None)
+
object Invoker {
/**
@@ -104,8 +107,24 @@ object Invoker {
abort("Bad configuration, cannot start.")
}
- val proposedInvokerId: Option[Int] = args.headOption.map(_.toInt)
- val assignedInvokerId = proposedInvokerId
+ // process command line arguments
+ // We accept the command line grammar of:
+ // Usage: invoker [options] [<proposedInvokerId>]
+ // --name <value> a unique name to use for this invoker
+ // --id <value> proposed invokerId
+ def parse(ls: List[String], c: CmdLineArgs): CmdLineArgs = {
+ ls match {
+ case "--name" :: name :: tail => parse(tail, c.copy(name = Some(name)))
+ case "--id" :: id :: tail if Try(id.toInt).isSuccess => parse(tail, c.copy(id = Some(id.toInt)))
+ case id :: Nil if Try(id.toInt).isSuccess => c.copy(id = Some(id.toInt))
+ case Nil => c
+ case _ => abort(s"Error processing command line arguments $ls")
+ }
+ }
+ val cmdLineArgs = parse(args.toList, CmdLineArgs())
+ logger.info(this, "Command line arguments parsed to yield " + cmdLineArgs)
+
+ val assignedInvokerId = cmdLineArgs.id
.map { id =>
logger.info(this, s"invokerReg: using proposedInvokerId ${id}")
id
@@ -114,7 +133,7 @@ object Invoker {
if (config.zookeeperHost.startsWith(":") || config.zookeeperHost.endsWith(":")) {
abort(s"Must provide valid zookeeper host and port to use dynamicId assignment (${config.zookeeperHost})")
}
- val invokerName = config.invokerName
+ val invokerName = cmdLineArgs.name.getOrElse(config.invokerName)
if (invokerName.trim.isEmpty) {
abort("Invoker name can't be empty to use dynamicId assignment.")
}
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].