Example #1
0
        private void SelectFastest(NodeSelectorState state, int index)
        {
            state.Fastest = index;
            Interlocked.Exchange(ref state.SpeedTestMode, 0);

            _updateFastestNodeTimer.Change(TimeSpan.FromMinutes(1), Timeout.InfiniteTimeSpan);
        }
Example #2
0
        public bool OnUpdateTopology(Topology topology, bool forceUpdate = false)
        {
            if (topology == null)
            {
                return(false);
            }

            if (_state.Topology.Etag >= topology.Etag && forceUpdate == false)
            {
                return(false);
            }

            var state = new NodeSelectorState(topology);

            Interlocked.Exchange(ref _state, state);

            return(true);
        }
Example #3
0
        private static int FindMaxIndex(NodeSelectorState state)
        {
            var stateFastest = state.FastestRecords;
            var maxIndex     = 0;
            var maxValue     = 0;

            for (var i = 0; i < stateFastest.Length; i++)
            {
                if (maxValue >= stateFastest[i])
                {
                    continue;
                }
                maxIndex = i;
                maxValue = stateFastest[i];
            }

            return(maxIndex);
        }
Example #4
0
 public NodeSelector(Topology topology)
 {
     _state = new NodeSelectorState(topology);
 }
Example #5
0
 private static ValueTuple <int, ServerNode> UnlikelyEveryoneFaultedChoice(NodeSelectorState state)
 {
     // if there are all marked as failed, we'll chose the first
     // one so the user will get an error (or recover :-) );
     return(0, state.Nodes[0]);
 }