Esempio n. 1
0
 /// <summary>Tests DataTransferProtocol with the given client configuration.</summary>
 /// <param name="conf">client configuration</param>
 /// <exception cref="System.IO.IOException">if there is an I/O error</exception>
 private void DoTest(HdfsConfiguration conf)
 {
     fs = FileSystem.Get(cluster.GetURI(), conf);
     FileSystemTestHelper.CreateFile(fs, Path, NumBlocks, BlockSize);
     Assert.AssertArrayEquals(FileSystemTestHelper.GetFileData(NumBlocks, BlockSize),
                              Sharpen.Runtime.GetBytesForString(DFSTestUtil.ReadFile(fs, Path), "UTF-8"));
     BlockLocation[] blockLocations = fs.GetFileBlockLocations(Path, 0, long.MaxValue);
     NUnit.Framework.Assert.IsNotNull(blockLocations);
     NUnit.Framework.Assert.AreEqual(NumBlocks, blockLocations.Length);
     foreach (BlockLocation blockLocation in blockLocations)
     {
         NUnit.Framework.Assert.IsNotNull(blockLocation.GetHosts());
         NUnit.Framework.Assert.AreEqual(3, blockLocation.GetHosts().Length);
     }
 }
Esempio n. 2
0
 /// <exception cref="System.Exception"/>
 private void TestTruncate()
 {
     if (!IsLocalFS())
     {
         short      repl        = 3;
         int        blockSize   = 1024;
         int        numOfBlocks = 2;
         FileSystem fs          = FileSystem.Get(GetProxiedFSConf());
         fs.Mkdirs(GetProxiedFSTestDir());
         Path   file = new Path(GetProxiedFSTestDir(), "foo.txt");
         byte[] data = FileSystemTestHelper.GetFileData(numOfBlocks, blockSize);
         FileSystemTestHelper.CreateFile(fs, file, data, blockSize, repl);
         int  newLength = blockSize;
         bool isReady   = fs.Truncate(file, newLength);
         NUnit.Framework.Assert.IsTrue("Recovery is not expected.", isReady);
         FileStatus fileStatus = fs.GetFileStatus(file);
         NUnit.Framework.Assert.AreEqual(fileStatus.GetLen(), newLength);
         AppendTestUtil.CheckFullFile(fs, file, newLength, data, file.ToString());
         fs.Close();
     }
 }