//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustNotThrowIfHeaderLongEnough()
        internal virtual void MustNotThrowIfHeaderLongEnough()
        {
            ByteBuffer emptyBuffer = ByteBuffer.wrap(new sbyte[1]);
            NativeIndexHeaderReader nativeIndexHeaderReader = new NativeIndexHeaderReader(NO_HEADER_READER);

            nativeIndexHeaderReader.Read(emptyBuffer);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static String readFailureMessage(org.neo4j.io.pagecache.PageCache pageCache, java.io.File indexFile) throws java.io.IOException
        internal static string ReadFailureMessage(PageCache pageCache, File indexFile)
        {
            NativeIndexHeaderReader headerReader = new NativeIndexHeaderReader(NO_HEADER_READER);

            GBPTree.readHeader(pageCache, indexFile, headerReader);
            return(headerReader.FailureMessage);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustReportFailedIfHeaderTooShort()
        internal virtual void MustReportFailedIfHeaderTooShort()
        {
            ByteBuffer emptyBuffer = ByteBuffer.wrap(new sbyte[1]);
            NativeIndexHeaderReader nativeIndexHeaderReader = new NativeIndexHeaderReader(ByteBuffer.get);

            nativeIndexHeaderReader.Read(emptyBuffer);
            assertSame(BYTE_FAILED, nativeIndexHeaderReader.State);
            assertThat(nativeIndexHeaderReader.FailureMessage, containsString("Could not read header, most likely caused by index not being fully constructed. Index needs to be recreated. Stacktrace:"));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.internal.kernel.api.InternalIndexState readState(org.neo4j.io.pagecache.PageCache pageCache, java.io.File indexFile) throws java.io.IOException
        public static InternalIndexState ReadState(PageCache pageCache, File indexFile)
        {
            NativeIndexHeaderReader headerReader = new NativeIndexHeaderReader(NO_HEADER_READER);

            GBPTree.readHeader(pageCache, indexFile, headerReader);
            switch (headerReader.State)
            {
            case BYTE_FAILED:
                return(InternalIndexState.FAILED);

            case BYTE_ONLINE:
                return(InternalIndexState.ONLINE);

            case BYTE_POPULATING:
                return(InternalIndexState.POPULATING);

            default:
                throw new System.InvalidOperationException("Unexpected initial state byte value " + headerReader.State);
            }
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertHeader(org.neo4j.internal.kernel.api.InternalIndexState expectedState, String failureMessage, boolean messageTruncated) throws java.io.IOException
        private void AssertHeader(InternalIndexState expectedState, string failureMessage, bool messageTruncated)
        {
            NativeIndexHeaderReader headerReader = new NativeIndexHeaderReader(NO_HEADER_READER);

            using (GBPTree <KEY, VALUE> ignored = (new GBPTreeBuilder <KEY, VALUE>(pageCache, IndexFile, layout)).with(headerReader).build())
            {
                switch (expectedState)
                {
                case InternalIndexState.ONLINE:
                    assertEquals("Index was not marked as online when expected not to be.", BYTE_ONLINE, headerReader.State);
                    assertNull("Expected failure message to be null when marked as online.", headerReader.FailureMessage);
                    break;

                case InternalIndexState.FAILED:
                    assertEquals("Index was marked as online when expected not to be.", BYTE_FAILED, headerReader.State);
                    if (messageTruncated)
                    {
                        assertTrue(headerReader.FailureMessage.Length < failureMessage.Length);
                        assertTrue(failureMessage.StartsWith(headerReader.FailureMessage, StringComparison.Ordinal));
                    }
                    else
                    {
                        assertEquals(failureMessage, headerReader.FailureMessage);
                    }
                    break;

                case InternalIndexState.POPULATING:
                    assertEquals("Index was not left as populating when expected to be.", BYTE_POPULATING, headerReader.State);
                    assertNull("Expected failure message to be null when marked as populating.", headerReader.FailureMessage);
                    break;

                default:
                    throw new System.NotSupportedException("Unexpected index state " + expectedState);
                }
            }
        }