Beispiel #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)
        {
            string query = input[0].ToString();

            try
            {
                // Find all beans that match the query name pattern
                IEnumerator <ObjectName> names = _jmxServer.queryNames(new ObjectName(query), null).GetEnumerator();

                // Then convert them to a Neo4j type system representation
                return(RawIterator.from(() =>
                {
                    if (!names.hasNext())
                    {
                        return null;
                    }

                    ObjectName name = names.next();
                    try
                    {
                        MBeanInfo beanInfo = _jmxServer.getMBeanInfo(name);
                        return new object[] { name.CanonicalName, beanInfo.Description, ToNeo4jValue(name, beanInfo.Attributes) };
                    }
                    catch (JMException e)
                    {
                        throw new ProcedureException(Status.General.UnknownError, e, "JMX error while accessing `%s`, please report this. Message was: %s", name, e.Message);
                    }
                }));
            }
            catch (MalformedObjectNameException)
            {
                throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureCallFailed, "'%s' is an invalid JMX name pattern. Valid queries should use" + "the syntax outlined in the javax.management.ObjectName API documentation." + "For instance, try 'org.neo4j:*' to find all JMX beans of the 'org.neo4j' " + "domain, or '*:*' to find every JMX bean.", query);
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCreateSimpleRawIterator()
        internal virtual void ShouldCreateSimpleRawIterator()
        {
            assertEquals(Collections.emptyList(), List(RawIterator.of()));
            assertEquals(Collections.singletonList(1), List(RawIterator.of(1)));
            assertEquals(asList(1, 2), List(RawIterator.of(1, 2)));
            assertEquals(asList(1, 2, 3), List(RawIterator.of(1, 2, 3)));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testCreateIndexWithGivenProvider(String label, String... properties) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private void TestCreateIndexWithGivenProvider(string label, params string[] properties)
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         labelId     = transaction.TokenWrite().labelGetOrCreateForName(label);

            int[]     propertyKeyIds = CreateProperties(transaction, properties);
            TextValue value          = stringValue("some value");
            long      node           = CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);

            Commit();

            // when
            NewTransaction(AnonymousContext.full());
            string pattern           = IndexPattern(label, properties);
            string specifiedProvider = NATIVE10.providerName();
            RawIterator <object[], ProcedureException> result = CallIndexProcedure(pattern, specifiedProvider);

            // then
            assertThat(Arrays.asList(result.Next()), contains(pattern, specifiedProvider, ExpectedSuccessfulCreationStatus));
            Commit();
            AwaitIndexOnline();

            // and then
            transaction = NewTransaction(AnonymousContext.read());
            SchemaRead     schemaRead = transaction.SchemaRead();
            IndexReference index      = schemaRead.Index(labelId, propertyKeyIds);

            AssertCorrectIndex(labelId, propertyKeyIds, UniquenessConstraint, index);
            AssertIndexData(transaction, propertyKeyIds, value, node, index);
            Commit();
        }
Beispiel #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.List<ProtocolInfo> installedProtocols(org.neo4j.kernel.impl.factory.GraphDatabaseFacade db, String wantedOrientation) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private IList <ProtocolInfo> InstalledProtocols(GraphDatabaseFacade db, string wantedOrientation)
        {
            IList <ProtocolInfo> infos = new LinkedList <ProtocolInfo>();
            Kernel kernel = Db.DependencyResolver.resolveDependency(typeof(Kernel));

            using (Transaction tx = kernel.BeginTransaction([email protected]_Type.Implicit, AnonymousContext.read()))
            {
                RawIterator <object[], ProcedureException> itr = tx.Procedures().procedureCallRead(procedureName("dbms", "cluster", InstalledProtocolsProcedure.PROCEDURE_NAME), null, ProcedureCallContext.EMPTY);

                while (itr.HasNext())
                {
                    object[] row         = itr.Next();
                    string   orientation = ( string )row[0];
                    string   address     = Localhost(( string )row[1]);
                    string   protocol    = ( string )row[2];
                    long     version     = ( long )row[3];
                    string   modifiers   = ( string )row[4];
                    if (orientation.Equals(wantedOrientation))
                    {
                        infos.Add(new ProtocolInfo(orientation, address, protocol, version, modifiers));
                    }
                }
                return(infos);
            }
        }
