-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved Helios transport to separate project + DotNetty backward compat…
…ibility spec for config
- Loading branch information
Showing
12 changed files
with
1,356 additions
and
14 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
81 changes: 81 additions & 0 deletions
81
src/contrib/transports/Akka.Remote.Transport.Helios/Akka.Remote.Transport.Helios.csproj
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,81 @@ | ||
<?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>{29FEAABC-E326-450A-9008-B5FCECF0115F}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Akka.Remote.Transport.Helios</RootNamespace> | ||
<AssemblyName>Akka.Remote.Transport.Helios</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</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> | ||
</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> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Google.ProtocolBuffers, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL"> | ||
<HintPath>..\..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Google.ProtocolBuffers.Serialization, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL"> | ||
<HintPath>..\..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Helios, Version=2.1.3.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\..\packages\Helios.2.1.3\lib\net45\Helios.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<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="HeliosHelpers.cs" /> | ||
<Compile Include="HeliosTcpTransport.cs" /> | ||
<Compile Include="HeliosTransport.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\core\Akka.Remote\Akka.Remote.csproj"> | ||
<Project>{ea4ff8fd-7c53-49c8-b9aa-02e458b3e6a7}</Project> | ||
<Name>Akka.Remote</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\..\core\Akka\Akka.csproj"> | ||
<Project>{5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}</Project> | ||
<Name>Akka</Name> | ||
</ProjectReference> | ||
</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> |
141 changes: 141 additions & 0 deletions
141
src/contrib/transports/Akka.Remote.Transport.Helios/HeliosHelpers.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,141 @@ | ||
#region copyright | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="HeliosHelpers.cs" company="Akka.NET project"> | ||
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2017 Akka.NET project <https://github.com/akkadotnet> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
#endregion | ||
|
||
using System; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Event; | ||
using Google.ProtocolBuffers; | ||
using Helios; | ||
using Helios.Buffers; | ||
using Helios.Channels; | ||
using Helios.Exceptions; | ||
using Helios.Net; | ||
using Helios.Ops; | ||
using Helios.Serialization; | ||
using Helios.Topology; | ||
|
||
namespace Akka.Remote.Transport.Helios | ||
{ | ||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
internal abstract class CommonHandlers : ChannelHandlerAdapter | ||
{ | ||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
protected readonly HeliosTransport WrappedTransport; | ||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
protected readonly ILoggingAdapter Log; | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="wrappedTransport">TBD</param> | ||
/// <param name="log">TBD</param> | ||
protected CommonHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) | ||
{ | ||
WrappedTransport = wrappedTransport; | ||
Log = log; | ||
} | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="context">TBD</param> | ||
public override void ChannelActive(IChannelHandlerContext context) | ||
{ | ||
if (!WrappedTransport.ConnectionGroup.TryAdd(context.Channel)) | ||
{ | ||
Log.Warning("Unable to REMOVE channel [{0}->{1}](Id={2}) to connection group. May not shut down cleanly.", | ||
context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="context">TBD</param> | ||
public override void ChannelInactive(IChannelHandlerContext context) | ||
{ | ||
if (!WrappedTransport.ConnectionGroup.TryRemove(context.Channel)) | ||
{ | ||
Log.Warning("Unable to ADD channel [{0}->{1}](Id={2}) to connection group. May not shut down cleanly.", | ||
context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="context">TBD</param> | ||
/// <param name="exception">TBD</param> | ||
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) | ||
{ | ||
Log.Error(exception, "Error caught channel [{0}->{1}](Id={2})", context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id); | ||
} | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="channel">TBD</param> | ||
/// <param name="localAddress">TBD</param> | ||
/// <param name="remoteAddress">TBD</param> | ||
/// <returns>TBD</returns> | ||
protected abstract AssociationHandle CreateHandle(IChannel channel, Address localAddress, | ||
Address remoteAddress); | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="channel">TBD</param> | ||
/// <param name="listener">TBD</param> | ||
/// <param name="msg">TBD</param> | ||
/// <param name="remoteAddress">TBD</param> | ||
/// <returns>TBD</returns> | ||
protected abstract void RegisterListener(IChannel channel, IHandleEventListener listener, object msg, | ||
IPEndPoint remoteAddress); | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="channel">TBD</param> | ||
/// <param name="remoteSocketAddress">TBD</param> | ||
/// <param name="remoteAddress">TBD</param> | ||
/// <param name="msg">TBD</param> | ||
/// <param name="op">TBD</param> | ||
protected void Init(IChannel channel, IPEndPoint remoteSocketAddress, Address remoteAddress, object msg, | ||
out AssociationHandle op) | ||
{ | ||
var localAddress = HeliosTransport.MapSocketToAddress((IPEndPoint)channel.LocalAddress, WrappedTransport.SchemeIdentifier, | ||
WrappedTransport.System.Name, WrappedTransport.Settings.Hostname); | ||
|
||
if (localAddress != null) | ||
{ | ||
var handle = CreateHandle(channel, localAddress, remoteAddress); | ||
handle.ReadHandlerSource.Task.ContinueWith(s => | ||
{ | ||
var listener = s.Result; | ||
RegisterListener(channel, listener, msg, remoteSocketAddress); | ||
channel.Configuration.AutoRead = true; // turn reads back on | ||
}, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.NotOnCanceled | TaskContinuationOptions.NotOnFaulted); | ||
op = handle; | ||
} | ||
else | ||
{ | ||
op = null; | ||
channel.CloseAsync(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.