示例#1
0
        /// <exception cref="System.IO.IOException"/>
        internal virtual void AddBlockPool(string bpid, Configuration conf)
        {
            FilePath       bpdir = new FilePath(currentDir, bpid);
            BlockPoolSlice bp    = new BlockPoolSlice(bpid, this, bpdir, conf);

            bpSlices[bpid] = bp;
        }
示例#2
0
        public virtual void TestDuplicateReplicaResolution()
        {
            FsVolumeImpl fsv1              = Org.Mockito.Mockito.Mock <FsVolumeImpl>();
            FsVolumeImpl fsv2              = Org.Mockito.Mockito.Mock <FsVolumeImpl>();
            FilePath     f1                = new FilePath("d1/block");
            FilePath     f2                = new FilePath("d2/block");
            ReplicaInfo  replicaOlder      = new FinalizedReplica(1, 1, 1, fsv1, f1);
            ReplicaInfo  replica           = new FinalizedReplica(1, 2, 2, fsv1, f1);
            ReplicaInfo  replicaSame       = new FinalizedReplica(1, 2, 2, fsv1, f1);
            ReplicaInfo  replicaNewer      = new FinalizedReplica(1, 3, 3, fsv1, f1);
            ReplicaInfo  replicaOtherOlder = new FinalizedReplica(1, 1, 1, fsv2, f2);
            ReplicaInfo  replicaOtherSame  = new FinalizedReplica(1, 2, 2, fsv2, f2);
            ReplicaInfo  replicaOtherNewer = new FinalizedReplica(1, 3, 3, fsv2, f2);

            // equivalent path so don't remove either
            NUnit.Framework.Assert.IsNull(BlockPoolSlice.SelectReplicaToDelete(replicaSame, replica
                                                                               ));
            NUnit.Framework.Assert.IsNull(BlockPoolSlice.SelectReplicaToDelete(replicaOlder,
                                                                               replica));
            NUnit.Framework.Assert.IsNull(BlockPoolSlice.SelectReplicaToDelete(replicaNewer,
                                                                               replica));
            // keep latest found replica
            NUnit.Framework.Assert.AreSame(replica, BlockPoolSlice.SelectReplicaToDelete(replicaOtherSame
                                                                                         , replica));
            NUnit.Framework.Assert.AreSame(replicaOtherOlder, BlockPoolSlice.SelectReplicaToDelete
                                               (replicaOtherOlder, replica));
            NUnit.Framework.Assert.AreSame(replica, BlockPoolSlice.SelectReplicaToDelete(replicaOtherNewer
                                                                                         , replica));
        }
示例#3
0
        internal virtual void ShutdownBlockPool(string bpid)
        {
            BlockPoolSlice bp = bpSlices[bpid];

            if (bp != null)
            {
                bp.Shutdown();
            }
            Sharpen.Collections.Remove(bpSlices, bpid);
        }
示例#4
0
        /// <exception cref="System.IO.IOException"/>
        internal virtual BlockPoolSlice GetBlockPoolSlice(string bpid)
        {
            BlockPoolSlice bp = bpSlices[bpid];

            if (bp == null)
            {
                throw new IOException("block pool " + bpid + " is not found");
            }
            return(bp);
        }
示例#5
0
 internal virtual void IncDfsUsed(string bpid, long value)
 {
     lock (dataset)
     {
         BlockPoolSlice bp = bpSlices[bpid];
         if (bp != null)
         {
             bp.IncDfsUsed(value);
         }
     }
 }
示例#6
0
        // Wait until the test times out.
        /// <exception cref="System.Exception"/>
        public virtual void TestRBWFileCreationError()
        {
            short replication = 1;

            StartCluster(BlockSize, replication, -1);
            FsVolumeImpl fsVolumeImpl = (FsVolumeImpl)cluster.GetDataNodes()[0].GetFSDataset(
                ).GetVolumes()[0];
            string methodName = GenericTestUtils.GetMethodName();
            Path   file       = new Path("/" + methodName + ".01.dat");
            // Mock BlockPoolSlice so that RBW file creation gives IOExcception
            BlockPoolSlice blockPoolSlice = Org.Mockito.Mockito.Mock <BlockPoolSlice>();

            Org.Mockito.Mockito.When(blockPoolSlice.CreateRbwFile((Block)Org.Mockito.Mockito.
                                                                  Any())).ThenThrow(new IOException("Synthetic IO Exception Throgh MOCK"));
            FieldInfo field = Sharpen.Runtime.GetDeclaredField(typeof(FsVolumeImpl), "bpSlices"
                                                               );
            IDictionary <string, BlockPoolSlice> bpSlices = (IDictionary <string, BlockPoolSlice
                                                                          >)field.GetValue(fsVolumeImpl);

            bpSlices[fsVolumeImpl.GetBlockPoolList()[0]] = blockPoolSlice;
            try
            {
                // Write 1 byte to the file
                FSDataOutputStream os = fs.Create(file, replication);
                os.Write(new byte[1]);
                os.Hsync();
                os.Close();
                NUnit.Framework.Assert.Fail("Expecting IOException file creation failure");
            }
            catch (IOException)
            {
            }
            // Exception can be ignored (expected)
            // Ensure RBW space reserved is released
            NUnit.Framework.Assert.IsTrue("Expected ZERO but got " + fsVolumeImpl.GetReservedForRbw
                                              (), fsVolumeImpl.GetReservedForRbw() == 0);
        }
示例#7
0
 public _Runnable_145(BlockPoolSlice _enclosing)
 {
     this._enclosing = _enclosing;
 }