Exemplo n.º 1
0
        public virtual void TestMRAsyncDiskServiceStartupCleaning()
        {
            FileSystem localFileSystem = FileSystem.GetLocal(new Configuration());

            string[] vols = new string[] { TestRootDir + "/0", TestRootDir + "/1" };
            string   a    = "a";
            string   b    = "b";
            string   c    = "b/c";
            string   d    = "d";
            // Create directories inside SUBDIR
            string   suffix = Path.SeparatorChar + MRAsyncDiskService.Tobedeleted;
            FilePath fa     = new FilePath(vols[0] + suffix, a);
            FilePath fb     = new FilePath(vols[1] + suffix, b);
            FilePath fc     = new FilePath(vols[1] + suffix, c);
            FilePath fd     = new FilePath(vols[1] + suffix, d);

            // Create the directories
            fa.Mkdirs();
            fb.Mkdirs();
            fc.Mkdirs();
            fd.Mkdirs();
            NUnit.Framework.Assert.IsTrue(fa.Exists());
            NUnit.Framework.Assert.IsTrue(fb.Exists());
            NUnit.Framework.Assert.IsTrue(fc.Exists());
            NUnit.Framework.Assert.IsTrue(fd.Exists());
            // Create the asyncDiskService which will delete all contents inside SUBDIR
            MRAsyncDiskService service = new MRAsyncDiskService(localFileSystem, vols);

            // Make sure everything is cleaned up
            MakeSureCleanedUp(vols, service);
        }
Exemplo n.º 2
0
        public virtual void TestMRAsyncDiskServiceMoveAndDeleteAllVolumes()
        {
            FileSystem localFileSystem = FileSystem.GetLocal(new Configuration());

            string[]           vols    = new string[] { TestRootDir + "/0", TestRootDir + "/1" };
            MRAsyncDiskService service = new MRAsyncDiskService(localFileSystem, vols);
            string             a       = "a";
            string             b       = "b";
            string             c       = "b/c";
            string             d       = "d";
            FilePath           fa      = new FilePath(vols[0], a);
            FilePath           fb      = new FilePath(vols[1], b);
            FilePath           fc      = new FilePath(vols[1], c);
            FilePath           fd      = new FilePath(vols[1], d);

            // Create the directories
            fa.Mkdirs();
            fb.Mkdirs();
            fc.Mkdirs();
            fd.Mkdirs();
            NUnit.Framework.Assert.IsTrue(fa.Exists());
            NUnit.Framework.Assert.IsTrue(fb.Exists());
            NUnit.Framework.Assert.IsTrue(fc.Exists());
            NUnit.Framework.Assert.IsTrue(fd.Exists());
            // Delete all of them
            service.CleanupAllVolumes();
            NUnit.Framework.Assert.IsFalse(fa.Exists());
            NUnit.Framework.Assert.IsFalse(fb.Exists());
            NUnit.Framework.Assert.IsFalse(fc.Exists());
            NUnit.Framework.Assert.IsFalse(fd.Exists());
            // Make sure everything is cleaned up
            MakeSureCleanedUp(vols, service);
        }
Exemplo n.º 3
0
 /// <summary>Delete a file/directory (recursively if needed).</summary>
 /// <param name="volume">The volume that the file/dir is in.</param>
 /// <param name="originalPath">The original name, relative to volume root.</param>
 /// <param name="pathToBeDeleted">
 /// The name after the move, relative to volume root,
 /// containing TOBEDELETED.
 /// </param>
 internal DeleteTask(MRAsyncDiskService _enclosing, string volume, string originalPath
                     , string pathToBeDeleted)
 {
     this._enclosing      = _enclosing;
     this.volume          = volume;
     this.originalPath    = originalPath;
     this.pathToBeDeleted = pathToBeDeleted;
 }
