openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rab...@apache.org
Subject [incubator-openwhisk] branch master updated: Add TID stride configuration (#3104)
Date Fri, 12 Jan 2018 14:16:11 GMT
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 d2a40ce  Add TID stride configuration (#3104)
d2a40ce is described below

commit d2a40ce59034247431dc743d5dd39d97905792ca
Author: James Dubee <jwdubee@us.ibm.com>
AuthorDate: Fri Jan 12 09:16:08 2018 -0500

    Add TID stride configuration (#3104)
    
    Decouple the stride used to count transaction from container instance. The counter generates
a sequence: instance-ordinal + n * stride.
---
 ansible/group_vars/all                                     |  3 +++
 ansible/roles/controller/tasks/deploy.yml                  |  2 ++
 common/scala/src/main/resources/application.conf           |  5 +++++
 .../scala/src/main/scala/whisk/common/TransactionId.scala  | 14 +++++++++++---
 common/scala/src/main/scala/whisk/core/WhiskConfig.scala   |  3 +++
 .../src/main/scala/whisk/core/controller/Controller.scala  |  1 -
 .../src/main/scala/whisk/core/invoker/InvokerServer.scala  |  2 --
 .../whisk/core/controller/test/ControllerTestCommon.scala  |  1 -
 .../src/test/scala/whisk/core/database/test/DbUtils.scala  |  1 -
 9 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 2ffa75e..c6957fc 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -63,6 +63,9 @@ controller:
   ha: "{{ controller_enable_ha | default(True) and groups['controllers'] | length > 1
}}"
   loglevel: "{{ controller_loglevel | default(whisk_loglevel) | default('INFO') }}"
 
+transactions:
+  stride: "{{ groups['controllers'] | length }}"
+
 registry:
   confdir: "{{ config_root_dir }}/registry"
 
diff --git a/ansible/roles/controller/tasks/deploy.yml b/ansible/roles/controller/tasks/deploy.yml
index ca1aa2a..5f9687e 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -104,6 +104,8 @@
       "CONFIG_whisk_spi_LogStoreProvider": "{{ userLogs.spi }}"
       
       "CONFIG_logback_log_level": "{{ controller.loglevel }}"
+
+      "CONFIG_whisk_transactions_stride": "{{ transactions.stride | default() }}"
     volumes:
       - "{{ whisk_logs_dir }}/controller{{ groups['controllers'].index(inventory_hostname)
}}:/logs"
     ports:
diff --git a/common/scala/src/main/resources/application.conf b/common/scala/src/main/resources/application.conf
index 8af1d3d..3ba04c8 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -82,4 +82,9 @@ whisk {
         activations-ddoc = "whisks.v2"
         activations-filter-ddoc = "whisks-filters.v2"
     }
+    # transaction ID related configuration
+    transactions {
+        stride = 1
+        stride = ${?CONTROLLER_INSTANCES}
+    }
 }
diff --git a/common/scala/src/main/scala/whisk/common/TransactionId.scala b/common/scala/src/main/scala/whisk/common/TransactionId.scala
index 95e6eef..7f422ac 100644
--- a/common/scala/src/main/scala/whisk/common/TransactionId.scala
+++ b/common/scala/src/main/scala/whisk/common/TransactionId.scala
@@ -32,6 +32,10 @@ import spray.json.JsNumber
 import spray.json.JsValue
 import spray.json.RootJsonFormat
 
+import whisk.core.ConfigKeys
+
+import pureconfig._
+
 /**
  * A transaction id for tracking operations in the system that are specific to a request.
  * An instance of TransactionId is implicitly received by all logging methods. The actual
@@ -241,12 +245,16 @@ object TransactionId {
  * A thread-safe transaction counter.
  */
 trait TransactionCounter {
-  val numberOfInstances: Int
+  case class TransactionCounterConfig(stride: Int)
+
+  val transCounterConfig = loadConfigOrThrow[TransactionCounterConfig](ConfigKeys.transactions)
+  val stride = transCounterConfig.stride
   val instanceOrdinal: Int
 
-  private lazy val cnt = new AtomicInteger(numberOfInstances + instanceOrdinal)
+  // seed the counter so transids do not overlap: instanceOrdinal + n * stride, start at
n = 1
+  private lazy val cnt = new AtomicInteger(instanceOrdinal + stride)
 
   def transid(): TransactionId = {
-    TransactionId(cnt.addAndGet(numberOfInstances))
+    TransactionId(cnt.addAndGet(stride))
   }
 }
diff --git a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
index f0db605..c9fc503 100644
--- a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
+++ b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
@@ -249,4 +249,7 @@ object ConfigKeys {
   val dockerTimeouts = s"$docker.timeouts"
   val runc = "whisk.runc"
   val runcTimeouts = s"$runc.timeouts"
+
+  val transactions = "whisk.transactions"
+  val stride = s"$transactions.stride"
 }
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 08b8f1d..ba58452 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Controller.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Controller.scala
@@ -83,7 +83,6 @@ class Controller(val instance: InstanceId,
                  implicit val logging: Logging)
     extends BasicRasService {
 
-  override val numberOfInstances = whiskConfig.controllerInstances.toInt
   override val instanceOrdinal = instance.toInt
 
   TransactionId.controller.mark(
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 f8cb163..2b45fca 100644
--- a/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala
+++ b/core/invoker/src/main/scala/whisk/core/invoker/InvokerServer.scala
@@ -24,7 +24,5 @@ import whisk.http.BasicRasService
  * Currently provides a health ping route, only.
  */
 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 28f4bb9..f0c9fe5 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ControllerTestCommon.scala
@@ -60,7 +60,6 @@ protected trait ControllerTestCommon
 
   override val instanceOrdinal = 0
   override val instance = InstanceId(instanceOrdinal)
-  override val numberOfInstances = 1
   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 62c705b..85b69fb 100644
--- a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
@@ -46,7 +46,6 @@ import whisk.core.entity.types.EntityStore
  */
 trait DbUtils extends TransactionCounter {
   implicit val dbOpTimeout = 15 seconds
-  override val numberOfInstances = 1
   override val instanceOrdinal = 0
   val instance = InstanceId(instanceOrdinal)
   val docsToDelete = ListBuffer[(ArtifactStore[_], DocInfo)]()

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Mime
View raw message