Skip to content

Commit

Permalink
Merge pull request #314 from basho/features/lrb/ts-ttb-encoding
Browse files Browse the repository at this point in the history
READY: Implement TTB encoding for Riak TS put / query messages
  • Loading branch information
lukebakken authored Jul 5, 2016
2 parents 58f542d + 38376ab commit 02b588c
Show file tree
Hide file tree
Showing 79 changed files with 2,617 additions and 582 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ CommonAssemblyInfo.cs
*.DotSettings
*.dcvr.settings
StyleCop.Cache
.vs/
6 changes: 6 additions & 0 deletions RELNOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

[v2.4.0](https://github.com/basho/riak-dotnet-client/issues?q=milestone%3Ariak-dotnet-client-2.4.0)
------

* Add support of encoding `Store` and `Query` Riak TS commands in Erlang term format. Compatible with Riak TS 1.3 and above.
* Add `useTtbEncoding` cluster and node configuration option. Set `useTtbEncoding=false` to *disable* Erlang term format encoding when connecting to a Riak TS 1.2 cluster.

[v2.3.0](https://github.com/basho/riak-dotnet-client/issues?q=milestone%3Ariak-dotnet-client-2.3.0)
------

Expand Down
7 changes: 5 additions & 2 deletions build/build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@
</Target>

<Target Name="CodeAnalysis">
<PropertyGroup Condition="'$(VisualStudioVersion)' == ''">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
<MSBuild Projects="$(SolutionFile)"
Properties="Configuration=Debug;VisualStudioVersion=12.0;CodeAnalysisTreatWarningsAsErrors=true;CodeAnalysisRuleSet=MinimumRecommendedRules.ruleset;RunCodeAnalysis=true" />
Properties="Configuration=Debug;VisualStudioVersion=$(VisualStudioVersion);CodeAnalysisTreatWarningsAsErrors=true;CodeAnalysisRuleSet=MinimumRecommendedRules.ruleset;RunCodeAnalysis=true" />
</Target>

<Target Name="UnitTest" DependsOnTargets="GitSubmodule;SetupTests;Debug;CodeAnalysis">
Expand All @@ -231,7 +234,7 @@
<Exec WorkingDirectory="$(SolutionDir)"
Command="$(NUnitConsoleRunnerCommand) -work=$(ProjDir)\RiakClientTests.Live $(ProjDir)\RiakClientTests.Live\RiakClientTests.Live.nunit" />
<Exec WorkingDirectory="$(SolutionDir)"
Command="$(NUnitConsoleRunnerCommand) -work=$(ProjDir)\Test -run=Test.Integration.CRDT,Test.Integration.KV $(ProjDir)\Test\Test.nunit" />
Command="$(NUnitConsoleRunnerCommand) -work=$(ProjDir)\Test -run=Test.Integration.CRDT,Test.Integration.KV,Test.Integration.Issues $(ProjDir)\Test\Test.nunit" />
</Target>

<Target Name="TimeseriesTest" DependsOnTargets="SetupTests;Debug">
Expand Down
9 changes: 7 additions & 2 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ if (! ([String]::IsNullOrEmpty($VersionString))) {
$version_property = "/property:VersionString=$VersionString"
}

$vs_version_property = ''
if (Test-Path -Path HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0) {
$vs_version_property = '/property:VisualStudioVersion=14.0'
}

$script_path = Get-ScriptPath

$build_targets_file = Get-BuildTargetsFile -ScriptPath $script_path
Expand Down Expand Up @@ -246,8 +251,8 @@ else
$maxcpu_property = '/maxcpucount'
}

Write-Debug "MSBuild command: $msbuild_exe ""/verbosity:$Verbosity"" /nologo /m ""/property:SolutionDir=$script_path\"" ""$maxcpu_property"" ""$version_property"" ""$verbose_property"" ""$git_remote_property"" ""$protogen_property"" ""/target:$Target"" ""$build_targets_file"""
& $msbuild_exe "/verbosity:$Verbosity" /nologo /m "/property:SolutionDir=$script_path\" "$maxcpu_property" "$version_property" "$verbose_property" "$git_remote_property" "$protogen_property" "/target:$Target" "$build_targets_file"
Write-Debug "MSBuild command: $msbuild_exe ""/verbosity:$Verbosity"" /nologo /m ""/property:SolutionDir=$script_path\"" ""$maxcpu_property"" ""$version_property"" ""$vs_version_property"" ""$verbose_property"" ""$git_remote_property"" ""$protogen_property"" ""/target:$Target"" ""$build_targets_file"""
& $msbuild_exe "/verbosity:$Verbosity" /nologo /m "/property:SolutionDir=$script_path\" "$maxcpu_property" "$version_property" "$vs_version_property" "$verbose_property" "$git_remote_property" "$protogen_property" "/target:$Target" "$build_targets_file"
if ($? -ne $True) {
throw "$msbuild_exe failed: $LastExitCode"
}
Expand Down
2 changes: 2 additions & 0 deletions src/ChaosMonkeyApp/ChaosMonkeyApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -34,6 +35,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/RiakClient/Auth/RiakSecurityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public bool IsSecurityEnabled
{
get
{
return (false == MonoUtil.IsRunningOnMono) &&
return (MonoUtil.IsRunningOnMono == false) &&
(authConfig != null && (!string.IsNullOrWhiteSpace(authConfig.Username)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/RiakClient/Commands/CRDT/FetchCommand{TResponse}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override MessageCode ExpectedCode
get { return MessageCode.DtFetchResp; }
}

public override RpbReq ConstructPbRequest()
public override RiakReq ConstructRequest(bool useTtb)
{
var req = new DtFetchReq();

Expand Down
2 changes: 1 addition & 1 deletion src/RiakClient/Commands/CRDT/FetchCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public FetchCounter(FetchCounterOptions options)
{
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/RiakClient/Commands/CRDT/FetchMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public FetchMap(FetchMapOptions options)
{
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/RiakClient/Commands/CRDT/FetchSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public FetchSet(FetchSetOptions options)
{
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/RiakClient/Commands/CRDT/UpdateCommand{TResponse}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override MessageCode ExpectedCode
get { return MessageCode.DtUpdateResp; }
}

public override RpbReq ConstructPbRequest()
public override RiakReq ConstructRequest(bool useTtb)
{
var req = new DtUpdateReq();

Expand Down Expand Up @@ -73,7 +73,7 @@ public override RpbReq ConstructPbRequest()
return req;
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
15 changes: 2 additions & 13 deletions src/RiakClient/Commands/Command{TOptions,TResponse}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// </summary>
/// <typeparam name="TOptions">The type of the options for this command.</typeparam>
/// <typeparam name="TResponse">The type of the response data from Riak.</typeparam>
public abstract class Command<TOptions, TResponse> : IRiakCommand
public abstract class Command<TOptions, TResponse> : Command<TResponse>
where TOptions : CommandOptions
where TResponse : Response
{
Expand All @@ -33,18 +33,7 @@ public TOptions Options
get { return CommandOptions; }
}

/// <summary>
/// A sub-class instance of <see cref="Response"/> representing the response from Riak.
/// </summary>
public TResponse Response { get; protected set; }

public abstract MessageCode ExpectedCode { get; }

public abstract RpbReq ConstructPbRequest();

public abstract void OnSuccess(RpbResp rpbResp);

protected RiakString GetKey(RiakString optskey, RpbResp response)
protected RiakString GetKey(RiakString optskey, RiakResp response)
{
RiakString key = optskey;

Expand Down
26 changes: 23 additions & 3 deletions src/RiakClient/Commands/Command{TResponse}.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace RiakClient.Commands
{
using System;
using System.IO;
using Messages;
using ProtoBuf;

/// <summary>
/// Base class for Riak commands that don't have options.
Expand All @@ -23,8 +26,25 @@ public Command()

public abstract MessageCode ExpectedCode { get; }

public abstract RpbReq ConstructPbRequest();
public abstract RiakReq ConstructRequest(bool useTtb);

public abstract void OnSuccess(RpbResp rpbResp);
public abstract void OnSuccess(RiakResp rpbResp);

public virtual RiakResp DecodeResponse(byte[] buffer)
{
Type expectedType = MessageCodeTypeMapBuilder.GetTypeFor(ExpectedCode);

if (buffer == null || buffer.Length == 0)
{
return Activator.CreateInstance(expectedType) as RiakResp;
}
else
{
using (var memStream = new MemoryStream(buffer))
{
return Serializer.NonGeneric.Deserialize(expectedType, memStream) as RiakResp;
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/RiakClient/Commands/FetchServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public override MessageCode ExpectedCode
get { return MessageCode.RpbGetServerInfoResp; }
}

public override RpbReq ConstructPbRequest()
public override RiakReq ConstructRequest(bool useTtb)
{
return new RpbReq(MessageCode.RpbGetServerInfoReq);
return new RiakReq(MessageCode.RpbGetServerInfoReq);
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
8 changes: 6 additions & 2 deletions src/RiakClient/Commands/IRiakCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
/// </summary>
public interface IRiakCommand
{
// TODO FUTURE
// interface should not be concerned with encoding or Riak msg
MessageCode ExpectedCode { get; }

RpbReq ConstructPbRequest();
RiakReq ConstructRequest(bool useTtb);

void OnSuccess(RpbResp rpbResp);
RiakResp DecodeResponse(byte[] buffer);

void OnSuccess(RiakResp rpbResp);
}
}
4 changes: 2 additions & 2 deletions src/RiakClient/Commands/KV/FetchPreflist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override MessageCode ExpectedCode
get { return MessageCode.RpbGetBucketKeyPreflistResp; }
}

public override RpbReq ConstructPbRequest()
public override RiakReq ConstructRequest(bool useTtb)
{
var req = new RpbGetBucketKeyPreflistReq();

Expand All @@ -36,7 +36,7 @@ public override RpbReq ConstructPbRequest()
return req;
}

public override void OnSuccess(RpbResp response)
public override void OnSuccess(RiakResp response)
{
if (response == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/RiakClient/Commands/TS/ByKeyCommand{TResponse}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ByKeyCommand(ByKeyOptions options)
}
}

public override RpbReq ConstructPbRequest()
public override RiakReq ConstructRequest(bool useTtb)
{
ITsByKeyReq req = GetByKeyReq();

Expand All @@ -49,7 +49,7 @@ public override RpbReq ConstructPbRequest()

req.key.AddRange(CommandOptions.Key.ToTsCells());

return (RpbReq)req;
return (RiakReq)req;
}

protected abstract ITsByKeyReq GetByKeyReq();
Expand Down
Loading

0 comments on commit 02b588c

Please sign in to comment.