public virtual void TestConvertStoragInfo() { StorageInfo info = GetStorageInfo(HdfsServerConstants.NodeType.NameNode); HdfsProtos.StorageInfoProto infoProto = PBHelper.Convert(info); StorageInfo info2 = PBHelper.Convert(infoProto, HdfsServerConstants.NodeType.NameNode ); NUnit.Framework.Assert.AreEqual(info.GetClusterID(), info2.GetClusterID()); NUnit.Framework.Assert.AreEqual(info.GetCTime(), info2.GetCTime()); NUnit.Framework.Assert.AreEqual(info.GetLayoutVersion(), info2.GetLayoutVersion() ); NUnit.Framework.Assert.AreEqual(info.GetNamespaceID(), info2.GetNamespaceID()); }
// 0 // 1 // 2 // 3 // 4 // 5 // 6 // 7 // 8 // 9 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 // Test with invalid clusterId // 18 // Test with invalid block pool Id // 19 /// <summary> /// Determines if the given Namenode version and Datanode version /// are compatible with each other. /// </summary> /// <remarks> /// Determines if the given Namenode version and Datanode version /// are compatible with each other. Compatibility in this case mean /// that the Namenode and Datanode will successfully start up and /// will work together. The rules for compatibility, /// taken from the DFS Upgrade Design, are as follows: /// <pre> /// <ol> /// <li>Check 0: Datanode namespaceID != Namenode namespaceID the startup fails /// </li> /// <li>Check 1: Datanode clusterID != Namenode clusterID the startup fails /// </li> /// <li>Check 2: Datanode blockPoolID != Namenode blockPoolID the startup fails /// </li> /// <li>Check 3: The data-node does regular startup (no matter which options /// it is started with) if /// softwareLV == storedLV AND /// DataNode.FSSCTime == NameNode.FSSCTime /// </li> /// <li>Check 4: The data-node performs an upgrade if it is started without any /// options and /// |softwareLV| > |storedLV| OR /// (softwareLV == storedLV AND /// DataNode.FSSCTime < NameNode.FSSCTime) /// </li> /// <li>NOT TESTED: The data-node rolls back if it is started with /// the -rollback option and /// |softwareLV| >= |previous.storedLV| AND /// DataNode.previous.FSSCTime <= NameNode.FSSCTime /// </li> /// <li>Check 5: In all other cases the startup fails.</li> /// </ol> /// </pre> /// </remarks> internal virtual bool IsVersionCompatible(TestDFSStartupVersions.StorageData namenodeSd , TestDFSStartupVersions.StorageData datanodeSd) { StorageInfo namenodeVer = namenodeSd.storageInfo; StorageInfo datanodeVer = datanodeSd.storageInfo; // check #0 if (namenodeVer.GetNamespaceID() != datanodeVer.GetNamespaceID()) { Log.Info("namespaceIDs are not equal: isVersionCompatible=false"); return(false); } // check #1 if (!namenodeVer.GetClusterID().Equals(datanodeVer.GetClusterID())) { Log.Info("clusterIDs are not equal: isVersionCompatible=false"); return(false); } // check #2 if (!namenodeSd.blockPoolId.Equals(datanodeSd.blockPoolId)) { Log.Info("blockPoolIDs are not equal: isVersionCompatible=false"); return(false); } // check #3 int softwareLV = HdfsConstants.DatanodeLayoutVersion; int storedLV = datanodeVer.GetLayoutVersion(); if (softwareLV == storedLV && datanodeVer.GetCTime() == namenodeVer.GetCTime()) { Log.Info("layoutVersions and cTimes are equal: isVersionCompatible=true"); return(true); } // check #4 long absSoftwareLV = Math.Abs((long)softwareLV); long absStoredLV = Math.Abs((long)storedLV); if (absSoftwareLV > absStoredLV || (softwareLV == storedLV && datanodeVer.GetCTime () < namenodeVer.GetCTime())) { Log.Info("softwareLayoutVersion is newer OR namenode cTime is newer: isVersionCompatible=true" ); return(true); } // check #5 Log.Info("default case: isVersionCompatible=false"); return(false); }