From 6ddbe789065b4c13389ce87c114aed4d0ff88378 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Tue, 11 Jul 2017 21:38:37 +1000 Subject: [PATCH 1/4] Minor Service Fabric provider fixes and tweaks --- .../FabricGatewayProvider.cs | 4 ++-- .../FabricServiceSiloResolver.cs | 11 ++--------- .../Models/IResolvedServicePartition.cs | 4 +--- .../Utilities/FabricQueryManager.cs | 8 -------- .../Utilities/ResolvedServicePartitionExtensions.cs | 8 +++++--- .../Utilities/ServiceFabricExtensions.cs | 13 ------------- 6 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs index 093cd13767..c3b213ede3 100644 --- a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs +++ b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs @@ -41,8 +41,8 @@ internal class FabricGatewayProvider : IGatewayListProvider, IGatewayListObserva public FabricGatewayProvider(IFabricServiceSiloResolver siloResolver) { this.fabricServiceSiloResolver = siloResolver; - this.refreshPeriod = TimeSpan.FromSeconds(30); - this.MaxStaleness = TimeSpan.FromSeconds(this.refreshPeriod.TotalSeconds * 2); + this.refreshPeriod = TimeSpan.FromSeconds(5); + this.MaxStaleness = this.refreshPeriod; } /// diff --git a/src/OrleansServiceFabricUtils/FabricServiceSiloResolver.cs b/src/OrleansServiceFabricUtils/FabricServiceSiloResolver.cs index 536b2a5daf..52a61a19a3 100644 --- a/src/OrleansServiceFabricUtils/FabricServiceSiloResolver.cs +++ b/src/OrleansServiceFabricUtils/FabricServiceSiloResolver.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Fabric; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -132,14 +133,6 @@ private void OnPartitionChange(long handlerId, FabricPartitionResolutionChange a if (!existing.IsSamePartitionAs(updated.Partition)) continue; found = true; - if (updated.Partition.IsOlderThan(existing)) - { - this.log.Info($"Update for partition {updated} is superseded by existing version."); - - // Do not update the partition if the exiting one has a newer version than the update. - break; - } - // Update the partition. this.silos[i] = updated; this.NotifySubscribers(); diff --git a/src/OrleansServiceFabricUtils/Models/IResolvedServicePartition.cs b/src/OrleansServiceFabricUtils/Models/IResolvedServicePartition.cs index 99162b3608..8bb350e182 100644 --- a/src/OrleansServiceFabricUtils/Models/IResolvedServicePartition.cs +++ b/src/OrleansServiceFabricUtils/Models/IResolvedServicePartition.cs @@ -14,9 +14,7 @@ internal interface IResolvedServicePartition Guid Id { get; } ServicePartitionKind Kind { get; } - - bool IsOlderThan(IResolvedServicePartition other); - + bool IsSamePartitionAs(IResolvedServicePartition other); } } \ No newline at end of file diff --git a/src/OrleansServiceFabricUtils/Utilities/FabricQueryManager.cs b/src/OrleansServiceFabricUtils/Utilities/FabricQueryManager.cs index c69c7d3de5..9b1366fed9 100644 --- a/src/OrleansServiceFabricUtils/Utilities/FabricQueryManager.cs +++ b/src/OrleansServiceFabricUtils/Utilities/FabricQueryManager.cs @@ -155,14 +155,6 @@ public ResolvedServicePartitionWrapper(ResolvedServicePartition partition) public ServicePartitionKind Kind => this.Partition.Info.Kind; - public bool IsOlderThan(IResolvedServicePartition other) - { - var otherWrapper = other as ResolvedServicePartitionWrapper; - if (otherWrapper == null) return false; - - return this.Partition.IsOlderThan(otherWrapper.Partition); - } - public bool IsSamePartitionAs(IResolvedServicePartition other) { var otherWrapper = other as ResolvedServicePartitionWrapper; diff --git a/src/OrleansServiceFabricUtils/Utilities/ResolvedServicePartitionExtensions.cs b/src/OrleansServiceFabricUtils/Utilities/ResolvedServicePartitionExtensions.cs index b886ac1ee2..9b554bc286 100644 --- a/src/OrleansServiceFabricUtils/Utilities/ResolvedServicePartitionExtensions.cs +++ b/src/OrleansServiceFabricUtils/Utilities/ResolvedServicePartitionExtensions.cs @@ -14,8 +14,10 @@ internal static class ResolvedServicePartitionExtensions /// The active endpoints published by the specified partition. public static List GetPartitionEndpoints(this ResolvedServicePartition partition) { - var results = new List(partition.Endpoints.Count); - foreach (var silo in partition.Endpoints) + var resolvedServiceEndpoints = partition.Endpoints; + if (resolvedServiceEndpoints == null) return new List(); + var results = new List(resolvedServiceEndpoints.Count); + foreach (var silo in resolvedServiceEndpoints) { // Find the primary endpoint. If this is a stateless service, find any endpoint. if (silo.Role != ServiceEndpointRole.Stateless && silo.Role != ServiceEndpointRole.StatefulPrimary) continue; @@ -30,7 +32,7 @@ public static List GetPartitionEndpoints(this ResolvedServicePar } /// - /// Respresents endpoints returned from in JSON form. + /// Represents endpoints returned from in JSON form. /// internal class ServicePartitionEndpoints { diff --git a/src/OrleansServiceFabricUtils/Utilities/ServiceFabricExtensions.cs b/src/OrleansServiceFabricUtils/Utilities/ServiceFabricExtensions.cs index 56eed41c05..fdcfb406c8 100644 --- a/src/OrleansServiceFabricUtils/Utilities/ServiceFabricExtensions.cs +++ b/src/OrleansServiceFabricUtils/Utilities/ServiceFabricExtensions.cs @@ -6,19 +6,6 @@ namespace Microsoft.Orleans.ServiceFabric.Utilities { internal static class ServiceFabricExtensions { - /// - /// Returns a value indicating whether or not is older than . - /// - /// One resolved partition. - /// The other resolved partition. - /// - /// if is older than , otherwise. - /// - public static bool IsOlderThan(this ResolvedServicePartition left, ResolvedServicePartition right) - { - return left.Info.Id == right.Info.Id && left.CompareVersion(right) < 0; - } - /// /// Returns a value indicating whether or not is the same partition as . /// From 683fc124c25683caa719429bbb04aa922921e808 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Wed, 26 Jul 2017 14:02:22 +1000 Subject: [PATCH 2/4] Additional logging in SF gateway provider --- src/OrleansServiceFabricUtils/FabricGatewayProvider.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs index c3b213ede3..004480ebb4 100644 --- a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs +++ b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs @@ -67,14 +67,16 @@ public async Task InitializeGatewayListProvider(ClientConfiguration clientConfig /// public bool SubscribeToGatewayNotificationEvents(IGatewayListListener subscriber) { + this.log.Verbose($"Unsubscribing {subscriber} to gateway notification events."); this.subscribers.TryAdd(subscriber, subscriber); return true; } /// - public bool UnSubscribeFromGatewayNotificationEvents(IGatewayListListener listener) + public bool UnSubscribeFromGatewayNotificationEvents(IGatewayListListener subscriber) { - this.subscribers.TryRemove(listener, out listener); + this.log.Verbose($"Unsubscribing {subscriber} from gateway notification events."); + this.subscribers.TryRemove(subscriber, out subscriber); return true; } From 90cd2f783b4e93309e813190bf787c689a63c8bc Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Wed, 26 Jul 2017 21:03:19 +1000 Subject: [PATCH 3/4] FabricMembershipOracle reduce polling interval from 30s to 5s --- src/OrleansServiceFabricUtils/FabricMembershipOracle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrleansServiceFabricUtils/FabricMembershipOracle.cs b/src/OrleansServiceFabricUtils/FabricMembershipOracle.cs index c28457d3e5..2bdec02621 100644 --- a/src/OrleansServiceFabricUtils/FabricMembershipOracle.cs +++ b/src/OrleansServiceFabricUtils/FabricMembershipOracle.cs @@ -21,7 +21,7 @@ internal class FabricMembershipOracle : IMembershipOracle, IFabricServiceStatusL private readonly AutoResetEvent notificationEvent = new AutoResetEvent(false); private readonly BlockingCollection notifications = new BlockingCollection(); - private readonly TimeSpan refreshPeriod = TimeSpan.FromSeconds(30); + private readonly TimeSpan refreshPeriod = TimeSpan.FromSeconds(5); private readonly ILocalSiloDetails localSiloDetails; private readonly GlobalConfiguration globalConfig; private readonly IFabricServiceSiloResolver fabricServiceSiloResolver; From 755e15ee57d113d22d9fc256d1c2b85d51ae2085 Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Tue, 1 Aug 2017 06:50:18 +1000 Subject: [PATCH 4/4] review feedback --- src/OrleansServiceFabricUtils/FabricGatewayProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs index 004480ebb4..b36a04dcf9 100644 --- a/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs +++ b/src/OrleansServiceFabricUtils/FabricGatewayProvider.cs @@ -67,7 +67,7 @@ public async Task InitializeGatewayListProvider(ClientConfiguration clientConfig /// public bool SubscribeToGatewayNotificationEvents(IGatewayListListener subscriber) { - this.log.Verbose($"Unsubscribing {subscriber} to gateway notification events."); + this.log.Verbose($"Subscribing {subscriber} to gateway notification events."); this.subscribers.TryAdd(subscriber, subscriber); return true; }