Ejemplo n.º 1
0
        /// <summary>
        /// Test that when access time updates are not needed, the FSNamesystem
        /// write lock is not taken by getBlockLocations.
        /// </summary>
        /// <remarks>
        /// Test that when access time updates are not needed, the FSNamesystem
        /// write lock is not taken by getBlockLocations.
        /// Regression test for HDFS-3981.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestGetBlockLocationsOnlyUsesReadLock()
        {
            Configuration conf = new HdfsConfiguration();

            conf.SetInt(DFSConfigKeys.DfsNamenodeAccesstimePrecisionKey, 100 * 1000);
            MiniDFSCluster         cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(0).Build();
            ReentrantReadWriteLock spyLock = NameNodeAdapter.SpyOnFsLock(cluster.GetNamesystem
                                                                             ());

            try
            {
                // Create empty file in the FSN.
                Path p = new Path("/empty-file");
                DFSTestUtil.CreateFile(cluster.GetFileSystem(), p, 0, (short)1, 0L);
                // getBlockLocations() should not need the write lock, since we just created
                // the file (and thus its access time is already within the 100-second
                // accesstime precision configured above).
                MockitoUtil.DoThrowWhenCallStackMatches(new Exception("Should not need write lock"
                                                                      ), ".*getBlockLocations.*").When(spyLock).WriteLock();
                cluster.GetFileSystem().GetFileBlockLocations(p, 0, 100);
            }
            finally
            {
                cluster.Shutdown();
            }
        }
Ejemplo n.º 2
0
 public virtual void Setup()
 {
     mockProtocol     = MockitoUtil.MockProtocol <HAServiceProtocol>();
     mockZkfcProtocol = MockitoUtil.MockProtocol <ZKFCProtocol>();
     tool             = new _DFSHAAdmin_118(this);
     // OVerride the target to return our mock protocol
     // mock setup doesn't really throw
     tool.SetConf(GetHAConf());
     tool.SetErrOut(new TextWriter(errOutBytes));
     tool.SetOut(new TextWriter(outBytes));
 }
Ejemplo n.º 3
0
 public virtual void TestStopMockObject()
 {
     RPC.StopProxy(MockitoUtil.MockProtocol <TestRPC.TestProtocol>());
 }