コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.collection.RawIterator<Object[],org.neo4j.internal.kernel.api.exceptions.ProcedureException> apply(org.neo4j.kernel.api.proc.Context ctx, Object[] input, org.neo4j.kernel.api.ResourceTracker resourceTracker) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public override RawIterator <object[], ProcedureException> Apply(Context ctx, object[] input, ResourceTracker resourceTracker)
        {
            IDictionary <string, IList <Endpoint> > routersPerDb = RouteEndpoints();
            MultiClusterRoutingResult result = new MultiClusterRoutingResult(routersPerDb, _timeToLiveMillis);

            return(RawIterator.of <object[], ProcedureException>(MultiClusterRoutingResultFormat.Build(result)));
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.collection.RawIterator<Object[],org.neo4j.internal.kernel.api.exceptions.ProcedureException> apply(org.neo4j.kernel.api.proc.Context ctx, Object[] input, org.neo4j.kernel.api.ResourceTracker resourceTracker) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public override RawIterator <object[], ProcedureException> Apply(Context ctx, object[] input, ResourceTracker resourceTracker)
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") String dbName = (String) input[0];
            string           dbName  = ( string )input[0];
            IList <Endpoint> routers = RouteEndpoints(dbName);

            Dictionary <string, IList <Endpoint> > routerMap = new Dictionary <string, IList <Endpoint> >();

            routerMap[dbName] = routers;

            MultiClusterRoutingResult result = new MultiClusterRoutingResult(routerMap, _timeToLiveMillis);

            return(RawIterator.of <object[], ProcedureException>(MultiClusterRoutingResultFormat.Build(result)));
        }
コード例 #3
0
        internal static object[] Build(MultiClusterRoutingResult result)
        {
            System.Func <IList <Endpoint>, object[]> stringifyAddresses = es => es.Select(e => e.address().ToString()).ToArray();

            IList <IDictionary <string, object> > response = result.Routers().SetOfKeyValuePairs().Select(entry =>
            {
                string dbName      = entry.Key;
                object[] addresses = stringifyAddresses(entry.Value);

                IDictionary <string, object> responseRow = new SortedDictionary <string, object>();

                responseRow.put(DB_NAME_KEY, dbName);
                responseRow.put(ADDRESSES_KEY, addresses);

                return(responseRow);
            }).ToList();

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

            return(new object[] { ttlSeconds, response });
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSerializeToAndFromRecordFormat()
        public virtual void ShouldSerializeToAndFromRecordFormat()
        {
            IList <Endpoint> fooRouters = new IList <Endpoint> {
                Endpoint.route(new AdvertisedSocketAddress("host1", 1)), Endpoint.route(new AdvertisedSocketAddress("host2", 1)), Endpoint.route(new AdvertisedSocketAddress("host3", 1))
            };

            IList <Endpoint> barRouters = new IList <Endpoint> {
                Endpoint.route(new AdvertisedSocketAddress("host4", 1)), Endpoint.route(new AdvertisedSocketAddress("host5", 1)), Endpoint.route(new AdvertisedSocketAddress("host6", 1))
            };

            IDictionary <string, IList <Endpoint> > routers = new Dictionary <string, IList <Endpoint> >();

            routers["foo"] = fooRouters;
            routers["bar"] = barRouters;

            long ttlSeconds = 5;
            MultiClusterRoutingResult original = new MultiClusterRoutingResult(routers, ttlSeconds * 1000);

            object[] record = MultiClusterRoutingResultFormat.Build(original);

            MultiClusterRoutingResult parsed = MultiClusterRoutingResultFormat.Parse(record);

            assertEquals(original, parsed);
        }