/// <exception cref="System.IO.IOException"/> public virtual void ValidateStorage(NNStorage storage) { if (layoutVersion != storage.GetLayoutVersion() || namespaceID != storage.GetNamespaceID () || cTime != storage.cTime || !clusterID.Equals(storage.GetClusterID()) || !blockPoolID .Equals(storage.GetBlockPoolID())) { throw new IOException("Inconsistent namespace information:\n" + "NamespaceInfo has:\n" + "LV=" + layoutVersion + ";" + "NS=" + namespaceID + ";" + "cTime=" + cTime + ";" + "CID=" + clusterID + ";" + "BPID=" + blockPoolID + ".\nStorage has:\n" + "LV=" + storage.GetLayoutVersion() + ";" + "NS=" + storage.GetNamespaceID() + ";" + "cTime=" + storage.GetCTime() + ";" + "CID=" + storage.GetClusterID() + ";" + "BPID=" + storage.GetBlockPoolID() + "."); } }
/// <summary>Register this backup node with the active name-node.</summary> /// <param name="nsInfo">namespace information</param> /// <exception cref="System.IO.IOException"/> private void RegisterWith(NamespaceInfo nsInfo) { BackupImage bnImage = (BackupImage)GetFSImage(); NNStorage storage = bnImage.GetStorage(); // verify namespaceID if (storage.GetNamespaceID() == 0) { // new backup storage storage.SetStorageInfo(nsInfo); storage.SetBlockPoolID(nsInfo.GetBlockPoolID()); storage.SetClusterID(nsInfo.GetClusterID()); } else { nsInfo.ValidateStorage(storage); } bnImage.InitEditLog(HdfsServerConstants.StartupOption.Regular); SetRegistration(); NamenodeRegistration nnReg = null; while (!IsStopRequested()) { try { nnReg = namenode.RegisterSubordinateNamenode(GetRegistration()); break; } catch (SocketTimeoutException e) { // name-node is busy Log.Info("Problem connecting to name-node: " + nnRpcAddress); try { Sharpen.Thread.Sleep(1000); } catch (Exception) { Log.Warn("Encountered exception ", e); } } } string msg = null; if (nnReg == null) { // consider as a rejection msg = "Registration rejected by " + nnRpcAddress; } else { if (!nnReg.IsRole(HdfsServerConstants.NamenodeRole.Namenode)) { msg = "Name-node " + nnRpcAddress + " is not active"; } } if (msg != null) { msg += ". Shutting down."; Log.Error(msg); throw new IOException(msg); } // stop the node nnRpcAddress = nnReg.GetAddress(); }