Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSerializeToString()
        public virtual void ShouldSerializeToString()
        {
            // given
            ClientConnectorAddresses connectorAddresses = new ClientConnectorAddresses(new IList <ConnectorUri>
            {
                new ConnectorUri(bolt, new AdvertisedSocketAddress("host", 1)),
                new ConnectorUri(http, new AdvertisedSocketAddress("host", 2)),
                new ConnectorUri(https, new AdvertisedSocketAddress("host", 3)),
                new ConnectorUri(bolt, new AdvertisedSocketAddress("::1", 4)),
                new ConnectorUri(http, new AdvertisedSocketAddress("::", 5)),
                new ConnectorUri(https, new AdvertisedSocketAddress("fe80:1:2::3", 6))
            });

            string expectedString = "bolt://host:1,http://host:2,https://host:3,bolt://[::1]:4,http://[::]:5,https://[fe80:1:2::3]:6";

            // when
            string connectorAddressesString = connectorAddresses.ToString();

            // then
            assertEquals(expectedString, connectorAddressesString);

            // when
            ClientConnectorAddresses @out = ClientConnectorAddresses.FromString(connectorAddressesString);

            // then
            assertEquals(connectorAddresses, @out);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Given a hazelcast member id and a set of non-null attribute maps, this method builds a discovery representation of a read replica
        /// (i.e. `Pair<MemberId,ReadReplicaInfo>`). Any missing attributes which are missing for a given hazelcast member id are logged and this
        /// method will return null.
        /// </summary>
        private static Pair <MemberId, ReadReplicaInfo> BuildReadReplicaFromAttrMap(string hzId, IDictionary <string, IMap <string, string> > simpleAttrMaps, MultiMap <string, string> serverGroupsMap, Log log)
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IDictionary <string, string> memberAttrs = simpleAttrMaps.SetOfKeyValuePairs().Select(e => Pair.of(e.Key, e.Value.get(hzId))).Where(p => HasAttribute(p, hzId, log)).collect(CollectorsUtil.pairsToMap());

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
            if (!memberAttrs.Keys.containsAll(RrAttrKeys))
            {
                return(null);
            }

            ICollection <string> memberServerGroups = serverGroupsMap.get(hzId);

            if (memberServerGroups == null)
            {
                log.Warn("Missing attribute %s for read replica with hz id %s", SERVER_GROUPS_MULTIMAP, hzId);
                return(null);
            }

            ClientConnectorAddresses boltAddresses = ClientConnectorAddresses.FromString(memberAttrs[READ_REPLICA_BOLT_ADDRESS_MAP]);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            AdvertisedSocketAddress catchupAddress = socketAddress(memberAttrs[READ_REPLICA_TRANSACTION_SERVER_ADDRESS_MAP], AdvertisedSocketAddress::new);
            MemberId      memberId       = new MemberId(System.Guid.Parse(memberAttrs[READ_REPLICA_MEMBER_ID_MAP]));
            string        memberDbName   = memberAttrs[READ_REPLICAS_DB_NAME_MAP];
            ISet <string> serverGroupSet = asSet(memberServerGroups);

            ReadReplicaInfo rrInfo = new ReadReplicaInfo(boltAddresses, catchupAddress, serverGroupSet, memberDbName);

            return(Pair.of(memberId, rrInfo));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSerializeWithNoHttpsAddress()
        public virtual void ShouldSerializeWithNoHttpsAddress()
        {
            // given
            ClientConnectorAddresses connectorAddresses = new ClientConnectorAddresses(asList(new ConnectorUri(bolt, new AdvertisedSocketAddress("host", 1)), new ConnectorUri(http, new AdvertisedSocketAddress("host", 2))
                                                                                              ));

            // when
            ClientConnectorAddresses @out = ClientConnectorAddresses.FromString(connectorAddresses.ToString());

            // then
            assertEquals(connectorAddresses, @out);
        }
Exemplo n.º 4
0
        internal static IDictionary <MemberId, CoreServerInfo> ToCoreMemberMap(ISet <Member> members, Log log, HazelcastInstance hazelcastInstance)
        {
            IDictionary <MemberId, CoreServerInfo> coreMembers = new Dictionary <MemberId, CoreServerInfo>();
            MultiMap <string, string> serverGroupsMMap         = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP);

            foreach (Member member in members)
            {
                IDictionary <string, string> attrMap = new Dictionary <string, string>();
                bool incomplete = false;
                foreach (string attrKey in CoreAttrKeys)
                {
                    string attrValue = member.getStringAttribute(attrKey);
                    if (string.ReferenceEquals(attrValue, null))
                    {
                        log.Warn("Missing member attribute '%s' for member %s", attrKey, member);
                        incomplete = true;
                    }
                    else
                    {
                        attrMap[attrKey] = attrValue;
                    }
                }

                if (incomplete)
                {
                    continue;
                }

//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                CoreServerInfo coreServerInfo = new CoreServerInfo(socketAddress(attrMap[RAFT_SERVER], AdvertisedSocketAddress::new), socketAddress(attrMap[TRANSACTION_SERVER], AdvertisedSocketAddress::new), ClientConnectorAddresses.FromString(attrMap[CLIENT_CONNECTOR_ADDRESSES]), asSet(serverGroupsMMap.get(attrMap[MEMBER_UUID])), attrMap[MEMBER_DB_NAME], member.getBooleanAttribute(REFUSE_TO_BE_LEADER_KEY));

                MemberId memberId = new MemberId(System.Guid.Parse(attrMap[MEMBER_UUID]));
                coreMembers[memberId] = coreServerInfo;
            }

            return(coreMembers);
        }