dgrove-oss commented on a change in pull request #2689: first stage of support
for dynamic invoker id assignment
URL:
https://github.com/apache/incubator-openwhisk/pull/2689#discussion_r141369090
##########
File path: core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
##########
@@ -85,6 +86,41 @@ object Invoker {
abort()
}
+ val proposedInvokerId: Option[Int] = args.headOption.map(_.toInt)
+ val assignedInvokerId = proposedInvokerId
+ .map { id =>
+ logger.info(this, s"invokerReg: using proposedInvokerId ${id}")
+ id
+ }
+ .getOrElse {
+ val invokerName = config.invokerName
+ val redisClient = new RedisClient(config.redisHostName,
config.redisHostPort.toInt)
+ val assignedId = redisClient
+ .hget("controller:registar:idAssignments", invokerName)
+ .map { oldId =>
+ logger.info(this, s"invokerReg: invoker ${invokerName} was
assigned its previous invokerId ${oldId}")
+ oldId.toInt
+ }
+ .getOrElse {
+ // If key not present, incr initializes to 0 before applying
increment.
+ // Convert from 1-based to 0-based invokerIds by subtracting 1
from incr's result
+ val newId = redisClient
+ .incr("controller:registrar:nextInvokerId")
+ .map { id =>
+ id.toInt - 1
+ }
+ .getOrElse {
+ logger.error(this, "Failed to increment invokerId")
+ abort()
+ }
+ redisClient.hset("controller:registar:idAssignments", invokerName,
newId)
+ logger.info(this, s"invokerReg: invoker ${invokerName} was
assigned invokerId ${newId}")
+ newId
+ }
+ redisClient.disconnect
Review comment:
I realized it would be better to call quit instead of disconnect, so I
changed that.
In either case, the compiler doesn't like it if I put (). I think it is a
property, not a method?
/Users/dgrove/code/openwhisk/openwhisk/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala:120:
Boolean does not take parameters
redisClient.quit()
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services