Пример #1
0
 /// <summary>
 /// Creates a new id file.
 /// </summary>
 /// <param name="file"> The name of the id generator </param>
 /// <param name="throwIfFileExists"> if {@code true} will cause an <seealso cref="System.InvalidOperationException"/> to be thrown if
 /// the file already exists. if {@code false} will truncate the file writing the header in it. </param>
 public static void CreateEmptyIdFile(FileSystemAbstraction fs, File file, long highId, bool throwIfFileExists)
 {
     // sanity checks
     if (fs == null)
     {
         throw new System.ArgumentException("Null filesystem");
     }
     if (file == null)
     {
         throw new System.ArgumentException("Null filename");
     }
     if (throwIfFileExists && fs.FileExists(file))
     {
         throw new System.InvalidOperationException("Can't create id file [" + file + "], file already exists");
     }
     try
     {
         using (StoreChannel channel = fs.Create(file))
         {
             // write the header
             channel.Truncate(0);
             ByteBuffer buffer = ByteBuffer.allocate(HeaderSize);
             buffer.put(_cleanGenerator).putLong(highId).flip();
             channel.WriteAll(buffer);
             channel.Force(false);
         }
     }
     catch (IOException e)
     {
         throw new UnderlyingStorageException("Unable to create id file " + file, e);
     }
 }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static java.io.File createNeoStoreFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        private static File CreateNeoStoreFile(FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout)
        {
            File neoStoreFile = databaseLayout.MetadataStore();

            fileSystem.Create(neoStoreFile).close();
            return(neoStoreFile);
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleStoreConsistingOfOneEmptyFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleStoreConsistingOfOneEmptyFile()
        {
            StoreFactory          storeFactory = storeFactory(Config.defaults());
            FileSystemAbstraction fs           = _fsRule.get();

            fs.Create(_testDirectory.databaseLayout().file("neostore.nodestore.db.labels"));
            storeFactory.OpenAllNeoStores(true).close();
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.io.File emptyFile(org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException
        private File EmptyFile(FileSystemAbstraction fs)
        {
            File shortFile = _directory.file("empty");

            fs.DeleteFile(shortFile);
            fs.Create(shortFile).close();
            return(shortFile);
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void skipLogFileWithoutHeader() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SkipLogFileWithoutHeader()
        {
            FileSystemAbstraction fs = _fileSystemRule.get();
            LogFiles logFiles        = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build();

            _life.add(logFiles);
            _life.start();

            // simulate new file without header presence
            _logVersionRepository.incrementAndGetVersion();
            fs.Create(logFiles.GetLogFileForVersion(_logVersionRepository.CurrentLogVersion)).close();
            _transactionIdStore.transactionCommitted(5L, 5L, 5L);

            PhysicalLogicalTransactionStore.LogVersionLocator versionLocator = new PhysicalLogicalTransactionStore.LogVersionLocator(4L);
            logFiles.Accept(versionLocator);

            LogPosition logPosition = versionLocator.LogPosition;

            assertEquals(1, logPosition.LogVersion);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.io.fs.StoreChannel create(java.io.File fileName) throws java.io.IOException
        public override StoreChannel Create(File fileName)
        {
            return(@delegate.Create(fileName));
        }