Beispiel #5
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)));
        }
        public void RawIteratorTest()
        {
            // 测试 IEnumerator
            int         count    = 0;
            RawIterator iterator = new RawIterator();

            foreach (int item in iterator)
            {
                Assert.AreEqual <int>(count++, item);
            }

            //测试具有参数控制的IEnumerable
            count = 1;
            foreach (int item in iterator.GetRange(1, 3))
            {
                Assert.AreEqual <int>(count++, item);
            }

            //测试手工捏出来的IEnumerable
            string[] data = new string[] { "hello", "world", "!" };
            count = 0;
            foreach (string item in iterator.Greeting)
            {
                Assert.AreEqual <string>(data[count++], item);
            }
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldTrackAbsolutePosition() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldTrackAbsolutePosition()
        {
            // GIVEN
            string[][] data = new string[][]
            {
                new string[] { "this is", "the first line" },
                new string[] { "where this", "is the second line" }
            };
            RawIterator <CharReadable, IOException> readers = ReaderIteratorFromStrings(data, '\n');
            CharReadable reader = new MultiReadable(readers);

            assertEquals(0L, reader.Position());
            SectionedCharBuffer buffer = new SectionedCharBuffer(15);

            // WHEN
            reader.Read(buffer, buffer.Front());
            assertEquals(15, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertEquals(23, reader.Position(), "Should not transition to a new reader in the middle of a read");
            assertEquals("Reader1", reader.SourceDescription());

            // we will transition to the new reader in the call below
            reader.Read(buffer, buffer.Front());
            assertEquals(23 + 15, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertEquals(23 + 30, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertFalse(buffer.HasAvailable());
        }
Beispiel #8
0
        public override RawIterator <object[], ProcedureException> Apply(Context ctx, object[] input, ResourceTracker resourceTracker)
        {
            IList <Endpoint> routeEndpoints = routeEndpoints();
            IList <Endpoint> writeEndpoints = writeEndpoints();
            IList <Endpoint> readEndpoints  = readEndpoints();

            return(RawIterator.of <object[], ProcedureException>(ResultFormatV1.Build(new LoadBalancingResult(routeEndpoints, writeEndpoints, readEndpoints, _config.get(CausalClusteringSettings.cluster_routing_ttl).toMillis()))));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.List<Object[]> callListConfig(String seatchString) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private IList <object[]> CallListConfig(string seatchString)
        {
            QualifiedName procedureName = procedureName("dbms", "listConfig");
            RawIterator <object[], ProcedureException> callResult = DbmsOperations().procedureCallDbms(procedureName, toArray(seatchString), DependencyResolver, AUTH_DISABLED, _resourceTracker, ProcedureCallContext.EMPTY);

            return(new IList <object[]> {
                callResult
            });
        }
Beispiel #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <T, EX extends Exception> java.util.List<T> asList(org.neo4j.collection.RawIterator<T, EX> iterator) throws EX
        public static IList <T> AsList <T, EX>(RawIterator <T, EX> iterator) where EX : Exception
        {
            IList <T> @out = new List <T>();

            while (iterator.HasNext())
            {
                @out.Add(iterator.Next());
            }
            return(@out);
        }
Beispiel #11
0
        private static IList <int> List(RawIterator <int, Exception> iter)
        {
            LinkedList <int> @out = new LinkedList <int>();

            while (iter.HasNext())
            {
                @out.AddLast(iter.Next());
            }
            return(@out);
        }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveEmptyOutputIfNoInstalledProtocols() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaveEmptyOutputIfNoInstalledProtocols()
        {
            // given
            InstalledProtocolsProcedure installedProtocolsProcedure = new InstalledProtocolsProcedure(Stream.empty, Stream.empty);

            // when
            RawIterator <object[], ProcedureException> result = installedProtocolsProcedure.Apply(null, null, null);

            // then
            assertFalse(result.HasNext());
        }
Beispiel #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallRegisteredProcedure() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallRegisteredProcedure()
        {
            // Given
            _procs.register(_procedure);

            // When
            RawIterator <object[], ProcedureException> result = _procs.callProcedure(new BasicContext(), _signature.name(), new object[] { 1337 }, _resourceTracker);

            // Then
            assertThat(asList(result), contains(equalTo(new object[] { 1337 })));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunSimpleReadOnlyProcedure() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunSimpleReadOnlyProcedure()
        {
            // Given
            CallableProcedure proc = Compile(typeof(SingleReadOnlyProcedure))[0];

            // When
            RawIterator <object[], ProcedureException> @out = proc.Apply(new BasicContext(), new object[0], _resourceTracker);

            // Then
            assertThat(asList(@out), contains(new object[] { "Bonnie" }, new object[] { "Clyde" }));
        }
Beispiel #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnReadReplica() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnReadReplica()
        {
            // given
            RoleProcedure proc = new ReadReplicaRoleProcedure();

            // when
            RawIterator <object[], ProcedureException> result = proc.Apply(null, null, null);

            // then
            assertEquals(RoleInfo.READ_REPLICA.name(), Single(result)[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 context, Object[] objects, org.neo4j.kernel.api.ResourceTracker resourceTracker) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
            public override RawIterator <object[], ProcedureException> apply(Context context, object[] objects, ResourceTracker resourceTracker)
            {
                try
                {
                    Thread.Sleep(50);
                }
                catch (InterruptedException e)
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError, e, "Interrupted");
                }
                return(RawIterator.empty());
            }
Beispiel #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleBasicMBean() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleBasicMBean()
        {
            // given
            when(_jmxServer.getAttribute(_beanName, "name")).thenReturn("Hello, world!");
            JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), _jmxServer);

            // when
            RawIterator <object[], ProcedureException> result = procedure.Apply(null, new object[] { "*:*" }, _resourceTracker);

            // then
            assertThat(asList(result), contains(equalTo(new object[] { "org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference", "This is a description", map(_attributeName, map("description", "This is the attribute desc.", "value", "Hello, world!")) })));
        }
Beispiel #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallReadOnlyProcedure() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallReadOnlyProcedure()
        {
            // Given
            InternalKernel().registerProcedure(_procedure);

            // When
            RawIterator <object[], ProcedureException> found = Procs().procedureCallRead(Procs().procedureGet(new QualifiedName(new string[] { "example" }, "exampleProc")).id(), new object[] { 1337 }, ProcedureCallContext.EMPTY);

            // Then
            assertThat(asList(found), contains(equalTo(new object[] { 1337 })));
            Commit();
        }
Beispiel #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void registeredProcedureShouldGetRead() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RegisteredProcedureShouldGetRead()
        {
            // Given
            InternalKernel().registerProcedure(new CallableProcedure_BasicProcedureAnonymousInnerClass(this, _signature));

            // When
            RawIterator <object[], ProcedureException> stream = Procs().procedureCallRead(Procs().procedureGet(_signature.name()).id(), new object[] { "" }, ProcedureCallContext.EMPTY);

            // Then
            assertNotNull(asList(stream).get(0)[0]);
            Commit();
        }
Beispiel #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long[] sample(Iterable<DataFactory> dataFactories, Header.Factory headerFactory, System.Func<org.neo4j.values.storable.Value[], int> valueSizeCalculator, System.Func<org.neo4j.unsafe.impl.batchimport.input.InputEntity, int> additionalCalculator) throws java.io.IOException
        private long[] Sample(IEnumerable <DataFactory> dataFactories, Header.Factory headerFactory, System.Func <Value[], int> valueSizeCalculator, System.Func <InputEntity, int> additionalCalculator)
        {
            long[] estimates = new long[4];               // [entity count, property count, property size, labels (for nodes only)]
            using (CsvInputChunkProxy chunk = new CsvInputChunkProxy())
            {
                // One group of input files
                int groupId = 0;
                foreach (DataFactory dataFactory in dataFactories)                           // one input group
                {
                    groupId++;
                    Header header = null;
                    Data   data   = dataFactory.Create(_config);
                    RawIterator <CharReadable, IOException> sources = data.Stream();
                    while (sources.HasNext())
                    {
                        using (CharReadable source = sources.Next())
                        {
                            if (header == null)
                            {
                                // Extract the header from the first file in this group
                                header = extractHeader(source, headerFactory, _idType, _config, _groups);
                            }
                            using (CsvInputIterator iterator = new CsvInputIterator(source, data.Decorator(), header, _config, _idType, EMPTY, extractors(_config), groupId), InputEntity entity = new InputEntity())
                            {
                                int entities     = 0;
                                int properties   = 0;
                                int propertySize = 0;
                                int additional   = 0;
                                while (iterator.Position() < _estimateSampleSize && iterator.Next(chunk))
                                {
                                    for ( ; chunk.Next(entity); entities++)
                                    {
                                        properties   += entity.PropertyCount();
                                        propertySize += calculatePropertySize(entity, valueSizeCalculator);
                                        additional   += additionalCalculator(entity);
                                    }
                                }
                                if (entities > 0)
                                {
                                    long entityCountInSource = ( long )((( double )source.Length() / iterator.Position()) * entities);
                                    estimates[0] += entityCountInSource;
                                    estimates[1] += ( long )((( double )properties / entities) * entityCountInSource);
                                    estimates[2] += ( long )((( double )propertySize / entities) * entityCountInSource);
                                    estimates[3] += ( long )((( double )additional / entities) * entityCountInSource);
                                }
                            }
                        }
                    }
                }
            }
            return(estimates);
        }
Beispiel #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListOutboundProtocols() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListOutboundProtocols()
        {
            // given
            InstalledProtocolsProcedure installedProtocolsProcedure = new InstalledProtocolsProcedure(() => Stream.of(_outbound1, _outbound2), Stream.empty);

            // when
            RawIterator <object[], ProcedureException> result = installedProtocolsProcedure.Apply(null, null, null);

            // then
            assertThat(result.Next(), arrayContaining("outbound", "host1:1", "raft", 1L, "[TestSnappy]"));
            assertThat(result.Next(), arrayContaining("outbound", "host2:2", "raft", 2L, "[TestSnappy,ROT13]"));
            assertFalse(result.HasNext());
        }
Beispiel #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListInboundProtocols() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListInboundProtocols()
        {
            // given
            InstalledProtocolsProcedure installedProtocolsProcedure = new InstalledProtocolsProcedure(Stream.empty, () => Stream.of(_inbound1, _inbound2));

            // when
            RawIterator <object[], ProcedureException> result = installedProtocolsProcedure.Apply(null, null, null);

            // then
            assertThat(result.Next(), arrayContaining("inbound", "host3:3", "raft", 3L, "[TestSnappy]"));
            assertThat(result.Next(), arrayContaining("inbound", "host4:4", "raft", 4L, "[]"));
            assertFalse(result.HasNext());
        }
Beispiel #23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Callables loadProcedures(java.net.URL jar, ClassLoader loader, Callables target) throws java.io.IOException, org.neo4j.internal.kernel.api.exceptions.KernelException
        private Callables LoadProcedures(URL jar, ClassLoader loader, Callables target)
        {
            RawIterator <Type, IOException> classes = ListClassesIn(jar, loader);

            while (classes.HasNext())
            {
                Type next = classes.Next();
                target.AddAllProcedures(_compiler.compileProcedure(next, null, false));
                target.AddAllFunctions(_compiler.compileFunction(next));
                target.AddAllAggregationFunctions(_compiler.compileAggregationFunction(next));
            }
            return(target);
        }
Beispiel #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleMBeanThatThrowsOnGetAttribute() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleMBeanThatThrowsOnGetAttribute()
        {
            // given some JVM MBeans do not allow accessing their attributes, despite marking
            // then as readable
            when(_jmxServer.getAttribute(_beanName, "name")).thenThrow(new RuntimeMBeanException(new System.NotSupportedException("Haha, screw discoverable services!")));

            JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), _jmxServer);

            // when
            RawIterator <object[], ProcedureException> result = procedure.Apply(null, new object[] { "*:*" }, _resourceTracker);

            // then
            assertThat(asList(result), contains(equalTo(new object[] { "org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference", "This is a description", map(_attributeName, map("description", "This is the attribute desc.", "value", null)) })));
        }
Beispiel #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testEmptyGraph() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestEmptyGraph()
        {
            // Given the database is empty

            // When
            Procedures procs = procs();
            RawIterator <object[], ProcedureException> stream = procs.procedureCallRead(procs.ProcedureGet(procedureName("db", "schema")).id(), new object[0], ProcedureCallContext.EMPTY);

            // Then
            assertThat(asList(stream), contains(equalTo(new object[]
            {
                new List <>(),
                new List <>()
            })));
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIgnoreWhiteListingIfFullAccess() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIgnoreWhiteListingIfFullAccess()
        {
            // Given
            ProcedureConfig             config            = new ProcedureConfig(Config.defaults(procedure_whitelist, "empty"));
            Log                         log               = mock(typeof(Log));
            ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config);

            // When
            CallableProcedure proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, true)[0];
            // Then
            RawIterator <object[], ProcedureException> result = proc.Apply(new BasicContext(), new object[0], _resourceTracker);

            assertEquals(result.Next()[0], "Bonnie");
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void listAllIndexesWithFailedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ListAllIndexesWithFailedIndex()
        {
            // Given
            Transaction transaction    = NewTransaction(AUTH_DISABLED);
            int         failedLabel    = transaction.TokenWrite().labelGetOrCreateForName("Fail");
            int         propertyKeyId1 = transaction.TokenWrite().propertyKeyGetOrCreateForName("foo");

            _failNextIndexPopulation.set(true);
            LabelSchemaDescriptor descriptor = forLabel(failedLabel, propertyKeyId1);

            transaction.SchemaWrite().indexCreate(descriptor);
            Commit();

            //let indexes come online
            try
            {
                using (Org.Neo4j.Graphdb.Transaction ignored = Db.beginTx())
                {
                    Db.schema().awaitIndexesOnline(2, MINUTES);
                    fail("Expected to fail when awaiting for index to come online");
                }
            }
            catch (System.InvalidOperationException)
            {
                // expected
            }

            // When
            RawIterator <object[], ProcedureException> stream = Procs().procedureCallRead(Procs().procedureGet(procedureName("db", "indexes")).id(), new object[0], ProcedureCallContext.EMPTY);

            assertTrue(stream.HasNext());
            object[] result = stream.Next();
            assertFalse(stream.HasNext());

            // Then
            assertEquals("INDEX ON :Fail(foo)", result[0]);
            assertEquals("Unnamed index", result[1]);
            assertEquals(Collections.singletonList("Fail"), result[2]);
            assertEquals(Collections.singletonList("foo"), result[3]);
            assertEquals("FAILED", result[4]);
            assertEquals("node_label_property", result[5]);
            assertEquals(0.0, result[6]);
            IDictionary <string, string> providerDescriptionMap = MapUtil.stringMap("key", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerKey(), "version", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerVersion());

            assertEquals(providerDescriptionMap, result[7]);
            assertEquals(IndexingService.getIndexId(descriptor), result[8]);
            assertThat(( string )result[9], containsString("java.lang.RuntimeException: Fail on update during population"));

            Commit();
        }
Beispiel #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void warnAboutDuplicateSourceFiles(java.util.Set<String> seenSourceFiles, Iterable<DataFactory> dataFactories) throws java.io.IOException
        private void WarnAboutDuplicateSourceFiles(ISet <string> seenSourceFiles, IEnumerable <DataFactory> dataFactories)
        {
            foreach (DataFactory dataFactory in dataFactories)
            {
                RawIterator <CharReadable, IOException> stream = dataFactory.Create(_config).stream();
                while (stream.HasNext())
                {
                    using (CharReadable source = stream.Next())
                    {
                        WarnAboutDuplicateSourceFiles(seenSourceFiles, source);
                    }
                }
            }
        }
        /*
         * This method can be used to print to result stream to System.out -> Useful for debugging
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unused") private void printStream(org.neo4j.collection.RawIterator<Object[],org.neo4j.internal.kernel.api.exceptions.ProcedureException> stream) throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        private void PrintStream(RawIterator <object[], ProcedureException> stream)
        {
            IEnumerator <object[]> iterator = asList(stream).GetEnumerator();

            while (iterator.MoveNext())
            {
                object[] row = iterator.Current;
                foreach (object column in row)
                {
                    Console.WriteLine(column);
                }
                Console.WriteLine();
            }
        }
Beispiel #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnFollower() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnFollower()
        {
            // given
            RaftMachine raft = mock(typeof(RaftMachine));

            when(raft.Leader).thenReturn(false);
            RoleProcedure proc = new CoreRoleProcedure(raft);

            // when
            RawIterator <object[], ProcedureException> result = proc.Apply(null, null, null);

            // then
            assertEquals(RoleInfo.FOLLOWER.name(), Single(result)[0]);
        }