private void SelectFastest(NodeSelectorState state, int index) { state.Fastest = index; Interlocked.Exchange(ref state.SpeedTestMode, 0); _updateFastestNodeTimer.Change(TimeSpan.FromMinutes(1), Timeout.InfiniteTimeSpan); }
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); }
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); }
public NodeSelector(Topology topology) { _state = new NodeSelectorState(topology); }
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]); }