Example #1
0
                                    > GetAllPendingReplications()
        {
            LinkedListMultimap <DatanodeStorageInfo, DatanodeDescriptor.BlockTargetPair> repls
                = LinkedListMultimap.Create();

            foreach (DatanodeDescriptor dn in nodes)
            {
                IList <DatanodeDescriptor.BlockTargetPair> thisRepls = dn.GetReplicationCommand(10
                                                                                                );
                if (thisRepls != null)
                {
                    foreach (DatanodeStorageInfo storage in dn.GetStorageInfos())
                    {
                        repls.PutAll(storage, thisRepls);
                    }
                }
            }
            return(repls);
        }
Example #2
0
        private DatanodeStorageInfo[] ScheduleSingleReplication(Block block)
        {
            // list for priority 1
            IList <Block> list_p1 = new AList <Block>();

            list_p1.AddItem(block);
            // list of lists for each priority
            IList <IList <Block> > list_all = new AList <IList <Block> >();

            list_all.AddItem(new AList <Block>());
            // for priority 0
            list_all.AddItem(list_p1);
            // for priority 1
            NUnit.Framework.Assert.AreEqual("Block not initially pending replication", 0, bm.
                                            pendingReplications.GetNumReplicas(block));
            NUnit.Framework.Assert.AreEqual("computeReplicationWork should indicate replication is needed"
                                            , 1, bm.ComputeReplicationWorkForBlocks(list_all));
            NUnit.Framework.Assert.IsTrue("replication is pending after work is computed", bm
                                          .pendingReplications.GetNumReplicas(block) > 0);
            LinkedListMultimap <DatanodeStorageInfo, DatanodeDescriptor.BlockTargetPair> repls
                = GetAllPendingReplications();

            NUnit.Framework.Assert.AreEqual(1, repls.Size());
            KeyValuePair <DatanodeStorageInfo, DatanodeDescriptor.BlockTargetPair> repl = repls
                                                                                          .Entries().GetEnumerator().Next();

            DatanodeStorageInfo[] targets  = repl.Value.targets;
            DatanodeStorageInfo[] pipeline = new DatanodeStorageInfo[1 + targets.Length];
            pipeline[0] = repl.Key;
            System.Array.Copy(targets, 0, pipeline, 1, targets.Length);
            return(pipeline);
        }