Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _fs         = FileSystemRule.get();
            _pageCache  = PageCacheRule.getPageCache(_fs);
            _storeFiles = new StoreFiles(_fs, _pageCache);
            _logFiles   = LogFilesBuilder.logFilesBasedOnlyBuilder(TestDirectory.directory(), _fs).build();
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void restoreTransactionLogsInCustomDirectoryForTargetDatabaseWhenConfigured() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RestoreTransactionLogsInCustomDirectoryForTargetDatabaseWhenConfigured()
        {
            string databaseName                  = "to";
            Config config                        = ConfigWith(databaseName, Directory.absolutePath().AbsolutePath);
            File   customTxLogDirectory          = Directory.directory("customLogicalLog");
            string customTransactionLogDirectory = customTxLogDirectory.AbsolutePath;

            config.AugmentDefaults(GraphDatabaseSettings.logical_logs_location, customTransactionLogDirectory);

            File fromPath      = new File(Directory.absolutePath(), "from");
            File toPath        = config.Get(GraphDatabaseSettings.database_path);
            int  fromNodeCount = 10;
            int  toNodeCount   = 20;

            CreateDbAt(fromPath, fromNodeCount);

            GraphDatabaseService db = CreateDatabase(toPath, customTransactionLogDirectory);

            CreateTestData(toNodeCount, db);
            Db.shutdown();

            // when
            (new RestoreDatabaseCommand(FileSystemRule.get(), fromPath, config, databaseName, true)).execute();

            LogFiles fromStoreLogFiles         = LogFilesBuilder.logFilesBasedOnlyBuilder(fromPath, FileSystemRule.get()).build();
            LogFiles toStoreLogFiles           = LogFilesBuilder.logFilesBasedOnlyBuilder(toPath, FileSystemRule.get()).build();
            LogFiles customLogLocationLogFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(customTxLogDirectory, FileSystemRule.get()).build();

            assertThat(toStoreLogFiles.LogFilesConflict(), emptyArray());
            assertThat(customLogLocationLogFiles.LogFilesConflict(), arrayWithSize(1));
            assertEquals(fromStoreLogFiles.GetLogFileForVersion(0).length(), customLogLocationLogFiles.GetLogFileForVersion(0).length());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseWithCustomTransactionLogsLocation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseWithCustomTransactionLogsLocation()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(_serverStorePath, true, backupPort, "customLogLocation");

            try
            {
                CreateInitialDataSet(db);

                OnlineBackup backup      = OnlineBackup.From("127.0.0.1", backupPort);
                string       backupStore = _backupDatabasePath.Path;
                LogFiles     logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(backupStore), _fileSystemRule.get()).build();

                backup.Full(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                DbRepresentation representation = AddLotsOfData(db);
                backup.Incremental(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                assertEquals(representation, DbRepresentation);
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void nonRecoveredDatabase() throws java.io.IOException
        private void NonRecoveredDatabase()
        {
            File tmpLogDir = new File(_testDirectory.directory(), "logs");

            _fs.mkdir(tmpLogDir);
            File             storeDir = _testDirectory.databaseDir();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            RelationshipType relationshipType = RelationshipType.withName("testRelationshipType");

            using (Transaction tx = Db.beginTx())
            {
                Node node1 = set(Db.createNode());
                Node node2 = set(Db.createNode(), property("key", "value"));
                node1.CreateRelationshipTo(node2, relationshipType);
                tx.Success();
            }
            File[] txLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDir, _fs).build().logFiles();
            foreach (File file in txLogs)
            {
                _fs.copyToDirectory(file, tmpLogDir);
            }
            Db.shutdown();
            foreach (File txLog in txLogs)
            {
                _fs.deleteFile(txLog);
            }

            foreach (File file in LogFilesBuilder.logFilesBasedOnlyBuilder(tmpLogDir, _fs).build().logFiles())
            {
                _fs.moveToDirectory(file, storeDir);
            }
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.storemigration.UpgradableDatabase getUpgradableDatabase(org.neo4j.kernel.impl.storemigration.StoreVersionCheck check) throws java.io.IOException
        private UpgradableDatabase GetUpgradableDatabase(StoreVersionCheck check)
        {
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles       logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(_workingDatabaseLayout.databaseDirectory(), _fs).build();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());

            return(new UpgradableDatabase(check, Standard.LATEST_RECORD_FORMATS, tailScanner));
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private UpgradableDatabase getUpgradableDatabase(org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private UpgradableDatabase GetUpgradableDatabase(PageCache pageCache)
        {
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> entryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles       logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseLayout.databaseDirectory(), _fileSystem).withLogEntryReader(entryReader).build();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, entryReader, new Monitors());

            return(new UpgradableDatabase(new StoreVersionCheck(pageCache), RecordFormats, tailScanner));
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _databaseDirectory = TestDirectory.databaseDir();
            SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
            SimpleTransactionIdStore   transactionIdStore   = new SimpleTransactionIdStore();

            _logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseDirectory, FileSystemRule).withRotationThreshold(LogHeader.LOG_HEADER_SIZE + 9L).withLogVersionRepository(logVersionRepository).withTransactionIdStore(transactionIdStore).build();
            Life.add(_logFiles);
            _logPruner = new CorruptedLogsTruncator(_databaseDirectory, _logFiles, FileSystemRule);
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void Setup()
            {
                FileSystem     = FileSystemRule.get();
                DatabaseLayout = TestDirectory.databaseLayout();
                MigrationTestUtils.FindFormatStoreDirectoryForVersion(Version, DatabaseLayout.databaseDirectory());
                VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(DatabaseLayout.databaseDirectory(), FileSystem).build();

                TailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());
            }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void deleteLogs(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        private static void DeleteLogs(DatabaseLayout databaseLayout)
        {
            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fileSystem).build();
                foreach (File file in logFiles.LogFilesConflict())
                {
                    fileSystem.DeleteFile(file);
                }
            }
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void deleteAllLogsOn(java.io.File storeDirectory) throws java.io.IOException
        private static void DeleteAllLogsOn(File storeDirectory)
        {
            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirectory, fileSystem).build();
                foreach (File file in logFiles.LogFilesConflict())
                {
                    fileSystem.DeleteFile(file);
                }
            }
        }
 /// <summary>
 /// Add all available log files as sources.
 /// </summary>
 /// <param name="sources"> destination of the sources. </param>
 private void GetTransactionLogFiles(IList <DiagnosticsReportSource> sources)
 {
     try
     {
         LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseLayout.databaseDirectory(), _fs).build();
         foreach (File file in logFiles.LogFilesConflict())
         {
             sources.Add(DiagnosticsReportSources.NewDiagnosticsFile("tx/" + file.Name, _fs, file));
         }
     }
     catch (IOException e)
     {
         sources.Add(DiagnosticsReportSources.NewDiagnosticsString("tx.txt", () => "Error getting tx logs: " + e.Message));
     }
 }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyTransactionLogs(java.io.File txDirectory, java.io.File storeDir) throws java.io.IOException
        private void VerifyTransactionLogs(File txDirectory, File storeDir)
        {
            FileSystemAbstraction fileSystem = FileSystemRule.get();
            LogFiles storeDirLogs            = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDir, fileSystem).build();

            assertFalse(storeDirLogs.VersionExists(0));

            LogFiles txDirectoryLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(txDirectory, fileSystem).build();

            assertTrue(txDirectoryLogs.VersionExists(0));
            using (PhysicalLogVersionedStoreChannel physicalLogVersionedStoreChannel = txDirectoryLogs.OpenForVersion(0))
            {
                assertThat(physicalLogVersionedStoreChannel.Size(), greaterThan(0L));
            }
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void Setup()
            {
                FileSystem     = FileSystemRule.get();
                DatabaseLayout = TestDirectory.databaseLayout();
                // doesn't matter which version we pick we are changing it to the wrong one...
                MigrationTestUtils.FindFormatStoreDirectoryForVersion(StandardV2_3.STORE_VERSION, DatabaseLayout.databaseDirectory());
                changeVersionNumber(FileSystem, DatabaseLayout.file(NEOSTORE_FILENAME), Version);
                File      metadataStore = DatabaseLayout.metadataStore();
                PageCache pageCache     = PageCacheRule.getPageCache(FileSystem);

                MetaDataStore.setRecord(pageCache, metadataStore, STORE_VERSION, MetaDataStore.versionStringToLong(Version));
                VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(DatabaseLayout.databaseDirectory(), FileSystem).build();

                TailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());
            }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseTransactionLogsStoredWithDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseTransactionLogsStoredWithDatabase()
        {
            int backupPort = PortAuthority.allocatePort();

            StartDb(backupPort);
            string ip   = ":" + backupPort;
            string name = "backupWithTxLogs" + RecordFormat;

            assertEquals(0, RunBackupTool(_testDirectory.absolutePath(), "--from", ip, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--name=" + name));
            _db.shutdown();

            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(_backupDir, name), fileSystem).build();
                assertTrue(logFiles.VersionExists(0));
                assertThat(logFiles.GetLogFileForVersion(0).length(), greaterThan(50L));
            }
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.storageengine.api.StoreId simulateStoreCopy() throws java.io.IOException
        private Org.Neo4j.Storageengine.Api.StoreId SimulateStoreCopy()
        {
            // create an empty store
            Org.Neo4j.Storageengine.Api.StoreId storeId;
            NeoStoreDataSource ds = DsRule.getDataSource(_databaseLayout, _fs, _pageCache);

            using (Lifespan ignored = new Lifespan(ds))
            {
                storeId = ds.StoreId;
            }

            // we don't have log files after a store copy
            LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseLayout.databaseDirectory(), FsRule.get()).build();

            //noinspection ResultOfMethodCallIgnored
            logFiles.Accept((file, version) => file.delete());

            return(storeId);
        }
Exemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SetUp()
        {
            _logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_testDirectory.databaseDir(), _fs).build();

            Dependencies       dependencies      = new Dependencies();
            Config             config            = Config.defaults(default_schema_provider, _indexProvider.ProviderDescriptor.name());
            DataSourceManager  dataSourceManager = new DataSourceManager(config);
            GraphDatabaseAPI   db         = mock(typeof(GraphDatabaseAPI));
            NeoStoreDataSource dataSource = mock(typeof(NeoStoreDataSource));

            dependencies.SatisfyDependency(_indexProvider);
            dependencies.SatisfyDependency(_indexProvider2);

            DefaultIndexProviderMap indexProviderMap = new DefaultIndexProviderMap(dependencies, config);

            indexProviderMap.Init();

            // Setup all dependencies
            dependencies.SatisfyDependency(_fs);
            dependencies.SatisfyDependencies(dataSourceManager);
            dependencies.SatisfyDependency(_logFiles);
            dependencies.SatisfyDependency(_explicitIndexProviderLookup);
            dependencies.SatisfyDependency(indexProviderMap);
            dependencies.SatisfyDependency(_labelScanStore);
            when(Db.DependencyResolver).thenReturn(dependencies);
            when(dataSource.DependencyResolver).thenReturn(dependencies);
            when(dataSource.DatabaseLayout).thenReturn(_testDirectory.databaseLayout());

            // Start DataSourceManager
            dataSourceManager.Register(dataSource);
            dataSourceManager.Start();

            // Create bean
            KernelData kernelData = new KernelData(_fs, mock(typeof(PageCache)), _testDirectory.databaseDir(), config, dataSourceManager);

            _managementData = new ManagementData(new StoreSizeBean(), kernelData, ManagementSupport.Load());
            _storeSizeBean  = StoreSizeBean.CreateBean(_managementData, false, 0, mock(typeof(Clock)));

            when(_indexProvider.directoryStructure()).thenReturn(mock(typeof(IndexDirectoryStructure)));
            when(_indexProvider2.directoryStructure()).thenReturn(mock(typeof(IndexDirectoryStructure)));
            when(_labelScanStore.LabelScanStoreFile).thenReturn(_testDirectory.databaseLayout().labelScanStore());
        }
Exemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "Migrate: {0}->{1}") public static Iterable<Object[]> data() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public static IEnumerable <object[]> Data()
        {
            FileSystemAbstraction fs            = _fileSystemRule.get();
            PageCache             pageCache     = _pageCacheRule.getPageCache(fs);
            TestDirectory         testDirectory = TestDirectory.testDirectory();

            testDirectory.PrepareDirectory(typeof(StoreMigrationIT), "migration");
            DatabaseLayout    databaseLayout    = testDirectory.DatabaseLayout();
            StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache);
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles             logFiles      = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fs).withLogEntryReader(logEntryReader).build();
            LogTailScanner       tailScanner   = new LogTailScanner(logFiles, logEntryReader, new Monitors());
            IList <object[]>     data          = new List <object[]>();
            List <RecordFormats> recordFormats = new List <RecordFormats>();

            RecordFormatSelector.allFormats().forEach(f => addIfNotThere(f, recordFormats));
            foreach (RecordFormats toFormat in recordFormats)
            {
                UpgradableDatabase upgradableDatabase = new UpgradableDatabase(storeVersionCheck, toFormat, tailScanner);
                foreach (RecordFormats fromFormat in recordFormats)
                {
                    try
                    {
                        CreateDb(fromFormat, databaseLayout.DatabaseDirectory());
                        if (!upgradableDatabase.HasCurrentVersion(databaseLayout))
                        {
                            upgradableDatabase.CheckUpgradable(databaseLayout);
                            data.Add(new object[] { fromFormat, toFormat });
                        }
                    }
                    catch (Exception)
                    {
                        //This means that the combination is not migratable.
                    }
                    fs.DeleteRecursively(databaseLayout.DatabaseDirectory());
                }
            }

            return(data);
        }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.recovery.LogTailScanner getTailScanner(java.io.File databaseDirectory) throws java.io.IOException
        private LogTailScanner GetTailScanner(File databaseDirectory)
        {
            LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseDirectory, _fs).build();

            return(new LogTailScanner(logFiles, new VersionAwareLogEntryReader <Org.Neo4j.Kernel.impl.transaction.log.ReadableClosablePositionAwareChannel>(), _monitors));
        }
Exemplo n.º 19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: CheckPointCollector(java.io.File directory, org.neo4j.io.fs.FileSystemAbstraction fileSystem) throws java.io.IOException
            internal CheckPointCollector(File directory, FileSystemAbstraction fileSystem)
            {
                this.LogEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
                this.LogFiles       = LogFilesBuilder.logFilesBasedOnlyBuilder(directory, fileSystem).withLogEntryReader(LogEntryReader).build();
            }