/// <summary> /// Schedules the next delayed execution /// </summary> private void ScheduleNext(Host currentHost) { if (Statement == null || Statement.IsIdempotent == false) { //its not idempotent, we should not schedule an speculative execution return; } if (_executionPlan == null) { _executionPlan = Policies.SpeculativeExecutionPolicy.NewPlan(_session.Keyspace, Statement); } var delay = _executionPlan.NextExecution(currentHost); if (delay <= 0) { return; } //There is one live timer at a time. _nextExecutionTimeout = _session.Cluster.Configuration.Timer.NewTimeout(_ => { // Start the speculative execution outside the IO thread Task.Run(() => { if (HasCompleted()) { return; } RequestHandler.Logger.Info("Starting new speculative execution after {0}, last used host {1}", delay, currentHost.Address); StartNewExecution(); }); }, null, delay); }
/// <summary> /// Schedules the next delayed execution /// </summary> private void ScheduleNext() { if (Statement == null || !(Statement.IsIdempotent ?? _session.Cluster.Configuration.QueryOptions.GetDefaultIdempotence())) { //its not idempotent, we should not schedule an speculative execution return; } if (_executionPlan == null) { _executionPlan = Policies.SpeculativeExecutionPolicy.NewPlan(_session.Keyspace, Statement); } var delay = _executionPlan.NextExecution(_host); if (delay <= 0) { return; } //There is one live timer at a time. _nextExecutionTimeout = _session.Cluster.Configuration.Timer.NewTimeout(_ => { if (HasCompleted()) { return; } Logger.Info("Starting new speculative execution after {0}, last used host {1}", delay, _host.Address); StartNewExecution(); }, null, delay); }