Skip to content

Commit

Permalink
Support ProxyGatewayEndpoint from legacy configuration (dotnet#5214)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond authored and sergeybykov committed Dec 11, 2018
1 parent e39ee56 commit af8347b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ private static void AddLegacyClusterConfigurationSupport(IServiceCollection serv
options.AdvertisedIPAddress = nodeConfig.Endpoint.Address;
options.SiloPort = nodeConfig.Endpoint.Port;
}

var gatewayEndpoint = nodeConfig.ProxyGatewayEndpoint;
if (gatewayEndpoint != null)
{
options.GatewayPort = gatewayEndpoint.Port;
options.GatewayListeningEndpoint = gatewayEndpoint;
}
});

services.Configure<SerializationProviderOptions>(options =>
Expand Down
13 changes: 7 additions & 6 deletions src/Orleans.Runtime/Hosting/EndpointOptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using System.Net;
using System.Net.Sockets;
using Orleans.Configuration;
using Orleans.Hosting;
Expand Down Expand Up @@ -87,8 +87,12 @@ internal static IPEndPoint GetPublicSiloEndpoint(this EndpointOptions options)

internal static IPEndPoint GetPublicProxyEndpoint(this EndpointOptions options)
{
return options.GatewayPort != 0
? new IPEndPoint(options.AdvertisedIPAddress, options.GatewayPort)
var gatewayPort = options.GatewayPort != 0
? options.GatewayPort
: options.GatewayListeningEndpoint?.Port ?? 0;

return gatewayPort != 0
? new IPEndPoint(options.AdvertisedIPAddress, gatewayPort)
: null;
}

Expand All @@ -99,9 +103,6 @@ internal static IPEndPoint GetListeningSiloEndpoint(this EndpointOptions options

internal static IPEndPoint GetListeningProxyEndpoint(this EndpointOptions options)
{
if (options.GatewayPort == 0)
return null;

return options.GatewayListeningEndpoint ?? options.GetPublicProxyEndpoint();
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Orleans.Runtime/Silo/LocalSiloDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ public LocalSiloDetails(

var endpointOptions = siloEndpointOptions.Value;
this.siloAddressLazy = new Lazy<SiloAddress>(() => SiloAddress.New(endpointOptions.GetPublicSiloEndpoint(), SiloAddress.AllocateNewGeneration()));
this.gatewayAddressLazy = new Lazy<SiloAddress>(() => endpointOptions.GatewayPort != 0 ? SiloAddress.New(endpointOptions.GetPublicProxyEndpoint(), 0) : null);
this.gatewayAddressLazy = new Lazy<SiloAddress>(() =>
{
var publicProxyEndpoint = endpointOptions.GetPublicProxyEndpoint();
return publicProxyEndpoint != null
? SiloAddress.New(publicProxyEndpoint, 0)
: null;
});
}

/// <inheritdoc />
Expand Down

0 comments on commit af8347b

Please sign in to comment.