예제 #1
0
        private void MigrateBranchedDataDirectoriesToRootDirectory()
        {
            File branchedDir = StoreUtil.getBranchedDataRootDirectory(_storeDir);

            branchedDir.mkdirs();
            foreach (File oldBranchedDir in _storeDir.listFiles())
            {
                if (!oldBranchedDir.Directory || !oldBranchedDir.Name.StartsWith("branched-"))
                {
                    continue;
                }

                long timestamp = 0;
                try
                {
                    timestamp = long.Parse(oldBranchedDir.Name.substring(oldBranchedDir.Name.IndexOf('-') + 1));
                }
                catch (System.FormatException)
                {                         // OK, it wasn't a branched directory after all.
                    continue;
                }

                File targetDir = StoreUtil.getBranchedDataDirectory(_storeDir, timestamp);
                try
                {
                    FileUtils.moveFile(oldBranchedDir, targetDir);
                }
                catch (IOException e)
                {
                    throw new Exception("Couldn't move branched directories to " + branchedDir, e);
                }
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migrationOfBranchedDataDirectories() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MigrationOfBranchedDataDirectories()
        {
            long[] timestamps = new long[3];
            for (int i = 0; i < timestamps.Length; i++)
            {
                StartDbAndCreateNode();
                timestamps[i] = MoveAwayToLookLikeOldBranchedDirectory();
                Thread.Sleep(1);                           // To make sure we get different timestamps
            }

            File databaseDirectory = _directory.databaseDir();
            int  clusterPort       = PortAuthority.allocatePort();

            (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(ClusterSettings.server_id, "1").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.initial_hosts, "localhost:" + clusterPort).setConfig(HaSettings.ha_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).newGraphDatabase().shutdown();
            // It should have migrated those to the new location. Verify that.
            foreach (long timestamp in timestamps)
            {
                assertFalse("directory branched-" + timestamp + " still exists.", (new File(databaseDirectory, "branched-" + timestamp)).exists());
                assertTrue("directory " + timestamp + " is not there", StoreUtil.getBranchedDataDirectory(databaseDirectory, timestamp).exists());
            }
        }