public async Task Test_Indexing_IndexLookup3()
        {
            await base.StartAndWaitForSecondSilo();

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

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

            await p2.SetLocation(ITC.Seattle);

            await p3.SetLocation(ITC.SanFrancisco);

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

            Task <int> getLocationCount(string location) => this.GetPlayerLocationCount <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>(location);

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

            await p2.Deactivate();

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

            p2 = base.GetGrain <IPlayer2GrainNonFaultTolerant>(2);
            Assert.Equal(ITC.Seattle, await p2.GetLocation());
            Assert.Equal(2, await getLocationCount(ITC.Seattle));
        }
Exemplo n.º 2
0
        public async Task Test_Indexing_IndexLookup2()
        {
            IPlayer2GrainNonFaultTolerant p1 = base.GetGrain <IPlayer2GrainNonFaultTolerant>(1);
            await p1.SetLocation(ITC.Tehran);

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

            await p2.SetLocation(ITC.Tehran);

            await p3.SetLocation(ITC.Yazd);

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

            Task <int> getLocationCount(string location) => this.GetLocationCount <IPlayer2GrainNonFaultTolerant, Player2PropertiesNonFaultTolerant>(location);

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

            await p2.Deactivate();

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

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