Exemplo n.º 4
0
        public virtual void TestMRAsyncDiskService()
        {
            FileSystem localFileSystem = FileSystem.GetLocal(new Configuration());

            string[]           vols    = new string[] { TestRootDir + "/0", TestRootDir + "/1" };
            MRAsyncDiskService service = new MRAsyncDiskService(localFileSystem, vols);
            string             a       = "a";
            string             b       = "b";
            string             c       = "b/c";
            string             d       = "d";
            FilePath           fa      = new FilePath(vols[0], a);
            FilePath           fb      = new FilePath(vols[1], b);
            FilePath           fc      = new FilePath(vols[1], c);
            FilePath           fd      = new FilePath(vols[1], d);

            // Create the directories
            fa.Mkdirs();
            fb.Mkdirs();
            fc.Mkdirs();
            fd.Mkdirs();
            NUnit.Framework.Assert.IsTrue(fa.Exists());
            NUnit.Framework.Assert.IsTrue(fb.Exists());
            NUnit.Framework.Assert.IsTrue(fc.Exists());
            NUnit.Framework.Assert.IsTrue(fd.Exists());
            // Move and delete them
            service.MoveAndDeleteRelativePath(vols[0], a);
            NUnit.Framework.Assert.IsFalse(fa.Exists());
            service.MoveAndDeleteRelativePath(vols[1], b);
            NUnit.Framework.Assert.IsFalse(fb.Exists());
            NUnit.Framework.Assert.IsFalse(fc.Exists());
            NUnit.Framework.Assert.IsFalse(service.MoveAndDeleteRelativePath(vols[1], "not_exists"
                                                                             ));
            // asyncDiskService is NOT able to delete files outside all volumes.
            IOException ee = null;

            try
            {
                service.MoveAndDeleteAbsolutePath(TestRootDir + "/2");
            }
            catch (IOException e)
            {
                ee = e;
            }
            NUnit.Framework.Assert.IsNotNull("asyncDiskService should not be able to delete files "
                                             + "outside all volumes", ee);
            // asyncDiskService is able to automatically find the file in one
            // of the volumes.
            NUnit.Framework.Assert.IsTrue(service.MoveAndDeleteAbsolutePath(vols[1] + Path.SeparatorChar
                                                                            + d));
            // Make sure everything is cleaned up
            MakeSureCleanedUp(vols, service);
        }
Exemplo n.º 5
0
        public virtual void TestVolumeNormalization()
        {
            Log.Info("TEST_ROOT_DIR is " + TestRootDir);
            string     relativeTestRoot = RelativeToWorking(TestRootDir);
            FileSystem localFileSystem  = FileSystem.GetLocal(new Configuration());

            string[] vols = new string[] { relativeTestRoot + "/0", relativeTestRoot + "/1" };
            // Put a file in one of the volumes to be cleared on startup.
            Path delDir = new Path(vols[0], MRAsyncDiskService.Tobedeleted);

            localFileSystem.Mkdirs(delDir);
            localFileSystem.Create(new Path(delDir, "foo")).Close();
            MRAsyncDiskService service = new MRAsyncDiskService(localFileSystem, vols);

            MakeSureCleanedUp(vols, service);
        }
Exemplo n.º 6
0
 /// <exception cref="System.Exception"/>
 private void MakeSureCleanedUp(string[] vols, MRAsyncDiskService service)
 {
     // Sleep at most 5 seconds to make sure the deleted items are all gone.
     service.Shutdown();
     if (!service.AwaitTermination(5000))
     {
         Fail("MRAsyncDiskService is still not shutdown in 5 seconds!");
     }
     // All contents should be gone by now.
     for (int i = 0; i < vols.Length; i++)
     {
         FilePath subDir        = new FilePath(vols[0]);
         string[] subDirContent = subDir.List();
         NUnit.Framework.Assert.AreEqual("Volume should contain a single child: " + MRAsyncDiskService
                                         .Tobedeleted, 1, subDirContent.Length);
         FilePath toBeDeletedDir = new FilePath(vols[0], MRAsyncDiskService.Tobedeleted);
         string[] content        = toBeDeletedDir.List();
         NUnit.Framework.Assert.IsNotNull("Cannot find " + toBeDeletedDir, content);
         NUnit.Framework.Assert.AreEqual(string.Empty + toBeDeletedDir + " should be empty now."
                                         , 0, content.Length);
     }
 }