Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddressAlreadyBoundMessage() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestAddressAlreadyBoundMessage()
        {
            // given
            _testSocket = BindPort("localhost", PortAuthority.allocatePort());

            // when
            AssertableLogProvider logProvider         = new AssertableLogProvider();
            AssertableLogProvider userLogProvider     = new AssertableLogProvider();
            ListenSocketAddress   listenSocketAddress = new ListenSocketAddress("localhost", _testSocket.LocalPort);

            Server catchupServer = new Server(channel =>
            {
            }, logProvider, userLogProvider, listenSocketAddress, "server-name");

            //then
            try
            {
                catchupServer.Start();
            }
            catch (Exception)
            {
                //expected.
            }
            logProvider.FormattedMessageMatcher().assertContains("server-name: address is already bound: ");
            userLogProvider.FormattedMessageMatcher().assertContains("server-name: address is already bound: ");
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldValidateNullReadReplicaAttrMaps()
        public virtual void ShouldValidateNullReadReplicaAttrMaps()
        {
            // given
            MemberId        memberId        = new MemberId(System.Guid.randomUUID());
            ReadReplicaInfo readReplicaInfo = GenerateReadReplicaInfo();

            MockReadReplicaAttributes(singletonMap(memberId, readReplicaInfo), singleton(READ_REPLICAS_DB_NAME_MAP), emptyMap());

            // when
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            IDictionary <MemberId, ReadReplicaInfo> rrMap = HazelcastClusterTopology.ReadReplicas(_hzInstance, log);

            // then
            assertEquals(emptyMap(), rrMap);
            logProvider.FormattedMessageMatcher().assertContains("Some, but not all, of the read replica attribute maps are null");
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogAndExcludeMembersWithMissingAttributes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogAndExcludeMembersWithMissingAttributes()
        {
            // given
            int              numMembers       = 4;
            ISet <Member>    hazelcastMembers = new HashSet <Member>();
            IList <MemberId> coreMembers      = new List <MemberId>();

            System.Func <int, Dictionary <string, string> > generator = i =>
            {
                Dictionary <string, string> settings = _defaultSettingsGenerator.apply(i);
                settings.remove(CausalClusteringSettings.transaction_advertised_address.name());
                settings.remove(CausalClusteringSettings.raft_advertised_address.name());
                return(settings);
            };

            IList <Config> configs = GenerateConfigs(numMembers, generator);

            for (int i = 0; i < configs.Count; i++)
            {
                MemberId memberId = new MemberId(System.Guid.randomUUID());
                coreMembers.Add(memberId);
                Config c = configs[i];
                IDictionary <string, object> attributes = buildMemberAttributesForCore(memberId, c).Attributes;
                if (i == 2)
                {
                    attributes.Remove(HazelcastClusterTopology.RAFT_SERVER);
                }
                hazelcastMembers.Add(new MemberImpl(new Address("localhost", i), null, attributes, false));
            }

            // when
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            IDictionary <MemberId, CoreServerInfo> map = toCoreMemberMap(hazelcastMembers, log, _hzInstance);

            // then
            assertThat(map.Keys, hasItems(coreMembers[0], coreMembers[1], coreMembers[3]));
            assertThat(map.Keys, not(hasItems(coreMembers[2])));
            logProvider.FormattedMessageMatcher().assertContains("Missing member attribute");
        }