Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Orleans.sln
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.TestingHost.Legacy"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.TestingHost.AppDomain", "test\Orleans.TestingHost.AppDomain\Orleans.TestingHost.AppDomain.csproj", "{DF911257-3617-4B5C-9B78-AED17BA6DC9C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Transactions.DynamoDB", "src\AWS\Orleans.Transactions.DynamoDB\Orleans.Transactions.DynamoDB.csproj", "{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Orleans.Transactions.DynamoDB.Test", "test\Orleans.Transactions.DynamoDB.Test\Orleans.Transactions.DynamoDB.Test.csproj", "{8B3EEA6B-BE00-482D-9625-15A70B534183}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1236,6 +1240,30 @@ Global
{DF911257-3617-4B5C-9B78-AED17BA6DC9C}.Release|x64.Build.0 = Release|Any CPU
{DF911257-3617-4B5C-9B78-AED17BA6DC9C}.Release|x86.ActiveCfg = Release|Any CPU
{DF911257-3617-4B5C-9B78-AED17BA6DC9C}.Release|x86.Build.0 = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|x64.ActiveCfg = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|x64.Build.0 = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|x86.ActiveCfg = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Debug|x86.Build.0 = Debug|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|Any CPU.Build.0 = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|x64.ActiveCfg = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|x64.Build.0 = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|x86.ActiveCfg = Release|Any CPU
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205}.Release|x86.Build.0 = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|x64.ActiveCfg = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|x64.Build.0 = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|x86.ActiveCfg = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Debug|x86.Build.0 = Debug|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|Any CPU.Build.0 = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|x64.ActiveCfg = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|x64.Build.0 = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|x86.ActiveCfg = Release|Any CPU
{8B3EEA6B-BE00-482D-9625-15A70B534183}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1307,6 +1335,7 @@ Global
{CFD22413-CB67-40D6-B389-F038C8C38365} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{BE7FB595-FA25-4D88-8504-E9D4F9D8183D} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
{651C7B8E-6EEB-4A6B-84A3-B5D7E4554B99} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{8B3EEA6B-BE00-482D-9625-15A70B534183} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{E9A8A1F9-1943-45E2-9B9C-1E51A9154D76} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
{B090606B-651C-42CA-B459-1E8CBDE987EA} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
{A47E75C9-283F-4530-90D1-FA57AEFB6F65} = {4C5D66BF-EE1C-4DD8-8551-D1B7F3768A34}
Expand Down Expand Up @@ -1334,6 +1363,7 @@ Global
{262A898E-0EED-4235-908B-322A699CDD01} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{AC640F05-E013-4D80-A1A4-E577D6883D16} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{DF911257-3617-4B5C-9B78-AED17BA6DC9C} = {A6573187-FD0D-4DF7-91D1-03E07E470C0A}
{17A7F27C-DBDE-4339-A7F5-18BD80C3F205} = {DA8E126B-BCDB-4E8F-BFB9-2DBFD41F8F70}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BFB3429-B5BB-4DB1-95B4-67D77A864952}
Expand Down
1 change: 1 addition & 0 deletions Test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set TESTS=^
%CMDHOME%\test\RuntimeCodeGen.Tests,^
%CMDHOME%\test\Orleans.Transactions.Tests,^
%CMDHOME%\test\Orleans.Transactions.Azure.Test,^
%CMDHOME%\test\Orleans.Transactions.DynamoDB.Test,^
%CMDHOME%\test\Orleans.TestingHost.Tests

if []==[%TEST_FILTERS%] set TEST_FILTERS=-trait Category=BVT -trait Category=SlowBVT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task DeleteMembershipTableEntries(string clusterId)
var records = await storage.QueryAsync(this.options.TableName, keys, $"{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME} = :{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", item => new SiloInstanceRecord(item));

