Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToResumeMigrationOnRebuildingCounts()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // WHEN simulating resuming the migration
            progressMonitor = new SilentMigrationProgressMonitor();
            CountsMigrator countsMigrator = new CountsMigrator(_fs, pageCache, _config);

            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
        }
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 shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGenerateTransactionInformationWhenLogsAreEmpty()
        {
            // given
            long           txId           = 1;
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           neoStore       = databaseLayout.MetadataStore();

            neoStore.createNewFile();
            Config     config     = mock(typeof(Config));
            LogService logService = new SimpleLogService(NullLogProvider.Instance, NullLogProvider.Instance);

            // when
            // ... transaction info not in neo store
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_ID));
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_CHECKSUM));
            assertEquals(FIELD_NOT_PRESENT, getRecord(_pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP));
            // ... and with migrator
            StoreMigrator migrator = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            TransactionId actual   = migrator.ExtractTransactionIdInformation(neoStore, txId);

            // then
            assertEquals(txId, actual.TransactionIdConflict());
            assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_CHECKSUM, actual.Checksum());
            assertEquals(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_COMMIT_TIMESTAMP, actual.CommitTimestamp());
        }
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 shouldBeAbleToMigrateWithoutErrors() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToMigrateWithoutErrors()
        {
            // GIVEN a legacy database
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);

            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            LogService            logService  = new SimpleLogService(logProvider, logProvider);
            PageCache             pageCache   = _pageCacheRule.getPageCache(_fs);

            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            CountsMigrator countsMigrator  = new CountsMigrator(_fs, pageCache, _config);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // WHEN migrating
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            migrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());
            countsMigrator.MoveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // THEN starting the new store should be successful
            StoreFactory storeFactory = new StoreFactory(databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), pageCache, _fs, logService.InternalLogProvider, EmptyVersionContextSupplier.EMPTY);

            storeFactory.OpenAllNeoStores().close();
            logProvider.RawMessageMatcher().assertNotContains("ERROR");
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void extractTransactionalInformationFromLogs(String path, java.io.File customLogLocation, org.neo4j.io.layout.DatabaseLayout databaseLayout, java.io.File storeDir) throws java.io.IOException
        private void ExtractTransactionalInformationFromLogs(string path, File customLogLocation, DatabaseLayout databaseLayout, File storeDir)
        {
            LogService logService = new SimpleLogService(NullLogProvider.Instance, NullLogProvider.Instance);
            File       neoStore   = databaseLayout.MetadataStore();

            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir).setConfig(logical_logs_location, path).newGraphDatabase();

            for (int i = 0; i < 10; i++)
            {
                using (Transaction transaction = database.BeginTx())
                {
                    Node node = database.CreateNode();
                    transaction.Success();
                }
            }
            database.Shutdown();

            MetaDataStore.setRecord(_pageCache, neoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_VERSION, MetaDataRecordFormat.FIELD_NOT_PRESENT);
            Config        config      = Config.defaults(logical_logs_location, path);
            StoreMigrator migrator    = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            LogPosition   logPosition = migrator.ExtractTransactionLogPosition(neoStore, databaseLayout, 100);

            File[] logFiles = customLogLocation.listFiles();
            assertNotNull(logFiles);
            assertEquals(0, logPosition.LogVersion);
            assertEquals(logFiles[0].length(), logPosition.ByteOffset);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExtractTransactionInformationFromMetaDataStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldExtractTransactionInformationFromMetaDataStore()
        {
            // given
            // ... variables
            long          txId      = 42;
            long          checksum  = 123456789123456789L;
            long          timestamp = 919191919191919191L;
            TransactionId expected  = new TransactionId(txId, checksum, timestamp);

            // ... and files
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           neoStore       = databaseLayout.MetadataStore();

            neoStore.createNewFile();

            // ... and mocks
            Config     config     = mock(typeof(Config));
            LogService logService = mock(typeof(LogService));

            // when
            // ... data in record
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_ID, txId);
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_CHECKSUM, checksum);
            setRecord(_pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, timestamp);

            // ... and with migrator
            StoreMigrator migrator = new StoreMigrator(_fileSystemRule.get(), _pageCache, config, logService, _jobScheduler);
            TransactionId actual   = migrator.ExtractTransactionIdInformation(neoStore, txId);

            // then
            assertEquals(expected, actual);
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDoActualStoreMigrationBetween3_0_5_and_next() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotDoActualStoreMigrationBetween3_0_5AndNext()
        {
            // GIVEN a store in vE.H.0 format
            DatabaseLayout databaseLayout = _directory.databaseLayout();

            (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseLayout.DatabaseDirectory()).setConfig(GraphDatabaseSettings.record_format, HighLimitV3_0_0.NAME).newGraphDatabase().shutdown();
            Config config = Config.defaults(pagecache_memory, "8m");

            try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction(); JobScheduler _jobScheduler = new ThreadPoolJobScheduler(); PageCache _pageCache = new ConfiguringPageCacheFactory(fs, config, NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, NullLog.Instance, EmptyVersionContextSupplier.EMPTY, _jobScheduler)
                                                                                                                                                                  .OrCreatePageCache)
                {
                    // For test code sanity
                    string fromStoreVersion = StoreVersion.HIGH_LIMIT_V3_0_0.versionString();
                    StoreVersionCheck.Result hasVersionResult = (new StoreVersionCheck(_pageCache)).hasVersion(databaseLayout.MetadataStore(), fromStoreVersion);
                    assertTrue(hasVersionResult.ActualVersion, hasVersionResult.Outcome.Successful);

                    // WHEN
                    StoreMigrator    migrator        = new StoreMigrator(fs, _pageCache, config, NullLogService.Instance, _jobScheduler);
                    ProgressReporter monitor         = mock(typeof(ProgressReporter));
                    DatabaseLayout   migrationLayout = _directory.databaseLayout("migration");
                    migrator.Migrate(_directory.databaseLayout(), migrationLayout, monitor, fromStoreVersion, StoreVersion.HIGH_LIMIT_V3_0_6.versionString());

                    // THEN
                    verifyNoMoreInteractions(monitor);
                }
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void writeAndReadLastTxLogPosition() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void WriteAndReadLastTxLogPosition()
        {
            StoreMigrator migrator           = NewStoreMigrator();
            LogPosition   writtenLogPosition = new LogPosition(_random.nextLong(), _random.nextLong());

            migrator.WriteLastTxLogPosition(_directory.databaseLayout(), writtenLogPosition);

            LogPosition readLogPosition = migrator.ReadLastTxLogPosition(_directory.databaseLayout());

            assertEquals(writtenLogPosition, readLogPosition);
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void writeAndReadLastTxInformation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void WriteAndReadLastTxInformation()
        {
            StoreMigrator migrator    = NewStoreMigrator();
            TransactionId writtenTxId = new TransactionId(_random.nextLong(), _random.nextLong(), _random.nextLong());

            migrator.WriteLastTxInformation(_directory.databaseLayout(), writtenTxId);

            TransactionId readTxId = migrator.ReadLastTxInformation(_directory.databaseLayout());

            assertEquals(writtenTxId, readTxId);
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotMigrateFilesForVersionsWithSameCapability() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotMigrateFilesForVersionsWithSameCapability()
        {
            // Prepare migrator and file
            StoreMigrator  migrator = NewStoreMigrator();
            DatabaseLayout dbLayout = _directory.databaseLayout();
            File           neoStore = dbLayout.MetadataStore();

            neoStore.createNewFile();

            // Monitor what happens
            MyProgressReporter progressReporter = new MyProgressReporter();

            // Migrate with two storeversions that have the same FORMAT capabilities
            migrator.Migrate(dbLayout, _directory.databaseLayout("migrationDir"), progressReporter, StandardV3_0.STORE_VERSION, StandardV3_2.STORE_VERSION);

            // Should not have started any migration
            assertFalse(progressReporter.Started);
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComputeTheLastTxInfoCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldComputeTheLastTxInfoCorrectly()
        {
            // given
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // when
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // then
            assertTrue(TxIdComparator.apply(migrator.ReadLastTxInformation(migrationLayout)));
        }
Exemplo n.º 11
0
 public Configuration_OverriddenAnonymousInnerClass(StoreMigrator outerInstance, Config config, DatabaseLayout sourceDirectoryStructure) : base(config)
 {
     this.outerInstance             = outerInstance;
     this._sourceDirectoryStructure = sourceDirectoryStructure;
 }