/// <summary>Verify the first block of the file is corrupted (for all its replica).</summary>
        /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
        /// <exception cref="System.IO.FileNotFoundException"/>
        /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/>
        /// <exception cref="System.IO.IOException"/>
        private void VerifyFirstBlockCorrupted(Path filePath, bool isCorrupted)
        {
            LocatedBlocks locatedBlocks = dfs.dfs.GetNamenode().GetBlockLocations(filePath.ToUri
                                                                                      ().GetPath(), 0, long.MaxValue);
            LocatedBlock firstLocatedBlock = locatedBlocks.Get(0);

            NUnit.Framework.Assert.AreEqual(isCorrupted, firstLocatedBlock.IsCorrupt());
        }
Example #2
0
 private void Compare(LocatedBlock expected, LocatedBlock actual)
 {
     NUnit.Framework.Assert.AreEqual(expected.GetBlock(), actual.GetBlock());
     Compare(expected.GetBlockToken(), actual.GetBlockToken());
     NUnit.Framework.Assert.AreEqual(expected.GetStartOffset(), actual.GetStartOffset(
                                         ));
     NUnit.Framework.Assert.AreEqual(expected.IsCorrupt(), actual.IsCorrupt());
     DatanodeInfo[] ei = expected.GetLocations();
     DatanodeInfo[] ai = actual.GetLocations();
     NUnit.Framework.Assert.AreEqual(ei.Length, ai.Length);
     for (int i = 0; i < ei.Length; i++)
     {
         Compare(ei[i], ai[i]);
     }
 }
Example #3
0
        /// <summary>Convert a LocatedBlock to a Json map.</summary>
        /// <exception cref="System.IO.IOException"/>
        private static IDictionary <string, object> ToJsonMap(LocatedBlock locatedblock)
        {
            if (locatedblock == null)
            {
                return(null);
            }
            IDictionary <string, object> m = new SortedDictionary <string, object>();

            m["blockToken"]      = ToJsonMap(locatedblock.GetBlockToken());
            m["isCorrupt"]       = locatedblock.IsCorrupt();
            m["startOffset"]     = locatedblock.GetStartOffset();
            m["block"]           = ToJsonMap(locatedblock.GetBlock());
            m["locations"]       = ToJsonArray(locatedblock.GetLocations());
            m["cachedLocations"] = ToJsonArray(locatedblock.GetCachedLocations());
            return(m);
        }