public async Task Test_Indexing_IndexLookup4() { IPlayer3Grain p1 = base.GetGrain <IPlayer3Grain>(1); await p1.SetLocation(ITC.Seattle); IPlayer3Grain p2 = base.GetGrain <IPlayer3Grain>(2); IPlayer3Grain p3 = base.GetGrain <IPlayer3Grain>(3); await p2.SetLocation(ITC.Seattle); await p3.SetLocation(ITC.SanFrancisco); var locIdx = await base.GetAndWaitForIndex <string, IPlayer3Grain>(ITC.LocationIndex); Task <int> getLocationCount(string location) => this.GetLocationCount <IPlayer3Grain, Player3Properties>(location, ITC.DelayUntilIndexesAreUpdatedLazily); Assert.Equal(2, await getLocationCount(ITC.Seattle)); await p2.Deactivate(); await Task.Delay(ITC.DelayUntilIndexesAreUpdatedLazily); Assert.Equal(2, await getLocationCount(ITC.Seattle)); p2 = base.GetGrain <IPlayer3Grain>(2); Assert.Equal(ITC.Seattle, await p2.GetLocation()); Assert.Equal(2, await getLocationCount(ITC.Seattle)); }
public async Task Test_Indexing_IndexLookup5() { //await base.StartAndWaitForSecondSilo(); IPlayer3Grain p1 = base.GetGrain <IPlayer3Grain>(1); await p1.SetLocation(ITC.Seattle); IPlayer3Grain p2 = base.GetGrain <IPlayer3Grain>(2); IPlayer3Grain p3 = base.GetGrain <IPlayer3Grain>(3); IPlayer3Grain p4 = base.GetGrain <IPlayer3Grain>(4); IPlayer3Grain p5 = base.GetGrain <IPlayer3Grain>(5); await p2.SetLocation(ITC.Seattle); await p3.SetLocation(ITC.SanFrancisco); await p4.SetLocation(ITC.Tehran); await p5.SetLocation(ITC.Yazd); for (int i = 0; i < 100; ++i) { var tasks = new List <Task>(); for (int j = 0; j < 10; ++j) { p1 = base.GetGrain <IPlayer3Grain>(j); tasks.Add(p1.SetLocation(ITC.Yazd + i + "-" + j)); } await Task.WhenAll(tasks); } }
public async Task Test_Indexing_IndexLookup5() { //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>(); //if (HostedCluster.SecondarySilos.Count == 0) //{ // HostedCluster.StartAdditionalSilos(1); // await HostedCluster.WaitForLivenessToStabilizeAsync(); //} //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>(); IPlayer3Grain p1 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(1); await p1.SetLocation("Seattle"); //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__Location"); //Assert.IsTrue(isLocIndexCreated); IPlayer3Grain p2 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(2); IPlayer3Grain p3 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(3); IPlayer3Grain p4 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(4); IPlayer3Grain p5 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(5); await p2.SetLocation("Seattle"); await p3.SetLocation("San Fransisco"); await p4.SetLocation("Tehran"); await p5.SetLocation("Yazd"); for (int i = 0; i < 100; ++i) { List <Task> tasks = new List <Task>(); for (int j = 0; j < 10; ++j) { p1 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(j); tasks.Add(p1.SetLocation("Yazd" + i + "-" + j)); } await Task.WhenAll(tasks); } }
public async Task Test_Indexing_IndexLookup4() { //await GrainClient.GrainFactory.DropAllIndexes<IPlayerGrain>(); IPlayer3Grain p1 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(1); await p1.SetLocation("Seattle"); //bool isLocIndexCreated = await GrainClient.GrainFactory.CreateAndRegisterIndex<HashIndexSingleBucketInterface<string, IPlayerGrain>, PlayerLocIndexGen>("__Location"); //Assert.IsTrue(isLocIndexCreated); IPlayer3Grain p2 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(2); IPlayer3Grain p3 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(3); await p2.SetLocation("Seattle"); await p3.SetLocation("San Fransisco"); IndexInterface <string, IPlayer3Grain> locIdx = GrainClient.GrainFactory.GetIndex <string, IPlayer3Grain>("__Location"); while (!await locIdx.IsAvailable()) { Thread.Sleep(50); } Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer3Grain, Player3Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY)); await p2.Deactivate(); await Task.Delay(DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY); Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer3Grain, Player3Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY)); p2 = GrainClient.GrainFactory.GetGrain <IPlayer3Grain>(2); Assert.Equal("Seattle", await p2.GetLocation()); Assert.Equal(2, await IndexingTestUtils.CountPlayersStreamingIn <IPlayer3Grain, Player3Properties>("Seattle", output, DELAY_UNTIL_INDEXES_ARE_UPDATED_LAZILY)); }