public async Task Test_Indexing_IndexLookup1()
        {
            IPlayer1GrainNonFaultTolerantLazy p1 = base.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(1);
            await p1.SetLocation(ITC.Seattle);

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

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

            var locIdx = await base.GetAndWaitForIndex <string, IPlayer1GrainNonFaultTolerantLazy>(ITC.LocationIndex);

            Task <int> getLocationCount(string location) => this.GetLocationCount <IPlayer1GrainNonFaultTolerantLazy, Player1PropertiesNonFaultTolerantLazy>(location, ITC.DelayUntilIndexesAreUpdatedLazily);

            Assert.Equal(2, await getLocationCount(ITC.Seattle));

            await p2.Deactivate();

            await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);

            Assert.Equal(1, await getLocationCount(ITC.Seattle));

            p2 = base.GetGrain <IPlayer1GrainNonFaultTolerantLazy>(2);
            Assert.Equal(ITC.Seattle, await p2.GetLocation());
            Assert.Equal(2, await getLocationCount(ITC.Seattle));
        }
Exemplo n.º 2
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));
        }