コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static long readHighId(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException
        internal static long ReadHighId(FileSystemAbstraction fileSystem, File file)
        {
            using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ))
            {
                return(ReadAndValidate(channel, file));
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static long readDefragCount(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException
        internal static long ReadDefragCount(FileSystemAbstraction fileSystem, File file)
        {
            using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ))
            {
                return(FreeIdKeeper.CountFreeIds(new OffsetChannel(channel, HeaderSize)));
            }
        }
コード例 #3
0
ファイル: LogHeaderReader.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static LogHeader readLogHeader(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, boolean strict) throws java.io.IOException
        public static LogHeader ReadLogHeader(FileSystemAbstraction fileSystem, File file, bool strict)
        {
            using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ))
            {
                return(ReadLogHeader(ByteBuffer.allocate(LOG_HEADER_SIZE), channel, strict, file));
            }
        }
コード例 #4
0
ファイル: BlockReader.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: BlockReader(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File file, org.neo4j.index.internal.gbptree.Layout<KEY,VALUE> layout) throws java.io.IOException
        internal BlockReader(FileSystemAbstraction fs, File file, Layout <KEY, VALUE> layout)
        {
            this._fs      = fs;
            this._file    = file;
            this._layout  = layout;
            this._channel = fs.Open(file, OpenMode.READ);
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSuppressFailureToCloseChannelInFailedAttemptToReadHeaderAfterOpen()
        {
            // GIVEN a file which returns 1/2 log header size worth of bytes
            FileSystemAbstraction fs = mock(typeof(FileSystemAbstraction));
            LogFiles     logFiles    = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build();
            int          logVersion  = 0;
            File         logFile     = logFiles.GetLogFileForVersion(logVersion);
            StoreChannel channel     = mock(typeof(StoreChannel));

            when(channel.read(any(typeof(ByteBuffer)))).thenReturn(LogHeader.LOG_HEADER_SIZE / 2);
            when(fs.FileExists(logFile)).thenReturn(true);
            when(fs.Open(eq(logFile), any(typeof(OpenMode)))).thenReturn(channel);
            doThrow(typeof(IOException)).when(channel).close();

            // WHEN
            try
            {
                logFiles.OpenForVersion(logVersion);
                fail("Should have failed");
            }
            catch (IncompleteLogHeaderException e)
            {
                // THEN good
                verify(channel).close();
                assertEquals(1, e.Suppressed.length);
                assertTrue(e.Suppressed[0] is IOException);
            }
        }
コード例 #6
0
ファイル: LogHeaderWriter.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void writeLogHeader(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file, long logVersion, long previousLastCommittedTxId) throws java.io.IOException
        public static void WriteLogHeader(FileSystemAbstraction fileSystem, File file, long logVersion, long previousLastCommittedTxId)
        {
            using (StoreChannel channel = fileSystem.Open(file, OpenMode.READ_WRITE))
            {
                WriteLogHeader(channel, logVersion, previousLastCommittedTxId);
            }
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: MigrationTestUtils.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void changeVersionNumber(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File storeFile, String versionString) throws java.io.IOException
        internal static void ChangeVersionNumber(FileSystemAbstraction fileSystem, File storeFile, string versionString)
        {
            sbyte[] versionBytes = UTF8.encode(versionString);
            using (StoreChannel fileChannel = fileSystem.Open(storeFile, OpenMode.READ_WRITE))
            {
                fileChannel.Position(fileSystem.GetFileSize(storeFile) - versionBytes.Length);
                fileChannel.write(ByteBuffer.wrap(versionBytes));
            }
        }
コード例 #9
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);
                }
            }
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldForceChannelAfterWritingMetadata() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldForceChannelAfterWritingMetadata()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel[] channelUsedToCreateFile = {null};
            StoreChannel[] channelUsedToCreateFile = new StoreChannel[] { null };

            FileSystemAbstraction fs = spy(_fileSystem);
            StoreChannel          tempChannel;

            when(tempChannel = fs.Open(_file, OpenMode.READ_WRITE)).then(ignored =>
            {
                StoreChannel channel = _fileSystem.open(_file, OpenMode.READ_WRITE);
                if (channelUsedToCreateFile[0] == null)
                {
                    StoreChannel channelSpy    = spy(channel);
                    channelUsedToCreateFile[0] = channelSpy;
                    channel = channelSpy;
                }
                return(channel);
            });

            // Doing the FSA spying above, calling fs.open, actually invokes that method and so a channel
            // is opened. We put that in tempChannel and close it before deleting the file below.
            tempChannel.close();
            fs.DeleteFile(_file);

            // When
            IndexProviderStore store = new IndexProviderStore(_file, fs, MetaDataStore.versionStringToLong("3.5"), false);

            // Then
            StoreChannel channel = channelUsedToCreateFile[0];

            verify(channel).writeAll(any(typeof(ByteBuffer)), eq(0L));
            verify(channel).force(true);
            verify(channel).close();
            verifyNoMoreInteractions(channel);
            store.Close();
        }
コード例 #11
0
ファイル: MigrationTestUtils.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void verifyFilesHaveSameContent(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File original, java.io.File other) throws java.io.IOException
        public static void VerifyFilesHaveSameContent(FileSystemAbstraction fileSystem, File original, File other)
        {
            const int bufferBatchSize = 32 * 1024;

            File[] files = fileSystem.ListFiles(original);
            foreach (File originalFile in files)
            {
                File otherFile = new File(other, originalFile.Name);
                if (!fileSystem.IsDirectory(originalFile))
                {
                    using (StoreChannel originalChannel = fileSystem.Open(originalFile, OpenMode.READ), StoreChannel otherChannel = fileSystem.Open(otherFile, OpenMode.READ))
                    {
                        ByteBuffer buffer = ByteBuffer.allocate(bufferBatchSize);
                        while (true)
                        {
                            if (!readAndFlip(originalChannel, buffer, bufferBatchSize))
                            {
                                break;
                            }
                            sbyte[] originalBytes = new sbyte[buffer.limit()];
                            buffer.get(originalBytes);

                            if (!readAndFlip(otherChannel, buffer, bufferBatchSize))
                            {
                                fail("Files have different sizes");
                            }

                            sbyte[] otherBytes = new sbyte[buffer.limit()];
                            buffer.get(otherBytes);

                            assertArrayEquals("Different content in " + originalFile, originalBytes, otherBytes);
                        }
                    }
                }
            }
        }
コード例 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: Reader(org.neo4j.io.fs.FileSystemAbstraction fsa, java.io.File file, long version) throws java.io.IOException
        internal Reader(FileSystemAbstraction fsa, File file, long version)
        {
            this._storeChannel = fsa.Open(file, OpenMode.READ);
            this._version      = version;
        }
コード例 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.io.fs.StoreChannel open(java.io.File fileName, org.neo4j.io.fs.OpenMode openMode) throws java.io.IOException
        public override StoreChannel Open(File fileName, OpenMode openMode)
        {
            return(@delegate.Open(fileName, openMode));
        }