예제 #1
0
        private void DeleteCounts(FileSystemAbstraction snapshot)
        {
            DatabaseLayout databaseLayout = TestDirectory.databaseLayout();
            File           alpha          = databaseLayout.CountStoreA();
            File           beta           = databaseLayout.CountStoreB();

            assertTrue(snapshot.DeleteFile(alpha));
            assertTrue(snapshot.DeleteFile(beta));
        }
예제 #2
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);
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.io.File fileContaining(org.neo4j.io.fs.FileSystemAbstraction fs, String content) throws java.io.IOException
        private File FileContaining(FileSystemAbstraction fs, string content)
        {
            File shortFile = _directory.file("file");

            fs.DeleteFile(shortFile);
            using (Stream outputStream = fs.OpenAsOutputStream(shortFile, false))
            {
                outputStream.Write(UTF8.encode(content), 0, UTF8.encode(content).Length);
                return(shortFile);
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void createStore(java.io.File super, org.neo4j.io.fs.FileSystemAbstraction fileSystem, String dbName, int nodesToCreate, String recordFormat, boolean recoveryNeeded, String logicalLogsLocation) throws java.io.IOException
            internal static void CreateStore(File @base, FileSystemAbstraction fileSystem, string dbName, int nodesToCreate, string recordFormat, bool recoveryNeeded, string logicalLogsLocation)
            {
                File storeDir           = new File(@base, dbName);
                GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(fileSystem).newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.record_format, recordFormat).setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).setConfig(GraphDatabaseSettings.logical_logs_location, logicalLogsLocation).newGraphDatabase();

                for (int i = 0; i < (nodesToCreate / 2); i++)
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        Node node1 = Db.createNode(Label.label("Label-" + i));
                        Node node2 = Db.createNode(Label.label("Label-" + i));
                        node1.CreateRelationshipTo(node2, RelationshipType.withName("REL-" + i));
                        tx.Success();
                    }
                }

                if (recoveryNeeded)
                {
                    File tmpLogs = new File(@base, "unrecovered");
                    fileSystem.Mkdir(tmpLogs);
                    File txLogsDir = new File(storeDir, logicalLogsLocation);
                    foreach (File file in fileSystem.ListFiles(txLogsDir, TransactionLogFiles.DEFAULT_FILENAME_FILTER))
                    {
                        fileSystem.CopyFile(file, new File(tmpLogs, file.Name));
                    }

                    Db.shutdown();

                    foreach (File file in fileSystem.ListFiles(txLogsDir, TransactionLogFiles.DEFAULT_FILENAME_FILTER))
                    {
                        fileSystem.DeleteFile(file);
                    }

                    foreach (File file in fileSystem.ListFiles(tmpLogs, TransactionLogFiles.DEFAULT_FILENAME_FILTER))
                    {
                        fileSystem.CopyFile(file, new File(txLogsDir, file.Name));
                    }
                }
                else
                {
                    Db.shutdown();
                }
            }
예제 #5
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();
        }
 public override bool DeleteFile(File fileName)
 {
     return(@delegate.DeleteFile(fileName));
 }