From d4990ec4fc42aa2fb1b55bd43c454067e141cd7b Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Mon, 16 Jan 2023 12:44:09 +0530 Subject: [PATCH 01/10] Added Priority Level as a Request Option --- Microsoft.Azure.Cosmos/src/DocumentClient.cs | 5 + .../src/RequestOptions/RequestOptions.cs | 10 + .../src/Resource/Settings/PriorityLevel.cs | 22 ++ .../PriorityLevelTests.cs | 190 ++++++++++++++++++ 4 files changed, 227 insertions(+) create mode 100644 Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs create mode 100644 Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 8aafec61fc..e5abe6aa22 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -6899,6 +6899,11 @@ private INameValueCollection GetRequestHeaders( headers.Set(HttpConstants.HttpHeaders.ConsistencyLevel, options.ConsistencyLevel.ToString()); } + if (options.PriorityLevel.HasValue) + { + headers.Set(HttpConstants.HttpHeaders.PriorityLevel, options.PriorityLevel.ToString()); + } + if (options.IndexingDirective.HasValue) { headers.Set(HttpConstants.HttpHeaders.IndexingDirective, options.IndexingDirective.ToString()); diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs index 5387a0fbac..00b0d87185 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs @@ -42,6 +42,11 @@ public class RequestOptions /// public Action AddRequestHeaders { get; set; } + /// + /// Gets or sets the priority level for a request. + /// + public PriorityLevel? PriorityLevel { get; set; } + /// /// Set Request Level Distributed Tracing Options. /// @@ -91,6 +96,11 @@ internal virtual void PopulateRequestOptions(RequestMessage request) request.Headers.Add(HttpConstants.HttpHeaders.IfNoneMatch, this.IfNoneMatchEtag); } + if (this.PriorityLevel.HasValue) + { + request.Headers.Add(HttpConstants.HttpHeaders.PriorityLevel, this.PriorityLevel.ToString()); + } + this.AddRequestHeaders?.Invoke(request.Headers); } diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs new file mode 100644 index 0000000000..deaddf8942 --- /dev/null +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +//------------------------------------------------------------ + +namespace Microsoft.Azure.Cosmos +{ + /// + /// Priority Level of Request + /// + public enum PriorityLevel + { + /// + /// High Priority + /// + High, + + /// + /// Low Priority + /// + Low + } +} diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs new file mode 100644 index 0000000000..e6533a9dde --- /dev/null +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs @@ -0,0 +1,190 @@ +namespace Microsoft.Azure.Cosmos.EmulatorTests +{ + using System; + using System.Linq; + using System.Threading.Tasks; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using Newtonsoft.Json; + using Microsoft.Azure.Cosmos.Fluent; + using Microsoft.Azure.Cosmos; + using IndexingPolicy = IndexingPolicy; + using IndexingMode = IndexingMode; + using PriorityLevel = PriorityLevel; + + [TestClass] + public class PriorityLevelTests + { + // The Azure Cosmos DB endpoint for running this sample. + private static readonly string EndpointUri = "https://testdocumentservice-northcentralus.documents-test.windows-int.net:443/"; + // The primary key for the Azure Cosmos account. + private static readonly string PrimaryKey = ""; + + private Cosmos.Database database; + + private Container container; + + private CosmosClient cosmosClient; + + private readonly string databaseId = "db_priorityMixed"; + private readonly string containerId = "col"; + + private class Document + { + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + [JsonProperty(PropertyName = "address")] + public string Address { get; set; } + + [JsonProperty(PropertyName = "city")] + public string City { get; set; } + + [JsonProperty(PropertyName = "pkey")] + public string Pkey { get; set; } + + } + + public async Task InitializeTest() + { + // Direct Mode + CosmosClientBuilder builder = null; + try + { + builder = new CosmosClientBuilder(EndpointUri, PrimaryKey); + } + catch (CosmosException) + { + Console.WriteLine("CosmosClientBuilder error"); + } + + try + { + builder.WithConnectionModeDirect() + .WithThrottlingRetryOptions(TimeSpan.FromSeconds(1), 0); + } + catch (CosmosException) + { + Console.WriteLine("WithConnectionModeDirect error"); + } + this.cosmosClient = builder.Build(); + + await this.CreateDatabaseAsync(); + await this.CreateContainerAsync(); + } + private async Task CreateDatabaseAsync() + { + // Create a new database + this.database = await this.cosmosClient.CreateDatabaseIfNotExistsAsync(this.databaseId); + Console.WriteLine("Created Database: {0}\n", this.database.Id); + } + + private async Task CreateContainerAsync() + { + // Create a new container + IndexingPolicy policy = new() + { + IndexingMode = IndexingMode.None, + Automatic = false + }; + ContainerProperties options = new(this.containerId, "/pkey") + { + IndexingPolicy = policy + }; + ContainerResponse containerResponse = await this.database.CreateContainerIfNotExistsAsync(options, throughput: 1600); + this.container = containerResponse.Container; + Console.WriteLine("Created Container: {0}\n", this.container.Id); + } + + [TestMethod] + public async Task PriorityLevelHighDirectTestAsync() + { + await this.InitializeTest(); + + Document doc = new Document() + { + Id = "id", + Address = "address1", + Pkey = "pkey1" + }; + try + { + for (int i = 0; i < 10; i++) + { + doc.Id = "id" + i; + ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), requestOptions: new ItemRequestOptions { PriorityLevel = Cosmos.PriorityLevel.High }); + } + } + catch (CosmosException) + { + Assert.Fail("Document insert failed with Priority Level Headers"); + } + } + + [TestMethod] + public async Task PriorityLevelLowDirectTestAsync() + { + await this.InitializeTest(); + + Document doc = new Document() + { + Id = "id", + Address = "address1", + Pkey = "pkey1" + }; + try + { + for (int i = 10; i < 20; i++) + { + doc.Id = "id" + i; + ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), requestOptions: new ItemRequestOptions { PriorityLevel = Cosmos.PriorityLevel.Low }); + } + } + catch (CosmosException) + { + Assert.Fail("Document insert failed with Priority Level Headers"); + } + } + + [TestMethod] + public async Task DirectTestAsync() + { + await this.InitializeTest(); + + Document doc = new Document() + { + Id = "id", + Address = "address1", + Pkey = "pkey1" + }; + Microsoft.Azure.Cosmos.ItemRequestOptions itemRequestOptions = new ItemRequestOptions(); + try + { + doc.Id = "id"; + ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), itemRequestOptions); + } + catch (CosmosException) + { + Assert.Fail("Document insert failed with Priority Level Headers"); + } + } + + [TestCleanup] + public async Task TestCleanupAsync() + { + if (this.container != null) + { + await this.container.DeleteContainerAsync(); + } + + if (this.database != null) + { + await this.database.DeleteAsync(); + } + + this.cosmosClient?.Dispose(); + } + } +} \ No newline at end of file From 438ba479f53533d46a63b84e517da235bc45369d Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Fri, 20 Jan 2023 11:44:33 +0530 Subject: [PATCH 02/10] Changed Priority Level Low and High to 1 and 2 respectively --- Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs index deaddf8942..7bccc09ce7 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs @@ -12,11 +12,11 @@ public enum PriorityLevel /// /// High Priority /// - High, + High = 1, /// /// Low Priority /// - Low + Low = 2, } } From e2104e059402315522f6b067722e1a6ed17752b0 Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Fri, 3 Feb 2023 09:44:27 +0530 Subject: [PATCH 03/10] Bumped DirectVersion --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 658186357b..d04b35b068 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ 3.31.2 3.31.2 preview - 3.30.0 + 3.30.2 2.0.0 2.0.0 preview From c64a67ec50dd3b88ad577163df85d39c474976e1 Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Fri, 3 Feb 2023 09:51:48 +0530 Subject: [PATCH 04/10] Added made PriorityLevel internal for non preview packages --- .../src/RequestOptions/RequestOptions.cs | 7 ++++++- .../src/Resource/Settings/PriorityLevel.cs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs index 00b0d87185..bb36afb5a1 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs @@ -45,7 +45,12 @@ public class RequestOptions /// /// Gets or sets the priority level for a request. /// - public PriorityLevel? PriorityLevel { get; set; } +#if PREVIEW + public +#else + internal +#endif + PriorityLevel? PriorityLevel { get; set; } /// /// Set Request Level Distributed Tracing Options. diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs index 7bccc09ce7..443e223378 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs @@ -7,7 +7,12 @@ namespace Microsoft.Azure.Cosmos /// /// Priority Level of Request /// - public enum PriorityLevel +#if PREVIEW + public +#else + internal +#endif + enum PriorityLevel { /// /// High Priority From ed79c255b7870455d68d2fdf6563c309ec41202a Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Fri, 3 Feb 2023 12:27:11 +0530 Subject: [PATCH 05/10] Deleted PriorityLevelTests.cs --- .../PriorityLevelTests.cs | 190 ------------------ 1 file changed, 190 deletions(-) delete mode 100644 Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs deleted file mode 100644 index e6533a9dde..0000000000 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/PriorityLevelTests.cs +++ /dev/null @@ -1,190 +0,0 @@ -namespace Microsoft.Azure.Cosmos.EmulatorTests -{ - using System; - using System.Linq; - using System.Threading.Tasks; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Newtonsoft.Json; - using Microsoft.Azure.Cosmos.Fluent; - using Microsoft.Azure.Cosmos; - using IndexingPolicy = IndexingPolicy; - using IndexingMode = IndexingMode; - using PriorityLevel = PriorityLevel; - - [TestClass] - public class PriorityLevelTests - { - // The Azure Cosmos DB endpoint for running this sample. - private static readonly string EndpointUri = "https://testdocumentservice-northcentralus.documents-test.windows-int.net:443/"; - // The primary key for the Azure Cosmos account. - private static readonly string PrimaryKey = ""; - - private Cosmos.Database database; - - private Container container; - - private CosmosClient cosmosClient; - - private readonly string databaseId = "db_priorityMixed"; - private readonly string containerId = "col"; - - private class Document - { - [JsonProperty(PropertyName = "id")] - public string Id { get; set; } - - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - [JsonProperty(PropertyName = "address")] - public string Address { get; set; } - - [JsonProperty(PropertyName = "city")] - public string City { get; set; } - - [JsonProperty(PropertyName = "pkey")] - public string Pkey { get; set; } - - } - - public async Task InitializeTest() - { - // Direct Mode - CosmosClientBuilder builder = null; - try - { - builder = new CosmosClientBuilder(EndpointUri, PrimaryKey); - } - catch (CosmosException) - { - Console.WriteLine("CosmosClientBuilder error"); - } - - try - { - builder.WithConnectionModeDirect() - .WithThrottlingRetryOptions(TimeSpan.FromSeconds(1), 0); - } - catch (CosmosException) - { - Console.WriteLine("WithConnectionModeDirect error"); - } - this.cosmosClient = builder.Build(); - - await this.CreateDatabaseAsync(); - await this.CreateContainerAsync(); - } - private async Task CreateDatabaseAsync() - { - // Create a new database - this.database = await this.cosmosClient.CreateDatabaseIfNotExistsAsync(this.databaseId); - Console.WriteLine("Created Database: {0}\n", this.database.Id); - } - - private async Task CreateContainerAsync() - { - // Create a new container - IndexingPolicy policy = new() - { - IndexingMode = IndexingMode.None, - Automatic = false - }; - ContainerProperties options = new(this.containerId, "/pkey") - { - IndexingPolicy = policy - }; - ContainerResponse containerResponse = await this.database.CreateContainerIfNotExistsAsync(options, throughput: 1600); - this.container = containerResponse.Container; - Console.WriteLine("Created Container: {0}\n", this.container.Id); - } - - [TestMethod] - public async Task PriorityLevelHighDirectTestAsync() - { - await this.InitializeTest(); - - Document doc = new Document() - { - Id = "id", - Address = "address1", - Pkey = "pkey1" - }; - try - { - for (int i = 0; i < 10; i++) - { - doc.Id = "id" + i; - ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), requestOptions: new ItemRequestOptions { PriorityLevel = Cosmos.PriorityLevel.High }); - } - } - catch (CosmosException) - { - Assert.Fail("Document insert failed with Priority Level Headers"); - } - } - - [TestMethod] - public async Task PriorityLevelLowDirectTestAsync() - { - await this.InitializeTest(); - - Document doc = new Document() - { - Id = "id", - Address = "address1", - Pkey = "pkey1" - }; - try - { - for (int i = 10; i < 20; i++) - { - doc.Id = "id" + i; - ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), requestOptions: new ItemRequestOptions { PriorityLevel = Cosmos.PriorityLevel.Low }); - } - } - catch (CosmosException) - { - Assert.Fail("Document insert failed with Priority Level Headers"); - } - } - - [TestMethod] - public async Task DirectTestAsync() - { - await this.InitializeTest(); - - Document doc = new Document() - { - Id = "id", - Address = "address1", - Pkey = "pkey1" - }; - Microsoft.Azure.Cosmos.ItemRequestOptions itemRequestOptions = new ItemRequestOptions(); - try - { - doc.Id = "id"; - ItemResponse response = await this.container.CreateItemAsync(doc, new Cosmos.PartitionKey("pkey1"), itemRequestOptions); - } - catch (CosmosException) - { - Assert.Fail("Document insert failed with Priority Level Headers"); - } - } - - [TestCleanup] - public async Task TestCleanupAsync() - { - if (this.container != null) - { - await this.container.DeleteContainerAsync(); - } - - if (this.database != null) - { - await this.database.DeleteAsync(); - } - - this.cosmosClient?.Dispose(); - } - } -} \ No newline at end of file From 229f6afc15a42cc692c5f46d5e1337e79642fe6f Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Mon, 6 Feb 2023 14:36:34 +0530 Subject: [PATCH 06/10] Added description of Priority Level in RequestOptions.cs --- Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs index bb36afb5a1..ece2ffee50 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs @@ -44,6 +44,8 @@ public class RequestOptions /// /// Gets or sets the priority level for a request. + /// When Priority Based Throttling is enabled, once the user has exhausted their provisioned throughput, + /// low priority requests are throttled before high priority requests start getting throttled. /// #if PREVIEW public From 1dc96df3c10ee79a229ee0da7afba576b7107997 Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:12:00 +0530 Subject: [PATCH 07/10] Modified comments for PriorityLevel in RequestOptions.cs --- Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs index ece2ffee50..32e14a8937 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs @@ -44,9 +44,12 @@ public class RequestOptions /// /// Gets or sets the priority level for a request. + /// + /// /// When Priority Based Throttling is enabled, once the user has exhausted their provisioned throughput, /// low priority requests are throttled before high priority requests start getting throttled. - /// + /// Default PriorityLevel for each request is treated as High. It can be explicitly set to Low for some requests. + /// #if PREVIEW public #else From c69e4a54c913dfb116597486bec8f25e21241f6e Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:09:49 +0530 Subject: [PATCH 08/10] Updated Contracts --- .../Contracts/DotNetPreviewSDKAPI.json | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json index 43801584fe..6586153ff3 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @@ -425,6 +425,52 @@ } }, "NestedTypes": {} + }, + "Microsoft.Azure.Cosmos.PriorityLevel;System.Enum;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:True;IsClass:False;IsValueType:True;IsNested:False;IsGenericType:False;IsSerializable:True": { + "Subclasses": {}, + "Members": { + "Int32 value__": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Int32 value__;IsInitOnly:False;IsStatic:False;" + }, + "Microsoft.Azure.Cosmos.PriorityLevel High": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.PriorityLevel High;IsInitOnly:False;IsStatic:True;" + }, + "Microsoft.Azure.Cosmos.PriorityLevel Low": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.PriorityLevel Low;IsInitOnly:False;IsStatic:True;" + } + }, + "NestedTypes": {} + }, + "Microsoft.Azure.Cosmos.RequestOptions;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { + "Subclasses": {}, + "Members": { + "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] PriorityLevel": { + "Type": "Property", + "Attributes": [], + "MethodInfo": "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] PriorityLevel;CanRead:True;CanWrite:True;System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + } + }, + "NestedTypes": {} } }, "Members": {}, From 002f6dc4b9babe82da2d9f40c13c5bd14f38db08 Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:40:05 +0530 Subject: [PATCH 09/10] Modified Remarks for PriorityLevel and added see also link. --- .../src/RequestOptions/RequestOptions.cs | 12 +++++++++--- .../src/Resource/Settings/PriorityLevel.cs | 14 +++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs index 32e14a8937..dc02f9a248 100644 --- a/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs +++ b/Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs @@ -46,10 +46,16 @@ public class RequestOptions /// Gets or sets the priority level for a request. /// /// - /// When Priority Based Throttling is enabled, once the user has exhausted their provisioned throughput, - /// low priority requests are throttled before high priority requests start getting throttled. + /// Setting priority level only has an effect if Priority Based Execution is enabled. + /// If it is not enabled, the priority level is ignored by the backend. /// Default PriorityLevel for each request is treated as High. It can be explicitly set to Low for some requests. + /// When Priority based execution is enabled, if there are more requests than the configured RU/S in a second, + /// then Cosmos DB will throttle low priority requests to allow high priority requests to execute. + /// This does not limit the throughput available to each priority level. Each priority level can consume the complete + /// provisioned throughput in absence of the other. If both priorities are present and the user goes above the + /// configured RU/s, low priority requests start getting throttled first to allow execution of mission critical workloads. /// + /// #if PREVIEW public #else @@ -61,7 +67,7 @@ public class RequestOptions /// Set Request Level Distributed Tracing Options. /// internal DistributedTracingOptions DistributedTracingOptions { get; set; } - + /// /// Gets or sets the boolean to use effective partition key routing in the cosmos db request. /// diff --git a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs index 443e223378..6644d0931f 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Settings/PriorityLevel.cs @@ -5,8 +5,20 @@ namespace Microsoft.Azure.Cosmos { /// - /// Priority Level of Request + /// Valid values of Priority Level for a request /// + /// + /// Setting priority level only has an effect if Priority Based Execution is enabled. + /// If it is not enabled, the priority level is ignored by the backend. + /// Default PriorityLevel for each request is treated as High. It can be explicitly set to Low for some requests. + /// When Priority based execution is enabled, if there are more requests than the configured RU/S in a second, + /// then Cosmos DB will throttle low priority requests to allow high priority requests to execute. + /// This does not limit the throughput available to each priority level. Each priority level can consume the complete + /// provisioned throughput in absence of the other. If both priorities are present and the user goes above the + /// configured RU/s, low priority requests start getting throttled first to allow execution of mission critical workloads. + /// + /// + #if PREVIEW public #else From f47800e175d3aaae57bb2a9c361309e52c39fdf7 Mon Sep 17 00:00:00 2001 From: Achint-Agrawal <45819170+Achint-Agrawal@users.noreply.github.com> Date: Mon, 27 Mar 2023 23:23:28 +0530 Subject: [PATCH 10/10] Updated contracts --- .../Contracts/DotNetPreviewSDKAPI.json | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json index 39ae1d2eca..8a3d326d50 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @@ -362,6 +362,52 @@ } }, "NestedTypes": {} + }, + "Microsoft.Azure.Cosmos.PriorityLevel;System.Enum;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:True;IsClass:False;IsValueType:True;IsNested:False;IsGenericType:False;IsSerializable:True": { + "Subclasses": {}, + "Members": { + "Int32 value__": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Int32 value__;IsInitOnly:False;IsStatic:False;" + }, + "Microsoft.Azure.Cosmos.PriorityLevel High": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.PriorityLevel High;IsInitOnly:False;IsStatic:True;" + }, + "Microsoft.Azure.Cosmos.PriorityLevel Low": { + "Type": "Field", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.PriorityLevel Low;IsInitOnly:False;IsStatic:True;" + } + }, + "NestedTypes": {} + }, + "Microsoft.Azure.Cosmos.RequestOptions;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { + "Subclasses": {}, + "Members": { + "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] PriorityLevel": { + "Type": "Property", + "Attributes": [], + "MethodInfo": "System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] PriorityLevel;CanRead:True;CanWrite:True;System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel] get_PriorityLevel();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, + "Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": { + "Type": "Method", + "Attributes": [ + "CompilerGeneratedAttribute" + ], + "MethodInfo": "Void set_PriorityLevel(System.Nullable`1[Microsoft.Azure.Cosmos.PriorityLevel]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + } + }, + "NestedTypes": {} } }, "Members": {},