Esempio n. 1
0
        public virtual void TestLocatedBlockConstructorWithNullCachedLocs()
        {
            DatanodeInfo d = DFSTestUtil.GetLocalDatanodeInfo();

            DatanodeInfo[] ds = new DatanodeInfo[1];
            ds[0] = d;
            ExtendedBlock b1 = new ExtendedBlock("bpid", 1, 1, 1);
            LocatedBlock  l1 = new LocatedBlock(b1, ds, null, null, 0, false, null);

            DatanodeInfo[] cachedLocs = l1.GetCachedLocations();
            NUnit.Framework.Assert.IsTrue(cachedLocs.Length == 0);
        }
Esempio n. 2
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);
        }