Exemplo n.º 1
0
        /// <summary>Convert a DatanodeInfo to a Json map.</summary>
        internal static IDictionary <string, object> ToJsonMap(DatanodeInfo datanodeinfo)
        {
            if (datanodeinfo == null)
            {
                return(null);
            }
            // TODO: Fix storageID
            IDictionary <string, object> m = new SortedDictionary <string, object>();

            m["ipAddr"] = datanodeinfo.GetIpAddr();
            // 'name' is equivalent to ipAddr:xferPort. Older clients (1.x, 0.23.x)
            // expects this instead of the two fields.
            m["name"]                = datanodeinfo.GetXferAddr();
            m["hostName"]            = datanodeinfo.GetHostName();
            m["storageID"]           = datanodeinfo.GetDatanodeUuid();
            m["xferPort"]            = datanodeinfo.GetXferPort();
            m["infoPort"]            = datanodeinfo.GetInfoPort();
            m["infoSecurePort"]      = datanodeinfo.GetInfoSecurePort();
            m["ipcPort"]             = datanodeinfo.GetIpcPort();
            m["capacity"]            = datanodeinfo.GetCapacity();
            m["dfsUsed"]             = datanodeinfo.GetDfsUsed();
            m["remaining"]           = datanodeinfo.GetRemaining();
            m["blockPoolUsed"]       = datanodeinfo.GetBlockPoolUsed();
            m["cacheCapacity"]       = datanodeinfo.GetCacheCapacity();
            m["cacheUsed"]           = datanodeinfo.GetCacheUsed();
            m["lastUpdate"]          = datanodeinfo.GetLastUpdate();
            m["lastUpdateMonotonic"] = datanodeinfo.GetLastUpdateMonotonic();
            m["xceiverCount"]        = datanodeinfo.GetXceiverCount();
            m["networkLocation"]     = datanodeinfo.GetNetworkLocation();
            m["adminState"]          = datanodeinfo.GetAdminState().ToString();
            return(m);
        }
Exemplo n.º 2
0
 private void Compare(DatanodeInfo dn1, DatanodeInfo dn2)
 {
     NUnit.Framework.Assert.AreEqual(dn1.GetAdminState(), dn2.GetAdminState());
     NUnit.Framework.Assert.AreEqual(dn1.GetBlockPoolUsed(), dn2.GetBlockPoolUsed());
     NUnit.Framework.Assert.AreEqual(dn1.GetBlockPoolUsedPercent(), dn2.GetBlockPoolUsedPercent
                                         (), Delta);
     NUnit.Framework.Assert.AreEqual(dn1.GetCapacity(), dn2.GetCapacity());
     NUnit.Framework.Assert.AreEqual(dn1.GetDatanodeReport(), dn2.GetDatanodeReport());
     NUnit.Framework.Assert.AreEqual(dn1.GetDfsUsed(), dn1.GetDfsUsed());
     NUnit.Framework.Assert.AreEqual(dn1.GetDfsUsedPercent(), dn1.GetDfsUsedPercent(),
                                     Delta);
     NUnit.Framework.Assert.AreEqual(dn1.GetIpAddr(), dn2.GetIpAddr());
     NUnit.Framework.Assert.AreEqual(dn1.GetHostName(), dn2.GetHostName());
     NUnit.Framework.Assert.AreEqual(dn1.GetInfoPort(), dn2.GetInfoPort());
     NUnit.Framework.Assert.AreEqual(dn1.GetIpcPort(), dn2.GetIpcPort());
     NUnit.Framework.Assert.AreEqual(dn1.GetLastUpdate(), dn2.GetLastUpdate());
     NUnit.Framework.Assert.AreEqual(dn1.GetLevel(), dn2.GetLevel());
     NUnit.Framework.Assert.AreEqual(dn1.GetNetworkLocation(), dn2.GetNetworkLocation(
                                         ));
 }