Skip to content

move Akka.DistributedData.LightningDb onto vendored package #5180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 1 addition & 1 deletion src/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\common.props" />

<!-- Needed to resolve https://github.com/akkadotnet/akka.net/pull/5180 and https://github.com/akkadotnet/akka.net/issues/5174 -->
<Import Project="../lib-hack/LightningDB.targets" />

<PropertyGroup>
<AssemblyTitle>Akka.Cluster.Sharding.Tests.MultiNode</AssemblyTitle>
Expand All @@ -20,12 +23,11 @@
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>


<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>



</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,4 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("666698ab-85bc-4c91-894c-cbb4316dc1a4")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: Guid("666698ab-85bc-4c91-894c-cbb4316dc1a4")]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LightningDB" Version="0.13.0" />
<PackageReference Include="LightningDB.Vendored.Akka" Version="0.14.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\common.props" />

<!-- Needed to resolve https://github.com/akkadotnet/akka.net/pull/5180 and https://github.com/akkadotnet/akka.net/issues/5174 -->
<Import Project="../lib-hack/LightningDB.targets" />

<PropertyGroup>
<AssemblyTitle>Akka.DistributedData.Tests.MultiNode</AssemblyTitle>
Expand All @@ -20,10 +23,6 @@
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
Expand Down
59 changes: 59 additions & 0 deletions src/contrib/cluster/lib-hack/LightningDB.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to resolve this by re-using the .targets file from the original projects.

Everything using the original LightningDb package runs just fine in a stand-alone project, but the MNTR isn't able to resolve these DLLs when it's running. Best bet is to just stick the DLLs in a folder adjacent to the .NET dlls, which is how things work in the current dev branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this targets file is only necessary because of the quirks of the MNTR, transitive dependencies, and multi-targeting in MSBuild. A normal software application using Akka.Cluster.Sharding will not have this issue.

<PropertyGroup>
<LightningDBTargetRuntimeRelativePath Condition=" '$(LightningDBTargetRuntimeRelativePath)' == '' ">./</LightningDBTargetRuntimeRelativePath>
</PropertyGroup>
<ItemGroup Condition="'$([MSBuild]::IsOsPlatform(Windows))' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)'=='X64'">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\win-x64\native\lmdb.dll">
<Visible>false</Visible>
<Link>lmdb.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\win-x64\native\lmdbautoresize.dll">
<Visible>false</Visible>
<Link>lmdbautoresize.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$([MSBuild]::IsOsPlatform(Windows))' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)'=='X86'">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\win-x86\native\lmdb.dll">
<Visible>false</Visible>
<Link>lmdb.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\win-x86\native\lmdbautoresize.dll">
<Visible>false</Visible>
<Link>lmdbautoresize.dll</Link>

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition=" '$([MSBuild]::IsOsPlatform(OSX))' ">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\osx\native\lmdb.dylib">
<Visible>false</Visible>
<Link>lmdb.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$([MSBuild]::IsOsPlatform(Linux))' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)'=='Arm'">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\linux-arm\native\liblmdb.so">
<Visible>false</Visible>
<Link>liblmdb.so</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$([MSBuild]::IsOsPlatform(Linux))' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)'=='Arm64'">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\linux-arm64\native\liblmdb.so">
<Visible>false</Visible>
<Link>liblmdb.so</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$([MSBuild]::IsOsPlatform(Linux))' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)'=='X64'">
<None Include="$(MSBuildThisFileDirectory)$(LightningDBTargetRuntimeRelativePath)runtimes\linux-x64\native\liblmdb.so">
<Visible>false</Visible>
<Link>liblmdb.so</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Akka.Cluster.Sharding;
using Akka.Persistence;

namespace ClusterSharding.Node
Expand Down Expand Up @@ -38,15 +39,22 @@ public ItemPurchased(string itemName)

#endregion

public override string PersistenceId { get; } = Context.Parent.Path.Name + "/" + Context.Self.Path.Name;
public override string PersistenceId { get; }

public ICollection<string> _purchasedItems = new List<string>();

public Customer()
public Customer(string persistenceId)
{
PersistenceId = persistenceId;
SetReceiveTimeout(TimeSpan.FromSeconds(60));
Recover<ItemPurchased>(purchased => _purchasedItems.Add(purchased.ItemName));

Command<ShardRegion.StartEntity>(e =>
{
Console.WriteLine($"'{PersistenceId}' started via remember-entities");

});

Command<PurchaseItem>(purchase =>
{
Persist(new ItemPurchased(purchase.ItemName), purchased =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,29 @@ public ShardEnvelope(string entityId, object payload)

public sealed class MessageExtractor : HashCodeMessageExtractor
{
public MessageExtractor(int maxNumberOfShards) : base(maxNumberOfShards) { }
public MessageExtractor(int maxNumberOfShards) : base(maxNumberOfShards)
{
}

public override string EntityId(object message) => (message as ShardEnvelope)?.EntityId;
public override string EntityId(object message)
{
switch (message)
{
case ShardRegion.StartEntity start: return start.EntityId;
case ShardEnvelope e: return e.EntityId;
}

public override object EntityMessage(object message) => (message as ShardEnvelope)?.Payload;
return null;
}

public override object EntityMessage(object message)
{
switch (message)
{
case ShardEnvelope e: return e.Payload;
default:
return message;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ static void Main(string[] args)
dot-netty.tcp {
public-hostname = ""localhost""
hostname = ""localhost""
port = 0
port = 14445
}
}
cluster {
auto-down-unreachable-after = 5s
sharding {
remember-entities = on
least-shard-allocation-strategy.rebalance-threshold = 3
state-store-mode = ddata
}
}
persistence {
Expand Down Expand Up @@ -89,7 +91,7 @@ private static void RunExample(ActorSystem system)
var sharding = ClusterSharding.Get(system);
var shardRegion = sharding.Start(
typeName: "customer",
entityProps: Props.Create<Customer>(),
entityPropsFactory: e => Props.Create(() => new Customer(e)),
settings: ClusterShardingSettings.Create(system),
messageExtractor: new MessageExtractor(10));

Expand Down