Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadFromMultipleChannels() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadFromMultipleChannels()
        {
            // GIVEN
            WriteSomeData(File(0), element =>
            {
                for (int i = 0; i < 10; i++)
                {
                    element.putLong(i);
                }
                return(true);
            });
            WriteSomeData(File(1), element =>
            {
                for (int i = 10; i < 20; i++)
                {
                    element.putLong(i);
                }
                return(true);
            });

            StoreChannel storeChannel = FileSystemRule.get().open(File(0), OpenMode.READ);
            PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(storeChannel, -1, ( sbyte )-1);

            try (ReadAheadLogChannel channel = new ReadAheadLogChannel(versionedStoreChannel, new LogVersionBridgeAnonymousInnerClass(this)
                                                                       , 10))
                {
                    // THEN
                    for (long i = 0; i < 20; i++)
                    {
                        assertEquals(i, channel.Long);
                    }
                }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOpenTheNextChannelWhenItExists() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOpenTheNextChannelWhenItExists()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel newStoreChannel = mock(org.neo4j.io.fs.StoreChannel.class);
            StoreChannel newStoreChannel = mock(typeof(StoreChannel));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge bridge = new org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge(logFiles);
            ReaderLogVersionBridge bridge = new ReaderLogVersionBridge(_logFiles);

            when(_channel.Version).thenReturn(_version);
            when(_channel.LogFormatVersion).thenReturn(CURRENT_LOG_VERSION);
            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            when(_fs.open(any(typeof(File)), eq(OpenMode.READ))).thenReturn(newStoreChannel);
            when(newStoreChannel.read(ArgumentMatchers.any <ByteBuffer>())).then(invocationOnMock =>
            {
                ByteBuffer buffer = invocationOnMock.getArgument(0);
                buffer.putLong(encodeLogVersion(_version + 1));
                buffer.putLong(42);
                return(LOG_HEADER_SIZE);
            });

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel result = bridge.next(channel);
            LogVersionedStoreChannel result = bridge.Next(_channel);

            // then
            PhysicalLogVersionedStoreChannel expected = new PhysicalLogVersionedStoreChannel(newStoreChannel, _version + 1, CURRENT_LOG_VERSION);

            assertEquals(expected, result);
            verify(_channel, times(1)).close();
        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadFromSingleChannel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadFromSingleChannel()
        {
            // GIVEN
            File file = file(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte byteValue = (byte) 5;
            sbyte byteValue = ( sbyte )5;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final short shortValue = (short) 56;
            short        shortValue  = ( short )56;
            const int    intValue    = 32145;
            const long   longValue   = 5689456895869L;
            const float  floatValue  = 12.12345f;
            const double doubleValue = 3548.45748D;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] byteArrayValue = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
            sbyte[] byteArrayValue = new sbyte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            WriteSomeData(file, element =>
            {
                element.put(byteValue);
                element.putShort(shortValue);
                element.putInt(intValue);
                element.putLong(longValue);
                element.putFloat(floatValue);
                element.putDouble(doubleValue);
                element.put(byteArrayValue);
                return(true);
            });

            StoreChannel storeChannel = FileSystemRule.get().open(file, OpenMode.READ);
            PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel(storeChannel, -1, ( sbyte )-1);

            using (ReadAheadLogChannel channel = new ReadAheadLogChannel(versionedStoreChannel, NO_MORE_CHANNELS, 16))
            {
                // THEN
                assertEquals(byteValue, channel.Get());
                assertEquals(shortValue, channel.Short);
                assertEquals(intValue, channel.Int);
                assertEquals(longValue, channel.Long);
                assertEquals(floatValue, channel.Float, 0.1f);
                assertEquals(doubleValue, channel.Double, 0.1d);

                sbyte[] bytes = new sbyte[byteArrayValue.Length];
                channel.Get(bytes, byteArrayValue.Length);
                assertArrayEquals(byteArrayValue, bytes);
            }
        }
Ejemplo n.º 5
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);
                }
            }
        }