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 fec91db Enable configuring Connection Mode (#4273)
fec91db is described below
commit fec91db86f90bae395e267e3522ca7e3020cc9e3
Author: Chetan Mehrotra <[email protected]>
AuthorDate: Mon Feb 25 22:05:29 2019 +0530
Enable configuring Connection Mode (#4273)
Fixes #4269
---
common/scala/src/main/resources/application.conf | 4 ++++
.../org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfig.scala | 5 ++++-
.../openwhisk/core/database/cosmosdb/CosmosDBConfigTests.scala | 4 +++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/common/scala/src/main/resources/application.conf
b/common/scala/src/main/resources/application.conf
index 747b27f..1cf474f 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -203,6 +203,10 @@ whisk {
# available writable locations of geo-replicated database account
using-multiple-write-locations = false
+ # Select from one of the supported connection mode
+ #
https://github.com/Azure/azure-cosmosdb-java/blob/master/commons/src/main/java/com/microsoft/azure/cosmosdb/ConnectionMode.java
+ connection-mode = "Gateway"
+
# Sets the preferred locations for geo-replicated database
accounts e.g. "East US"
# See names at
https://azure.microsoft.com/en-in/global-infrastructure/locations/
preferred-locations = []
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfig.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfig.scala
index 38332b3..564b0f1 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfig.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfig.scala
@@ -18,6 +18,7 @@
package org.apache.openwhisk.core.database.cosmosdb
import com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient
import com.microsoft.azure.cosmosdb.{
+ ConnectionMode,
ConsistencyLevel,
ConnectionPolicy => JConnectionPolicy,
RetryOptions => JRetryOptions
@@ -51,13 +52,15 @@ case class CosmosDBConfig(endpoint: String,
case class ConnectionPolicy(maxPoolSize: Int,
preferredLocations: Seq[String],
usingMultipleWriteLocations: Boolean,
- retryOptions: RetryOptions) {
+ retryOptions: RetryOptions,
+ connectionMode: ConnectionMode) {
def asJava: JConnectionPolicy = {
val p = new JConnectionPolicy
p.setMaxPoolSize(maxPoolSize)
p.setUsingMultipleWriteLocations(usingMultipleWriteLocations)
p.setPreferredLocations(preferredLocations.asJava)
p.setRetryOptions(retryOptions.asJava)
+ p.setConnectionMode(connectionMode)
p
}
}
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfigTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfigTests.scala
index 09a96f8..94c36bd 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfigTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/cosmosdb/CosmosDBConfigTests.scala
@@ -20,7 +20,7 @@ import com.typesafe.config.ConfigFactory
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, Matchers}
-import com.microsoft.azure.cosmosdb.{ConnectionPolicy => JConnectionPolicy}
+import com.microsoft.azure.cosmosdb.{ConnectionMode, ConnectionPolicy =>
JConnectionPolicy}
import scala.collection.JavaConverters._
@@ -108,6 +108,7 @@ class CosmosDBConfigTests extends FlatSpec with Matchers {
| connection-policy {
| using-multiple-write-locations = true
| preferred-locations = [a, b]
+ | connection-mode = Direct
| }
| }
| }
@@ -119,6 +120,7 @@ class CosmosDBConfigTests extends FlatSpec with Matchers {
val policy = cosmos.connectionPolicy.asJava
policy.isUsingMultipleWriteLocations shouldBe true
policy.getMaxPoolSize shouldBe 42
+ policy.getConnectionMode shouldBe ConnectionMode.Direct
policy.getPreferredLocations.asScala.toSeq should contain only ("a", "b")
policy.getRetryOptions.getMaxRetryWaitTimeInSeconds shouldBe 120
}