rabbah closed pull request #3104: Add TID stride configuration
URL: https://github.com/apache/incubator-openwhisk/pull/3104
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 2ffa75e1a7..c6957fcb60 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 ca1aa2a41d..5f9687ef7b 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 8af1d3d3d2..3ba04c845d 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 95e6eefc09..7f422ac8f6 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 f0db605e94..c9fc5031bd 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 08b8f1d544..ba5845276c 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 f8cb163f18..2b45fca469 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 1370964ef8..081a3ac367 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 62c705b63d..85b69fb7c2 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)]()
----------------------------------------------------------------
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