Esempio 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.");
        }
Esempio n. 3
0
 public Task ScheduleDelayedIncrement(INonReentrantGrain target, TimeSpan delay)
 {
     RegisterTimer(async o =>
     {
         await target.IncrementCounter();
     },
                   null,
                   delay,
                   TimeSpan.FromMilliseconds(-1));
     return(Task.CompletedTask);
 }
Esempio n. 4
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return(Task.CompletedTask);
 }
Esempio n. 5
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.LogInformation("SetSelf {Self}", self);
     Self = self;
     return(Task.CompletedTask);
 }
Esempio n. 6
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return TaskDone.Done;
 }
Esempio n. 7
0
 public Task SetSelf(INonReentrantGrain self)
 {
     logger.Info("SetSelf {0}", self);
     Self = self;
     return(TaskDone.Done);
 }
Esempio n. 8
0
 public Task <int> PingSelfThroughOtherInterleaving(INonReentrantGrain target, int t)
 {
     return(target.PingOther(this, t));
 }
Esempio n. 9
0
 public Task <int> PingOther(INonReentrantGrain target, int t)
 {
     return(target.Ping(t));
 }