Skip to content

Commit

Permalink
moved Helios transport to separate project + DotNetty backward compat…
Browse files Browse the repository at this point in the history
…ibility spec for config
  • Loading branch information
Horusiath committed Jan 19, 2017
1 parent c9dc11e commit 1d22345
Show file tree
Hide file tree
Showing 12 changed files with 1,356 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DistributedData.Tests"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DistributedData.Tests.MultiNode", "contrib\cluster\Akka.DistributedData.Tests.MultiNode\Akka.DistributedData.Tests.MultiNode.csproj", "{53A657B3-D3CD-461E-9759-664331218060}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Transports", "Transports", "{6AD34FA4-7584-454D-ACD4-A8911E0BDB00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Remote.Transport.Helios", "contrib\transports\Akka.Remote.Transport.Helios\Akka.Remote.Transport.Helios.csproj", "{29FEAABC-E326-450A-9008-B5FCECF0115F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Mono|Any CPU = Debug Mono|Any CPU
Expand Down Expand Up @@ -949,6 +953,14 @@ Global
{53A657B3-D3CD-461E-9759-664331218060}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{53A657B3-D3CD-461E-9759-664331218060}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53A657B3-D3CD-461E-9759-664331218060}.Release|Any CPU.Build.0 = Release|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29FEAABC-E326-450A-9008-B5FCECF0115F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1063,5 +1075,7 @@ Global
{59CFFC88-8A73-445D-B191-281E40BE9421} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
{0DBF3D66-6E5E-4A89-AA3D-674B92FE81B7} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
{53A657B3-D3CD-461E-9759-664331218060} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
{6AD34FA4-7584-454D-ACD4-A8911E0BDB00} = {588C1513-FAB6-42C3-B6FC-3485F13620CF}
{29FEAABC-E326-450A-9008-B5FCECF0115F} = {6AD34FA4-7584-454D-ACD4-A8911E0BDB00}
EndGlobalSection
EndGlobal
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 src/contrib/transports/Akka.Remote.Transport.Helios/HeliosHelpers.cs
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();
}
}
}
}
Loading

0 comments on commit 1d22345

Please sign in to comment.