Ejemplo n.º 1
0
 /// <summary>
 /// Signal a routing table change. We do this using an Interlocked
 /// operation to avoid having to manage yet another prioritized message
 /// in the actor loop.
 /// </summary>
 /// <param name="table"></param>
 public void ChangeRoutingTable(RoutingTable table)
 {
     if (_routingTable != null && _routingTable.LastRefreshed >= table.LastRefreshed)
     {
         return;
     }
     Interlocked.Exchange(ref _routingTable, new RoutingTable(table));
     _innerActor.Post(new ConsumerMessage
     {
         MessageType = ConsumerMessageType.CheckPostponedAfterRoutingTableChange
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize from existing routing table, removing partitions with NbIsr less
        /// than a given value
        /// </summary>
        /// <param name="fromTable"></param>
        /// <param name="minIsr"></param>
        public RoutingTable(RoutingTable fromTable, int minIsr)
        {
            _routes = new Dictionary <string, Partition[]>();
            var tmp = new List <Partition>();

            foreach (var kv in fromTable._routes)
            {
                tmp.AddRange(kv.Value.Where(partition => partition.NbIsr >= minIsr));
                _routes.Add(kv.Key, tmp.ToArray());
                tmp.Clear();
            }
            LastRefreshed = fromTable.LastRefreshed;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize from existing routing table, removing partitions with dead nodes
        /// </summary>
        /// <param name="fromTable"></param>
        /// <param name="deadNode"></param>
        public RoutingTable(RoutingTable fromTable, INode deadNode)
        {
            _routes = new Dictionary <string, Partition[]>();
            var tmp = new List <Partition>();

            foreach (var kv in fromTable._routes)
            {
                tmp.AddRange(kv.Value.Where(partition => !Equals(partition.Leader, deadNode)));
                _routes.Add(kv.Key, tmp.ToArray());
                tmp.Clear();
            }
            LastRefreshed = fromTable.LastRefreshed;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Signal a routing table change. We do this using an Interlocked
 /// operation to avoid having to manage yet another prioritized message
 /// in the actor loop. Will also initiate a check of postponed messages.
 /// </summary>
 /// <param name="table"></param>
 public void ChangeRoutingTable(RoutingTable table)
 {
     if (_routingTable != null && _routingTable.LastRefreshed >= table.LastRefreshed)
     {
         return;
     }
     if (_configuration.RequiredAcks == RequiredAcks.AllInSyncReplicas)
     {
         Interlocked.Exchange(ref _routingTable, new RoutingTable(table, _configuration.MinInSyncReplicas));
     }
     else
     {
         Interlocked.Exchange(ref _routingTable, new RoutingTable(table));
     }
     _messages.Post(RouterMessageType.CheckPostponedFollowingRoutingTableChange);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initialize from existing routing table
 /// than a given value
 /// </summary>
 /// <param name="fromTable"></param>
 public RoutingTable(RoutingTable fromTable)
 {
     _routes       = new Dictionary <string, Partition[]>(fromTable._routes);
     LastRefreshed = fromTable.LastRefreshed;
 }