//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void dropShouldDeleteEntireIndexFolder()
        public virtual void DropShouldDeleteEntireIndexFolder()
        {
            // given
            File root = Storage.directory().directory("root");
            IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider(root).forProvider(GenericNativeIndexProvider.Descriptor);
            long indexId                    = 8;
            File indexDirectory             = directoryStructure.DirectoryForIndex(indexId);
            StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(1, 1)).withId(indexId);
            IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock(typeof(IndexSpecificSpaceFillingCurveSettingsCache));
            PageCache             pageCache        = Storage.pageCache();
            FileSystemAbstraction fs               = Storage.fileSystem();
            File          indexFile                = new File(indexDirectory, "my-index");
            GenericLayout layout                   = new GenericLayout(1, spatialSettings);
            RecoveryCleanupWorkCollector immediate = immediate();
            IndexDropAction             dropAction = new FileSystemIndexDropAction(fs, directoryStructure);
            GenericNativeIndexPopulator populator  = new GenericNativeIndexPopulator(pageCache, fs, indexFile, layout, EMPTY, descriptor, spatialSettings, directoryStructure, mock(typeof(SpaceFillingCurveConfiguration)), dropAction, false);

            populator.Create();

            // when
            assertTrue(fs.ListFiles(indexDirectory).Length > 0);
            populator.Drop();

            // then
            assertFalse(fs.FileExists(indexDirectory));
        }
Beispiel #2
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();
                }
            }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteInitializationOfStoresWithIncompleteHeaders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCompleteInitializationOfStoresWithIncompleteHeaders()
        {
            StoreFactory storeFactory = storeFactory(Config.defaults());

            storeFactory.OpenAllNeoStores(true).close();
            FileSystemAbstraction fs = _fsRule.get();

            foreach (File f in fs.ListFiles(_testDirectory.databaseDir()))
            {
                fs.Truncate(f, 0);
            }
            storeFactory.OpenAllNeoStores(true).close();
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migrateHighLimit3_0StoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MigrateHighLimit3_0StoreFiles()
        {
            FileSystemAbstraction fileSystem = _fileSystemRule.get();
            PageCache             pageCache  = _pageCacheRule.getPageCache(fileSystem);

            using (JobScheduler jobScheduler = new ThreadPoolJobScheduler())
            {
                StoreMigrator migrator = new StoreMigrator(fileSystem, pageCache, Config.defaults(), NullLogService.Instance, jobScheduler);

                DatabaseLayout databaseLayout  = _testDirectory.databaseLayout();
                DatabaseLayout migrationLayout = _testDirectory.databaseLayout("migration");

                PrepareNeoStoreFile(fileSystem, databaseLayout, HighLimitV3_0_0.STORE_VERSION, pageCache);

                ProgressReporter progressMonitor = mock(typeof(ProgressReporter));

                migrator.Migrate(databaseLayout, migrationLayout, progressMonitor, HighLimitV3_0_0.STORE_VERSION, HighLimit.StoreVersion);

                int newStoreFilesCount = fileSystem.ListFiles(migrationLayout.DatabaseDirectory()).Length;
                assertThat("Store should be migrated and new store files should be created.", newStoreFilesCount, Matchers.greaterThanOrEqualTo(StoreType.values().length));
            }
        }
Beispiel #5
0
//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);
                        }
                    }
                }
            }
        }
 public override File[] ListFiles(File directory, FilenameFilter filter)
 {
     return(@delegate.ListFiles(directory, filter));
 }