From 3a2be47aa1a49cbe3e162fe3cfec47cd6a473879 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Tue, 11 Dec 2018 09:08:49 -0800 Subject: [PATCH] Support ProxyGatewayEndpoint from legacy configuration (#5214) --- .../LegacyClusterConfigurationExtensions.cs | 7 +++++++ .../Hosting/EndpointOptionsExtensions.cs | 13 +++++++------ src/Orleans.Runtime/Silo/LocalSiloDetails.cs | 8 +++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Orleans.Runtime.Legacy/Configuration/LegacyClusterConfigurationExtensions.cs b/src/Orleans.Runtime.Legacy/Configuration/LegacyClusterConfigurationExtensions.cs index 18ec2c7c79..eb50cdbe16 100644 --- a/src/Orleans.Runtime.Legacy/Configuration/LegacyClusterConfigurationExtensions.cs +++ b/src/Orleans.Runtime.Legacy/Configuration/LegacyClusterConfigurationExtensions.cs @@ -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(options => diff --git a/src/Orleans.Runtime/Hosting/EndpointOptionsExtensions.cs b/src/Orleans.Runtime/Hosting/EndpointOptionsExtensions.cs index a1294aa357..b836406ff9 100644 --- a/src/Orleans.Runtime/Hosting/EndpointOptionsExtensions.cs +++ b/src/Orleans.Runtime/Hosting/EndpointOptionsExtensions.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using System.Net.Sockets; using Orleans.Configuration; using Orleans.Hosting; @@ -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; } @@ -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(); } } diff --git a/src/Orleans.Runtime/Silo/LocalSiloDetails.cs b/src/Orleans.Runtime/Silo/LocalSiloDetails.cs index d00043efe3..f87f1274cd 100644 --- a/src/Orleans.Runtime/Silo/LocalSiloDetails.cs +++ b/src/Orleans.Runtime/Silo/LocalSiloDetails.cs @@ -22,7 +22,13 @@ public LocalSiloDetails( var endpointOptions = siloEndpointOptions.Value; this.siloAddressLazy = new Lazy(() => SiloAddress.New(endpointOptions.GetPublicSiloEndpoint(), SiloAddress.AllocateNewGeneration())); - this.gatewayAddressLazy = new Lazy(() => endpointOptions.GatewayPort != 0 ? SiloAddress.New(endpointOptions.GetPublicProxyEndpoint(), 0) : null); + this.gatewayAddressLazy = new Lazy(() => + { + var publicProxyEndpoint = endpointOptions.GetPublicProxyEndpoint(); + return publicProxyEndpoint != null + ? SiloAddress.New(publicProxyEndpoint, 0) + : null; + }); } ///