public void IsNoOpp()
            {
                var ranges1 = master.Join(endPoint);
                var ranges2 = master.Join(endPoint);

                Assert.Equal(ranges1, ranges2);
            }
            public void AddingNewNodeResultInAllSegmentsHavingSingleBackupCopy()
            {
                var ranges = master.Join(endPoint);

                master.CaughtUp(endPoint, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
                Assert.True(master.Segments.All(x => x.PendingBackups.Count == 1));
            }
            public NewEndpointJoiningMasterWithTwoNodes()
            {
                master.Join(endPoint);
                var ranges = master.Join(anotherNodeInTheMaster);

                master.CaughtUp(anotherNodeInTheMaster, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
                master.Join(newEndpoint);
            }
Beispiel #4
0
            public void WillRaiseTopologyChangedEvent()
            {
                var ranges = master.Join(endPoint);

                bool wasCalled = false;

                master.TopologyChanged += () => wasCalled = true;
                master.CaughtUp(endPoint, ReplicationType.Ownership, ranges.First().Index);
                Assert.True(wasCalled);
            }
            public void WillRemoveThePendingMoveFromTheSegment()
            {
                var ranges = master.Join(endPoint);

                var range = ranges.First();

                Assert.NotNull(range.InProcessOfMovingToEndpoint);

                master.GaveUp(endPoint, ReplicationType.Ownership, range.Index);

                Assert.Null(range.InProcessOfMovingToEndpoint);
            }
            public OnMasterWithTwoNodes()
            {
                master   = new DistributedHashTableMaster();
                endPoint = NodeEndpoint.ForTest(9);

                var existingEndpoint = NodeEndpoint.ForTest(3);
                var ranges           = master.Join(existingEndpoint);

                master.CaughtUp(existingEndpoint, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
                var anotherPoint = NodeEndpoint.ForTest(10);

                ranges = master.Join(anotherPoint);
                master.CaughtUp(anotherPoint, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
            }
 public OnGaveUp()
 {
     master = new DistributedHashTableMaster();
     master.CaughtUp(NodeEndpoint.ForTest(9),
                     ReplicationType.Ownership,
                     master.Join(NodeEndpoint.ForTest(9)).Select(x => x.Index).ToArray());
     endPoint = NodeEndpoint.ForTest(5);
 }
 public OnGaveUp()
 {
     master = new DistributedHashTableMaster();
     master.CaughtUp(NodeEndpoint.ForTest(9),
                     ReplicationType.Ownership,
                     master.Join(NodeEndpoint.ForTest(9)).Select(x => x.Index).ToArray());
     endPoint = NodeEndpoint.ForTest(5);
 }
            public void AddingNewNodeResultInAllSegmentsHavingAtLeastTwoBackupCopy()
            {
                var yetAnotherEndPoint = NodeEndpoint.ForTest(7);
                var ranges             = master.Join(yetAnotherEndPoint);

                master.CaughtUp(yetAnotherEndPoint, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
                Assert.True(master.Segments.All(x => x.PendingBackups.Count >= 2));
            }
Beispiel #10
0
            public OnMasterWithOneExistingNode()
            {
                master = new DistributedHashTableMaster();
                endPoint = NodeEndpoint.ForTest(9);

                var existingEndpoint = NodeEndpoint.ForTest(3);
                var ranges = master.Join(existingEndpoint);
                master.CaughtUp(existingEndpoint, ReplicationType.Ownership, ranges.Select(x => x.Index).ToArray());
            }
        private void HandleJoin(MasterMessageUnion wrapper,
                                MessageStreamWriter <MasterMessageUnion> writer)
        {
            var endpoint = wrapper.JoinRequest.EndpointJoining;
            var segments = master.Join(new NodeEndpoint
            {
                Async = new Uri(endpoint.Async),
                Sync  = new Uri(endpoint.Sync)
            });
            var joinResponse = new JoinResponseMessage.Builder
            {
                SegmentsList = { segments.Select(x => x.GetSegment()) }
            };

            writer.Write(new MasterMessageUnion.Builder
            {
                Type         = MasterMessageType.JoinResult,
                JoinResponse = joinResponse.Build()
            }.Build());
        }
 public NewEndpointJoiningNonEmptyMaster()
 {
     master.Join(endPoint);
     master.Join(newEndpoint);
 }
            public void AllSegmentsAreDirectlyAllocatedToEndpoint()
            {
                master.Join(endPoint);

                Assert.True(master.Segments.All(x => x.AssignedEndpoint == endPoint));
            }
 public NewEndpointJoiningMasterWhenAnotherJoinIsInTheProcessOfJoining()
 {
     master.Join(endPoint);
     master.Join(anotherNodeInTheProcessOfJoining);
     master.Join(newEndpoint);
 }
            public void AddingNewNodeResultInAllSegmentsHavingNoBackupCopies()
            {
                master.Join(endPoint);

                Assert.True(master.Segments.All(x => x.PendingBackups.Count == 0));
            }