public async Task Test_Indexing_IndexLookup2()
        {
            IPlayer2GrainNonFaultTolerantLazy p1 = base.GetGrain <IPlayer2GrainNonFaultTolerantLazy>(1);
            await p1.SetLocation(ITC.Tehran);

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

            await p2.SetLocation(ITC.Tehran);

            await p3.SetLocation(ITC.Yazd);

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

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

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

            await p2.Deactivate();

            await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily);

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

            p2 = base.GetGrain <IPlayer2GrainNonFaultTolerantLazy>(2);
            Assert.Equal(ITC.Tehran, await p2.GetLocation());
            Assert.Equal(2, await getLocationCount(ITC.Tehran));
        }
Beispiel #2
0
        public async Task Test_Indexing_IndexLookup3()
        {
            await base.StartAndWaitForSecondSilo();

            IPlayer2GrainNonFaultTolerantLazy p1 = base.GetGrain <IPlayer2GrainNonFaultTolerantLazy>(1);
            await p1.SetLocation(ITC.Seattle);

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

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

            var locIdx = await base.GetAndWaitForIndex <string, IPlayer2GrainNonFaultTolerantLazy>(ITC.LocationProperty);

            Task <int> getLocationCount(string location) => this.GetPlayerLocationCount <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>(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 <IPlayer2GrainNonFaultTolerantLazy>(2);
            Assert.Equal(ITC.Seattle, await p2.GetLocation());

            Assert.Equal(2, await getLocationCount(ITC.Seattle));
        }
        public async Task Test_Indexing_IndexLookup3()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

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

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

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

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

            await p2.SetLocation("Seattle");

            await p3.SetLocation("San Fransisco");

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

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

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("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 <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

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

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));
        }
Beispiel #4
0
        public async Task Test_Indexing_IndexLookup2()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

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

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

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

            await p2.SetLocation("Tehran");

            await p3.SetLocation("Yazd");

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

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

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("Tehran", 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 <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("Tehran", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));

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

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer2GrainNonFaultTolerantLazy, Player2PropertiesNonFaultTolerantLazy>("Tehran", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY));
        }