예제 #1
0
        public virtual void TestScheduleSameBlock()
        {
            Configuration  conf    = new HdfsConfiguration();
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(4).Build();

            try
            {
                cluster.WaitActive();
                DistributedFileSystem dfs = cluster.GetFileSystem();
                string file = "/testScheduleSameBlock/file";
                {
                    FSDataOutputStream @out = dfs.Create(new Path(file));
                    @out.WriteChars("testScheduleSameBlock");
                    @out.Close();
                }
                Org.Apache.Hadoop.Hdfs.Server.Mover.Mover mover = NewMover(conf);
                mover.Init();
                Mover.Processor         processor    = new Mover.Processor(this);
                LocatedBlock            lb           = dfs.GetClient().GetLocatedBlocks(file, 0).Get(0);
                IList <Mover.MLocation> locations    = Mover.MLocation.ToLocations(lb);
                Mover.MLocation         ml           = locations[0];
                Dispatcher.DBlock       db           = mover.NewDBlock(lb.GetBlock().GetLocalBlock(), locations);
                IList <StorageType>     storageTypes = new AList <StorageType>(Arrays.AsList(StorageType
                                                                                             .Default, StorageType.Default));
                NUnit.Framework.Assert.IsTrue(processor.ScheduleMoveReplica(db, ml, storageTypes)
                                              );
                NUnit.Framework.Assert.IsFalse(processor.ScheduleMoveReplica(db, ml, storageTypes
                                                                             ));
            }
            finally
            {
                cluster.Shutdown();
            }
        }
예제 #2
0
 private static G Get <G>(Dispatcher.StorageGroupMap <G> map, Mover.MLocation ml)
     where G : Dispatcher.DDatanode.StorageGroup
 {
     return(map.Get(ml.datanode.GetDatanodeUuid(), ml.storageType));
 }
예제 #3
0
 private Dispatcher.Source GetSource(Mover.MLocation ml)
 {
     return(Get(sources, ml));
 }
예제 #4
0
 internal virtual bool ScheduleMoveReplica(Dispatcher.DBlock db, Mover.MLocation ml
                                           , IList <StorageType> targetTypes)
 {
     Dispatcher.Source source = this._enclosing.storages.GetSource(ml);
     return(source == null ? false : this.ScheduleMoveReplica(db, source, targetTypes));
 }