diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 3352c4744a3b..f3a1a4beab5d 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -10,6 +10,7 @@
# Service teams
/sdk/appconfiguration/ @alzimmermsft @conniey @sima-zhu
+/sdk/batch/ @xingwu1 @bgklein @matthchr
/sdk/core/ @alzimmermsft @jianghaolu @srnagar @hemanttanwar
/sdk/cosmos/ @moderakh @christopheranderson @kushagraThapar
/sdk/eventhubs/ @conniey @srnagar @mssfang
@@ -18,7 +19,7 @@
/sdk/servicebus/ @yvgopal @nemakam
/sdk/tracing/ @samvaity @alzimmermsft
-/sdk/storage/ @rickle-msft @jaschrep-msft @alzimmermsft @sima-zhu
+/sdk/storage/ @rickle-msft @jaschrep-msft @gapra-msft @alzimmermsft @sima-zhu
# Management Plane
/**/resource-manager/ @yaohaizh
@@ -28,5 +29,8 @@
###########
/eng/ @weshaggard @mitchdenny @danieljurek
/eng/code-quality-reports/ @mssfang @JonathanGiles
+/eng/jacoco-test-coverage/ @srnagar @JonathanGiles
+/eng/spotbugs-aggregate-report/ @srnagar @JonathanGiles
+
/**/tests.yml @danieljurek
/**/ci.yml @mitchdenny
diff --git a/README.md b/README.md
index 3a89fec4d97e..a93b2e3fb049 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Each service might have a number of libraries available from each of the followi
* [Management](#Management)
### Client: July 2019 Preview
-New wave of packages that we are currently releasing in **preview**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azuresdkspecs.z5.web.core.windows.net/JavaSpec.html) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](core).
+New wave of packages that we are currently releasing in **preview**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java/guidelines/) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](core).
These preview libraries can be easily identified by their folder, package, and namespaces names starting with `azure-`, e.g. `azure-keyvault`.
diff --git a/cosmosdb/data-plane/.github/ISSUE_TEMPLATE/Bug_report.md b/cosmosdb/data-plane/.github/ISSUE_TEMPLATE/Bug_report.md
deleted file mode 100644
index 7531bf124a13..000000000000
--- a/cosmosdb/data-plane/.github/ISSUE_TEMPLATE/Bug_report.md
+++ /dev/null
@@ -1,25 +0,0 @@
----
-name: "Bug report"
-about: Create a report to help us improve
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior.
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Actual behavior**
-Provide a description of the actual behavior observed.
-
-**Environment summary**
-SDK Version:
-Java JDK version:
-OS Version (e.g. Windows, Linux, MacOSX)
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/cosmosdb/data-plane/.gitignore b/cosmosdb/data-plane/.gitignore
deleted file mode 100644
index bdb262af0bac..000000000000
--- a/cosmosdb/data-plane/.gitignore
+++ /dev/null
@@ -1,21 +0,0 @@
-*.class
-target
-
-# Package Files #
-*.jar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-# MacOS files #
-.DS_Store
-
-# IDE files #
-.project
-.settings
-.classpath
-.idea
-*.iml
-
-doc
-docs
diff --git a/cosmosdb/data-plane/.travis.yml b/cosmosdb/data-plane/.travis.yml
deleted file mode 100644
index 02ba5c532eaf..000000000000
--- a/cosmosdb/data-plane/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-language: java
-sudo: false # faster builds
-
-matrix:
- include:
- - os: linux
- jdk: oraclejdk8
-# - os: osx
-# osx_image: xcode8
-script:
-- mvn dependency:resolve
-- mvn test -P fast -DargLine="-DACCOUNT_HOST=$ACCOUNT_HOST -DACCOUNT_KEY=$ACCOUNT_KEY" cobertura:cobertura
-after_success:
- - bash <(curl -s https://codecov.io/bash)
-
-cache:
- directories:
- - $HOME/.m2
diff --git a/cosmosdb/data-plane/CODEOWNERS b/cosmosdb/data-plane/CODEOWNERS
deleted file mode 100644
index 26da20e9f2cf..000000000000
--- a/cosmosdb/data-plane/CODEOWNERS
+++ /dev/null
@@ -1,10 +0,0 @@
-# CODEOWNERS is a GitHub standard to specify who is automatically assigned pull requests to review.
-# This helps to prevent pull requests from languishing without review.
-# GitHub can also be configured to require review from code owners before a pull request can be merged.
-
-# Further reading is available from the following two URLs:
-# https://blog.github.com/2017-07-06-introducing-code-owners/
-# https://help.github.com/articles/about-codeowners/
-
-# Default owner for repo
-* @moderakh @christopheranderson @kushagraThapar
diff --git a/cosmosdb/data-plane/LICENSE b/cosmosdb/data-plane/LICENSE
deleted file mode 100644
index 21071075c245..000000000000
--- a/cosmosdb/data-plane/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
- MIT License
-
- Copyright (c) Microsoft Corporation. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE
diff --git a/cosmosdb/data-plane/README.md b/cosmosdb/data-plane/README.md
deleted file mode 100644
index 19399df1e3db..000000000000
--- a/cosmosdb/data-plane/README.md
+++ /dev/null
@@ -1,301 +0,0 @@
-## Java SDK for SQL API of Azure Cosmos DB
-[](https://search.maven.org/artifact/com.microsoft.azure/azure-cosmosdb/2.4.3/jar)
-[](https://travis-ci.org/Azure/azure-cosmosdb-java)
-[](https://snyk.io/test/github/Azure/azure-cosmosdb-java?targetFile=sdk%2Fpom.xml)
-
-
-
-
-- [Consuming the official Microsoft Azure Cosmos DB Java SDK](#consuming-the-official-microsoft-azure-cosmos-db-java-sdk)
-- [Prerequisites](#prerequisites)
-- [API Documentation](#api-documentation)
-- [Usage Code Sample](#usage-code-sample)
-- [Guide for Prod](#guide-for-prod)
-- [Future, CompletableFuture, and ListenableFuture](#future-completablefuture-and-listenablefuture)
-- [Checking out the Source Code](#checking-out-the-source-code)
-- [FAQ](#faq)
-- [Release changes](#release-changes)
-- [Contribution and Feedback](#contribution-and-feedback)
-- [License](#license)
-
-
-
-
-## Consuming the official Microsoft Azure Cosmos DB Java SDK
-
-This project provides a SDK library in Java for interacting with [SQL API](https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sql-query) of [Azure Cosmos DB
-Database Service](https://azure.microsoft.com/en-us/services/cosmos-db/). This project also includes samples, tools, and utilities.
-
-Jar dependency binary information for maven and gradle can be found here at [maven]( https://mvnrepository.com/artifact/com.microsoft.azure/azure-cosmosdb/2.4.3).
-
-For example, using maven, you can add the following dependency to your maven pom file:
-
-```xml
-
- com.microsoft.azure
- azure-cosmosdb
- 2.4.3
-
-```
-
-
-
-Useful links:
-- [Sample Get Started APP](https://github.com/Azure-Samples/azure-cosmos-db-sql-api-async-java-getting-started)
-- [Introduction to Resource Model of Azure Cosmos DB Service]( https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-resources)
-- [Introduction to SQL API of Azure Cosmos DB Service](https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-sql-query)
-- [SDK JavaDoc API](https://azure.github.io/azure-cosmosdb-java/2.4.0/com/microsoft/azure/cosmosdb/rx/AsyncDocumentClient.html)
-- [RxJava Observable JavaDoc API](http://reactivex.io/RxJava/1.x/javadoc/rx/Observable.html)
-- [SDK FAQ](faq/)
-
-## Prerequisites
-* Java Development Kit 8
-* An active Azure account. If you don't have one, you can sign up for a [free account](https://azure.microsoft.com/free/). Alternatively, you can use the [Azure Cosmos DB Emulator](https://azure.microsoft.com/documentation/articles/documentdb-nosql-local-emulator) for development and testing. As emulator https certificate is self signed, you need to import its certificate to java trusted cert store as [explained here](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator-export-ssl-certificates)
-* (Optional) SLF4J is a logging facade.
-* (Optional) [SLF4J binding](http://www.slf4j.org/manual.html) is used to associate a specific logging framework with SLF4J.
-* (Optional) Maven
-
-SLF4J is only needed if you plan to use logging, please also download an SLF4J binding which will link the SLF4J API with the logging implementation of your choice. See the [SLF4J user manual](http://www.slf4j.org/manual.html) for more information.
-
-
-## API Documentation
-Javadoc is available [here](https://azure.github.io/azure-cosmosdb-java/2.4.0/com/microsoft/azure/cosmosdb/rx/AsyncDocumentClient.html).
-
-The SDK provide Reactive Extension Observable based async API. You can read more about RxJava and [Observable APIs here](http://reactivex.io/RxJava/1.x/javadoc/rx/Observable.html).
-
-
-## Usage Code Sample
-
-Code Sample for creating a Document:
-```java
-import com.microsoft.azure.cosmosdb.rx.*;
-import com.microsoft.azure.cosmosdb.*;
-
-ConnectionPolicy policy = new ConnectionPolicy();
-policy.setConnectionMode(ConnectionMode.Direct);
-
-AsyncDocumentClient asyncClient = new AsyncDocumentClient.Builder()
- .withServiceEndpoint(HOST)
- .withMasterKeyOrResourceToken(MASTER_KEY)
- .withConnectionPolicy(policy)
- .withConsistencyLevel(ConsistencyLevel.Eventual)
- .build();
-
-Document doc = new Document(String.format("{ 'id': 'doc%d', 'counter': '%d'}", 1, 1));
-
-Observable> createDocumentObservable =
- asyncClient.createDocument(collectionLink, doc, null, false);
- createDocumentObservable
- .single() // we know there will be one response
- .subscribe(
-
- documentResourceResponse -> {
- System.out.println(documentResourceResponse.getRequestCharge());
- },
-
- error -> {
- System.err.println("an error happened: " + error.getMessage());
- });
-```
-
-We have a get started sample app available [here](https://github.com/Azure-Samples/azure-cosmos-db-sql-api-async-java-getting-started).
-
-Also We have more examples in form of standalone unit tests in [examples project](examples/src/test/java/com/microsoft/azure/cosmosdb/rx/examples).
-
-
-## Guide for Prod
-To achieve better performance and higher throughput there are a few tips that are helpful to follow:
-
-### Use Appropriate Scheduler (Avoid stealing Eventloop IO Netty threads)
-SDK uses [netty](https://netty.io/) for non-blocking IO. The SDK uses a fixed number of IO netty eventloop threads (as many CPU cores your machine has) for executing IO operations.
-
- The Observable returned by API emits the result on one of the shared IO eventloop netty threads. So it is important to not block the shared IO eventloop netty threads. Doing CPU intensive work or blocking operation on the IO eventloop netty thread may cause deadlock or significantly reduce SDK throughput.
-
-For example the following code executes a cpu intensive work on the eventloop IO netty thread:
-
-
-```java
-Observable> createDocObs = asyncDocumentClient.createDocument(
- collectionLink, document, null, true);
-
-createDocObs.subscribe(
- resourceResponse -> {
- //this is executed on eventloop IO netty thread.
- //the eventloop thread is shared and is meant to return back quickly.
- //
- // DON'T do this on eventloop IO netty thread.
- veryCpuIntensiveWork();
- });
-
-```
-
-After result is received if you want to do CPU intensive work on the result you should avoid doing so on eventloop IO netty thread. You can instead provide your own Scheduler to provide your own thread for running your work.
-
-```java
-import rx.schedulers;
-
-Observable> createDocObs = asyncDocumentClient.createDocument(
- collectionLink, document, null, true);
-
-createDocObs.subscribeOn(Schedulers.computation())
-subscribe(
- resourceResponse -> {
- // this is executed on threads provided by Scheduler.computation()
- // Schedulers.computation() should be used only the work is cpu intensive and you are not doing blocking IO, thread sleep, etc. in this thread against other resources.
- veryCpuIntensiveWork();
- });
-
-```
-
-Based on the type of your work you should use the appropriate existing RxJava Scheduler for your work. Please read here
-[``Schedulers``](http://reactivex.io/RxJava/1.x/javadoc/rx/schedulers/Schedulers.html).
-
-
-### Disable netty's logging
-Netty library logging is very chatty and need to be turned off (suppressing log in the configuration may not be enough) to avoid additional CPU costs.
-If you are not in debugging mode disable netty's logging altogether. So if you are using log4j to remove the additional CPU costs incurred by ``org.apache.log4j.Category.callAppenders()`` from netty add the following line to your codebase:
-
-```java
-org.apache.log4j.Logger.getLogger("io.netty").setLevel(org.apache.log4j.Level.OFF);
-```
-
-### OS Open files Resource Limit
-Some Linux systems (like Redhat) have an upper limit on the number of open files and so the total number of connections. Run the following to view the current limits:
-
-```bash
-ulimit -a
-```
-
-The number of open files (nofile) need to be large enough to have enough room for your configured connection pool size and other open files by the OS. It can be modified to allow for a larger connection pool size.
-
-Open the limits.conf file:
-
-```bash
-vim /etc/security/limits.conf
-```
-Add/modify the following lines:
-
-```
-* - nofile 100000
-```
-
-### Use native SSL implementation for netty
-Netty can use OpenSSL directly for SSL implementation stack to achieve better performance.
-In the absence of this configuration netty will fall back to Java's default SSL implementation.
-
-on Ubuntu:
-```bash
-sudo apt-get install openssl
-sudo apt-get install libapr1
-```
-
-and add the following dependency to your project maven dependencies:
-```xml
-
- io.netty
- netty-tcnative
- 2.0.20.Final
- linux-x86_64
-
-```
-
-For other platforms (Redhat, Windows, Mac, etc) please refer to these instructions https://netty.io/wiki/forked-tomcat-native.html
-
-### Common Perf Tips
-There is a set of common perf tips written for our sync SDK. The majority of them also apply to the async SDK. It is available [here](https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips-java).
-
-## Future, CompletableFuture, and ListenableFuture
-
-The SDK provide Reactive Extension (Rx) [Observable](http://reactivex.io/RxJava/1.x/javadoc/rx/Observable.html) based async API.
-
-
-RX API has advantages over Future based APIs. But if you wish to use ``Future`` you can translate Observables to Java native Futures:
-
-```java
-// You can convert an Observable to a ListenableFuture.
-// ListenableFuture (part of google guava library) is a popular extension
-// of Java's Future which allows registering listener callbacks:
-// https://github.com/google/guava/wiki/ListenableFutureExplained
-
-import rx.observable.ListenableFutureObservable;
-
-Observable> createDocObservable = asyncClient.createDocument(
- collectionLink, document, null, false);
-
-// NOTE: if you are going to do CPU intensive work
-// on the result thread consider changing the scheduler see Use Proper Scheduler
-// (Avoid Stealing Eventloop IO Netty threads) section
-ListenableFuture> listenableFuture =
- ListenableFutureObservable.to(createDocObservable);
-
-ResourceResponse rrd = listenableFuture.get();
-```
-
-For this to work you will need [RxJava Guava library dependency ](https://mvnrepository.com/artifact/io.reactivex/rxjava-guava/1.0.3). More information available here https://github.com/ReactiveX/RxJavaGuava.
-
-You can see more details on how to convert Observables to Futures here:
-https://dzone.com/articles/converting-between
-
-## Checking out the Source Code
-The SDK is open source and is available here [sdk](sdk/).
-
- Clone the Repo
-```bash
-git clone https://github.com/Azure/azure-cosmosdb-java.git
-cd azure-cosmosdb-java
-```
-
-### How to Build from Command Line
-
-* Run the following maven command to build:
-
-```bash
-maven clean package -DskipTests
-```
-
-#### Running Tests from Command Line
-
-Running tests require Azure Cosmos DB Endpoint credentials:
-
-```bash
-mvn test -DACCOUNT_HOST="https://REPLACE_ME_WITH_YOURS.documents.azure.com:443/" -DACCOUNT_KEY="REPLACE_ME_WITH_YOURS"
-```
-
-### Import into Intellij or Eclipse
-
-* Load the main parent project pom file in Intellij/Eclipse (That should automatically load examples).
-* For running the samples you need a proper Azure Cosmos DB Endpoint. The endpoints are picked up from [TestConfigurations.java](examples/src/test/java/com/microsoft/azure/cosmosdb/rx/examples/TestConfigurations.java). There is a similar endpoint config file for the sdk tests [here](sdk/src/test/java/com/microsoft/azure/cosmosdb/rx/TestConfigurations.java).
-* You can pass your endpoint credentials as VM Arguments in Eclipse JUnit Run Config:
-```bash
- -DACCOUNT_HOST="https://REPLACE_ME.documents.azure.com:443/" -DACCOUNT_KEY="REPLACE_ME"
- ```
-* or you can simply put your endpoint credentials in TestConfigurations.java
-* The SDK tests are written using TestNG framework, if you use Eclipse you may have to
- add TestNG plugin to your eclipse IDE as explained [here](http://testng.org/doc/eclipse.html).
- Intellij has builtin support for TestNG.
-* Now you can run the tests in your Intellij/Eclipse IDE.
-
-
-## FAQ
-We have a frequently asked questions which is maintained [here](faq/).
-
-## Release changes
-Release changelog is available [here](changelog/).
-
-
-## Contribution and Feedback
-
-This is an open source project and we welcome contributions.
-
-If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).
-
-We have [travis build CI](https://travis-ci.org/Azure/azure-cosmosdb-java) which should pass for any PR.
-
-If you encounter any bugs with the SDK please file an [issue](https://github.com/Azure/azure-cosmosdb-java/issues) in the Issues section of the project.
-
-
-## License
-MIT License
-Copyright (c) 2018 Copyright (c) Microsoft Corporation
diff --git a/cosmosdb/data-plane/benchmark/README.md b/cosmosdb/data-plane/benchmark/README.md
deleted file mode 100644
index 4f7aadcc7796..000000000000
--- a/cosmosdb/data-plane/benchmark/README.md
+++ /dev/null
@@ -1,81 +0,0 @@
-# Benchmark tool
-
-## Build the benchmarking tool
-
-```bash
-git clone https://github.com/Azure/azure-cosmosdb-java.git
-cd azure-cosmosdb-java
-
-mvn clean package -DskipTests
-```
-
-and then the package will be generated.
-
-## Run the WriteLatency workload
-
-```bash
-java -jar benchmark/target/azure-cosmosdb-benchmark-2.4.1-SNAPSHOT-jar-with-dependencies.jar \
- -serviceEndpoint $endpoint -masterKey $masterkey \
- -databaseId $dbname -collectionId $colname \
- -consistencyLevel Eventual -concurrency 10 -numberOfOperations 1000000 \
- -operation WriteLatency -connectionMode Direct
-```
-
-## Sample Report:
-
-```
-2/13/19 9:32:39 PM =============================================================
-
--- Meters ----------------------------------------------------------------------
-#Successful Operations
- count = 89934
- mean rate = 1798.56 events/second
- 1-minute rate = 1718.45 events/second
- 5-minute rate = 1630.17 events/second
- 15-minute rate = 1610.01 events/second
-#Unsuccessful Operations
- count = 0
- mean rate = 0.00 events/second
- 1-minute rate = 0.00 events/second
- 5-minute rate = 0.00 events/second
- 15-minute rate = 0.00 events/second
-
--- Timers ----------------------------------------------------------------------
-Latency
- count = 89938
- mean rate = 1798.64 calls/second
- 1-minute rate = 1718.65 calls/second
- 5-minute rate = 1630.37 calls/second
- 15-minute rate = 1610.21 calls/second
- min = 3.97 milliseconds
- max = 22.81 milliseconds
- mean = 5.37 milliseconds
- stddev = 0.96 milliseconds
- median = 5.26 milliseconds
- 75% <= 5.70 milliseconds
- 95% <= 6.40 milliseconds
- 98% <= 6.93 milliseconds
- 99% <= 7.51 milliseconds
- 99.9% <= 17.37 milliseconds
-```
-
-## Other Currently Supported Workloads
-
-* ReadLatency,
-* WriteLatency,
-* ReadThroughput,
-* WriteThroughput,
-* QueryCross,
-* QuerySingle,
-* QuerySingleMany,
-* QueryParallel,
-* QueryOrderby,
-* QueryAggregate,
-* QueryAggregateTopOrderby,
-* QueryTopOrderby,
-* Mixed
-* ReadMyWrites
-
-
-You can provide ``--help`` to the tool to see the list of other work loads (read, etc) and other options.
-
diff --git a/cosmosdb/data-plane/benchmark/pom.xml b/cosmosdb/data-plane/benchmark/pom.xml
deleted file mode 100644
index 1bf6722f0281..000000000000
--- a/cosmosdb/data-plane/benchmark/pom.xml
+++ /dev/null
@@ -1,196 +0,0 @@
-
-
-
- 4.0.0
-
- com.microsoft.azure
- azure-cosmosdb-parent
- 2.4.5
-
-
- azure-cosmosdb-benchmark
- Async SDK for SQL API of Azure Cosmos DB Service - Benchmarking tool
- Benchmarking tool for Async SDK for SQL API of Azure Cosmos DB Service
-
-
- UTF-8
- 1.7.6
- 1.2.17
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.2.1
-
- com.microsoft.azure.cosmosdb.benchmark.Main
-
-
-
- maven-assembly-plugin
- 2.2
-
-
- jar-with-dependencies
-
-
-
- com.microsoft.azure.cosmosdb.benchmark.Main
-
-
-
-
-
- make-assembly
- package
-
- single
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-eclipse-plugin
- 2.8
-
-
-
- org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8
-
-
-
-
-
-
-
-
- com.microsoft.azure
- azure-cosmosdb
-
-
- com.microsoft.azure
- azure-cosmosdb-commons-test-utils
-
-
- io.netty
- netty-tcnative
- 2.0.20.Final
- linux-x86_64
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
- io.reactivex
- rxjava-guava
- 1.0.3
-
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
-
- org.hamcrest
- hamcrest-all
- 1.3
- test
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.slf4j
- slf4j-log4j12
- ${slf4j.version}
-
-
- log4j
- log4j
- ${log4j.version}
-
-
- io.dropwizard.metrics
- metrics-core
- ${metrics.version}
-
-
- io.dropwizard.metrics
- metrics-jvm
- ${metrics.version}
-
-
- io.dropwizard.metrics
- metrics-graphite
- ${metrics.version}
-
-
- com.beust
- jcommander
- 1.58
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
- org.testng
- testng
- ${testng.version}
- test
-
-
- org.assertj
- assertj-core
- ${assertj.version}
- test
-
-
- org.mockito
- mockito-all
- ${mockito.version}
- test
-
-
-
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncBenchmark.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncBenchmark.java
deleted file mode 100644
index 477118e3d51c..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncBenchmark.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.Timer;
-import com.codahale.metrics.graphite.Graphite;
-import com.codahale.metrics.graphite.GraphiteReporter;
-import com.codahale.metrics.jvm.CachedThreadStatesGaugeSet;
-import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
-import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
-import com.microsoft.azure.cosmosdb.Database;
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.DocumentCollection;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.benchmark.Configuration.Operation;
-import com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import rx.Observable;
-import rx.Subscriber;
-
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-abstract class AsyncBenchmark {
- private final MetricRegistry metricsRegistry = new MetricRegistry();
- private final ScheduledReporter reporter;
- private final CountDownLatch operationCounterLatch;
- private final String nameCollectionLink;
-
- private Meter successMeter;
- private Meter failureMeter;
-
- final Logger logger;
- final AsyncDocumentClient client;
- final DocumentCollection collection;
- final String partitionKey;
- final Configuration configuration;
- final List docsToRead;
- final Semaphore concurrencyControlSemaphore;
- Timer latency;
-
- AsyncBenchmark(Configuration cfg) {
- client = new AsyncDocumentClient.Builder()
- .withServiceEndpoint(cfg.getServiceEndpoint())
- .withMasterKeyOrResourceToken(cfg.getMasterKey())
- .withConnectionPolicy(cfg.getConnectionPolicy())
- .withConsistencyLevel(cfg.getConsistencyLevel())
- .build();
-
- logger = LoggerFactory.getLogger(this.getClass());
-
- Database database = DocDBUtils.getDatabase(client, cfg.getDatabaseId());
- collection = DocDBUtils.getCollection(client, database.getSelfLink(), cfg.getCollectionId());
- nameCollectionLink = String.format("dbs/%s/colls/%s", database.getId(), collection.getId());
- partitionKey = collection.getPartitionKey().getPaths().iterator().next().split("/")[1];
- concurrencyControlSemaphore = new Semaphore(cfg.getConcurrency());
- operationCounterLatch = new CountDownLatch(cfg.getNumberOfOperations());
- configuration = cfg;
-
- ArrayList> createDocumentObservables = new ArrayList<>();
-
- if (configuration.getOperationType() != Operation.WriteLatency
- && configuration.getOperationType() != Operation.WriteThroughput
- && configuration.getOperationType() != Operation.ReadMyWrites) {
- String dataFieldValue = RandomStringUtils.randomAlphabetic(cfg.getDocumentDataFieldSize());
- for (int i = 0; i < cfg.getNumberOfPreCreatedDocuments(); i++) {
- String uuid = UUID.randomUUID().toString();
- Document newDoc = new Document();
- newDoc.setId(uuid);
- newDoc.set(partitionKey, uuid);
- newDoc.set("dataField1", dataFieldValue);
- newDoc.set("dataField2", dataFieldValue);
- newDoc.set("dataField3", dataFieldValue);
- newDoc.set("dataField4", dataFieldValue);
- newDoc.set("dataField5", dataFieldValue);
- Observable obs = client.createDocument(collection.getSelfLink(), newDoc, null, false)
- .map(ResourceResponse::getResource);
- createDocumentObservables.add(obs);
- }
- }
-
- docsToRead = Observable.merge(createDocumentObservables, 100).toList().toBlocking().single();
- init();
-
- if (configuration.isEnableJvmStats()) {
- metricsRegistry.register("gc", new GarbageCollectorMetricSet());
- metricsRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
- metricsRegistry.register("memory", new MemoryUsageGaugeSet());
- }
-
- if (configuration.getGraphiteEndpoint() != null) {
- final Graphite graphite = new Graphite(new InetSocketAddress(configuration.getGraphiteEndpoint(), configuration.getGraphiteEndpointPort()));
- reporter = GraphiteReporter.forRegistry(metricsRegistry)
- .prefixedWith(configuration.getOperationType().name())
- .convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(TimeUnit.MILLISECONDS)
- .filter(MetricFilter.ALL)
- .build(graphite);
- } else {
- reporter = ConsoleReporter.forRegistry(metricsRegistry).convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(TimeUnit.MILLISECONDS).build();
- }
- }
-
- protected void init() {
- }
-
- void shutdown() {
- client.close();
- }
-
- protected void onSuccess() {
- }
-
- protected void onError(Throwable throwable) {
- }
-
- protected String getCollectionLink() {
- if (configuration.isUseNameLink()) {
- return this.nameCollectionLink;
- } else {
- return collection.getSelfLink();
- }
- }
-
- protected String getDocumentLink(Document doc) {
- if (configuration.isUseNameLink()) {
- return this.nameCollectionLink + "/docs/" + doc.getId();
- } else {
- return doc.getSelfLink();
- }
- }
-
- protected abstract void performWorkload(Subscriber subs, long i) throws Exception;
-
- void run() throws Exception {
-
- successMeter = metricsRegistry.meter("#Successful Operations");
- failureMeter = metricsRegistry.meter("#Unsuccessful Operations");
- if (configuration.getOperationType() == Operation.ReadLatency
- || configuration.getOperationType() == Operation.WriteLatency)
- latency = metricsRegistry.timer("Latency");
-
- reporter.start(configuration.getPrintingInterval(), TimeUnit.SECONDS);
-
- long startTime = System.currentTimeMillis();
-
- for (long i = 1; i <= configuration.getNumberOfOperations(); i++) {
-
- Subscriber subs = new Subscriber() {
-
- @Override
- public void onStart() {
- }
-
- @Override
- public void onCompleted() {
- successMeter.mark();
- concurrencyControlSemaphore.release();
- operationCounterLatch.countDown();
- AsyncBenchmark.this.onSuccess();
- }
-
- @Override
- public void onError(Throwable e) {
- failureMeter.mark();
- logger.error("Encountered failure {} on thread {}" ,
- e.getMessage(), Thread.currentThread().getName(), e);
- concurrencyControlSemaphore.release();
- operationCounterLatch.countDown();
- AsyncBenchmark.this.onError(e);
- }
-
- @Override
- public void onNext(T value) {
- }
- };
-
- performWorkload(subs, i);
- }
-
- operationCounterLatch.await();
- long endTime = System.currentTimeMillis();
- logger.info("[{}] operations performed in [{}] seconds.",
- configuration.getNumberOfOperations(), (int) ((endTime - startTime) / 1000));
-
- reporter.report();
- reporter.close();
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncMixedBenchmark.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncMixedBenchmark.java
deleted file mode 100644
index 9af6ddd21e59..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncMixedBenchmark.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.FeedOptions;
-import com.microsoft.azure.cosmosdb.PartitionKey;
-import com.microsoft.azure.cosmosdb.RequestOptions;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import org.apache.commons.lang3.RandomStringUtils;
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import java.util.Random;
-import java.util.UUID;
-
-class AsyncMixedBenchmark extends AsyncBenchmark {
-
- private final String uuid;
- private final String dataFieldValue;
- private final Random r;
-
- AsyncMixedBenchmark(Configuration cfg) {
- super(cfg);
- uuid = UUID.randomUUID().toString();
- dataFieldValue = RandomStringUtils.randomAlphabetic(configuration.getDocumentDataFieldSize());
- r = new Random();
- }
-
- @Override
- protected void performWorkload(Subscriber subs, long i) throws InterruptedException {
- Observable obs;
- if (i % 10 == 0 && i % 100 != 0) {
-
- String idString = uuid + i;
- Document newDoc = new Document();
- newDoc.setId(idString);
- newDoc.set(partitionKey, idString);
- newDoc.set("dataField1", dataFieldValue);
- newDoc.set("dataField2", dataFieldValue);
- newDoc.set("dataField3", dataFieldValue);
- newDoc.set("dataField4", dataFieldValue);
- newDoc.set("dataField5", dataFieldValue);
- obs = client.createDocument(getCollectionLink(), newDoc, null, false).map(ResourceResponse::getResource);
-
- } else if (i % 100 == 0) {
-
- FeedOptions options = new FeedOptions();
- options.setMaxItemCount(10);
- options.setEnableCrossPartitionQuery(true);
-
- String sqlQuery = "Select top 100 * from c order by c._ts";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options)
- .map(frp -> frp.getResults().get(0));
- } else {
-
- int index = r.nextInt(1000);
-
- RequestOptions options = new RequestOptions();
- options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId()));
-
- obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options).map(ResourceResponse::getResource);
- }
-
- concurrencyControlSemaphore.acquire();
-
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQueryBenchmark.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQueryBenchmark.java
deleted file mode 100644
index 73df9a4ab81d..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQueryBenchmark.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import java.util.Random;
-
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.FeedOptions;
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.PartitionKey;
-import com.microsoft.azure.cosmosdb.benchmark.Configuration.Operation;
-
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import javax.net.ssl.SSLException;
-
-class AsyncQueryBenchmark extends AsyncBenchmark> {
-
- private int pageCount = 0;
-
- AsyncQueryBenchmark(Configuration cfg) {
- super(cfg);
- }
-
- @Override
- protected void onSuccess() {
- pageCount++;
- if (pageCount % 10000 == 0) {
- if (pageCount == 0) {
- return;
- }
- logger.info("total pages so far: {}", pageCount);
- }
- }
-
- @Override
- protected void performWorkload(Subscriber> subs, long i) throws InterruptedException {
-
- Observable> obs;
- Random r = new Random();
- FeedOptions options = new FeedOptions();
-
- if (configuration.getOperationType() == Operation.QueryCross) {
-
- int index = r.nextInt(1000);
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select * from c where c._rid = \"" + docsToRead.get(index).getResourceId() + "\"";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QuerySingle) {
-
- int index = r.nextInt(1000);
- String pk = docsToRead.get(index).getString("pk");
- options.setPartitionKey(new PartitionKey(pk));
- String sqlQuery = "Select * from c where c.pk = \"" + pk + "\"";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QueryParallel) {
-
- options.setMaxItemCount(10);
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select * from c";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QueryOrderby) {
-
- options.setMaxItemCount(10);
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select * from c order by c._ts";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QueryAggregate) {
-
- options.setMaxItemCount(10);
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select value max(c._ts) from c";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QueryAggregateTopOrderby) {
-
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select top 1 value count(c) from c order by c._ts";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else if (configuration.getOperationType() == Operation.QueryTopOrderby) {
-
- options.setEnableCrossPartitionQuery(true);
- String sqlQuery = "Select top 1000 * from c order by c._ts";
- obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
- } else {
- throw new IllegalArgumentException("Unsupported Operation: " + configuration.getOperationType());
- }
- concurrencyControlSemaphore.acquire();
-
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQuerySinglePartitionMultiple.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQuerySinglePartitionMultiple.java
deleted file mode 100644
index 1d515226bea8..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncQuerySinglePartitionMultiple.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.FeedOptions;
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.PartitionKey;
-
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import javax.net.ssl.SSLException;
-
-class AsyncQuerySinglePartitionMultiple extends AsyncBenchmark> {
-
- private static final String SQL_QUERY = "Select * from c where c.pk = \"pk\"";
- private FeedOptions options;
- private int pageCount = 0;
-
- AsyncQuerySinglePartitionMultiple(Configuration cfg) {
- super(cfg);
- options = new FeedOptions();
- options.setPartitionKey(new PartitionKey("pk"));
- options.setMaxItemCount(10);
- }
-
- @Override
- protected void onSuccess() {
- pageCount++;
- if (pageCount % 10000 == 0) {
- if (pageCount == 0) {
- return;
- }
- logger.info("total pages so far: {}", pageCount);
- }
- }
-
- @Override
- protected void performWorkload(Subscriber> subs, long i) throws InterruptedException {
- Observable> obs = client.queryDocuments(getCollectionLink(), SQL_QUERY, options);
-
- concurrencyControlSemaphore.acquire();
-
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncReadBenchmark.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncReadBenchmark.java
deleted file mode 100644
index bdf0454f3824..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncReadBenchmark.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.codahale.metrics.Timer;
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.PartitionKey;
-import com.microsoft.azure.cosmosdb.RequestOptions;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.benchmark.Configuration.Operation;
-
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import javax.net.ssl.SSLException;
-
-class AsyncReadBenchmark extends AsyncBenchmark> {
-
- class LatencySubscriber extends Subscriber {
-
- Timer.Context context;
- Subscriber subscriber;
-
- LatencySubscriber(Subscriber subscriber) {
- this.subscriber = subscriber;
- }
-
- @Override
- public void onCompleted() {
- context.stop();
- subscriber.onCompleted();
- }
-
- @Override
- public void onError(Throwable e) {
- context.stop();
- subscriber.onError(e);
- }
-
- @Override
- public void onNext(T t) {
- subscriber.onNext(t);
- }
- }
-
- AsyncReadBenchmark(Configuration cfg) {
- super(cfg);
- }
-
- @Override
- protected void performWorkload(Subscriber> subs, long i) throws InterruptedException {
- int index = (int) (i % docsToRead.size());
- RequestOptions options = new RequestOptions();
- options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId()));
-
- Observable> obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options);
-
- concurrencyControlSemaphore.acquire();
-
- if (configuration.getOperationType() == Operation.ReadThroughput) {
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- } else {
- LatencySubscriber> latencySubscriber = new LatencySubscriber<>(
- subs);
- latencySubscriber.context = latency.time();
- obs.subscribeOn(Schedulers.computation()).subscribe(latencySubscriber);
- }
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncWriteBenchmark.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncWriteBenchmark.java
deleted file mode 100644
index 8256e1c48cba..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/AsyncWriteBenchmark.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import java.util.UUID;
-
-import org.apache.commons.lang3.RandomStringUtils;
-
-import com.codahale.metrics.Timer;
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.benchmark.Configuration.Operation;
-
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import javax.net.ssl.SSLException;
-
-class AsyncWriteBenchmark extends AsyncBenchmark> {
-
- private final String uuid;
- private final String dataFieldValue;
-
- class LatencySubscriber extends Subscriber {
-
- Timer.Context context;
- Subscriber subscriber;
-
- LatencySubscriber(Subscriber subscriber) {
- this.subscriber = subscriber;
- }
-
- @Override
- public void onCompleted() {
- context.stop();
- subscriber.onCompleted();
- }
-
- @Override
- public void onError(Throwable e) {
- context.stop();
- subscriber.onError(e);
- }
-
- @Override
- public void onNext(T t) {
- subscriber.onNext(t);
- }
- }
-
- AsyncWriteBenchmark(Configuration cfg) {
- super(cfg);
- uuid = UUID.randomUUID().toString();
- dataFieldValue = RandomStringUtils.randomAlphabetic(configuration.getDocumentDataFieldSize());
- }
-
- @Override
- protected void performWorkload(Subscriber> subs, long i) throws InterruptedException {
-
- String idString = uuid + i;
- Document newDoc = new Document();
- newDoc.setId(idString);
- newDoc.set(partitionKey, idString);
- newDoc.set("dataField1", dataFieldValue);
- newDoc.set("dataField2", dataFieldValue);
- newDoc.set("dataField3", dataFieldValue);
- newDoc.set("dataField4", dataFieldValue);
- newDoc.set("dataField5", dataFieldValue);
- Observable> obs = client.createDocument(getCollectionLink(), newDoc, null,
- false);
-
- concurrencyControlSemaphore.acquire();
-
- if (configuration.getOperationType() == Operation.WriteThroughput) {
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- } else {
- LatencySubscriber> latencySubscriber = new LatencySubscriber<>(
- subs);
- latencySubscriber.context = latency.time();
- obs.subscribeOn(Schedulers.computation()).subscribe(latencySubscriber);
- }
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Configuration.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Configuration.java
deleted file mode 100644
index 915591f8b7c9..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Configuration.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import java.util.Arrays;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-
-import com.beust.jcommander.IStringConverter;
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.ParameterException;
-import com.google.common.base.Strings;
-import com.microsoft.azure.cosmosdb.ConnectionMode;
-import com.microsoft.azure.cosmosdb.ConnectionPolicy;
-import com.microsoft.azure.cosmosdb.ConsistencyLevel;
-import com.microsoft.azure.cosmosdb.benchmark.Configuration.Operation.OperationTypeConverter;
-
-class Configuration {
- private final static int GRAPHITE_SERVER_DEFAULT_PORT = 2003;
-
- @Parameter(names = "-serviceEndpoint", description = "Service Endpoint")
- private String serviceEndpoint;
-
- @Parameter(names = "-masterKey", description = "Master Key")
- private String masterKey;
-
- @Parameter(names = "-databaseId", description = "Database ID")
- private String databaseId;
-
- @Parameter(names = "-collectionId", description = "Collection ID")
- private String collectionId;
-
- @Parameter(names = "-useNameLink", description = "Use name Link")
- private boolean useNameLink = false;
-
- @Parameter(names = "-documentDataFieldSize", description = "Length of a document data field in characters (16-bit)")
- private int documentDataFieldSize = 20;
-
- @Parameter(names = "-maxConnectionPoolSize", description = "Max Connection Pool Size")
- private Integer maxConnectionPoolSize = 1000;
-
- @Parameter(names = "-consistencyLevel", description = "Consistency Level", converter = ConsistencyLevelConverter.class)
- private ConsistencyLevel consistencyLevel = ConsistencyLevel.Session;
-
- @Parameter(names = "-connectionMode", description = "Connection Mode")
- private ConnectionMode connectionMode = ConnectionMode.Direct;
-
- @Parameter(names = "-graphiteEndpoint", description = "Graphite endpoint")
- private String graphiteEndpoint;
-
- @Parameter(names = "-enableJvmStats", description = "Enables JVM Stats")
- private boolean enableJvmStats;
-
- @Parameter(names = "-operation", description = "Type of Workload:\n"
- + "\tReadThroughput- run a Read workload that prints only throughput *\n"
- + "\tWriteThroughput - run a Write workload that prints only throughput\n"
- + "\tReadLatency - run a Read workload that prints both throughput and latency *\n"
- + "\tWriteLatency - run a Write workload that prints both throughput and latency\n"
- + "\tQueryCross - run a 'Select * from c where c._rid = SOME_RID' workload that prints throughput\n"
- + "\tQuerySingle - run a 'Select * from c where c.pk = SOME_PK' workload that prints throughput\n"
- + "\tQuerySingleMany - run a 'Select * from c where c.pk = \"pk\"' workload that prints throughput\n"
- + "\tQueryParallel - run a 'Select * from c' workload that prints throughput\n"
- + "\tQueryOrderby - run a 'Select * from c order by c._ts' workload that prints throughput\n"
- + "\tQueryAggregate - run a 'Select value max(c._ts) from c' workload that prints throughput\n"
- + "\tQueryAggregateTopOrderby - run a 'Select top 1 value count(c) from c order by c._ts' workload that prints throughput\n"
- + "\tQueryTopOrderby - run a 'Select top 1000 * from c order by c._ts' workload that prints throughput\n"
- + "\tMixed - runa workload of 90 reads, 9 writes and 1 QueryTopOrderby per 100 operations *\n"
- + "\tReadMyWrites - run a workflow of writes followed by reads and queries attempting to read the write.*\n"
- + "\n\t* writes 10k documents initially, which are used in the reads", converter = OperationTypeConverter.class)
- private Operation operation = Operation.WriteThroughput;
-
- @Parameter(names = "-concurrency", description = "Degree of Concurrency in Inserting Documents."
- + " If this value is not specified, the max connection pool size will be used as the concurrency level.")
- private Integer concurrency;
-
- @Parameter(names = "-numberOfOperations", description = "Total Number Of Documents To Insert")
- private int numberOfOperations = 100000;
-
- @Parameter(names = "-printingInterval", description = "Interval of time after which Metrics should be printed (seconds)")
- private int printingInterval = 10;
-
- @Parameter(names = "-numberOfPreCreatedDocuments", description = "Total Number Of Documents To pre create for a read workload to use")
- private int numberOfPreCreatedDocuments = 1000;
-
- @Parameter(names = {"-h", "-help", "--help"}, description = "Help", help = true)
- private boolean help = false;
-
- enum Operation {
- ReadThroughput,
- WriteThroughput,
- ReadLatency,
- WriteLatency,
- QueryCross,
- QuerySingle,
- QuerySingleMany,
- QueryParallel,
- QueryOrderby,
- QueryAggregate,
- QueryAggregateTopOrderby,
- QueryTopOrderby,
- Mixed,
- ReadMyWrites;
-
- static Operation fromString(String code) {
-
- for (Operation output : Operation.values()) {
- if (output.toString().equalsIgnoreCase(code)) {
- return output;
- }
- }
-
- return null;
- }
-
- static class OperationTypeConverter implements IStringConverter {
-
- /*
- * (non-Javadoc)
- *
- * @see com.beust.jcommander.IStringConverter#convert(java.lang.String)
- */
- @Override
- public Operation convert(String value) {
- Operation ret = fromString(value);
- if (ret == null) {
- throw new ParameterException("Value " + value + " can not be converted to ClientType. "
- + "Available values are: " + Arrays.toString(Operation.values()));
- }
- return ret;
- }
- }
- }
-
- private static ConsistencyLevel fromString(String code) {
- for (ConsistencyLevel output : ConsistencyLevel.values()) {
- if (output.toString().equalsIgnoreCase(code)) {
- return output;
- }
- }
- return null;
- }
-
- static class ConsistencyLevelConverter implements IStringConverter {
-
- /*
- * (non-Javadoc)
- *
- * @see com.beust.jcommander.IStringConverter#convert(java.lang.String)
- */
- @Override
- public ConsistencyLevel convert(String value) {
- ConsistencyLevel ret = fromString(value);
- if (ret == null) {
- throw new ParameterException("Value " + value + " can not be converted to ClientType. "
- + "Available values are: " + Arrays.toString(Operation.values()));
- }
- return ret;
- }
- }
-
- Operation getOperationType() {
- return operation;
- }
-
- int getNumberOfOperations() {
- return numberOfOperations;
- }
-
- String getServiceEndpoint() {
- return serviceEndpoint;
- }
-
- String getMasterKey() {
- return masterKey;
- }
-
- boolean isHelp() {
- return help;
- }
-
- int getDocumentDataFieldSize() {
- return documentDataFieldSize;
- }
-
- ConnectionPolicy getConnectionPolicy() {
- ConnectionPolicy policy = new ConnectionPolicy();
- policy.setConnectionMode(connectionMode);
- policy.setMaxPoolSize(maxConnectionPoolSize);
- return policy;
- }
-
- ConsistencyLevel getConsistencyLevel() {
- return consistencyLevel;
- }
-
- String getDatabaseId() {
- return databaseId;
- }
-
- String getCollectionId() {
- return collectionId;
- }
-
- int getNumberOfPreCreatedDocuments() {
- return numberOfPreCreatedDocuments;
- }
-
- int getPrintingInterval() {
- return printingInterval;
- }
-
- int getConcurrency() {
- if (this.concurrency != null) {
- return concurrency;
- } else {
- return this.maxConnectionPoolSize;
- }
- }
-
- boolean isUseNameLink() {
- return useNameLink;
- }
-
- public boolean isEnableJvmStats() {
- return enableJvmStats;
- }
-
- public String getGraphiteEndpoint() {
- if (graphiteEndpoint == null) {
- return null;
- }
-
- return StringUtils.substringBeforeLast(graphiteEndpoint, ":");
- }
-
- public int getGraphiteEndpointPort() {
- if (graphiteEndpoint == null) {
- return -1;
- }
-
- String portAsString = Strings.emptyToNull(StringUtils.substringAfterLast(graphiteEndpoint, ":"));
- if (portAsString == null) {
- return GRAPHITE_SERVER_DEFAULT_PORT;
- } else {
- return Integer.parseInt(portAsString);
- }
- }
-
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-
- void tryGetValuesFromSystem() {
- serviceEndpoint = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("SERVICE_END_POINT")),
- serviceEndpoint);
-
- masterKey = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("MASTER_KEY")), masterKey);
-
- databaseId = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("DATABASE_ID")), databaseId);
-
- collectionId = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("COLLECTION_ID")),
- collectionId);
-
- documentDataFieldSize = Integer.parseInt(
- StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("DOCUMENT_DATA_FIELD_SIZE")),
- Integer.toString(documentDataFieldSize)));
-
- maxConnectionPoolSize = Integer.parseInt(
- StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("MAX_CONNECTION_POOL_SIZE")),
- Integer.toString(maxConnectionPoolSize)));
-
- ConsistencyLevelConverter consistencyLevelConverter = new ConsistencyLevelConverter();
- consistencyLevel = consistencyLevelConverter.convert(StringUtils
- .defaultString(Strings.emptyToNull(System.getenv().get("CONSISTENCY_LEVEL")), consistencyLevel.name()));
-
- OperationTypeConverter operationTypeConverter = new OperationTypeConverter();
- operation = operationTypeConverter.convert(
- StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("OPERATION")), operation.name()));
-
- String concurrencyValue = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("CONCURRENCY")),
- concurrency == null ? null : Integer.toString(concurrency));
- concurrency = concurrencyValue == null ? null : Integer.parseInt(concurrencyValue);
-
- String numberOfOperationsValue = StringUtils.defaultString(
- Strings.emptyToNull(System.getenv().get("NUMBER_OF_OPERATIONS")), Integer.toString(numberOfOperations));
- numberOfOperations = Integer.parseInt(numberOfOperationsValue);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/DocDBUtils.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/DocDBUtils.java
deleted file mode 100644
index 4d05fb177cc6..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/DocDBUtils.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.microsoft.azure.cosmosdb.Database;
-import com.microsoft.azure.cosmosdb.DocumentCollection;
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.SqlParameter;
-import com.microsoft.azure.cosmosdb.SqlParameterCollection;
-import com.microsoft.azure.cosmosdb.SqlQuerySpec;
-import com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient;
-
-class DocDBUtils {
-
- private DocDBUtils() {
- }
-
- static Database getDatabase(AsyncDocumentClient client, String databaseId) {
- FeedResponse feedResponsePages = client
- .queryDatabases(new SqlQuerySpec("SELECT * FROM root r WHERE r.id=@id",
- new SqlParameterCollection(new SqlParameter("@id", databaseId))), null)
- .toBlocking().single();
-
- if (feedResponsePages.getResults().isEmpty()) {
- throw new RuntimeException("cannot find datatbase " + databaseId);
- }
- return feedResponsePages.getResults().get(0);
- }
-
- static DocumentCollection getCollection(AsyncDocumentClient client, String databaseLink,
- String collectionId) {
- FeedResponse feedResponsePages = client
- .queryCollections(databaseLink,
- new SqlQuerySpec("SELECT * FROM root r WHERE r.id=@id",
- new SqlParameterCollection(new SqlParameter("@id", collectionId))),
- null)
- .toBlocking().single();
-
- if (feedResponsePages.getResults().isEmpty()) {
- throw new RuntimeException("cannot find collection " + collectionId);
- }
- return feedResponsePages.getResults().get(0);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Main.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Main.java
deleted file mode 100644
index 18c20c619faf..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/Main.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.ParameterException;
-
-public class Main {
-
- private final static Logger LOGGER = LoggerFactory.getLogger(Main.class);
-
- public static void main(String[] args) throws Exception {
- org.apache.log4j.Logger.getLogger("io.netty").setLevel(org.apache.log4j.Level.OFF);
-
- try {
- LOGGER.debug("Parsing the arguments ...");
- Configuration cfg = new Configuration();
- cfg.tryGetValuesFromSystem();
-
- JCommander jcommander = new JCommander(cfg, args);
- if (cfg.isHelp()) {
- // prints out the usage help
- jcommander.usage();
- return;
- }
-
- AsyncBenchmark benchmark;
- switch (cfg.getOperationType()) {
- case WriteThroughput:
- case WriteLatency:
- benchmark = new AsyncWriteBenchmark(cfg);
- break;
-
- case ReadThroughput:
- case ReadLatency:
- benchmark = new AsyncReadBenchmark(cfg);
- break;
-
- case QueryCross:
- case QuerySingle:
- case QueryParallel:
- case QueryOrderby:
- case QueryAggregate:
- case QueryTopOrderby:
- case QueryAggregateTopOrderby:
- benchmark = new AsyncQueryBenchmark(cfg);
- break;
-
- case Mixed:
- benchmark = new AsyncMixedBenchmark(cfg);
- break;
-
- case QuerySingleMany:
- benchmark = new AsyncQuerySinglePartitionMultiple(cfg);
- break;
-
- case ReadMyWrites:
- benchmark = new ReadMyWriteWorkflow(cfg);
- break;
-
- default:
- throw new RuntimeException(cfg.getOperationType() + " is not supported");
- }
-
- benchmark.run();
- benchmark.shutdown();
-
- } catch (ParameterException e) {
- // if any error in parsing the cmd-line options print out the usage help
- System.err.println("Invalid Usage: " + e.getMessage());
- System.err.println("Try '-help' for more information.");
- System.exit(1);
- }
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/ReadMyWriteWorkflow.java b/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/ReadMyWriteWorkflow.java
deleted file mode 100644
index 5115dcfb0060..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/java/com/microsoft/azure/cosmosdb/benchmark/ReadMyWriteWorkflow.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.FeedOptions;
-import com.microsoft.azure.cosmosdb.PartitionKey;
-import com.microsoft.azure.cosmosdb.RequestOptions;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.SqlParameter;
-import com.microsoft.azure.cosmosdb.SqlParameterCollection;
-import com.microsoft.azure.cosmosdb.SqlQuerySpec;
-import com.microsoft.azure.cosmosdb.internal.Utils;
-import com.microsoft.azure.cosmosdb.rx.internal.NotFoundException;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.RandomUtils;
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-/**
- * This workflow is intended for session and above consistency levels.
- *
- * This workflow first will create some documents in cosmosdb and will store them all in its local cache.
- * Then at each step will randomly will try to do a write, read its own write, or query for its own write.
- */
-class ReadMyWriteWorkflow extends AsyncBenchmark {
- private final static String QUERY_FIELD_NAME = "prop";
- private final static String ORDER_BY_FIELD_NAME = "_ts";
- private final static int MAX_TOP_QUERY_COUNT = 2000;
-
- private ConcurrentHashMap cache;
- private int cacheSize;
-
- ReadMyWriteWorkflow(Configuration cfg) {
- super(cfg);
- }
-
- @Override
- protected void init() {
- this.cacheSize = configuration.getNumberOfPreCreatedDocuments();
- this.cache = new ConcurrentHashMap<>();
- this.populateCache();
- }
-
- @Override
- protected void performWorkload(Subscriber subs, long i) throws Exception {
- Observable obs;
- boolean readyMyWrite = RandomUtils.nextBoolean();
- if (readyMyWrite) {
- // will do a write and immediately upon success will either
- // do a point read
- // or single partition query
- // or cross partition query to find the write.
- int j = Math.toIntExact(Math.floorMod(i, 3));
- switch (j) {
- case 0:
- // write a random document to cosmodb and update the cache.
- // then try to read the document which just was written
- obs = writeDocument()
- .flatMap(d -> readDocument(d));
- break;
- case 1:
- // write a random document to cosmodb and update the cache.
- // then try to query for the document which just was written
- obs = writeDocument()
- .flatMap(d -> singlePartitionQuery(d)
- .switchIfEmpty(Observable.error(new NotFoundException(
- "couldn't find my write in a single partition query!"))));
- break;
- case 2:
- // write a random document to cosmodb and update the cache.
- // then try to query for the document which just was written
- obs = writeDocument()
- .flatMap(d -> xPartitionQuery(generateQuery(d))
- .switchIfEmpty(Observable.error(new NotFoundException(
- "couldn't find my write in a cross partition query!"))));
- break;
- default:
- assert false;
- throw new IllegalStateException();
- }
- } else {
- // will either do
- // a write
- // a point read for a in memory cached document
- // or single partition query for a in memory cached document
- // or cross partition query for a in memory cached document
- int j = Math.toIntExact(Math.floorMod(i, 4));
- switch (j) {
- case 0:
- // write a random document to cosmosdb and update the cache
- obs = writeDocument();
- break;
- case 1:
- // randomly choose a document from the cache and do a single point read
- obs = readDocument(cache.get(cacheKey()));
- break;
- case 2:
- // randomly choose a document from the cache and do a single partition query
- obs = singlePartitionQuery(cache.get(cacheKey()))
- .switchIfEmpty(Observable.error(new NotFoundException(
- "couldn't find my cached write in a single partition query!")));
- break;
- case 3:
- // randomly choose a document from the cache and do a cross partition query
- obs = xPartitionQuery(generateRandomQuery())
- .switchIfEmpty(Observable.error(new NotFoundException(
- "couldn't find my cached write in a cross partition query!")));
- break;
- default:
- assert false;
- throw new IllegalStateException();
- }
- }
-
- concurrencyControlSemaphore.acquire();
-
- obs.subscribeOn(Schedulers.computation()).subscribe(subs);
- }
-
- private void populateCache() {
- ArrayList> list = new ArrayList<>();
- for (int i = 0; i < cacheSize; i++) {
- Observable observable = writeDocument(i);
- list.add(observable);
- }
-
- logger.info("Pre-populating {} documents ....", cacheSize);
- Observable.merge(list, configuration.getConcurrency()).toCompletable().await();
- logger.info("Finished pre-populating {} documents", cacheSize);
- }
-
- /**
- * Writes a random document to cosmosdb and store it in a random location in the cache.
- *
- * @return Observable of document
- */
- private Observable writeDocument() {
- return writeDocument(null);
- }
-
- /**
- * Writes a random document to cosmosdb and store it in the slot i-th in the cache.
- *
- * @return Observable of document
- */
- private Observable writeDocument(Integer i) {
- String idString = Utils.randomUUID().toString();
- String randomVal = Utils.randomUUID().toString();
- Document document = new Document();
- document.setId(idString);
- document.set(partitionKey, idString);
- document.set(QUERY_FIELD_NAME, randomVal);
- document.set("dataField1", randomVal);
- document.set("dataField2", randomVal);
- document.set("dataField3", randomVal);
- document.set("dataField4", randomVal);
-
- Integer key = i == null ? cacheKey() : i;
- return client.createDocument(getCollectionLink(), document, null, false)
- .doOnNext(r -> cache.put(key, r.getResource()))
- .map(ResourceResponse::getResource);
- }
-
- /**
- * given a document tries to read it from cosmosdb
- *
- * @param d document to be read
- * @return Observable of document
- */
- private Observable readDocument(Document d) {
- RequestOptions options = new RequestOptions();
- options.setPartitionKey(new PartitionKey(d.getString(partitionKey)));
-
- return client.readDocument(getDocumentLink(d), options)
- .map(ResourceResponse::getResource);
- }
-
- /**
- * Generates a random query
- *
- * @return a randomly generated query
- */
- private SqlQuerySpec generateRandomQuery() {
- int docCount = RandomUtils.nextInt(1, 2);
- Set keys = new HashSet<>();
- for (int i = 0; i < docCount; i++) {
- int key = RandomUtils.nextInt(0, cacheSize);
- keys.add(key);
- }
- List documentList = null;
- if (RandomUtils.nextBoolean()) {
- documentList = keys.stream().map(cache::get).collect(Collectors.toList());
- }
-
- int top = RandomUtils.nextInt(0, MAX_TOP_QUERY_COUNT);
- boolean useOrderBy = RandomUtils.nextBoolean();
-
- return generateQuery(documentList, top > 1000 ? top : null, useOrderBy);
- }
-
- /**
- * given a query returns the corresponding observable result
- *
- * @param query to find document
- * @return Observable document
- */
- private Observable xPartitionQuery(SqlQuerySpec query) {
- FeedOptions options = new FeedOptions();
- options.setMaxDegreeOfParallelism(-1);
- options.setEnableCrossPartitionQuery(true);
-
- return client.queryDocuments(getCollectionLink(), query, options)
- .flatMap(p -> Observable.from(p.getResults()));
- }
-
- /**
- * given a document returns the corresponding observable result of issuing a single partition query
- * for the document.
- *
- * @param d document to be queried for.
- * @return Observable document
- */
- private Observable singlePartitionQuery(Document d) {
- FeedOptions options = new FeedOptions();
- options.setPartitionKey(new PartitionKey(d.get(partitionKey)));
-
- SqlQuerySpec sqlQuerySpec = new SqlQuerySpec(String.format("Select top 100 * from c where c.%s = '%s'",
- QUERY_FIELD_NAME,
- d.getString(QUERY_FIELD_NAME)));
- return client.queryDocuments(getCollectionLink(), sqlQuerySpec, options)
- .flatMap(p -> Observable.from(p.getResults()));
- }
-
- /**
- * Given a document list generates a randomly generated sql query which can find only and only the documents
- *
- * The generated query may have a top, orderby, top and orderby.
- *
- * @param documentList list of documents to be queried for
- * @return SqlQuerySpec
- */
- private SqlQuerySpec generateQuery(Document... documentList) {
- return generateQuery(Arrays.asList(documentList));
- }
-
- /**
- * Given a document list generates a randomly generated sql query which can find only and only the documents
- *
- * The generated query may have a top, orderby, top and orderby.
- *
- * @param documentList list of documents to be queried for
- * @return SqlQuerySpec
- */
- private SqlQuerySpec generateQuery(List documentList) {
- int top = RandomUtils.nextInt(0, MAX_TOP_QUERY_COUNT);
- boolean useOrderBy = RandomUtils.nextBoolean();
-
- return generateQuery(documentList, top >= documentList.size() ? top : null, useOrderBy);
- }
-
- /**
- * Given a document list generates sql query which can find only and only the documents
- *
- * @param documentList lists of documents to find
- * @param topCount if a valid top count, the query will have a top count
- * @param withOrderBy if not null, the query will have an orderby clause
- * @return SqlQuerySpec
- */
- private SqlQuerySpec generateQuery(List documentList, Integer topCount, boolean withOrderBy) {
- QueryBuilder queryBuilder = new QueryBuilder();
- if (withOrderBy) {
- queryBuilder.orderBy(ORDER_BY_FIELD_NAME);
- }
- if (documentList != null && !documentList.isEmpty()) {
- if (topCount != null) {
- topCount = Math.max(topCount, documentList.size());
- }
-
- queryBuilder.whereClause(QueryBuilder.WhereClause.InWhereClause.asInWhereClause(QUERY_FIELD_NAME, documentList));
- }
-
- if ((documentList == null || documentList.isEmpty()) && (topCount == null || topCount <= 0)) {
- topCount = 100;
- }
-
- if (topCount != null) {
- queryBuilder.top(topCount);
- }
-
- return queryBuilder.toSqlQuerySpec();
- }
-
- private int cacheKey() {
- return RandomUtils.nextInt(0, cacheSize);
- }
-
- /**
- * This is used for making random query generation with different terms (top, orderby) easier.
- */
- static class QueryBuilder {
- private String orderByFieldName;
- private Integer topCount;
- private WhereClause whereClause;
-
- QueryBuilder top(int top) {
- this.topCount = top;
- return this;
- }
-
- QueryBuilder orderBy(String fieldName) {
- this.orderByFieldName = fieldName;
- return this;
- }
-
- QueryBuilder whereClause(WhereClause whereClause) {
- this.whereClause = whereClause;
- return this;
- }
-
- static abstract class WhereClause {
- static class InWhereClause extends WhereClause {
- private final List parameters;
- private final String whereCondition;
-
- static InWhereClause asInWhereClause(String fieldName, List documentList) {
- List parameters = new ArrayList<>(documentList.size());
- for (int i = 0; i < documentList.size(); i++) {
- Object value = documentList.get(i).get(fieldName);
- SqlParameter sqlParameter = new SqlParameter("@param" + i, value);
- parameters.add(sqlParameter);
- }
-
- return new InWhereClause(fieldName, parameters);
- }
-
- InWhereClause(String fieldName, List parameters) {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(fieldName);
- stringBuilder.append(" IN (");
- List params = parameters.stream().map(SqlParameter::getName).collect(Collectors.toList());
- stringBuilder.append(String.join(", ", params));
- stringBuilder.append(")");
-
- this.whereCondition = stringBuilder.toString();
- this.parameters = parameters;
- }
-
- @Override
- String getWhereCondition(String rootName) {
- return rootName + "." + this.whereCondition;
- }
-
- @Override
- SqlParameterCollection getSqlParameterCollection() {
- return new SqlParameterCollection(this.parameters);
- }
- }
-
- abstract String getWhereCondition(String rootName);
-
- abstract SqlParameterCollection getSqlParameterCollection();
- }
-
- SqlQuerySpec toSqlQuerySpec() {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("SELECT");
-
- if (topCount != null) {
- stringBuilder.append(" TOP ").append(topCount);
- }
-
- stringBuilder.append(" * FROM root");
- if (whereClause != null) {
- stringBuilder.append(" WHERE ");
- stringBuilder.append(whereClause.getWhereCondition("root"));
-
- }
-
- if (orderByFieldName != null) {
- stringBuilder.append(" ORDER BY ").append("root.").append(orderByFieldName);
- }
-
- return whereClause == null ?
- new SqlQuerySpec(stringBuilder.toString()) :
- new SqlQuerySpec(stringBuilder.toString(), whereClause.getSqlParameterCollection());
- }
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/main/resources/log4j.properties b/cosmosdb/data-plane/benchmark/src/main/resources/log4j.properties
deleted file mode 100644
index 92751a419201..000000000000
--- a/cosmosdb/data-plane/benchmark/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# this is the log4j configuration for tests
-
-# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=INFO, A1
-
-log4j.category.com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd=WARN
-log4j.category.io.netty=INFO
-log4j.category.io.reactivex=INFO
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d %5X{pid} [%t] %-5p %c - %m%n
\ No newline at end of file
diff --git a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/QueryBuilderTest.java b/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/QueryBuilderTest.java
deleted file mode 100644
index d83d5505e1d3..000000000000
--- a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/QueryBuilderTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.google.common.collect.ImmutableList;
-import com.microsoft.azure.cosmosdb.SqlParameter;
-import org.testng.annotations.Test;
-
-import static com.microsoft.azure.cosmosdb.benchmark.ReadMyWriteWorkflow.QueryBuilder.WhereClause;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class QueryBuilderTest {
-
- @Test(groups = {"unit"})
- public void basic() {
- ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
- assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
- .isEqualTo("SELECT * FROM root");
- }
-
- @Test(groups = {"unit"})
- public void top() {
- ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
- queryBuilder.top(50);
- assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
- .isEqualTo("SELECT TOP 50 * FROM root");
- }
-
- @Test(groups = {"unit"})
- public void orderBy() {
- ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
- queryBuilder.orderBy("prop");
- assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
- .isEqualTo("SELECT * FROM root ORDER BY root.prop");
- }
-
- @Test(groups = {"unit"})
- public void whereInClause() {
- ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
-
- ImmutableList parameters = ImmutableList.of(new SqlParameter("@param1", 1),
- new SqlParameter("@param2", 2));
- queryBuilder.whereClause(new WhereClause.InWhereClause("colName",
- parameters));
- assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
- .isEqualTo("SELECT * FROM root WHERE root.colName IN (@param1, @param2)");
- assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters);
- }
-
- @Test(groups = {"unit"})
- public void topOrderByWhereClause() {
- ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
- queryBuilder.orderBy("prop");
- queryBuilder.top(5);
-
- ImmutableList parameters = ImmutableList.of(new SqlParameter("@param1", 1),
- new SqlParameter("@param2", 2));
- queryBuilder.whereClause(new WhereClause.InWhereClause("colName",
- parameters));
- assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
- .isEqualTo("SELECT TOP 5 * FROM root WHERE root.colName IN (@param1, @param2) ORDER BY root.prop");
- assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters);
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/Utils.java b/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/Utils.java
deleted file mode 100644
index 49517fd05cb5..000000000000
--- a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/Utils.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-
-import com.microsoft.azure.cosmosdb.ConnectionPolicy;
-import com.microsoft.azure.cosmosdb.Database;
-import com.microsoft.azure.cosmosdb.DatabaseForTest;
-import com.microsoft.azure.cosmosdb.DocumentCollection;
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.RetryOptions;
-import com.microsoft.azure.cosmosdb.SqlQuerySpec;
-import com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient;
-import com.microsoft.azure.cosmosdb.rx.TestConfigurations;
-import rx.Observable;
-
-public class Utils {
- public static AsyncDocumentClient housekeepingClient() {
- ConnectionPolicy connectionPolicy = new ConnectionPolicy();
- RetryOptions options = new RetryOptions();
- options.setMaxRetryAttemptsOnThrottledRequests(100);
- options.setMaxRetryWaitTimeInSeconds(60);
- connectionPolicy.setRetryOptions(options);
- return new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST)
- .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY)
- .withConnectionPolicy(connectionPolicy)
- .build();
- }
-
- public static String getCollectionLink(Database db, DocumentCollection collection) {
- return "dbs/" + db.getId() + "/colls/" + collection;
- }
-
- public static Database createDatabaseForTest(AsyncDocumentClient client) {
- return DatabaseForTest.create(DatabaseManagerImpl.getInstance(client)).createdDatabase;
- }
-
- public static void safeCleanDatabases(AsyncDocumentClient client) {
- if (client != null) {
- DatabaseForTest.cleanupStaleTestDatabases(DatabaseManagerImpl.getInstance(client));
- }
- }
-
- public static void safeClean(AsyncDocumentClient client, Database database) {
- if (database != null) {
- safeClean(client, database.getId());
- }
- }
-
- public static void safeClean(AsyncDocumentClient client, String databaseId) {
- if (client != null) {
- if (databaseId != null) {
- try {
- client.deleteDatabase("/dbs/" + databaseId, null).toBlocking().single();
- } catch (Exception e) {
- }
- }
- }
- }
-
- public static String generateDatabaseId() {
- return DatabaseForTest.generateId();
- }
-
- public static void safeClose(AsyncDocumentClient client) {
- if (client != null) {
- client.close();
- }
- }
-
- private static class DatabaseManagerImpl implements DatabaseForTest.DatabaseManager {
- public static DatabaseManagerImpl getInstance(AsyncDocumentClient client) {
- return new DatabaseManagerImpl(client);
- }
-
- private final AsyncDocumentClient client;
-
- private DatabaseManagerImpl(AsyncDocumentClient client) {
- this.client = client;
- }
-
- @Override
- public Observable> queryDatabases(SqlQuerySpec query) {
- return client.queryDatabases(query, null);
- }
-
- @Override
- public Observable> createDatabase(Database databaseDefinition) {
- return client.createDatabase(databaseDefinition, null);
- }
-
- @Override
- public Observable> deleteDatabase(String id) {
-
- return client.deleteDatabase("dbs/" + id, null);
- }
- }
-}
diff --git a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/WorkflowTest.java b/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/WorkflowTest.java
deleted file mode 100644
index 6490d47bcb6d..000000000000
--- a/cosmosdb/data-plane/benchmark/src/test/java/com/microsoft/azure/cosmosdb/benchmark/WorkflowTest.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.benchmark;
-
-import com.beust.jcommander.JCommander;
-import com.microsoft.azure.cosmosdb.DataType;
-import com.microsoft.azure.cosmosdb.Database;
-import com.microsoft.azure.cosmosdb.DocumentCollection;
-import com.microsoft.azure.cosmosdb.IncludedPath;
-import com.microsoft.azure.cosmosdb.Index;
-import com.microsoft.azure.cosmosdb.IndexingPolicy;
-import com.microsoft.azure.cosmosdb.PartitionKeyDefinition;
-import com.microsoft.azure.cosmosdb.RequestOptions;
-import com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient;
-import com.microsoft.azure.cosmosdb.rx.TestConfigurations;
-import org.apache.commons.lang3.StringUtils;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class WorkflowTest {
- private static final int TIMEOUT = 120000;
- private Database database;
- private DocumentCollection collection;
-
- @Test(groups = "simple", timeOut = TIMEOUT)
- public void readMyWritesCLI() throws Exception {
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations 123" +
- " -operation ReadMyWrites -connectionMode Direct -numberOfPreCreatedDocuments 100";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId());
- Main.main(StringUtils.split(cmd));
- }
-
- @Test(dataProvider = "collectionLinkTypeArgProvider", groups = "simple", timeOut = TIMEOUT)
- public void readMyWrites(boolean useNameLink) throws Exception {
- int numberOfOperations = 123;
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations %s" +
- " -operation ReadMyWrites -connectionMode Direct -numberOfPreCreatedDocuments 100";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId(),
- numberOfOperations)
- + (useNameLink ? " -useNameLink" : "");
-
- Configuration cfg = new Configuration();
- new JCommander(cfg, StringUtils.split(cmd));
-
- AtomicInteger success = new AtomicInteger();
- AtomicInteger error = new AtomicInteger();
-
- ReadMyWriteWorkflow wf = new ReadMyWriteWorkflow(cfg) {
- @Override
- protected void onError(Throwable throwable) {
- error.incrementAndGet();
- }
-
- @Override
- protected void onSuccess() {
- success.incrementAndGet();
- }
- };
-
- wf.run();
- wf.shutdown();
-
- assertThat(error).hasValue(0);
- assertThat(success).hasValue(numberOfOperations);
- }
-
- @Test(groups = "simple", timeOut = TIMEOUT)
- public void writeLatencyCLI() throws Exception {
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations 1000" +
- " -operation WriteLatency -connectionMode Direct";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId());
- Main.main(StringUtils.split(cmd));
- }
-
- @Test(dataProvider = "collectionLinkTypeArgProvider", groups = "simple", timeOut = TIMEOUT)
- public void writeLatency(boolean useNameLink) throws Exception {
- int numberOfOperations = 123;
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations %s" +
- " -operation WriteLatency -connectionMode Direct";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId(),
- numberOfOperations)
- + (useNameLink ? " -useNameLink" : "");
-
- Configuration cfg = new Configuration();
- new JCommander(cfg, StringUtils.split(cmd));
-
- AtomicInteger success = new AtomicInteger();
- AtomicInteger error = new AtomicInteger();
-
- AsyncWriteBenchmark wf = new AsyncWriteBenchmark(cfg) {
- @Override
- protected void onError(Throwable throwable) {
- error.incrementAndGet();
- }
-
- @Override
- protected void onSuccess() {
- success.incrementAndGet();
- }
- };
-
- wf.run();
- wf.shutdown();
-
- assertThat(error).hasValue(0);
- assertThat(success).hasValue(numberOfOperations);
- }
-
- @Test(dataProvider = "collectionLinkTypeArgProvider", groups = "simple", timeOut = TIMEOUT)
- public void writeThroughput(boolean useNameLink) throws Exception {
- int numberOfOperations = 123;
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations %s" +
- " -operation WriteThroughput -connectionMode Direct";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId(),
- numberOfOperations)
- + (useNameLink ? " -useNameLink" : "");
-
- Configuration cfg = new Configuration();
- new JCommander(cfg, StringUtils.split(cmd));
-
- AtomicInteger success = new AtomicInteger();
- AtomicInteger error = new AtomicInteger();
-
- AsyncWriteBenchmark wf = new AsyncWriteBenchmark(cfg) {
- @Override
- protected void onError(Throwable throwable) {
- error.incrementAndGet();
- }
-
- @Override
- protected void onSuccess() {
- success.incrementAndGet();
- }
- };
-
- wf.run();
- wf.shutdown();
-
- assertThat(error).hasValue(0);
- assertThat(success).hasValue(numberOfOperations);
- }
-
- @Test(dataProvider = "collectionLinkTypeArgProvider", groups = "simple", timeOut = TIMEOUT)
- public void readLatency(boolean useNameLink) throws Exception {
- int numberOfOperations = 123;
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations %s" +
- " -operation ReadLatency -connectionMode Direct";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId(),
- numberOfOperations)
- + (useNameLink ? " -useNameLink" : "");
-
- Configuration cfg = new Configuration();
- new JCommander(cfg, StringUtils.split(cmd));
-
- AtomicInteger success = new AtomicInteger();
- AtomicInteger error = new AtomicInteger();
-
- AsyncReadBenchmark wf = new AsyncReadBenchmark(cfg) {
- @Override
- protected void onError(Throwable throwable) {
- error.incrementAndGet();
- }
-
- @Override
- protected void onSuccess() {
- success.incrementAndGet();
- }
- };
-
- wf.run();
- wf.shutdown();
-
- assertThat(error).hasValue(0);
- assertThat(success).hasValue(numberOfOperations);
- }
-
- @Test(dataProvider = "collectionLinkTypeArgProvider", groups = "simple", timeOut = TIMEOUT)
- public void readThroughput(boolean useNameLink) throws Exception {
- int numberOfOperations = 123;
- String cmdFormat = "-serviceEndpoint %s -masterKey %s" +
- " -databaseId %s -collectionId %s" +
- " -consistencyLevel Session -concurrency 2 -numberOfOperations %s" +
- " -operation ReadThroughput -connectionMode Direct";
-
- String cmd = String.format(cmdFormat,
- TestConfigurations.HOST,
- TestConfigurations.MASTER_KEY,
- database.getId(),
- collection.getId(),
- numberOfOperations)
- + (useNameLink ? " -useNameLink" : "");
-
- Configuration cfg = new Configuration();
- new JCommander(cfg, StringUtils.split(cmd));
-
- AtomicInteger success = new AtomicInteger();
- AtomicInteger error = new AtomicInteger();
-
- AsyncReadBenchmark wf = new AsyncReadBenchmark(cfg) {
- @Override
- protected void onError(Throwable throwable) {
- error.incrementAndGet();
- }
-
- @Override
- protected void onSuccess() {
- success.incrementAndGet();
- }
- };
-
- wf.run();
- wf.shutdown();
-
- assertThat(error).hasValue(0);
- assertThat(success).hasValue(numberOfOperations);
- }
-
- @BeforeClass(groups = "simple", timeOut = TIMEOUT)
- public void beforeClass() {
- RequestOptions options = new RequestOptions();
- options.setOfferThroughput(10000);
- AsyncDocumentClient housekeepingClient = Utils.housekeepingClient();
- database = Utils.createDatabaseForTest(housekeepingClient);
- collection = housekeepingClient.createCollection("dbs/"+ database.getId(),
- getCollectionDefinitionWithRangeRangeIndex(),
- options)
- .toBlocking().single().getResource();
- housekeepingClient.close();
- }
-
- @DataProvider(name = "collectionLinkTypeArgProvider")
- public Object[][] collectionLinkTypeArgProvider() {
- return new Object[][]{
- // is namebased
- {true},
- {false},
- };
- }
-
- @AfterClass(groups = "simple", timeOut = TIMEOUT)
- public void afterClass() {
- AsyncDocumentClient housekeepingClient = Utils.housekeepingClient();
- Utils.safeCleanDatabases(housekeepingClient);
- Utils.safeClean(housekeepingClient, database);
- Utils.safeClose(housekeepingClient);
- }
-
- DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
- PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
- ArrayList paths = new ArrayList<>();
- paths.add("/mypk");
- partitionKeyDef.setPaths(paths);
- IndexingPolicy indexingPolicy = new IndexingPolicy();
- Collection includedPaths = new ArrayList<>();
- IncludedPath includedPath = new IncludedPath();
- includedPath.setPath("/*");
- Collection indexes = new ArrayList<>();
- Index stringIndex = Index.Range(DataType.String);
- stringIndex.set("precision", -1);
- indexes.add(stringIndex);
-
- Index numberIndex = Index.Range(DataType.Number);
- numberIndex.set("precision", -1);
- indexes.add(numberIndex);
- includedPath.setIndexes(indexes);
- includedPaths.add(includedPath);
- indexingPolicy.setIncludedPaths(includedPaths);
-
- DocumentCollection collectionDefinition = new DocumentCollection();
- collectionDefinition.setIndexingPolicy(indexingPolicy);
- collectionDefinition.setId(UUID.randomUUID().toString());
- collectionDefinition.setPartitionKey(partitionKeyDef);
-
- return collectionDefinition;
- }
-}
diff --git a/cosmosdb/data-plane/changelog/README.md b/cosmosdb/data-plane/changelog/README.md
deleted file mode 100644
index f72d0684abc2..000000000000
--- a/cosmosdb/data-plane/changelog/README.md
+++ /dev/null
@@ -1,111 +0,0 @@
-## Changelog
-
-### 2.4.3
-* Fixed resource leak issue on closing client
-
-### 2.4.2
-* Fixed bugs in continuation token support for cross partition queries
-
-### 2.4.1
-* Fixed some bugs in Direct mode.
-* Improved logging in Direct mode.
-* Improved connection management.
-
-### 2.4.0
-* Direct GA.
-* Added support for QueryMetrics.
-* Changed the APIs accepting java.util.Collection for which order is important to accept java.util.List instead. Now ConnectionPolicy#getPreferredLocations(), JsonSerialization, and PartitionKey(.) accept List.
-
-### 2.4.0-beta1
-
-* Added support for Direct Https.
-* Changed the APIs accepting java.util.Collection for which order is important to accept java.util.List instead.
- Now ConnectionPolicy#getPreferredLocations(), JsonSerialization, and PartitionKey(.) accept List.
-* Fixed a Session bug for Document query in Gateway mode.
-* Upgraded dependencies (netty 0.4.20 [github #79](https://github.com/Azure/azure-cosmosdb-java/issues/79), RxJava 1.3.8).
-
-### 2.3.1
-
-* Fix handling very large query responses.
-* Fix resource token handling when instantiating client ([github #78](https://github.com/Azure/azure-cosmosdb-java/issues/78)).
-* Upgraded vulnerable dependency jackson-databind ([github #77](https://github.com/Azure/azure-cosmosdb-java/pull/77)).
-
-### 2.3.0
-
-* Fixed a resource leak bug.
-* Added support for MultiPolygon
-* Added support for custom headers in RequestOptions.
-
-### 2.2.2
-* Fixed a packaging bug.
-
-### 2.2.1
-* Fixed a NPE bug in write retry path.
-* Fixed a NPE bug in endpoint management.
-* Upgraded vulnerable dependencies ([github #68](https://github.com/Azure/azure-cosmosdb-java/issues/68)).
-* Added support for Netty network logging for troubleshooting.
-
-### 2.2.0
-* Added support for Multi-region write.
-
-### 2.1.0
-* Added support for Proxy.
-* Added support for resource token authorization.
-* Fixed a bug in handling large partition keys ([github #63](https://github.com/Azure/azure-cosmosdb-java/issues/63)).
-* Documentation improved.
-* SDK restructured into more granular modules.
-
-### 2.0.1
-- Fixed a bug for non-english locales ([github #51](https://github.com/Azure/azure-cosmosdb-java/issues/51)).
-- Added helper methods for Conflict resource.
-
-### 2.0.0
-- Replaced org.json dependency by jackson due to performance reasons and licensing ([github #29](https://github.com/Azure/azure-cosmosdb-java/issues/29)).
-- Removed deprecated OfferV2 class.
-- Added accessor method to Offer class for throughput content.
-- Any method in Document/Resource returning org.json types changed to return a jackson object type.
-- getObject(.) method of classes extending JsonSerializable changed to return a jackson ObjectNode type.
-- getCollection(.) method changed to return Collection of ObjectNode.
-- Removed JsonSerializable subclasses' constructors with org.json.JSONObject arg.
-- JsonSerializable.toJson (SerializationFormattingPolicy.Indented) now uses two spaces for indentation.
-
-### 1.0.2
-- Added support for Unique Index Policy.
-- Added support for limiting response continuation token size in feed options.
-- Added support for Partition Split in Cross Partition Query.
-- Fixed a bug in Json timestamp serialization ([github #32](https://github.com/Azure/azure-cosmosdb-java/issues/32)).
-- Fixed a bug in Json enum serialization.
-- Fixed a bug in managing documents of 2MB size ([github #33](https://github.com/Azure/azure-cosmosdb-java/issues/33)).
-- Dependency com.fasterxml.jackson.core:jackson-databind upgraded to 2.9.5 due to a bug ([jackson-databind: github #1599](https://github.com/FasterXML/jackson-databind/issues/1599))
-- Dependency on rxjava-extras upgraded to 0.8.0.17 due to a bug ([rxjava-extras: github #30](https://github.com/davidmoten/rxjava-extras/issues/30)).
-- The metadata description in pom file updated to be inline with the rest of documentation.
-- Syntax improvement ([github #41](https://github.com/Azure/azure-cosmosdb-java/issues/41)), ([github #40](https://github.com/Azure/azure-cosmosdb-java/issues/40)).
-
-### 1.0.1
-- Added back-pressure support in query.
-- Added support for partition key range id in query.
-- Changed to allow larger continuation token in request header (bugfix github #24).
-- netty dependency upgraded to 4.1.22.Final to ensure JVM shuts down after main thread finishes.
-- Changed to avoid passing session token when reading master resources.
-- Added more examples.
-- Added more benchmarking scenarios.
-- Fixed java header files for proper javadoc generation.
-
-### 1.0.0
-- Release 1.0.0 has fully end to end support for non-blocking IO using netty library in Gateway mode.
-- Dependency on ``azure-documentdb`` SDK removed.
-- Artifact id changed to ``azure-cosmosdb`` from ``azure-documentdb-rx`` in 0.9.0-rc2.
-- Java package name changed to ``com.microsoft.azure.cosmosdb`` from ``com.microsoft.azure.documentdb`` in 0.9.0-rc2.
-
-### 0.9.0-rc2
-- ``FeedResponsePage`` renamed to ``FeedReponse``
-- Some minor modifications to ``ConnectionPolicy`` configuration.
-All time fields and methods in ConnectionPolicy suffixed with "InMillis" to be more precise of the time unit.
-- ``ConnectionPolicy#setProxy()`` removed.
-- ``FeedOptions#pageSize`` renamed to
-``FeedOptions#maxItemCount``
-- Release 1.0.0 deprecates 0.9.x releases.
-
-### 0.9.0-rc1
-- First release of ``azure-documentdb-rx`` SDK.
-- CRUD Document API fully non-blocking using netty. Query async API implemented as a wrapper using blocking SDK ``azure-documentdb``.
diff --git a/cosmosdb/data-plane/commons-test-utils/pom.xml b/cosmosdb/data-plane/commons-test-utils/pom.xml
deleted file mode 100644
index f06ce657bcb6..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/pom.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
- 4.0.0
-
- com.microsoft.azure
- azure-cosmosdb-parent
- 2.4.5
-
- azure-cosmosdb-commons-test-utils
- Common Test Components for Testing Async SDK for SQL API of Azure Cosmos DB Service
- Common Test Components for Testing Async SDK for SQL API of Azure Cosmos DB Service
- jar
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-eclipse-plugin
- 2.8
-
-
-
- org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.2.1
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-report-plugin
- 2.22.0
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.4
-
-
- org.apache.maven.plugins
- maven-jxr-plugin
- 2.1
-
-
-
-
-
- com.microsoft.azure
- azure-cosmosdb-commons
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.testng
- testng
- ${testng.version}
-
-
- org.assertj
- assertj-core
- ${assertj.version}
-
-
- org.mockito
- mockito-all
- ${mockito.version}
-
-
- org.slf4j
- slf4j-log4j12
- ${slf4j.version}
-
-
- log4j
- log4j
- ${log4j.version}
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
-
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/BridgeUtils.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/BridgeUtils.java
deleted file mode 100644
index f5e449b53fc9..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/BridgeUtils.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb;
-
-import java.util.List;
-
-/**
- * This is a helper class for testing.
- */
-public class BridgeUtils {
-
- public static DatabaseAccount createDatabaseAccount(List readLocations,
- List writeLocations,
- boolean useMultipleWriteLocations) {
- DatabaseAccount dbAccount = new DatabaseAccount();
- dbAccount.setEnableMultipleWriteLocations(useMultipleWriteLocations);
-
- dbAccount.setReadableLocations(readLocations);
- dbAccount.setWritableLocations(writeLocations);
-
- return dbAccount;
- }
-
- public static DatabaseAccountLocation createDatabaseAccountLocation(String name, String endpoint) {
- DatabaseAccountLocation dal = new DatabaseAccountLocation();
- dal.setName(name);
- dal.setEndpoint(endpoint);
-
- return dal;
- }
-
- public static ConflictResolutionPolicy createConflictResolutionPolicy() {
- return new ConflictResolutionPolicy();
- }
-
- public static ConflictResolutionPolicy setMode(ConflictResolutionPolicy policy, ConflictResolutionMode mode) {
- policy.setMode(mode);
- return policy;
- }
-
- public static ConflictResolutionPolicy setPath(ConflictResolutionPolicy policy, String path) {
- policy.setConflictResolutionPath(path);
- return policy;
- }
-
- public static ConflictResolutionPolicy setStoredProc(ConflictResolutionPolicy policy, String storedProcLink) {
- policy.setConflictResolutionProcedure(storedProcLink);
- return policy;
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/ConfigsBuilder.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/ConfigsBuilder.java
deleted file mode 100644
index ff8ec498a823..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/ConfigsBuilder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb;
-
-import com.microsoft.azure.cosmosdb.internal.directconnectivity.Protocol;
-import com.microsoft.azure.cosmosdb.rx.internal.Configs;
-import org.mockito.Mockito;
-
-/**
- * This can be used for testing.
- */
-public class ConfigsBuilder {
- private Configs configs = Mockito.spy(new Configs());
-
- public static ConfigsBuilder instance() {
- return new ConfigsBuilder();
- }
-
- public ConfigsBuilder withProtocol(Protocol protocol) {
- Mockito.doReturn(protocol).when(configs).getProtocol();
- return this;
- }
-
- public Configs build() {
- return configs;
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/DatabaseForTest.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/DatabaseForTest.java
deleted file mode 100644
index 1e646d58e6eb..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/DatabaseForTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import rx.Observable;
-
-import java.time.Duration;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DatabaseForTest {
- private static Logger logger = LoggerFactory.getLogger(DatabaseForTest.class);
- public static final String SHARED_DB_ID_PREFIX = "RxJava.SDKTest.SharedDatabase";
- private static final Duration CLEANUP_THRESHOLD_DURATION = Duration.ofHours(1);
- private static final String DELIMITER = "_";
- private static DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss");
-
- public LocalDateTime createdTime;
- public Database createdDatabase;
-
- private DatabaseForTest(Database db, LocalDateTime createdTime) {
- this.createdDatabase = db;
- this.createdTime = createdTime;
- }
-
- private boolean isStale() {
- return isOlderThan(CLEANUP_THRESHOLD_DURATION);
- }
-
- private boolean isOlderThan(Duration dur) {
- return createdTime.isBefore(LocalDateTime.now().minus(dur));
- }
-
- public static String generateId() {
- return SHARED_DB_ID_PREFIX + DELIMITER + TIME_FORMATTER.format(LocalDateTime.now()) + DELIMITER + RandomStringUtils.randomAlphabetic(3);
- }
-
- private static DatabaseForTest from(Database db) {
- if (db == null || db.getId() == null || db.getSelfLink() == null) {
- return null;
- }
-
- String id = db.getId();
- if (id == null) {
- return null;
- }
-
- String[] parts = StringUtils.split(id, DELIMITER);
- if (parts.length != 3) {
- return null;
- }
- if (!StringUtils.equals(parts[0], SHARED_DB_ID_PREFIX)) {
- return null;
- }
-
- try {
- LocalDateTime parsedTime = LocalDateTime.parse(parts[1], TIME_FORMATTER);
- return new DatabaseForTest(db, parsedTime);
- } catch (Exception e) {
- return null;
- }
- }
-
- public static DatabaseForTest create(DatabaseManager client) {
- Database dbDef = new Database();
- dbDef.setId(generateId());
-
- Database db = client.createDatabase(dbDef).toBlocking().single().getResource();
- DatabaseForTest dbForTest = DatabaseForTest.from(db);
- assertThat(dbForTest).isNotNull();
- return dbForTest;
- }
-
- public static void cleanupStaleTestDatabases(DatabaseManager client) {
- logger.info("Cleaning stale test databases ...");
- List dbs = client.queryDatabases(
- new SqlQuerySpec("SELECT * FROM c WHERE STARTSWITH(c.id, @PREFIX)",
- new SqlParameterCollection(new SqlParameter("@PREFIX", DatabaseForTest.SHARED_DB_ID_PREFIX))))
- .flatMap(page -> Observable.from(page.getResults())).toList().toBlocking().single();
-
- for (Database db : dbs) {
- assertThat(db.getId()).startsWith(DatabaseForTest.SHARED_DB_ID_PREFIX);
-
- DatabaseForTest dbForTest = DatabaseForTest.from(db);
-
- if (db != null && dbForTest.isStale()) {
- logger.info("Deleting database {}", db.getId());
- client.deleteDatabase(db.getId()).toBlocking().single();
- }
- }
- }
-
- public interface DatabaseManager {
- Observable> queryDatabases(SqlQuerySpec query);
- Observable> createDatabase(Database databaseDefinition);
- Observable> deleteDatabase(String id);
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/HttpClientUnderTestWrapper.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/HttpClientUnderTestWrapper.java
deleted file mode 100644
index ffb118d8d852..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/HttpClientUnderTestWrapper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.internal.directconnectivity;
-
-import io.netty.buffer.ByteBuf;
-import io.reactivex.netty.client.RxClient;
-import io.reactivex.netty.protocol.http.client.CompositeHttpClient;
-import io.reactivex.netty.protocol.http.client.HttpClientRequest;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.mockito.Mockito.doAnswer;
-
-/**
- * This is a helper class for capturing requests sent over a httpClient.
- */
-public class HttpClientUnderTestWrapper {
- final private CompositeHttpClient origHttpClient;
- final private CompositeHttpClient spyHttpClient;
-
- public final List> capturedRequest = Collections.synchronizedList(new ArrayList<>());
-
- public HttpClientUnderTestWrapper(CompositeHttpClient origHttpClient) {
- this.origHttpClient = origHttpClient;
- this.spyHttpClient = Mockito.spy(origHttpClient);
-
- initRequestCapture(spyHttpClient);
- }
-
- public CompositeHttpClient getSpyHttpClient() {
- return spyHttpClient;
- }
-
- void initRequestCapture(CompositeHttpClient spyClient) {
-
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- RxClient.ServerInfo serverInfo = invocationOnMock.getArgumentAt(0, RxClient.ServerInfo.class);
- HttpClientRequest httpReq = invocationOnMock.getArgumentAt(1, HttpClientRequest.class);
- capturedRequest.add(httpReq);
- return origHttpClient.submit(serverInfo, httpReq);
- }
- }).when(spyClient).submit(Mockito.any(RxClient.ServerInfo.class), Mockito.any(HttpClientRequest.class));
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/StoreResponseBuilder.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/StoreResponseBuilder.java
deleted file mode 100644
index 5a1c1900d920..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/internal/directconnectivity/StoreResponseBuilder.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package com.microsoft.azure.cosmosdb.internal.directconnectivity;
-
-import com.microsoft.azure.cosmosdb.Resource;
-import com.microsoft.azure.cosmosdb.internal.HttpConstants;
-
-import java.math.BigDecimal;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class StoreResponseBuilder {
- private int status;
- private List> headerEntries;
- private String content;
-
- public static StoreResponseBuilder create() {
- return new StoreResponseBuilder();
- }
-
- public StoreResponseBuilder() {
- headerEntries = new ArrayList<>();
- }
-
- public StoreResponseBuilder withHeader(String key, String value) {
- headerEntries.add(new AbstractMap.SimpleEntry(key, value));
- return this;
- }
-
- public StoreResponseBuilder withLSN(long lsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.LSN, Long.toString(lsn)));
- return this;
- }
-
- public StoreResponseBuilder withRequestCharge(BigDecimal requestCharge) {
- withRequestCharge(requestCharge.doubleValue());
- return this;
- }
-
- public StoreResponseBuilder withRequestCharge(double requestCharge) {
- headerEntries.add(new AbstractMap.SimpleEntry(HttpConstants.HttpHeaders.REQUEST_CHARGE, Double.toString(requestCharge)));
- return this;
- }
-
- public StoreResponseBuilder withLocalLSN(long localLsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(localLsn)));
- return this;
- }
-
- public StoreResponseBuilder withPartitionKeyRangeId(String partitionKeyRangeId) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.PARTITION_KEY_RANGE_ID, partitionKeyRangeId));
- return this;
- }
-
- public StoreResponseBuilder withItemLocalLSN(long itemLocalLsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.ITEM_LOCAL_LSN, Long.toString(itemLocalLsn)));
- return this;
- }
-
- public StoreResponseBuilder withQuorumAckecdLsn(long quorumAckecdLsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.QUORUM_ACKED_LSN, Long.toString(quorumAckecdLsn)));
- return this;
- }
-
- public StoreResponseBuilder withQuorumAckecdLocalLsn(long quorumAckecdLocalLsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.QUORUM_ACKED_LOCAL_LSN, Long.toString(quorumAckecdLocalLsn)));
- return this;
- }
-
- public StoreResponseBuilder withGlobalCommittedLsn(long globalCommittedLsn) {
- headerEntries.add(new AbstractMap.SimpleEntry(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)));
- return this;
- }
-
- public StoreResponseBuilder withSessionToken(String sessionToken) {
- headerEntries.add(new AbstractMap.SimpleEntry(HttpConstants.HttpHeaders.SESSION_TOKEN, sessionToken));
- return this;
- }
-
- public StoreResponseBuilder withStatus(int status) {
- this.status = status;
- return this;
- }
-
- public StoreResponseBuilder withContent(String content) {
- this.content = content;
- return this;
- }
-
- public StoreResponse build() {
- return new StoreResponse(status, headerEntries, content);
- }
-}
\ No newline at end of file
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestContextValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestContextValidator.java
deleted file mode 100644
index 5458c36929b9..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestContextValidator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import com.microsoft.azure.cosmosdb.internal.OperationType;
-import com.microsoft.azure.cosmosdb.internal.ResourceType;
-import com.microsoft.azure.cosmosdb.internal.directconnectivity.StoreResponse;
-import com.microsoft.azure.cosmosdb.rx.internal.DocumentServiceRequestContext;
-import com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public interface DocumentServiceRequestContextValidator {
-
- static Builder builder() {
- return new Builder();
- }
-
- void validate(T v);
-
- class Builder {
- private List> validators = new ArrayList<>();
-
- public DocumentServiceRequestContextValidator build() {
- return new DocumentServiceRequestContextValidator() {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void validate(T v) {
- for (DocumentServiceRequestContextValidator validator : validators) {
- validator.validate(v);
- }
- }
- };
- }
-
-
- public Builder add(DocumentServiceRequestContextValidator validator) {
- validators.add(validator);
- return this;
- }
-
- public Builder qurorumSelectedLSN(long quoriumSelectedLSN) {
- add(new DocumentServiceRequestContextValidator() {
- @Override
- public void validate(DocumentServiceRequestContext v) {
- assertThat(v.quorumSelectedLSN).isEqualTo(quoriumSelectedLSN);
- }
- });
- return this;
- }
-
- public Builder globalCommittedSelectedLSN(long globalCommittedSelectedLSN) {
- add(new DocumentServiceRequestContextValidator() {
- @Override
- public void validate(DocumentServiceRequestContext v) {
- assertThat(v.globalCommittedSelectedLSN).isEqualTo(globalCommittedSelectedLSN);
- }
- });
- return this;
- }
-
- public Builder storeResponses(List storeResponses) {
- add(new DocumentServiceRequestContextValidator() {
- @Override
- public void validate(DocumentServiceRequestContext v) {
- assertThat(v.storeResponses).isEqualTo(storeResponses);
- }
- });
- return this;
- }
- }
-}
\ No newline at end of file
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestValidator.java
deleted file mode 100644
index d26d13cd3c57..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/DocumentServiceRequestValidator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import com.microsoft.azure.cosmosdb.internal.OperationType;
-import com.microsoft.azure.cosmosdb.internal.ResourceType;
-import com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceRequest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public interface DocumentServiceRequestValidator {
-
- static Builder builder() {
- return new Builder();
- }
-
- void validate(T v);
-
- class Builder {
- private List> validators = new ArrayList<>();
-
- public DocumentServiceRequestValidator build() {
- return new DocumentServiceRequestValidator() {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void validate(T v) {
- for (DocumentServiceRequestValidator validator : validators) {
- validator.validate(v);
- }
- }
- };
- }
-
- public Builder add(DocumentServiceRequestValidator validator) {
- validators.add(validator);
- return this;
- }
-
- public Builder withResourceType(ResourceType resourceType) {
- add(new DocumentServiceRequestValidator() {
- @Override
- public void validate(T v) {
- assertThat(v.getResourceType()).isEqualTo(resourceType);
- }
- });
- return this;
- }
-
- public Builder withOperationType(OperationType operationType) {
- add(new DocumentServiceRequestValidator() {
- @Override
- public void validate(T v) {
- assertThat(v.getOperationType()).isEqualTo(operationType);
- }
- });
- return this;
- }
-
- public Builder resourceTypeIn(ResourceType... resourceType) {
- add(new DocumentServiceRequestValidator() {
- @Override
- public void validate(T v) {
- assertThat(v.getResourceType()).isIn((Object[]) resourceType);
- }
- });
- return this;
- }
-
- public Builder resourceTypeNotIn(ResourceType... resourceType) {
- add(new DocumentServiceRequestValidator() {
- @Override
- public void validate(T v) {
- assertThat(v.getResourceType()).isNotIn((Object[]) resourceType);
- }
- });
- return this;
- }
-
- public Builder add(DocumentServiceRequestContextValidator validator) {
- add(new DocumentServiceRequestValidator() {
- @Override
- public void validate(RxDocumentServiceRequest request) {
- validator.validate(request.requestContext);
- }
- });
- return this;
- }
- }
-}
\ No newline at end of file
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FailureValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FailureValidator.java
deleted file mode 100644
index 2ad5ec534aa6..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FailureValidator.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import com.microsoft.azure.cosmosdb.BridgeInternal;
-import com.microsoft.azure.cosmosdb.DocumentClientException;
-import com.microsoft.azure.cosmosdb.Error;
-import com.microsoft.azure.cosmosdb.internal.HttpConstants;
-import com.microsoft.azure.cosmosdb.internal.directconnectivity.WFConstants;
-import com.microsoft.azure.cosmosdb.rx.internal.RMResources;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public interface FailureValidator {
-
- static Builder builder() {
- return new Builder();
- }
-
- void validate(Throwable t);
-
- class Builder {
- private List validators = new ArrayList<>();
-
- public FailureValidator build() {
- return new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- for (FailureValidator validator : validators) {
- validator.validate(t);
- }
- }
- };
- }
-
- public Builder statusCode(int statusCode) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getStatusCode()).isEqualTo(statusCode);
- }
- });
- return this;
- }
-
- public Builder lsnGreaterThan(long quorumAckedLSN) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(BridgeInternal.getLSN((DocumentClientException) t) > quorumAckedLSN).isTrue();
- }
- });
- return this;
- }
-
- public Builder lsnGreaterThanEqualsTo(long quorumAckedLSN) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(BridgeInternal.getLSN((DocumentClientException) t) >= quorumAckedLSN).isTrue();
- }
- });
- return this;
- }
-
- public Builder exceptionQuorumAckedLSNInNotNull() {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException documentClientException = (DocumentClientException) t;
- long exceptionQuorumAckedLSN = -1;
- if (documentClientException.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN) != null) {
- exceptionQuorumAckedLSN = Long.parseLong((String) documentClientException.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN));
-
- }
- assertThat(exceptionQuorumAckedLSN).isNotEqualTo(-1);
- }
- });
- return this;
- }
-
- public Builder errorMessageContains(String errorMsg) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t.getMessage()).contains(errorMsg);
- }
- });
- return this;
- }
-
- public Builder notNullActivityId() {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getActivityId()).isNotNull();
- }
- });
- return this;
- }
-
- public Builder error(Error error) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getError().toJson()).isEqualTo(error.toJson());
- }
- });
- return this;
- }
-
- public Builder subStatusCode(Integer substatusCode) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getSubStatusCode()).isEqualTo(substatusCode);
- }
- });
- return this;
- }
-
- public Builder unknownSubStatusCode() {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getSubStatusCode()).isEqualTo(HttpConstants.SubStatusCodes.UNKNOWN);
- }
- });
- return this;
- }
-
- public Builder responseHeader(String key, String value) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- assertThat(((DocumentClientException) t).getResponseHeaders().get(key)).isEqualTo(value);
- }
- });
- return this;
- }
-
- public Builder lsn(long lsn) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(BridgeInternal.getLSN(ex)).isEqualTo(lsn);
- }
- });
- return this;
- }
-
- public Builder partitionKeyRangeId(String pkrid) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(BridgeInternal.getPartitionKeyRangeId(ex)).isEqualTo(pkrid);
- }
- });
- return this;
- }
-
- public Builder resourceAddress(String resourceAddress) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(BridgeInternal.getResourceAddress(ex)).isEqualTo(resourceAddress);
- }
- });
- return this;
- }
-
- public Builder instanceOf(Class cls) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(cls);
- }
- });
- return this;
- }
-
- public Builder sameAs(Exception exception) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isSameAs(exception);
- }
- });
- return this;
- }
-
- public Builder resourceNotFound() {
-
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(ex.getStatusCode()).isEqualTo(404);
-
- }
- });
- return this;
- }
-
- public Builder resourceTokenNotFound() {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(IllegalArgumentException.class);
- IllegalArgumentException ex = (IllegalArgumentException) t;
- assertThat(ex.getMessage()).isEqualTo(RMResources.ResourceTokenNotFound);
- }
- });
- return this;
- }
-
- public Builder resourceAlreadyExists() {
-
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(ex.getStatusCode()).isEqualTo(409);
-
- }
- });
- return this;
- }
-
- public Builder causeInstanceOf(Class cls) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t.getCause()).isNotNull();
- assertThat(t.getCause()).isInstanceOf(cls);
- }
- });
- return this;
- }
-
- public Builder causeOfCauseInstanceOf(Class cls) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t.getCause()).isNotNull();
- assertThat(t.getCause().getCause()).isNotNull();
- assertThat(t.getCause().getCause()).isInstanceOf(cls);
- }
- });
- return this;
- }
-
- public Builder documentClientExceptionHeaderRequestContainsEntry(String key, String value) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(DocumentClientException.class);
- DocumentClientException ex = (DocumentClientException) t;
- assertThat(BridgeInternal.getRequestHeaders(ex)).containsEntry(key, value);
- }
- });
- return this;
- }
-
- public Builder withRuntimeExceptionMessage(String message) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(RuntimeException.class);
- assertThat(t.getMessage()).isEqualTo(message);
- }
- });
- return this;
- }
-
- public Builder withRuntimeExceptionClass(Class k) {
- validators.add(new FailureValidator() {
- @Override
- public void validate(Throwable t) {
- assertThat(t).isNotNull();
- assertThat(t).isInstanceOf(RuntimeException.class);
- assertThat(t).isInstanceOf(k);
- }
- });
- return this;
- }
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseListValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseListValidator.java
deleted file mode 100644
index 6356f1363fff..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseListValidator.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.time.Duration;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import com.microsoft.azure.cosmosdb.BridgeInternal;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.microsoft.azure.cosmosdb.CompositePath;
-import com.microsoft.azure.cosmosdb.Document;
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.QueryMetrics;
-import com.microsoft.azure.cosmosdb.Resource;
-
-public interface FeedResponseListValidator {
-
- void validate(List> feedList);
-
- class Builder {
- private List> validators = new ArrayList<>();
-
- public FeedResponseListValidator build() {
- return new FeedResponseListValidator() {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void validate(List> feedList) {
- for (FeedResponseListValidator validator : validators) {
- validator.validate(feedList);
- }
- }
- };
- }
-
- public Builder totalSize(final int expectedCount) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- int resultCount = feedList.stream().mapToInt(f -> f.getResults().size()).sum();
- assertThat(resultCount)
- .describedAs("total number of results").isEqualTo(expectedCount);
- }
- });
- return this;
- }
-
- public Builder containsExactly(List expectedIds) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- List actualIds = feedList
- .stream()
- .flatMap(f -> f.getResults().stream())
- .map(r -> r.getResourceId())
- .collect(Collectors.toList());
- assertThat(actualIds)
- .describedAs("Resource IDs of results")
- .containsExactlyElementsOf(expectedIds);
- }
- });
- return this;
- }
-
- public Builder validateAllResources(Map> resourceIDToValidator) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- List resources = feedList
- .stream()
- .flatMap(f -> f.getResults().stream())
- .collect(Collectors.toList());
-
- for(T r: resources) {
- ResourceValidator validator = resourceIDToValidator.get(r.getResourceId());
- assertThat(validator).isNotNull();
- validator.validate(r);
- }
- }
- });
- return this;
- }
-
- public Builder exactlyContainsInAnyOrder(List expectedIds) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- List actualIds = feedList
- .stream()
- .flatMap(f -> f.getResults().stream())
- .map(r -> r.getResourceId())
- .collect(Collectors.toList());
- assertThat(actualIds)
- .describedAs("Resource IDs of results")
- .containsOnlyElementsOf(expectedIds);
- }
- });
- return this;
- }
-
- public Builder numberOfPages(int expectedNumberOfPages) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- assertThat(feedList)
- .describedAs("number of pages")
- .hasSize(expectedNumberOfPages);
- }
- });
- return this;
- }
-
- public Builder numberOfPagesIsGreaterThanOrEqualTo(int leastNumber) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- assertThat(feedList.size())
- .describedAs("number of pages")
- .isGreaterThanOrEqualTo(leastNumber);
- }
- });
- return this;
- }
-
- public Builder totalRequestChargeIsAtLeast(double minimumCharge) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- assertThat(feedList.stream().mapToDouble(p -> p.getRequestCharge()).sum())
- .describedAs("total request charge")
- .isGreaterThanOrEqualTo(minimumCharge);
- }
- });
- return this;
- }
-
- public Builder pageSatisfy(int pageNumber, FeedResponseValidator pageValidator) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- assertThat(feedList.size()).isGreaterThan(pageNumber);
- pageValidator.validate(feedList.get(pageNumber));
- }
- });
- return this;
- }
-
- public Builder allPagesSatisfy(FeedResponseValidator pageValidator) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
-
- for(FeedResponse fp: feedList) {
- pageValidator.validate(fp);
- }
- }
- });
- return this;
- }
-
- public Builder withAggregateValue(Object value) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- List list = feedList.get(0).getResults();
- Document result = list.size() > 0 ? list.get(0) : null;
-
- if (result != null) {
- if (value instanceof Double) {
-
- Double d = result.getDouble("_aggregate");
- assertThat(d).isEqualTo(value);
- } else if (value instanceof Integer) {
-
- Integer d = result.getInt("_aggregate");
- assertThat(d).isEqualTo(value);
- } else if (value instanceof String) {
-
- String d = result.getString("_aggregate");
- assertThat(d).isEqualTo(value);
- } else if (value instanceof Document){
-
- assertThat(result.toString()).isEqualTo(value.toString());
- } else {
-
- assertThat(result.get("_aggregate")).isNull();
- assertThat(value).isNull();
- }
- } else {
-
- assertThat(value).isNull();
- }
-
- }
- });
- return this;
- }
-
- public Builder withOrderedResults(ArrayList expectedOrderedList,
- ArrayList compositeIndex) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
-
- List resultOrderedList = feedList.stream()
- .flatMap(f -> f.getResults().stream())
- .collect(Collectors.toList());
- assertThat(expectedOrderedList.size()).isEqualTo(resultOrderedList.size());
-
- ArrayList paths = new ArrayList();
- Iterator compositeIndexIterator = compositeIndex.iterator();
- while (compositeIndexIterator.hasNext()) {
- paths.add(compositeIndexIterator.next().getPath().replace("/", ""));
- }
- for (int i = 0; i < resultOrderedList.size(); i ++) {
- ArrayNode resultValues = (ArrayNode) resultOrderedList.get(i).get("$1");
- assertThat(resultValues.size()).isEqualTo(paths.size());
- for (int j = 0; j < paths.size(); j++) {
- if (paths.get(j).contains("number")) {
- assertThat(expectedOrderedList.get(i).getInt(paths.get(j))).isEqualTo(resultValues.get(j).intValue());
- } else if (paths.get(j).toLowerCase().contains("string")) {
- assertThat(expectedOrderedList.get(i).getString(paths.get(j))).isEqualTo(resultValues.get(j).asText());
- } else if (paths.get(j).contains("bool")) {
- assertThat(expectedOrderedList.get(i).getBoolean(paths.get(j))).isEqualTo(resultValues.get(j).asBoolean());
- } else {
- assertThat(resultValues.get(j).isNull()).isTrue();
- assertThat(expectedOrderedList.get(i).get("nullField")).isNull();
- }
- }
- }
-
- }
- });
- return this;
- }
-
- public Builder pageLengths(int[] pageLengths) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- assertThat(feedList).hasSize(pageLengths.length);
- for (int i = 0; i < pageLengths.length; i++)
- assertThat(feedList.get(i).getResults().size()).isEqualTo(pageLengths[i]);
- }
- });
- return this;
- }
-
- public Builder hasValidQueryMetrics(boolean shouldHaveMetrics) {
- validators.add(new FeedResponseListValidator() {
- @Override
- public void validate(List> feedList) {
- for(FeedResponse feedPage: feedList) {
- if (shouldHaveMetrics) {
- QueryMetrics queryMetrics = BridgeInternal.createQueryMetricsFromCollection(feedPage.getQueryMetrics().values());
- assertThat(queryMetrics.getIndexHitDocumentCount()).isGreaterThanOrEqualTo(0);
- assertThat(queryMetrics.getRetrievedDocumentSize()).isGreaterThan(0);
- assertThat(queryMetrics.getTotalQueryExecutionTime().compareTo(Duration.ZERO)).isGreaterThan(0);
- assertThat(queryMetrics.getOutputDocumentCount()).isGreaterThan(0);
- assertThat(queryMetrics.getRetrievedDocumentCount()).isGreaterThan(0);
- assertThat(queryMetrics.getDocumentLoadTime().compareTo(Duration.ZERO)).isGreaterThan(0);
- assertThat(queryMetrics.getDocumentWriteTime().compareTo(Duration.ZERO)).isGreaterThanOrEqualTo(0);
- assertThat(queryMetrics.getVMExecutionTime().compareTo(Duration.ZERO)).isGreaterThan(0);
- assertThat(queryMetrics.getQueryPreparationTimes().getLogicalPlanBuildTime().compareTo(Duration.ZERO)).isGreaterThan(0);
- assertThat(queryMetrics.getQueryPreparationTimes().getPhysicalPlanBuildTime().compareTo(Duration.ZERO)).isGreaterThanOrEqualTo(0);
- assertThat(queryMetrics.getQueryPreparationTimes().getQueryCompilationTime().compareTo(Duration.ZERO)).isGreaterThan(0);
- assertThat(queryMetrics.getRuntimeExecutionTimes().getQueryEngineExecutionTime().compareTo(Duration.ZERO)).isGreaterThanOrEqualTo(0);
- assertThat(BridgeInternal.getClientSideMetrics(queryMetrics).getRequestCharge()).isGreaterThan(0);
- } else {
- assertThat(feedPage.getQueryMetrics().isEmpty());
- }
- }
- }
- });
- return this;
- }
- }
-}
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseValidator.java
deleted file mode 100644
index d245f6f49593..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/FeedResponseValidator.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import com.microsoft.azure.cosmosdb.FeedResponse;
-import com.microsoft.azure.cosmosdb.Resource;
-import com.microsoft.azure.cosmosdb.internal.HttpConstants;
-
-public interface FeedResponseValidator {
-
- void validate(FeedResponse feedList);
-
- public class Builder {
- private List> validators = new ArrayList<>();
-
- public FeedResponseValidator build() {
- return new FeedResponseValidator() {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void validate(FeedResponse feedPage) {
- for (FeedResponseValidator validator : validators) {
- validator.validate(feedPage);
- }
- }
- };
- }
-
- public Builder pageSizeIsLessThanOrEqualTo(final int maxPageSize) {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getResults().size()).isLessThanOrEqualTo(maxPageSize);
- }
- });
- return this;
- }
-
- public Builder pageSizeOf(final int expectedCount) {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getResults()).hasSize(expectedCount);
- }
- });
- return this;
- }
-
- public Builder positiveRequestCharge() {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getRequestCharge()).isPositive();
- }
- });
- return this;
- }
-
- public Builder requestChargeGreaterThanOrEqualTo(double minRequestCharge) {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getRequestCharge()).isGreaterThanOrEqualTo(minRequestCharge);
- }
- });
- return this;
- }
-
- public Builder requestChargeLessThanOrEqualTo(double maxRequestCharge) {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getRequestCharge()).isLessThanOrEqualTo(maxRequestCharge);
- }
- });
- return this;
- }
-
- public Builder hasHeader(String headerKey) {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getResponseHeaders()).containsKey(headerKey);
- }
- });
- return this;
- }
-
- public Builder hasRequestChargeHeader() {
-
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage.getResponseHeaders()).containsKey(HttpConstants.HttpHeaders.REQUEST_CHARGE);
- }
- });
- return this;
- }
-
- public Builder idsExactlyAre(final List expectedIds) {
- validators.add(new FeedResponseValidator() {
- @Override
- public void validate(FeedResponse feedPage) {
- assertThat(feedPage
- .getResults().stream()
- .map(r -> r.getResourceId())
- .collect(Collectors.toList()))
- .containsExactlyElementsOf(expectedIds);
- }
- });
- return this;
- }
- }
-}
\ No newline at end of file
diff --git a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/ResourceResponseValidator.java b/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/ResourceResponseValidator.java
deleted file mode 100644
index 0686e7df1336..000000000000
--- a/cosmosdb/data-plane/commons-test-utils/src/main/java/com/microsoft/azure/cosmosdb/rx/ResourceResponseValidator.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * The MIT License (MIT)
- * Copyright (c) 2018 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package com.microsoft.azure.cosmosdb.rx;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.assertj.core.api.Condition;
-
-import com.microsoft.azure.cosmosdb.Attachment;
-import com.microsoft.azure.cosmosdb.CompositePath;
-import com.microsoft.azure.cosmosdb.DocumentCollection;
-import com.microsoft.azure.cosmosdb.IndexingMode;
-import com.microsoft.azure.cosmosdb.Offer;
-import com.microsoft.azure.cosmosdb.Permission;
-import com.microsoft.azure.cosmosdb.PermissionMode;
-import com.microsoft.azure.cosmosdb.Resource;
-import com.microsoft.azure.cosmosdb.ResourceResponse;
-import com.microsoft.azure.cosmosdb.SpatialSpec;
-import com.microsoft.azure.cosmosdb.StoredProcedure;
-import com.microsoft.azure.cosmosdb.Trigger;
-import com.microsoft.azure.cosmosdb.TriggerOperation;
-import com.microsoft.azure.cosmosdb.TriggerType;
-import com.microsoft.azure.cosmosdb.UserDefinedFunction;
-import com.microsoft.azure.cosmosdb.SpatialType;
-
-public interface ResourceResponseValidator {
-
- static Builder builder() {
- return new Builder();
- }
-
- void validate(ResourceResponse resourceResponse);
-
- class Builder {
- private List> validators = new ArrayList<>();
-
- public ResourceResponseValidator build() {
- return new ResourceResponseValidator() {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void validate(ResourceResponse resourceResponse) {
- for (ResourceResponseValidator validator : validators) {
- validator.validate(resourceResponse);
- }
- }
- };
- }
-
- public Builder withId(final String resourceId) {
- validators.add(new ResourceResponseValidator() {
-
- @Override
- public void validate(ResourceResponse resourceResponse) {
- assertThat(resourceResponse.getResource()).isNotNull();
- assertThat(resourceResponse.getResource().getId()).as("check Resource Id").isEqualTo(resourceId);
- }
- });
- return this;
- }
-
- public Builder nullResource() {
- validators.add(new ResourceResponseValidator() {
-
- @Override
- public void validate(ResourceResponse resourceResponse) {
- assertThat(resourceResponse.getResource()).isNull();
- }
- });
- return this;
- }
-
- public Builder withProperty(String propertyName, Condition