コード例 #1
0
        public async Task Test_Indexing_IndexLookup4()
        {
            IPlayer3GrainNonFaultTolerant p1 = base.GetGrain <IPlayer3GrainNonFaultTolerant>(1);
            await p1.SetLocation(ITC.Seattle);

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

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

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

            Task <int> getLocationCount(string location) => this.GetLocationCount <IPlayer3GrainNonFaultTolerant, Player3PropertiesNonFaultTolerant>(location);

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

            await p2.Deactivate();

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

            p2 = base.GetGrain <IPlayer3GrainNonFaultTolerant>(2);
            Assert.Equal(ITC.Seattle, await p2.GetLocation());
            Assert.Equal(2, await getLocationCount(ITC.Seattle));
        }
コード例 #2
0
        public async Task Test_Indexing_IndexLookup4()
        {
            //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>();

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

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

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

            await p2.SetLocation("Seattle");

            await p3.SetLocation("San Fransisco");

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

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

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

            await p2.Deactivate();

            Thread.Sleep(1000);

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

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

            Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer3GrainNonFaultTolerant, Player3PropertiesNonFaultTolerant>("Seattle", output));
        }