public void LeastShardAllocationStrategy_must_not_rebalance_when_regions_are_unreachable()
        {
            var member1 = NewUpMember("127.0.0.1");
            var member2 = NewUpMember("127.0.0.2");

            // multiple versions to simulate rolling update in progress
            var allocationStrategy =
                new TestLeastShardAllocationStrategy(rebalanceThreshold: 2, maxSimultaneousRebalance: 100, () => new CurrentClusterState().Copy(members: ImmutableSortedSet.Create(member1, member2), unreachable: ImmutableHashSet.Create(member2)), () => member2);

            var allocations = CreateAllocations(aCount: 5, bCount: 5);

            allocationStrategy.Rebalance(allocations, ImmutableHashSet <string> .Empty).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002")).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002", "051", "052")).Result.Should().BeEmpty();
        }
コード例 #2
0
        public void LeastShardAllocationStrategy_must_not_rebalance_when_rolling_update_in_progress()
        {
            var member1 = NewUpMember("127.0.0.1", version: AppVersion.Create("1.0.0"));
            var member2 = NewUpMember("127.0.0.1", version: AppVersion.Create("1.0.1"));

            // multiple versions to simulate rolling update in progress
            var allocationStrategy =
                new TestLeastShardAllocationStrategy(absoluteLimit: 1000, relativeLimit: 1.0, () => new CurrentClusterState().Copy(members: ImmutableSortedSet.Create(member1, member2)), () => member1);

            var allocations = CreateAllocations(aCount: 5, bCount: 5);

            allocationStrategy.Rebalance(allocations, ImmutableHashSet <string> .Empty).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002")).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002", "051", "052")).Result.Should().BeEmpty();
        }
コード例 #3
0
        public void LeastShardAllocationStrategy_must_not_rebalance_when_members_are_joining_dc()
        {
            var member1 = NewUpMember("127.0.0.1");
            var member2 =
                Member.Create(
                    new UniqueAddress(new Address("akka", "myapp", "127.0.0.2", 252525), 1),
                    ImmutableHashSet <string> .Empty,
                    member1.AppVersion);

            // multiple versions to simulate rolling update in progress
            var allocationStrategy =
                new TestLeastShardAllocationStrategy(absoluteLimit: 1000, relativeLimit: 1.0, () => new CurrentClusterState().Copy(members: ImmutableSortedSet.Create(member1, member2), unreachable: ImmutableHashSet.Create(member2)), () => member2);

            var allocations = CreateAllocations(aCount: 5, bCount: 5);

            allocationStrategy.Rebalance(allocations, ImmutableHashSet <string> .Empty).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002")).Result.Should().BeEmpty();
            allocationStrategy.Rebalance(allocations, ImmutableHashSet.Create("001", "002", "051", "052")).Result.Should().BeEmpty();
        }