var toDelete = new List<Dictionary<string, AttributeValue>>();
foreach (var record in records)
foreach (var record in records.results)
{
toDelete.Add(record.GetKeys());
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task<MembershipTableData> ReadAll()
var keys = new Dictionary<string, AttributeValue> { { $":{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", new AttributeValue(this.clusterId) } };
var records = await this.storage.QueryAsync(this.options.TableName, keys, $"{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME} = :{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", item => new SiloInstanceRecord(item));

MembershipTableData data = Convert(records);
MembershipTableData data = Convert(records.results);
if (this.logger.IsEnabled(LogLevel.Trace)) this.logger.Trace("ReadAll Table=" + Environment.NewLine + "{0}", data.ToString());

return data;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Orleans.Configuration;
using Orleans.Transactions.DynamoDB;

namespace Orleans.Hosting
{
public static class SiloBuilderExtensions
{
/// <summary>
/// Configure cluster to use dynamoDB transaction log using configure action.
/// </summary>
public static ISiloHostBuilder UseDynamoDBTransactionLog(this ISiloHostBuilder builder, Action<DynamoDBTransactionLogOptions> configureOptions)
{
return builder.UseDynamoDBTransactionLog(ob => ob.Configure(configureOptions));
}

/// <summary>
/// Configure cluster to use dynamoDB transaction log using configuration builder.
/// </summary>
public static ISiloHostBuilder UseDynamoDBTransactionLog(this ISiloHostBuilder builder, Action<OptionsBuilder<DynamoDBTransactionLogOptions>> configureOptions)
{
return builder.ConfigureServices(services => services.UseDynamoDBTransactionLog(configureOptions));
}

/// <summary>
/// Configure cluster service to use dynamoDB transaction log using configure action.
/// </summary>
public static IServiceCollection UseDynamoDBTransactionLog(this IServiceCollection services, Action<DynamoDBTransactionLogOptions> configureOptions)
{
return services.UseDynamoDBTransactionLog(ob => ob.Configure(configureOptions));
}

/// <summary>
/// Configure cluster service to use dynamoDB transaction log using configuration builder.
/// </summary>
public static IServiceCollection UseDynamoDBTransactionLog(this IServiceCollection services,
Action<OptionsBuilder<DynamoDBTransactionLogOptions>> configureOptions)
{
configureOptions?.Invoke(services.AddOptions<DynamoDBTransactionLogOptions>());
services.AddTransient<IConfigurationValidator, DynamoDBTransactionLogOptionsValidator>();
services.AddTransient(DynamoDBTransactionLogStorage.Create);
return services;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Microsoft.Orleans.Transactions.DynamoDB</PackageId>
<Title>Microsoft Orleans Transactions on DynamoDB</Title>
<Description>DynamoDB Transaction library of Microsoft Orleans used on the server.</Description>
<PackageTags>$(PackageTags) DynamoDB Transactions</PackageTags>
</PropertyGroup>

<PropertyGroup>
<AssemblyName>Orleans.Transactions.DynamoDB</AssemblyName>
<RootNamespace>Orleans.Transactions.DynamoDB</RootNamespace>
<DefineConstants>$(DefineConstants);TRANSACTIONS_DYNAMODB</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\AWSUtils.cs" Link="AWSUtils.cs" />
<Compile Include="..\Shared\Storage\DynamoDBStorage.cs" Link="Storage\DynamoDBStorage.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.DynamoDBv2" Version="$(AWSSDKDynamoDBv2Version)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Orleans.Transactions\Orleans.Transactions.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("AWSUtils.Tests")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Microsoft.Extensions.Options;
using Orleans.Runtime;
using Orleans.Transactions.DynamoDB;

namespace Orleans.Configuration
{
public class DynamoDBTransactionLogOptions
{
/// <summary>
/// AccessKey string for DynamoDB Storage
/// </summary>
[Redact]
public string AccessKey { get; set; }

/// <summary>
/// Secret key for DynamoDB storage
/// </summary>
[Redact]
public string SecretKey { get; set; }

/// <summary>
/// DynamoDB Service name
/// </summary>
public string Service { get; set; }

/// <summary>
/// Read capacity unit for DynamoDB storage
/// </summary>
public int ReadCapacityUnits { get; set; } = DynamoDBStorage.DefaultReadCapacityUnits;

/// <summary>
/// Write capacity unit for DynamoDB storage
/// </summary>
public int WriteCapacityUnits { get; set; } = DynamoDBStorage.DefaultWriteCapacityUnits;

/// <summary>
/// DynamoDB table name.
/// Defaults to 'TransactionLog'.
/// </summary>
public string TableName { get; set; } = "TransactionLog";
}

public class DynamoDBTransactionLogOptionsValidator : IConfigurationValidator
{
private readonly DynamoDBTransactionLogOptions options;

public DynamoDBTransactionLogOptionsValidator(IOptions<DynamoDBTransactionLogOptions> configurationOptions)
{
this.options = configurationOptions.Value;
}

public void ValidateConfiguration()
{
if (string.IsNullOrWhiteSpace(this.options.TableName))
throw new OrleansConfigurationException(
$"Configuration for DynamoDBTransactionLogStorage is invalid. {nameof(this.options.TableName)} is not valid.");

if (this.options.ReadCapacityUnits == 0)
throw new OrleansConfigurationException(
$"Configuration for DynamoDBTransactionLogStorage is invalid. {nameof(this.options.ReadCapacityUnits)} is not valid.");

if (this.options.WriteCapacityUnits == 0)
throw new OrleansConfigurationException(
$"Configuration for DynamoDBTransactionLogStorage is invalid. {nameof(this.options.WriteCapacityUnits)} is not valid.");
}
}
}
Loading