You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2017/09/12 14:42:49 UTC
[incubator-openwhisk] branch master updated: do not use
InstanceId.int within TransactionCounter (#2680)
This is an automated email from the ASF dual-hosted git repository.
rabbah 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 17e4dbc do not use InstanceId.int within TransactionCounter (#2680)
17e4dbc is described below
commit 17e4dbc10c014661c177c20fda5514c9fd964aa3
Author: David Grove <dg...@users.noreply.github.com>
AuthorDate: Tue Sep 12 10:42:46 2017 -0400
do not use InstanceId.int within TransactionCounter (#2680)
Abstract away the assumption that InstanceId must be an integer in the range 0..numInstances-1 in TransactionCounter.
---
common/scala/src/main/scala/whisk/common/TransactionId.scala | 5 ++---
.../src/main/scala/whisk/core/controller/Controller.scala | 3 ++-
core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala | 4 +---
.../invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala | 8 +++++---
.../scala/whisk/core/controller/test/ControllerTestCommon.scala | 5 +++--
tests/src/test/scala/whisk/core/database/test/DbUtils.scala | 3 ++-
6 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/common/scala/src/main/scala/whisk/common/TransactionId.scala b/common/scala/src/main/scala/whisk/common/TransactionId.scala
index 08fa6d9..0023b8b 100644
--- a/common/scala/src/main/scala/whisk/common/TransactionId.scala
+++ b/common/scala/src/main/scala/whisk/common/TransactionId.scala
@@ -31,7 +31,6 @@ import spray.json.JsArray
import spray.json.JsNumber
import spray.json.JsValue
import spray.json.RootJsonFormat
-import whisk.core.entity.InstanceId
/**
* A transaction id for tracking operations in the system that are specific to a request.
@@ -196,9 +195,9 @@ object TransactionId {
*/
trait TransactionCounter {
val numberOfInstances: Int
- val instance: InstanceId
+ val instanceOrdinal: Int
- private lazy val cnt = new AtomicInteger(numberOfInstances + instance.toInt)
+ private lazy val cnt = new AtomicInteger(numberOfInstances + instanceOrdinal)
def transid(): TransactionId = {
TransactionId(cnt.addAndGet(numberOfInstances))
diff --git a/core/controller/src/main/scala/whisk/core/controller/Controller.scala b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
index 85f5662..377ae22 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Controller.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
@@ -68,7 +68,7 @@ import whisk.http.BasicRasService
* @param verbosity logging verbosity
* @param executionContext Scala runtime support for concurrent operations
*/
-class Controller(override val instance: InstanceId,
+class Controller(val instance: InstanceId,
runtimes: Runtimes,
implicit val whiskConfig: WhiskConfig,
implicit val actorSystem: ActorSystem,
@@ -77,6 +77,7 @@ class Controller(override val instance: InstanceId,
extends BasicRasService {
override val numberOfInstances = whiskConfig.controllerInstances.toInt
+ override val instanceOrdinal = instance.toInt
TransactionId.controller.mark(
this,
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 e6612df..f9646c1 100644
--- a/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
+++ b/core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
@@ -96,8 +96,6 @@ object Invoker {
})
val port = config.servicePort.toInt
- BasicHttpService.startService(new InvokerServer(invokerInstance, invokerInstance.toInt).route, port)(
- actorSystem,
- ActorMaterializer.create(actorSystem))
+ BasicHttpService.startService(new InvokerServer().route, port)(actorSystem, ActorMaterializer.create(actorSystem))
}
}
diff --git a/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala b/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala
index a587e4a..f8cb163 100644
--- a/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala
+++ b/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala
@@ -17,12 +17,14 @@
package whisk.core.invoker
-import whisk.core.entity.InstanceId
-
import whisk.http.BasicRasService
/**
* Implements web server to handle certain REST API calls.
* Currently provides a health ping route, only.
*/
-class InvokerServer(override val instance: InstanceId, override val numberOfInstances: Int) extends BasicRasService {}
+class InvokerServer() extends BasicRasService {
+
+ override val numberOfInstances = 1
+ override val instanceOrdinal = 1
+}
diff --git a/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala b/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala
index 8c2f6d3..988033d 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala
@@ -61,9 +61,10 @@ protected trait ControllerTestCommon
with WhiskServices
with StreamLogging {
- override val instance = InstanceId(0)
+ override val instanceOrdinal = 0
+ override val instance = InstanceId(instanceOrdinal)
override val numberOfInstances = 1
- val activeAckTopicIndex = InstanceId(0)
+ val activeAckTopicIndex = InstanceId(instanceOrdinal)
implicit val routeTestTimeout = RouteTestTimeout(90 seconds)
diff --git a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
index 2e36de6..efe94f8 100644
--- a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
@@ -59,7 +59,8 @@ import whisk.core.entity.types.EntityStore
trait DbUtils extends TransactionCounter {
implicit val dbOpTimeout = 15 seconds
override val numberOfInstances = 1
- override val instance = InstanceId(0)
+ override val instanceOrdinal = 0
+ val instance = InstanceId(instanceOrdinal)
val docsToDelete = ListBuffer[(ArtifactStore[_], DocInfo)]()
case class RetryOp() extends Throwable
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].