Example #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)));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreTheSerialVersionIdOfAClassTheFirstTimeItsDeserialised() throws java.io.IOException, ClassNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStoreTheSerialVersionIdOfAClassTheFirstTimeItsDeserialised()
        {
            // given
            MemberIsAvailable memberIsAvailable = memberIsAvailable();
            Payload           payload           = PayloadFor(memberIsAvailable);
            VersionMapper     versionMapper     = new VersionMapper();

            // when
            (new LenientObjectInputStream(InputStreamFor(payload), versionMapper)).readObject();

            // then
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            assertTrue(versionMapper.HasMappingFor(memberIsAvailable.GetType().FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            assertEquals(SerialVersionUIDFor(memberIsAvailable), versionMapper.MappingFor(memberIsAvailable.GetType().FullName));
        }
Example #3
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)));
        }
Example #4
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)));
        }
Example #5
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)));
        }
Example #6
0
 private long SerialVersionUIDFor(MemberIsAvailable memberIsAvailable)
 {
     return(ObjectStreamClass.lookup(memberIsAvailable.GetType()).SerialVersionUID);
 }
Example #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private static org.hamcrest.Matcher<org.neo4j.cluster.member.paxos.MemberIsAvailable> memberIsAvailable(final org.neo4j.cluster.member.paxos.MemberIsAvailable expected)
        private static Matcher <MemberIsAvailable> MemberIsAvailable(MemberIsAvailable expected)
        {
            return(new BaseMatcherAnonymousInnerClass(expected));
        }