예제 #1
0
        private void MigrateStore(DatabaseLayout dbDirectoryLayout, DatabaseLayout migrationLayout, File migrationStateFile)
        {
            // One or more participants would like to do migration
            _progressMonitor.started(_participants.Count);

            MigrationStatus migrationStatus      = MigrationStatus.readMigrationStatus(_fileSystem, migrationStateFile);
            string          versionToMigrateFrom = null;

            // We don't need to migrate if we're at the phase where we have migrated successfully
            // and it's just a matter of moving over the files to the storeDir.
            if (MigrationStatus.Migrating.isNeededFor(migrationStatus))
            {
                versionToMigrateFrom = _upgradableDatabase.checkUpgradable(dbDirectoryLayout).storeVersion();
                CleanMigrationDirectory(migrationLayout.DatabaseDirectory());
                MigrationStatus.Migrating.setMigrationStatus(_fileSystem, migrationStateFile, versionToMigrateFrom);
                MigrateToIsolatedDirectory(dbDirectoryLayout, migrationLayout, versionToMigrateFrom);
                MigrationStatus.Moving.setMigrationStatus(_fileSystem, migrationStateFile, versionToMigrateFrom);
            }

            if (MigrationStatus.Moving.isNeededFor(migrationStatus))
            {
                versionToMigrateFrom = MigrationStatus.Moving.maybeReadInfo(_fileSystem, migrationStateFile, versionToMigrateFrom);
                MoveMigratedFilesToStoreDirectory(_participants, migrationLayout, dbDirectoryLayout, versionToMigrateFrom, _upgradableDatabase.currentVersion());
            }

            Cleanup(_participants, migrationLayout);

            _progressMonitor.completed();
        }
예제 #2
0
        public static MigrationStatus ReadMigrationStatus(Org.Neo4j.Io.fs.FileSystemAbstraction fs, java.io.File stateFile)
        {
            Pair <string, string> data = ReadFromFile(fs, stateFile, null);

            if (data == null)
            {
                return(null);
            }

            return(MigrationStatus.valueOf(data.First()));
        }
예제 #3
0
 private static Org.Neo4j.Helpers.Collection.Pair <string, string> ReadFromFile(Org.Neo4j.Io.fs.FileSystemAbstraction fs, java.io.File file, MigrationStatus expectedSate)
 {
     try
     {
         using (StreamReader reader = new StreamReader(fs.OpenAsReader(file, StandardCharsets.UTF_8)))
         {
             string state = reader.ReadLine().Trim();
             if (expectedSate != null && !expectedSate.name().Equals(state))
             {
                 throw new System.InvalidOperationException("Not in the expected state, expected=" + expectedSate.name() + ", actual=" + state);
             }
             string info = reader.ReadLine().Trim();
             return(Pair.of(state, info));
         }
     }
     catch (FileNotFoundException)
     {
         return(null);
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }
예제 #4
0
 public bool IsNeededFor(MigrationStatus current)
 {
     return(current == null || this.ordinal() >= current.ordinal());
 }