예제 #1
0
        public async Task Test_Indexing_IndexLookup1()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            IPlayerChain1Grain p1 = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(1);
            await p1.SetLocation("Seattle");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayerChain1Grain p2  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(2);
            IPlayerChain1Grain p3  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(3);
            IPlayerChain1Grain p4  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(4);
            IPlayerChain1Grain p5  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(5);
            IPlayerChain1Grain p6  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(6);
            IPlayerChain1Grain p7  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(7);
            IPlayerChain1Grain p8  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(8);
            IPlayerChain1Grain p9  = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(9);
            IPlayerChain1Grain p10 = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(10);

            await p2.SetLocation("San Jose");

            await p3.SetLocation("San Fransisco");

            await p4.SetLocation("Bellevue");

            await p5.SetLocation("Redmond");

            await p6.SetLocation("Kirkland");

            await p7.SetLocation("Kirkland");

            await p8.SetLocation("Kirkland");

            await p9.SetLocation("Seattle");

            await p10.SetLocation("Kirkland");

            IndexInterface <string, IPlayerChain1Grain> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayerChain1Grain>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayerChain1Grain, PlayerChain1Properties>("Seattle", output));
            Assert.Equal(4, await IndexingTestUtils.CountPlayersStreamingIn <IPlayerChain1Grain, PlayerChain1Properties>("Kirkland", output));

            await p8.Deactivate();

            await p9.Deactivate();

            Thread.Sleep(1000);

            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayerChain1Grain, PlayerChain1Properties>("Seattle", output));
            Assert.Equal(3, await IndexingTestUtils.CountPlayersStreamingIn <IPlayerChain1Grain, PlayerChain1Properties>("Kirkland", output));

            p10 = GrainClient.GrainFactory.GetGrain <IPlayerChain1Grain>(10);
            Assert.Equal("Kirkland", await p10.GetLocation());
        }
        public async Task Test_Indexing_IndexLookup3()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            if (HostedCluster.SecondarySilos.Count == 0)
            {
                HostedCluster.StartAdditionalSilo();
                await HostedCluster.WaitForLivenessToStabilizeAsync();
            }

            IPlayer2Grain p1 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(1);
            await p1.SetLocation("Seattle");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayer2Grain p2 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(2);
            IPlayer2Grain p3 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(3);

            await p2.SetLocation("Seattle");

            await p3.SetLocation("San Fransisco");

            IndexInterface <string, IPlayer2Grain> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer2Grain>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }

            output.WriteLine("Before check 1");
            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            await p2.Deactivate();

            await Task.Delay(DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY);

            output.WriteLine("Before check 2");
            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            p2 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(2);
            output.WriteLine("Before check 3");
            Assert.Equal("Seattle", await p2.GetLocation());

            output.WriteLine("Before check 4");
            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));
            output.WriteLine("Done.");
        }
예제 #3
0
        public async Task Test_Indexing_IndexLookup3()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            if (HostedCluster.SecondarySilos.Count == 0)
            {
                HostedCluster.StartAdditionalSilo();
                await HostedCluster.WaitForLivenessToStabilizeAsync();
            }

            IPlayer2GrainNonFaultTolerant p1 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(1);
            await p1.SetLocation("Seattle");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayer2GrainNonFaultTolerant p2 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(2);
            IPlayer2GrainNonFaultTolerant p3 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(3);

            await p2.SetLocation("Seattle");

            await p3.SetLocation("San Fransisco");

            IndexInterface <string, IPlayer2GrainNonFaultTolerant> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer2GrainNonFaultTolerant>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));

            await p2.Deactivate();

            Thread.Sleep(1000);

            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));

            p2 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(2);
            Assert.Equal("Seattle", await p2.GetLocation());

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Seattle", output));
        }
예제 #4
0
        public async Task Test_Indexing_IndexLookup2()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            IPlayer2Grain p1 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(1);
            await p1.SetLocation("Tehran");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayer2Grain p2 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(2);
            IPlayer2Grain p3 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(3);

            await p2.SetLocation("Tehran");

            await p3.SetLocation("Yazd");

            IndexInterface <string, IPlayer2Grain> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer2Grain>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }

            output.WriteLine("Before check 1");
            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Tehran", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            await p2.Deactivate();

            await Task.Delay(DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY);

            output.WriteLine("Before check 2");
            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Tehran", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            p2 = GrainClient.GrainFactory.GetGrain <IPlayer2Grain>(2);
            output.WriteLine("Before check 3");
            Assert.Equal("Tehran", await p2.GetLocation());

            output.WriteLine("Before check 4");
            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2Grain, Player2Properties>("Tehran", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));
            output.WriteLine("Done.");
        }
예제 #5
0
        public async Task Test_Indexing_IndexLookup1()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            IPlayer1GrainNonFaultTolerantLazy p1 = GrainClient.GrainFactory.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(1);
            await p1.SetLocation("Seattle");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayer1GrainNonFaultTolerantLazy p2 = GrainClient.GrainFactory.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(2);
            IPlayer1GrainNonFaultTolerantLazy p3 = GrainClient.GrainFactory.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(3);

            await p2.SetLocation("Seattle");

            await p3.SetLocation("San Fransisco");

            IndexInterface <string, IPlayer1GrainNonFaultTolerantLazy> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer1GrainNonFaultTolerantLazy>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }



            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer1GrainNonFaultTolerantLazy, Player1PropertiesNonFaultTolerantLazy>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            await p2.Deactivate();

            await Task.Delay(DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY);

            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer1GrainNonFaultTolerantLazy, Player1PropertiesNonFaultTolerantLazy>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

            p2 = GrainClient.GrainFactory.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(2);
            Assert.Equal("Seattle", await p2.GetLocation());

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer1GrainNonFaultTolerantLazy, Player1PropertiesNonFaultTolerantLazy>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));
        }
예제 #6
0
        public async Task Test_Indexing_IndexLookup2()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

            IPlayer2GrainNonFaultTolerant p1 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(1);
            await p1.SetLocation("Tehran");

            //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__GetLocation");
            //Assert.IsTrue(isLocIndexCreated);

            IPlayer2GrainNonFaultTolerant p2 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(2);
            IPlayer2GrainNonFaultTolerant p3 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(3);

            await p2.SetLocation("Tehran");

            await p3.SetLocation("Yazd");

            IndexInterface <string, IPlayer2GrainNonFaultTolerant> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer2GrainNonFaultTolerant>("__Location");

            while (!await locIdx.IsAvailable())
            {
                Thread.Sleep(50);
            }

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Tehran", output));

            await p2.Deactivate();

            Thread.Sleep(1000);

            Assert.Equal(1, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Tehran", output));

            p2 = GrainClient.GrainFactory.GetGrain <IPlayer2GrainNonFaultTolerant>(2);
            Assert.Equal("Tehran", await p2.GetLocation());

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>("Tehran", output));
        }