Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadALogHeaderFromAByteChannel() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadALogHeaderFromAByteChannel()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ByteBuffer buffer = ByteBuffer.allocate(LOG_HEADER_SIZE);
            ByteBuffer buffer = ByteBuffer.allocate(LOG_HEADER_SIZE);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.nio.channels.ReadableByteChannel channel = mock(java.nio.channels.ReadableByteChannel.class);
            ReadableByteChannel channel = mock(typeof(ReadableByteChannel));

            when(channel.read(buffer)).thenAnswer(invocation =>
            {
                buffer.putLong(encodeLogVersion(_expectedLogVersion));
                buffer.putLong(_expectedTxId);
                return(8 + 8);
            });

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogHeader result = readLogHeader(buffer, channel, true, null);
            LogHeader result = readLogHeader(buffer, channel, true, null);

            // then
            assertEquals(new LogHeader(CURRENT_LOG_VERSION, _expectedLogVersion, _expectedTxId), result);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadALogHeaderFromAFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadALogHeaderFromAFile()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File file = testDirectory.file("ReadLogHeader");
            File file = TestDirectory.file("ReadLogHeader");

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ByteBuffer buffer = ByteBuffer.allocate(LOG_HEADER_SIZE);
            ByteBuffer buffer = ByteBuffer.allocate(LOG_HEADER_SIZE);

            buffer.putLong(encodeLogVersion(_expectedLogVersion));
            buffer.putLong(_expectedTxId);

            using (Stream stream = FileSystemRule.get().openAsOutputStream(file, false))
            {
                stream.WriteByte(buffer.array());
            }

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogHeader result = readLogHeader(fileSystemRule.get(), file);
            LogHeader result = readLogHeader(FileSystemRule.get(), file);

            // then
            assertEquals(new LogHeader(CURRENT_LOG_VERSION, _expectedLogVersion, _expectedTxId), result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Opens a file in given {@code fileSystem} as a <seealso cref="LogVersionedStoreChannel"/>.
        /// </summary>
        /// <param name="fileSystem"> <seealso cref="FileSystemAbstraction"/> containing the file to open. </param>
        /// <param name="file"> file to open as a channel. </param>
        /// <returns> <seealso cref="LogVersionedStoreChannel"/> for the file. Its version is determined by its log header. </returns>
        /// <exception cref="IOException"> on I/O error. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel openVersionedChannel(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException
        public static PhysicalLogVersionedStoreChannel OpenVersionedChannel(FileSystemAbstraction fileSystem, File file)
        {
            StoreChannel fileChannel = fileSystem.Open(file, OpenMode.READ);
            LogHeader    logHeader   = readLogHeader(ByteBuffer.allocate(LOG_HEADER_SIZE), fileChannel, true, file);
            PhysicalLogVersionedStoreChannel channel = new PhysicalLogVersionedStoreChannel(fileChannel, logHeader.LogVersion, logHeader.LogFormatVersion);

            return(channel);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void filterTransactionLogFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, final LogHook<org.neo4j.kernel.impl.transaction.log.entry.LogEntry> filter) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        internal static void FilterTransactionLogFile(FileSystemAbstraction fileSystem, File file, LogHook <LogEntry> filter)
        {
            filter.File(file);
            using (StoreChannel @in = fileSystem.Open(file, OpenMode.READ))
            {
                LogHeader logHeader = readLogHeader(ByteBuffer.allocate(LOG_HEADER_SIZE), @in, true, file);
                PhysicalLogVersionedStoreChannel inChannel = new PhysicalLogVersionedStoreChannel(@in, logHeader.LogVersion, logHeader.LogFormatVersion);
                ReadableLogChannel inBuffer = new ReadAheadLogChannel(inChannel);
                LogEntryReader <ReadableLogChannel> entryReader = new VersionAwareLogEntryReader <ReadableLogChannel>();

                LogEntry entry;
                while ((entry = entryReader.ReadLogEntry(inBuffer)) != null)
                {
                    filter.test(entry);
                }
            }
        }