예제 #1
0
        private Optional <AdvertisedSocketAddress> LeaderBoltAddress()
        {
            MemberId leader;

            try
            {
                leader = _leaderLocator.Leader;
            }
            catch (NoLeaderFoundException)
            {
                _log.debug("No leader server found. This can happen during a leader switch. No write end points available");
                return(null);
            }

            return(_topologyService.localCoreServers().find(leader).map(extractBoltAddress()));
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor_Result run(java.util.Map<String,String> context) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public override Org.Neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor_Result Run(IDictionary <string, string> context)
        {
            Policy policy = _policies.selectFor(context);

            CoreTopology        coreTopology = _topologyService.localCoreServers();
            ReadReplicaTopology rrTopology   = _topologyService.localReadReplicas();

            return(new LoadBalancingResult(RouteEndpoints(coreTopology), WriteEndpoints(coreTopology), ReadEndpoints(coreTopology, rrTopology, policy), _timeToLive.Value));
        }
예제 #3
0
        private Optional <MemberId> RandomCoreMember()
        {
            IList <MemberId> coreMembersNotSelf = TopologyService.localCoreServers().members().Keys.Where(not(Myself.equals)).ToList();

            Collections.shuffle(coreMembersNotSelf);
            if (coreMembersNotSelf.Count == 0)
            {
                return(null);
            }
            return(coreMembersNotSelf[0]);
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.util.Optional<org.neo4j.causalclustering.identity.MemberId> upstreamDatabase() throws org.neo4j.causalclustering.upstream.UpstreamDatabaseSelectionException
        public override Optional <MemberId> UpstreamDatabase()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopology coreTopology = topologyService.localCoreServers();
            CoreTopology coreTopology = TopologyService.localCoreServers();

            if (coreTopology.Members().Count == 0)
            {
                throw new UpstreamDatabaseSelectionException("No core servers available");
            }

            int skippedServers = _random.Next(coreTopology.Members().Count);

            return(coreTopology.Members().Keys.Skip(skippedServers).First());
        }
예제 #5
0
        public override Optional <MemberId> UpstreamDatabase()
        {
            if (_counter.shouldReturnCoreMemberId())
            {
                return(RandomCoreMember());
            }
            else
            {
                // shuffled members
                IList <MemberId> readReplicaMembers = new List <MemberId>(TopologyService.localReadReplicas().members().Keys);
                Collections.shuffle(readReplicaMembers);

                IList <MemberId> coreMembers = new List <MemberId>(TopologyService.localCoreServers().members().Keys);
                Collections.shuffle(coreMembers);

                return(Stream.concat(readReplicaMembers.stream(), coreMembers.stream()).filter(not(Myself.equals)).findFirst());
            }
        }
예제 #6
0
        private ISet <ServerInfo> PossibleServers()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.stream.Stream<java.util.Map.Entry<org.neo4j.causalclustering.identity.MemberId,? extends org.neo4j.causalclustering.discovery.DiscoveryServerInfo>> infoMap = java.util.stream.Stream.of(topologyService.localReadReplicas(), topologyService.localCoreServers()).map(org.neo4j.causalclustering.discovery.Topology::members).map(java.util.Map::entrySet).flatMap(java.util.Set::stream);
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            Stream <KeyValuePair <MemberId, ? extends DiscoveryServerInfo> > infoMap = Stream.of(TopologyService.localReadReplicas(), TopologyService.localCoreServers()).map(Topology::members).map(System.Collections.IDictionary.entrySet).flatMap(ISet <object> .stream);

            return(infoMap.map(this.toServerInfo).collect(Collectors.toSet()));
        }