Пример #1
0
 private static void ClearRebalanceInProgress <TCoordinator>(this TCoordinator coordinator, string shard) where TCoordinator : IShardCoordinator
 {
     if (coordinator.RebalanceInProgress.TryGetValue(shard, out var pendingGetShardHome))
     {
         var msg = new PersistentShardCoordinator.GetShardHome(shard);
         foreach (var sender in pendingGetShardHome)
         {
             coordinator.Self.Tell(msg, sender);
         }
         coordinator.RebalanceInProgress = coordinator.RebalanceInProgress.Remove(shard);
     }
 }
Пример #2
0
        internal static bool HandleGetShardHome <TCoordinator>(this TCoordinator coordinator, PersistentShardCoordinator.GetShardHome getShardHome) where TCoordinator : IShardCoordinator
        {
            var shard = getShardHome.Shard;

            if (coordinator.RebalanceInProgress.ContainsKey(shard))
            {
                coordinator.DeferGetShardHomeRequest(shard, coordinator.Sender);
                return(true);
            }
            else if (!coordinator.HasAllRegionsRegistered())
            {
                coordinator.Log.Debug("GetShardHome [{0}] request ignored, because not all regions have registered yet.", shard);
                return(true);
            }
            else
            {
                if (coordinator.CurrentState.Shards.TryGetValue(shard, out var region))
                {
                    if (coordinator.RegionTerminationInProgress.Contains(region))
                    {
                        coordinator.Log.Debug("GetShardHome [{0}] request ignored, due to region [{1}] termination in progress.", shard, region);
                    }
                    else
                    {
                        coordinator.Sender.Tell(new PersistentShardCoordinator.ShardHome(shard, region));
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }