Ejemplo n.º 1
0
        /// <summary>Call all the constructors and verify the delegation is working properly</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestBlockLocationConstructors()
        {
            //
            BlockLocation loc;

            loc = new BlockLocation();
            CheckBlockLocation(loc);
            loc = new BlockLocation(null, null, 1, 2);
            CheckBlockLocation(loc, 1, 2, false);
            loc = new BlockLocation(null, null, null, 1, 2);
            CheckBlockLocation(loc, 1, 2, false);
            loc = new BlockLocation(null, null, null, 1, 2, true);
            CheckBlockLocation(loc, 1, 2, true);
            loc = new BlockLocation(null, null, null, null, 1, 2, true);
            CheckBlockLocation(loc, 1, 2, true);
        }
Ejemplo n.º 2
0
 /// <exception cref="System.Exception"/>
 private static void CheckBlockLocation(BlockLocation loc, string[] names, string[]
                                        hosts, string[] cachedHosts, string[] topologyPaths, long offset, long length,
                                        bool corrupt)
 {
     NUnit.Framework.Assert.IsNotNull(loc.GetHosts());
     NUnit.Framework.Assert.IsNotNull(loc.GetCachedHosts());
     NUnit.Framework.Assert.IsNotNull(loc.GetNames());
     NUnit.Framework.Assert.IsNotNull(loc.GetTopologyPaths());
     Assert.AssertArrayEquals(hosts, loc.GetHosts());
     Assert.AssertArrayEquals(cachedHosts, loc.GetCachedHosts());
     Assert.AssertArrayEquals(names, loc.GetNames());
     Assert.AssertArrayEquals(topologyPaths, loc.GetTopologyPaths());
     Assert.Equal(offset, loc.GetOffset());
     Assert.Equal(length, loc.GetLength());
     Assert.Equal(corrupt, loc.IsCorrupt());
 }
Ejemplo n.º 3
0
 /// <exception cref="System.Exception"/>
 private static void CheckBlockLocation(BlockLocation loc, long offset, long length
                                        , bool corrupt)
 {
     CheckBlockLocation(loc, EmptyStrArray, EmptyStrArray, EmptyStrArray, EmptyStrArray
                        , offset, length, corrupt);
 }
Ejemplo n.º 4
0
 /// <exception cref="System.Exception"/>
 private static void CheckBlockLocation(BlockLocation loc)
 {
     CheckBlockLocation(loc, 0, 0, false);
 }
Ejemplo n.º 5
0
 public virtual void TestFixBlockLocations()
 {
     {
         // do some tests where start == 0
         // case 1: range starts before current har block and ends after
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 0, 20, 5);
         Assert.Equal(b[0].GetOffset(), 5);
         Assert.Equal(b[0].GetLength(), 10);
     }
     {
         // case 2: range starts in current har block and ends after
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 0, 20, 15);
         Assert.Equal(b[0].GetOffset(), 0);
         Assert.Equal(b[0].GetLength(), 5);
     }
     {
         // case 3: range starts before current har block and ends in
         // current har block
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 0, 10, 5);
         Assert.Equal(b[0].GetOffset(), 5);
         Assert.Equal(b[0].GetLength(), 5);
     }
     {
         // case 4: range starts and ends in current har block
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 0, 6, 12);
         Assert.Equal(b[0].GetOffset(), 0);
         Assert.Equal(b[0].GetLength(), 6);
     }
     {
         // now try a range where start == 3
         // case 5: range starts before current har block and ends after
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 3, 20, 5);
         Assert.Equal(b[0].GetOffset(), 5);
         Assert.Equal(b[0].GetLength(), 10);
     }
     {
         // case 6: range starts in current har block and ends after
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 3, 20, 15);
         Assert.Equal(b[0].GetOffset(), 3);
         Assert.Equal(b[0].GetLength(), 2);
     }
     {
         // case 7: range starts before current har block and ends in
         // current har block
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 3, 7, 5);
         Assert.Equal(b[0].GetOffset(), 5);
         Assert.Equal(b[0].GetLength(), 5);
     }
     {
         // case 8: range starts and ends in current har block
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 10, 10) };
         HarFileSystem.FixBlockLocations(b, 3, 3, 12);
         Assert.Equal(b[0].GetOffset(), 3);
         Assert.Equal(b[0].GetLength(), 3);
     }
     {
         // test case from JIRA MAPREDUCE-1752
         BlockLocation[] b = new BlockLocation[] { new BlockLocation(null, null, 512, 512)
                                                   , new BlockLocation(null, null, 1024, 512) };
         HarFileSystem.FixBlockLocations(b, 0, 512, 896);
         Assert.Equal(b[0].GetOffset(), 0);
         Assert.Equal(b[0].GetLength(), 128);
         Assert.Equal(b[1].GetOffset(), 128);
         Assert.Equal(b[1].GetLength(), 384);
     }
 }
Ejemplo n.º 6
0
 /// <exception cref="System.IO.IOException"/>
 public HdfsBlockLocation(BlockLocation loc, LocatedBlock block)
     : base(loc)
 {
     // Initialize with data from passed in BlockLocation
     this.block = block;
 }