//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void createPageCache()
        internal virtual void CreatePageCache()
        {
            SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory();

            factory.Open(new DefaultFileSystemAbstraction(), Configuration.EMPTY);
            MemoryAllocator mman = MemoryAllocator.createAllocator("8 MiB", new LocalMemoryTracker());

            _jobScheduler = new ThreadPoolJobScheduler();
            _pageCache    = new MuninnPageCache(factory, mman, 256, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EMPTY, _jobScheduler);
            _layout       = SimpleLongLayout.LongLayout().withFixedSize(true).build();
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDetectAndThrowIOExceptionOnPartiallyCreatedFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDetectAndThrowIOExceptionOnPartiallyCreatedFile()
        {
            // given a crashed-on-open index
            File file = Storage.directory().file("index");
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            Process process = (new ProcessBuilder(asList("java", "-cp", System.getProperty("java.class.path"), this.GetType().FullName, file.AbsolutePath))).redirectError(INHERIT).redirectOutput(INHERIT).start();

            Thread.Sleep(ThreadLocalRandom.current().Next(1_000));
            int exitCode = process.destroyForcibly().waitFor();

            // then reading it should either work or throw IOException
            using (PageCache pageCache = Storage.pageCache())
            {
                SimpleLongLayout layout = longLayout().build();

                // check readHeader
                try
                {
                    GBPTree.ReadHeader(pageCache, file, NO_HEADER_READER);
                }
                catch (Exception e) when(e is MetadataMismatchException || e is IOException)
                {
                    // It's OK if the process was destroyed
                    assertNotEquals(0, exitCode);
                }

                // check constructor
                try
                {
                    (new GBPTreeBuilder <>(pageCache, file, layout)).Build().Dispose();
                }
                catch (Exception e) when(e is MetadataMismatchException || e is IOException)
                {
                    // It's OK if the process was destroyed
                    assertNotEquals(0, exitCode);
                }
            }
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReadWhatIsWritten() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustReadWhatIsWritten()
        {
            // given
            Layout layout  = SimpleLongLayout.LongLayout().withIdentifier(666).withMajorVersion(10).withMinorVersion(100).build();
            Meta   written = new Meta(( sbyte )1, ( sbyte )2, _pageSize, layout);
            int    offset  = _cursor.Offset;

            written.Write(_cursor, layout);

            // when
            _cursor.Offset = offset;
            Meta read = Meta.Read(_cursor, layout);

            // then
            assertEquals(written.FormatIdentifier, read.FormatIdentifier);
            assertEquals(written.FormatVersion, read.FormatVersion);
            assertEquals(written.UnusedVersionSlot3, read.UnusedVersionSlot3);
            assertEquals(written.UnusedVersionSlot4, read.UnusedVersionSlot4);
            assertEquals(written.LayoutIdentifier, read.LayoutIdentifier);
            assertEquals(written.LayoutMajorVersion, read.LayoutMajorVersion);
            assertEquals(written.LayoutMinorVersion, read.LayoutMinorVersion);
            assertEquals(written.PageSize, read.PageSize);
        }