Example #1
0
        public virtual void TestNoSpaceDisk()
        {
            Log.Info("testNoSpaceDisk");
            TestStorageMover.PathPolicyMap pathPolicyMap = new TestStorageMover.PathPolicyMap
                                                               (0);
            TestStorageMover.NamespaceScheme nsScheme = pathPolicyMap.NewNamespaceScheme();
            Configuration conf = new Configuration(DefaultConf);

            TestStorageMover.ClusterScheme clusterScheme = new TestStorageMover.ClusterScheme
                                                               (conf, NumDatanodes, Repl, GenStorageTypes(NumDatanodes), null);
            TestStorageMover.MigrationTest test = new TestStorageMover.MigrationTest(this, clusterScheme
                                                                                     , nsScheme);
            try
            {
                test.RunBasicTest(false);
                // create 2 hot files with replication 3
                short replication = 3;
                for (int i = 0; i < 2; i++)
                {
                    Path p = new Path(pathPolicyMap.hot, "file" + i);
                    DFSTestUtil.CreateFile(test.dfs, p, BlockSize, replication, 0L);
                    WaitForAllReplicas(replication, p, test.dfs);
                }
                // set all the DISK volume to full
                foreach (DataNode dn in test.cluster.GetDataNodes())
                {
                    SetVolumeFull(dn, StorageType.Disk);
                    DataNodeTestUtils.TriggerHeartbeat(dn);
                }
                // test increasing replication.  Since DISK is full,
                // new replicas should be stored in ARCHIVE as a fallback storage.
                Path file0 = new Path(pathPolicyMap.hot, "file0");
                TestStorageMover.Replication r = test.GetReplication(file0);
                short newReplication           = (short)5;
                test.dfs.SetReplication(file0, newReplication);
                Sharpen.Thread.Sleep(10000);
                test.VerifyReplication(file0, r.disk, newReplication - r.disk);
                // test creating a cold file and then increase replication
                Path p_1 = new Path(pathPolicyMap.cold, "foo");
                DFSTestUtil.CreateFile(test.dfs, p_1, BlockSize, replication, 0L);
                test.VerifyReplication(p_1, 0, replication);
                test.dfs.SetReplication(p_1, newReplication);
                Sharpen.Thread.Sleep(10000);
                test.VerifyReplication(p_1, 0, newReplication);
                //test move a hot file to warm
                Path file1 = new Path(pathPolicyMap.hot, "file1");
                test.dfs.Rename(file1, pathPolicyMap.warm);
                test.Migrate();
                test.VerifyFile(new Path(pathPolicyMap.warm, "file1"), Warm.GetId());
            }
            finally
            {
                test.ShutdownCluster();
            }
        }