Exemplo n.º 1
0
 /// <exception cref="System.IO.IOException"/>
 private void TestPlacement(string clientMachine, string clientRack)
 {
     // write 5 files and check whether all times block placed
     for (int i = 0; i < 5; i++)
     {
         string src = "/test-" + i;
         // Create the file with client machine
         HdfsFileStatus fileStatus = namesystem.StartFile(src, perm, clientMachine, clientMachine
                                                          , EnumSet.Of(CreateFlag.Create), true, ReplicationFactor, DefaultBlockSize, null
                                                          , false);
         LocatedBlock locatedBlock = nameNodeRpc.AddBlock(src, clientMachine, null, null,
                                                          fileStatus.GetFileId(), null);
         NUnit.Framework.Assert.AreEqual("Block should be allocated sufficient locations",
                                         ReplicationFactor, locatedBlock.GetLocations().Length);
         if (clientRack != null)
         {
             NUnit.Framework.Assert.AreEqual("First datanode should be rack local", clientRack
                                             , locatedBlock.GetLocations()[0].GetNetworkLocation());
         }
         nameNodeRpc.AbandonBlock(locatedBlock.GetBlock(), fileStatus.GetFileId(), src, clientMachine
                                  );
     }
 }