Beispiel #1
0
        internal static IDictionary <MemberId, ReadReplicaInfo> ReadReplicas(HazelcastInstance hazelcastInstance, Log log)
        {
            Pair <ISet <string>, IDictionary <string, IMap <string, string> > > validatedSimpleAttrMaps = validatedSimpleAttrMaps(hazelcastInstance);
            ISet <string> missingAttrKeys = validatedSimpleAttrMaps.First();
            IDictionary <string, IMap <string, string> > simpleAttrMaps = validatedSimpleAttrMaps.Other();

            MultiMap <string, string> serverGroupsMap = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP);

            if (serverGroupsMap == null)
            {
                missingAttrKeys.Add(SERVER_GROUPS_MULTIMAP);
            }

            if (missingAttrKeys.Count > 0)
            {
                // We might well not have any read replicas, in which case missing maps is not an error, but we *can't* have some maps and not others
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
                bool missingAllKeys = missingAttrKeys.containsAll(RrAttrKeys) && missingAttrKeys.Contains(SERVER_GROUPS_MULTIMAP);
                if (!missingAllKeys)
                {
                    string missingAttrs = string.join(", ", missingAttrKeys);
                    log.Warn("Some, but not all, of the read replica attribute maps are null, including %s", missingAttrs);
                }

                return(emptyMap());
            }

            Stream <string> readReplicaHzIds = simpleAttrMaps[READ_REPLICA_BOLT_ADDRESS_MAP].Keys.stream();

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IDictionary <MemberId, ReadReplicaInfo> validatedReadReplicas = readReplicaHzIds.flatMap(hzId => Streams.ofNullable(BuildReadReplicaFromAttrMap(hzId, simpleAttrMaps, serverGroupsMap, log))).collect(Collectors.toMap(Pair::first, Pair::other));

            return(validatedReadReplicas);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") com.hazelcast.core.MultiMap<String,String> serverGroupsMMap = mock(com.hazelcast.core.MultiMap.class);
            MultiMap <string, string> serverGroupsMMap = mock(typeof(MultiMap));

            when(serverGroupsMMap.get(any())).thenReturn(_groups);
            when(_hzInstance.getMultiMap(anyString())).thenReturn((MultiMap)serverGroupsMMap);
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            _rrAttributeMaps = RR_ATTR_KEYS.Select(k => Pair.of(k, (IMap <string, string>)mock(typeof(IMap)))).collect(CollectorsUtil.pairsToMap());
        }
Beispiel #3
0
        internal static void RefreshGroups(HazelcastInstance hazelcastInstance, string memberId, IList <string> groups)
        {
            MultiMap <string, string> groupsMap = hazelcastInstance.getMultiMap(SERVER_GROUPS_MULTIMAP);
            ICollection <string>      existing  = groupsMap.get(memberId);

//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <string> superfluous = existing.Where(t => !groups.Contains(t)).collect(Collectors.toSet());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <string> missing = groups.Where(t => !existing.Contains(t)).collect(Collectors.toSet());

            missing.forEach(group => groupsMap.put(memberId, group));
            superfluous.forEach(group => groupsMap.remove(memberId, group));
        }
Beispiel #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);
        }