Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void snapshotListPrunesOtherMemberWithSameMasterRole() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SnapshotListPrunesOtherMemberWithSameMasterRole()
        {
            // GIVEN
            // -- a snapshot containing one member with a role
            PaxosClusterMemberEvents.ClusterMembersSnapshot snapshot = new PaxosClusterMemberEvents.ClusterMembersSnapshot(new HANewSnapshotFunction());
            URI               clusterUri = new URI(URI);
            InstanceId        instanceId = new InstanceId(1);
            MemberIsAvailable @event     = new MemberIsAvailable(MASTER, instanceId, clusterUri, new URI(URI + "?something1"), DEFAULT);

            snapshot.AvailableMember(@event);

            // WHEN
            // -- another member, but with same role, gets added to the snapshot
            URI               otherClusterUri = new URI(URI);
            InstanceId        otherInstanceId = new InstanceId(2);
            MemberIsAvailable otherEvent      = new MemberIsAvailable(MASTER, otherInstanceId, otherClusterUri, new URI(URI + "?something2"), DEFAULT);

            snapshot.AvailableMember(otherEvent);

            // THEN
            // -- getting the snapshot list should only reveal the last member added, as it had the same role
            assertEquals(1, Iterables.count(snapshot.GetCurrentAvailable(otherInstanceId)));
            assertThat(snapshot.GetCurrentAvailable(otherInstanceId), hasItems(MemberIsAvailable(otherEvent)));
            assertEquals(1, Iterables.count(snapshot.CurrentAvailableMembers));
            assertThat(snapshot.CurrentAvailableMembers, hasItems(MemberIsAvailable(otherEvent)));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void snapshotListPrunesSameMemberOnIdenticalAvailabilityEvents() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SnapshotListPrunesSameMemberOnIdenticalAvailabilityEvents()
        {
            // GIVEN
            // -- a snapshot containing one member with a role
            PaxosClusterMemberEvents.ClusterMembersSnapshot snapshot = new PaxosClusterMemberEvents.ClusterMembersSnapshot(new PaxosClusterMemberEvents.UniqueRoleFilter()
                                                                                                                           );
            URI               clusterUri        = new URI(URI);
            InstanceId        instanceId        = new InstanceId(1);
            MemberIsAvailable memberIsAvailable = new MemberIsAvailable(MASTER, instanceId, clusterUri, new URI(URI + "?something"), DEFAULT);

            snapshot.AvailableMember(memberIsAvailable);

            // WHEN
            // -- the same member and role gets added to the snapshot
            snapshot.AvailableMember(memberIsAvailable);

            // THEN
            // -- getting the snapshot list should only reveal the last one
            assertEquals(1, Iterables.count(snapshot.GetCurrentAvailable(instanceId)));
            assertThat(snapshot.GetCurrentAvailable(instanceId), hasItem(memberIsAvailable(memberIsAvailable)));
            assertEquals(1, Iterables.count(snapshot.CurrentAvailableMembers));
            assertThat(snapshot.CurrentAvailableMembers, hasItems(memberIsAvailable(memberIsAvailable)));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void snapshotListDoesNotPruneOtherMemberWithSlaveRole() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SnapshotListDoesNotPruneOtherMemberWithSlaveRole()
        {
            // GIVEN
            // -- a snapshot containing one member with a role
            PaxosClusterMemberEvents.ClusterMembersSnapshot snapshot = new PaxosClusterMemberEvents.ClusterMembersSnapshot(new HANewSnapshotFunction());
            URI               clusterUri = new URI(URI);
            InstanceId        instanceId = new InstanceId(1);
            MemberIsAvailable @event     = new MemberIsAvailable(SLAVE, instanceId, clusterUri, new URI(URI + "?something1"), DEFAULT);

            snapshot.AvailableMember(@event);

            // WHEN
            // -- another member, but with same role, gets added to the snapshot
            URI               otherClusterUri = new URI(URI);
            InstanceId        otherInstanceId = new InstanceId(2);
            MemberIsAvailable otherEvent      = new MemberIsAvailable(SLAVE, otherInstanceId, otherClusterUri, new URI(URI + "?something2"), DEFAULT);

            snapshot.AvailableMember(otherEvent);

            // THEN
            assertEquals(2, Iterables.count(snapshot.CurrentAvailableMembers));
            assertThat(snapshot.CurrentAvailableMembers, hasItems(MemberIsAvailable(@event), MemberIsAvailable(otherEvent)));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void snapshotListShouldContainOnlyOneEventForARoleWithTheSameIdWhenSwitchingFromMasterToSlave() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SnapshotListShouldContainOnlyOneEventForARoleWithTheSameIdWhenSwitchingFromMasterToSlave()
        {
            // GIVEN
            // -- a snapshot containing one member with a role
            PaxosClusterMemberEvents.ClusterMembersSnapshot snapshot = new PaxosClusterMemberEvents.ClusterMembersSnapshot(new HANewSnapshotFunction());
            URI               clusterUri = new URI(URI);
            InstanceId        instanceId = new InstanceId(1);
            MemberIsAvailable event1     = new MemberIsAvailable(MASTER, instanceId, clusterUri, new URI(URI + "?something"), DEFAULT);

            snapshot.AvailableMember(event1);

            // WHEN
            // -- the same member, although different role, gets added to the snapshot
            MemberIsAvailable event2 = new MemberIsAvailable(SLAVE, instanceId, clusterUri, new URI(URI + "?something"), DEFAULT);

            snapshot.AvailableMember(event2);

            // THEN
            // -- getting the snapshot list should reveal both
            assertEquals(1, Iterables.count(snapshot.GetCurrentAvailable(instanceId)));
            assertThat(snapshot.GetCurrentAvailable(instanceId), hasItems(MemberIsAvailable(event2)));
            assertEquals(1, Iterables.count(snapshot.CurrentAvailableMembers));
            assertThat(snapshot.CurrentAvailableMembers, hasItems(MemberIsAvailable(event2)));
        }