예제 #1
0
        private void ResolveBuiltInStrategies()
        {
            var statelessWorker = new StatelessWorkerPlacement();

            var placementStrategies = new PlacementStrategy[]
            {
                RandomPlacement.Singleton,
                ActivationCountBasedPlacement.Singleton,
                statelessWorker,
                PreferLocalPlacement.Singleton
            };

            foreach (var strategy in placementStrategies)
            {
                this.ResolveDirector(strategy);
            }

            var selectorStrategies = new PlacementStrategy[]
            {
                RandomPlacement.Singleton,
                statelessWorker,
            };

            foreach (var strategy in selectorStrategies)
            {
                this.ResolveSelector(strategy, true);
            }
        }
예제 #2
0
        public async Task LocallyPlacedGrainShouldCreateActivationsOnLocalSilo()
        {
            await this.HostedCluster.WaitForLivenessToStabilizeAsync();

            logger.Info("********************** Starting the test LocallyPlacedGrainShouldCreateActivationsOnLocalSilo ******************************");
            TestSilosStarted(2);

            const int sampleSize = 5;
            var       placement  = new StatelessWorkerPlacement(sampleSize);
            var       proxy      = this.GrainFactory.GetGrain <IRandomPlacementTestGrain>(Guid.NewGuid());
            await proxy.StartLocalGrains(new List <Guid> {
                Guid.Empty
            });

            var expected = await proxy.GetEndpoint();

            // locally placed grains are multi-activation and stateless. this means that we have to sample the value of
            // the result, rather than simply ask for it once in order to get a consensus of the result.
            var actual = await proxy.SampleLocalGrainEndpoint(Guid.Empty, sampleSize);

            Assert.True(actual.All(expected.Equals),
                        "A grain instantiated with the local placement strategy should create activations on the local silo.");
        }