Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void prepareNeoStoreFile(String storeVersion, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private void PrepareNeoStoreFile(string storeVersion, PageCache pageCache)
        {
            File neoStoreFile = CreateNeoStoreFile();
            long value        = MetaDataStore.versionStringToLong(storeVersion);

            MetaDataStore.setRecord(pageCache, neoStoreFile, STORE_VERSION, value);
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void prepareNeoStoreFile(org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout, String storeVersion, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private static void PrepareNeoStoreFile(FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout, string storeVersion, PageCache pageCache)
        {
            File neoStoreFile = CreateNeoStoreFile(fileSystem, databaseLayout);
            long value        = MetaDataStore.versionStringToLong(storeVersion);

            MetaDataStore.setRecord(pageCache, neoStoreFile, STORE_VERSION, value);
        }
Exemple #3
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());
            }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StartTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed()
        {
            // given
            // create a store
            File databaseDirectory  = _testDirectory.databaseDir();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDirectory);

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }
            Db.shutdown();

            // mess up the version in the metadatastore
            string badStoreVersion = "bad";

            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler(), PageCache pageCache = createPageCache(fileSystem, scheduler))
            {
                MetaDataStore.setRecord(pageCache, _testDirectory.databaseLayout().metadataStore(), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong(badStoreVersion));
            }

            Exception exception = assertThrows(typeof(Exception), () => (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(GraphDatabaseSettings.allow_upgrade, "true").newGraphDatabase());

            assertTrue(exception.InnerException is LifecycleException);
            assertTrue(exception.InnerException.InnerException is StoreUpgrader.UnexpectedUpgradingStoreVersionException);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StartTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed()
        {
            // given
            // create a store
            File databaseDir        = _testDirectory.databaseDir();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir);

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }
            Db.shutdown();

            // mess up the version in the metadatastore
            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler(), PageCache pageCache = createPageCache(fileSystem, scheduler))
            {
                MetaDataStore.setRecord(pageCache, _testDirectory.databaseLayout().metadataStore(), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong("bad"));
            }

            Exception exception = assertThrows(typeof(Exception), () => (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir));

            assertTrue(exception.InnerException is LifecycleException);
            assertTrue(exception.InnerException.InnerException is System.ArgumentException);
            assertEquals("Unknown store version 'bad'", exception.InnerException.InnerException.Message);
        }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void updateOrAddNeoStoreFieldsAsPartOfMigration(org.neo4j.io.layout.DatabaseLayout migrationStructure, org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, String versionToMigrateTo, org.neo4j.kernel.impl.transaction.log.LogPosition lastClosedTxLogPosition) throws java.io.IOException
        private void UpdateOrAddNeoStoreFieldsAsPartOfMigration(DatabaseLayout migrationStructure, DatabaseLayout sourceDirectoryStructure, string versionToMigrateTo, LogPosition lastClosedTxLogPosition)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File storeDirNeoStore = sourceDirectoryStructure.metadataStore();
            File storeDirNeoStore = sourceDirectoryStructure.MetadataStore();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File migrationDirNeoStore = migrationStructure.metadataStore();
            File migrationDirNeoStore = migrationStructure.MetadataStore();

            fileOperation(COPY, _fileSystem, sourceDirectoryStructure, migrationStructure, Iterables.iterable(DatabaseFile.METADATA_STORE), true, ExistingTargetStrategy.SKIP);

            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_ID, MetaDataStore.getRecord(_pageCache, storeDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_ID));
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TIME, DateTimeHelper.CurrentUnixTimeMillis());

            // Store the checksum of the transaction id the upgrade is at right now. Store it both as
            // LAST_TRANSACTION_CHECKSUM and UPGRADE_TRANSACTION_CHECKSUM. Initially the last transaction and the
            // upgrade transaction will be the same, but imagine this scenario:
            //  - legacy store is migrated on instance A at transaction T
            //  - upgraded store is copied, via backup or HA or whatever to instance B
            //  - instance A performs a transaction
            //  - instance B would like to communicate with A where B's last transaction checksum
            //    is verified on A. A, at this point not having logs from pre-migration era, will need to
            //    know the checksum of transaction T to accommodate for this request from B. A will be able
            //    to look up checksums for transactions succeeding T by looking at its transaction logs,
            //    but T needs to be stored in neostore to be accessible. Obviously this scenario is only
            //    problematic as long as we don't migrate and translate old logs.
            TransactionId lastTxInfo = ReadLastTxInformation(migrationStructure);

            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_CHECKSUM, lastTxInfo.Checksum());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_CHECKSUM, lastTxInfo.Checksum());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.CommitTimestamp());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.CommitTimestamp());

            // add LAST_CLOSED_TRANSACTION_LOG_VERSION and LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET to the migrated
            // NeoStore
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_VERSION, lastClosedTxLogPosition.LogVersion);
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET, lastClosedTxLogPosition.ByteOffset);

            // Upgrade version in NeoStore
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong(versionToMigrateTo));
        }