Esempio n. 1
0
        public void SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
        {
            var lbp     = new OrderedLoadBalancingPolicy(2, 1, 3);
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);

            TestCluster.PauseNode(2);
            var t = session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false));

            Thread.Sleep(200);
            Assert.AreEqual(TaskStatus.WaitingForActivation, t.Status);
            TestCluster.ResumeNode(2);
            Thread.Sleep(200);
            Assert.AreEqual(TaskStatus.RanToCompletion, t.Status);
        }
        public async Task SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
        {
            var lbp = new OrderedLoadBalancingPolicy(
                TestCluster.GetNode(1).Address.ToString(), TestCluster.GetNode(0).Address.ToString());
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);

            TestCluster.GetNode(1).PrimeFluent(
                b => b.WhenQuery(QueryLocal)
                .ThenRowsSuccess(new[] { "key" }, r => r.WithRow("local")).WithDelayInMs(1000));

            var rs = await session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false)).ConfigureAwait(false);

            // Used the first host in the query plan
            Assert.AreEqual(TestCluster.GetNode(1).IpEndPoint, rs.Info.QueriedHost);
        }
        public async Task SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
        {
            var lbp     = new OrderedLoadBalancingPolicy(2, 1);
            var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);

            TestCluster.PauseNode(2);
            var t = session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false));
            await Task.Delay(200).ConfigureAwait(false);

            Assert.AreEqual(TaskStatus.WaitingForActivation, t.Status);

            TestCluster.ResumeNode(2);
            var rs = await t.ConfigureAwait(false);

            // Used the first host in the query plan
            Assert.AreEqual(2, TestHelper.GetLastAddressByte(rs.Info.QueriedHost));
        }
 public void SpeculativeExecution_Should_Not_Execute_On_Next_Node_When_Not_Idempotent()
 {
     var lbp = new OrderedLoadBalancingPolicy(2, 1, 3);
     var session = GetSession(new ConstantSpeculativeExecutionPolicy(50L, 1), true, lbp);
     TestCluster.PauseNode(2);
     var t = session.ExecuteAsync(new SimpleStatement(QueryLocal).SetIdempotence(false));
     Thread.Sleep(200);
     Assert.AreEqual(TaskStatus.WaitingForActivation, t.Status);
     TestCluster.ResumeNode(2);
     Thread.Sleep(200);
     Assert.AreEqual(TaskStatus.RanToCompletion, t.Status);
 }