Beispiel #1
0
        internal static object[] Build(Org.Neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor_Result result)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            object[] routers = result.RouteEndpoints().Select(Endpoint::address).Select(SocketAddress::toString).ToArray();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            object[] readers = result.ReadEndpoints().Select(Endpoint::address).Select(SocketAddress::toString).ToArray();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            object[] writers = result.WriteEndpoints().Select(Endpoint::address).Select(SocketAddress::toString).ToArray();

            IList <IDictionary <string, object> > servers = new List <IDictionary <string, object> >();

            if (writers.Length > 0)
            {
                IDictionary <string, object> map = new SortedDictionary <string, object>();

                map[ROLE_KEY]      = WRITE.name();
                map[ADDRESSES_KEY] = writers;

                servers.Add(map);
            }

            if (readers.Length > 0)
            {
                IDictionary <string, object> map = new SortedDictionary <string, object>();

                map[ROLE_KEY]      = READ.name();
                map[ADDRESSES_KEY] = readers;

                servers.Add(map);
            }

            if (routers.Length > 0)
            {
                IDictionary <string, object> map = new SortedDictionary <string, object>();

                map[ROLE_KEY]      = ROUTE.name();
                map[ADDRESSES_KEY] = routers;

                servers.Add(map);
            }

            long timeToLiveSeconds = MILLISECONDS.toSeconds(result.TtlMillis());

            return(new object[] { timeToLiveSeconds, servers });
        }
Beispiel #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)
        {
            Org.Neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor_Result result = @delegate.Run(context);

            Collections.shuffle(result.RouteEndpoints());
            Collections.shuffle(result.WriteEndpoints());
            Collections.shuffle(result.ReadEndpoints());

            return(result);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPassClientContextToPlugin() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPassClientContextToPlugin()
        {
            // given
            LoadBalancingPlugin plugin = mock(typeof(LoadBalancingPlugin));

            Org.Neo4j.causalclustering.routing.load_balancing.LoadBalancingProcessor_Result result = mock(typeof(LoadBalancingPlugin.Result));
            when(plugin.Run(anyMap())).thenReturn(result);
            GetServersProcedureForMultiDC getServers    = new GetServersProcedureForMultiDC(plugin);
            IDictionary <string, string>  clientContext = stringMap("key", "value", "key2", "value2");

            // when
            getServers.Apply(null, new object[] { clientContext }, null);

            // then
            verify(plugin).run(clientContext);
        }