-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
14,960 additions
and
7,328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ClientOfficialVersion>3.17.0</ClientOfficialVersion> | ||
<ClientPreviewVersion>3.17.0</ClientPreviewVersion> | ||
<ClientPreviewSuffixVersion>preview1</ClientPreviewSuffixVersion> | ||
<DirectVersion>3.17.1</DirectVersion> | ||
<EncryptionVersion>1.0.0-previewV12</EncryptionVersion> | ||
<HybridRowVersion>1.1.0-preview1</HybridRowVersion> | ||
<ClientOfficialVersion>3.17.1</ClientOfficialVersion> | ||
<ClientPreviewVersion>3.18.0</ClientPreviewVersion> | ||
<ClientPreviewSuffixVersion>preview</ClientPreviewSuffixVersion> | ||
<DirectVersion>3.17.2</DirectVersion> | ||
<EncryptionVersion>1.0.0-previewV13</EncryptionVersion> | ||
<HybridRowVersion>1.1.0-preview3</HybridRowVersion> | ||
<AboveDirBuildProps>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</AboveDirBuildProps> | ||
<DefineConstants Condition=" '$(IsNightly)' == 'true' or '$(IsPreview)' == 'true' ">$(DefineConstants);PREVIEW</DefineConstants> | ||
</PropertyGroup> | ||
<Import Project="$(AboveDirBuildProps)" Condition=" '$(AboveDirBuildProps)' != '' " /> | ||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
....Cosmos.Samples/Tools/Benchmark/v3/ReadStreamExistsWithDiagnosticsV3BenchmarkOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace CosmosBenchmark | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Cosmos; | ||
|
||
internal class ReadStreamExistsWithDiagnosticsV3BenchmarkOperation : IBenchmarkOperation | ||
{ | ||
private readonly Container container; | ||
private readonly string partitionKeyPath; | ||
private readonly Dictionary<string, object> sampleJObject; | ||
|
||
private readonly string databsaeName; | ||
private readonly string containerName; | ||
|
||
private string nextExecutionItemPartitionKey; | ||
private string nextExecutionItemId; | ||
|
||
public ReadStreamExistsWithDiagnosticsV3BenchmarkOperation( | ||
CosmosClient cosmosClient, | ||
string dbName, | ||
string containerName, | ||
string partitionKeyPath, | ||
string sampleJson) | ||
{ | ||
this.databsaeName = dbName; | ||
this.containerName = containerName; | ||
|
||
this.container = cosmosClient.GetContainer(this.databsaeName, this.containerName); | ||
this.partitionKeyPath = partitionKeyPath.Replace("/", ""); | ||
|
||
this.sampleJObject = JsonHelper.Deserialize<Dictionary<string, object>>(sampleJson); | ||
} | ||
|
||
public async Task<OperationResult> ExecuteOnceAsync() | ||
{ | ||
using (ResponseMessage itemResponse = await this.container.ReadItemStreamAsync( | ||
this.nextExecutionItemId, | ||
new PartitionKey(this.nextExecutionItemPartitionKey))) | ||
{ | ||
if (itemResponse.StatusCode != HttpStatusCode.OK) | ||
{ | ||
throw new Exception($"ReadItem failed wth {itemResponse.StatusCode}"); | ||
} | ||
|
||
string diagnostics = itemResponse.Diagnostics.ToString(); | ||
if (string.IsNullOrEmpty(diagnostics)) | ||
{ | ||
throw new Exception(); | ||
} | ||
|
||
return new OperationResult() | ||
{ | ||
DatabseName = databsaeName, | ||
ContainerName = containerName, | ||
RuCharges = itemResponse.Headers.RequestCharge, | ||
CosmosDiagnostics = itemResponse.Diagnostics, | ||
LazyDiagnostics = () => itemResponse.Diagnostics.ToString(), | ||
}; | ||
} | ||
} | ||
|
||
public async Task PrepareAsync() | ||
{ | ||
if (string.IsNullOrEmpty(this.nextExecutionItemId) || | ||
string.IsNullOrEmpty(this.nextExecutionItemPartitionKey)) | ||
{ | ||
this.nextExecutionItemId = Guid.NewGuid().ToString(); | ||
this.nextExecutionItemPartitionKey = Guid.NewGuid().ToString(); | ||
|
||
this.sampleJObject["id"] = this.nextExecutionItemId; | ||
this.sampleJObject[this.partitionKeyPath] = this.nextExecutionItemPartitionKey; | ||
|
||
using (MemoryStream inputStream = JsonHelper.ToStream(this.sampleJObject)) | ||
{ | ||
using (ResponseMessage itemResponse = await this.container.CreateItemStreamAsync( | ||
inputStream, | ||
new PartitionKey(this.nextExecutionItemPartitionKey))) | ||
{ | ||
|
||
System.Buffers.ArrayPool<byte>.Shared.Return(inputStream.GetBuffer()); | ||
|
||
if (itemResponse.StatusCode != HttpStatusCode.Created) | ||
{ | ||
throw new Exception($"Create failed with statuscode: {itemResponse.StatusCode}"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.