Exemplo n.º 1
0
 private void PutInternal(DatanodeID dnId, Peer peer)
 {
     lock (this)
     {
         StartExpiryDaemon();
         if (capacity == multimap.Size())
         {
             EvictOldest();
         }
         multimap.Put(new PeerCache.Key(dnId, peer.GetDomainSocket() != null), new PeerCache.Value
                          (peer, Time.MonotonicNow()));
     }
 }
Exemplo n.º 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);
        }