Exemplo n.º 1
0
        public void NonReentrantGrain()
        {
            INonReentrantGrain nonreentrant = GrainClient.GrainFactory.GetGrain <INonReentrantGrain>(GetRandomGrainId());

            nonreentrant.SetSelf(nonreentrant).Wait();
            bool timeout  = false;
            bool deadlock = false;

            try
            {
                timeout = !nonreentrant.Two().Wait(2000);
            }
            catch (Exception exc)
            {
                Exception baseExc = exc.GetBaseException();
                if (baseExc.GetType().Equals(typeof(DeadlockException)))
                {
                    deadlock = true;
                }
                else
                {
                    Assert.Fail("Unexpected exception {0}: {1}", exc.Message, exc.StackTrace);
                }
            }
            if (this.HostedCluster.Primary.Silo.GlobalConfig.PerformDeadlockDetection)
            {
                Assert.IsTrue(deadlock, "Non-reentrant grain should deadlock");
            }
            else
            {
                Assert.IsTrue(timeout, "Non-reentrant grain should timeout");
            }
            logger.Info("Reentrancy NonReentrantGrain Test finished OK.");
        }
        public void NonReentrantGrain(bool performDeadlockDetection)
        {
            INonReentrantGrain nonreentrant = this.grainFactory.GetGrain <INonReentrantGrain>(OrleansTestingBase.GetRandomGrainId());

            nonreentrant.SetSelf(nonreentrant).Wait();
            bool timeout  = false;
            bool deadlock = false;

            try
            {
                timeout = !nonreentrant.Two().Wait(2000);
            }
            catch (Exception exc)
            {
                Exception baseExc = exc.GetBaseException();
                if (baseExc.GetType().Equals(typeof(DeadlockException)))
                {
                    deadlock = true;
                }
                else
                {
                    Assert.True(false, string.Format("Unexpected exception {0}: {1}", exc.Message, exc.StackTrace));
                }
            }
            if (performDeadlockDetection)
            {
                Assert.True(deadlock, "Non-reentrant grain should deadlock");
            }
            else
            {
                Assert.True(timeout, "Non-reentrant grain should timeout");
            }
            this.logger.Info("Reentrancy NonReentrantGrain Test finished OK.");
        }
Exemplo n.º 3
0
 public Task ScheduleDelayedIncrement(INonReentrantGrain target, TimeSpan delay)
 {
     RegisterTimer(async o =>
     {
         await target.IncrementCounter();
     },
                   null,
                   delay,
                   TimeSpan.FromMilliseconds(-1));
     return(Task.CompletedTask);
 }
Exemplo n.º 4
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return(Task.CompletedTask);
 }
Exemplo n.º 5
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.LogInformation("SetSelf {Self}", self);
     Self = self;
     return(Task.CompletedTask);
 }
Exemplo n.º 6
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return TaskDone.Done;
 }
Exemplo n.º 7
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return(TaskDone.Done);
 }
Exemplo n.º 8
0
 public Task <int> PingSelfThroughOtherInterleaving(INonReentrantGrain target, int t)
 {
     return(target.PingOther(this, t));
 }
Exemplo n.º 9
0
 public Task <int> PingOther(INonReentrantGrain target, int t)
 {
     return(target.Ping(t));
 }