コード例 #1
0
        private async Task DeactivateOnIdle_NonExistentActivation_Runner(int forwardCount)
        {
            var builder = new TestClusterBuilder(2);

            builder.AddClientBuilderConfigurator <ClientConfigurator>();
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            builder.Properties["MaxForwardCount"] = forwardCount.ToString();
            Initialize(builder);

            ICollectionTestGrain grain = await PickGrainInNonPrimary();

            output.WriteLine("About to make a 1st GetAge() call.");
            TimeSpan age = await grain.GetAge();

            output.WriteLine(age.ToString());

            await grain.DeactivateSelf();

            await Task.Delay(3000);

            var thrownException = await Record.ExceptionAsync(() => grain.GetAge());

            Assert.Null(thrownException);
            output.WriteLine("\nThe 1st call after DeactivateSelf has NOT thrown any exception as expected, since forwardCount is {0}.\n", forwardCount);
        }
コード例 #2
0
        private async Task DeactivateOnIdle_NonExistentActivation_Runner(int forwardCount)
        {
            var builder = new TestClusterBuilder(2);

            builder.ConfigureLegacyConfiguration(legacy =>
            {
                legacy.ClusterConfiguration.Globals.MaxForwardCount = forwardCount;
                // For this test we only want to talk to the primary
                legacy.ClientConfiguration.Gateways.RemoveAt(1);
                if (forwardCount == 0)
                {
                    // Disable reminder service for this test: when the secondary silo starts it may
                    // not see right away the activation from the primary silo. This request should be forwarded
                    // to the correct activation, but since we deactivate forwarding, the secondary silo will
                    // fail to start...
                    legacy.ClusterConfiguration.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.Disabled;
                }
            });
            Initialize(builder);

            ICollectionTestGrain grain = await PickGrainInNonPrimary();

            output.WriteLine("About to make a 1st GetAge() call.");
            TimeSpan age = await grain.GetAge();

            output.WriteLine(age.ToString());

            await grain.DeactivateSelf();

            await Task.Delay(3000);

            // ReSharper disable once PossibleNullReferenceException
            var thrownException = await Record.ExceptionAsync(() => grain.GetAge());

            if (forwardCount != 0)
            {
                Assert.Null(thrownException);
                output.WriteLine("\nThe 1st call after DeactivateSelf has NOT thrown any exception as expected, since forwardCount is {0}.\n", forwardCount);
            }
            else
            {
                Assert.NotNull(thrownException);
                Assert.IsType <OrleansMessageRejectionException>(thrownException);
                Assert.Contains("Non-existent activation", thrownException.Message);
                output.WriteLine("\nThe 1st call after DeactivateSelf has thrown Non-existent activation exception as expected, since forwardCount is {0}.\n", forwardCount);

                // Try sending agan now and see it was fixed.
                await grain.GetAge();
            }
        }
コード例 #3
0
        private async Task DeactivateOnIdle_NonExistentActivation_Runner(int forwardCount)
        {
            var options = new TestClusterOptions(2);

            options.ClusterConfiguration.Globals.MaxForwardCount = forwardCount;
            options.ClusterConfiguration.Defaults.Generation     = 13;
            // For this test we only want to talk to the primary
            options.ClientConfiguration.Gateways.RemoveAt(1);
            Initialize(options);

            ICollectionTestGrain grain = await PickGrain();

            Assert.NotNull(grain);

            logger.Info("About to make a 1st GetAge() call.");
            TimeSpan age = await grain.GetAge();

            logger.Info(age.ToString());

            await grain.DeactivateSelf();

            Thread.Sleep(3000);

            // ReSharper disable once PossibleNullReferenceException
            var thrownException = await Record.ExceptionAsync(() => grain.GetAge());

            if (forwardCount != 0)
            {
                Assert.Null(thrownException);
                logger.Info("\nThe 1st call after DeactivateSelf has NOT thrown any exception as expected, since forwardCount is {0}.\n", forwardCount);
            }
            else
            {
                Assert.NotNull(thrownException);
                Assert.IsType <OrleansException>(thrownException);
                Assert.Contains("Non-existent activation", thrownException.Message);
                logger.Info("\nThe 1st call after DeactivateSelf has thrown Non-existent activation exception as expected, since forwardCount is {0}.\n", forwardCount);

                // Try sending agan now and see it was fixed.
                await grain.GetAge();
            }
        }
コード例 #4
0
        private async Task DeactivateOnIdle_NonExistentActivation_Runner(int forwardCount)
        {
            var builder = new TestClusterBuilder(2);

            builder.AddClientBuilderConfigurator <ClientConfigurator>();
            builder.AddSiloBuilderConfigurator <SiloConfigurator>();
            builder.Properties["MaxForwardCount"] = forwardCount.ToString();
            Initialize(builder);

            ICollectionTestGrain grain = await PickGrainInNonPrimary();

            output.WriteLine("About to make a 1st GetAge() call.");
            TimeSpan age = await grain.GetAge();

            output.WriteLine(age.ToString());

            await grain.DeactivateSelf();

            await Task.Delay(3000);

            // ReSharper disable once PossibleNullReferenceException
            var thrownException = await Record.ExceptionAsync(() => grain.GetAge());

            if (forwardCount != 0)
            {
                Assert.Null(thrownException);
                output.WriteLine("\nThe 1st call after DeactivateSelf has NOT thrown any exception as expected, since forwardCount is {0}.\n", forwardCount);
            }
            else
            {
                Assert.NotNull(thrownException);
                Assert.IsType <OrleansMessageRejectionException>(thrownException);
                Assert.Contains("Non-existent activation", thrownException.Message);
                output.WriteLine("\nThe 1st call after DeactivateSelf has thrown Non-existent activation exception as expected, since forwardCount is {0}.\n", forwardCount);

                // Try sending agan now and see it was fixed.
                await grain.GetAge();
            }
        }