/// <exception cref="System.IO.IOException"/> public NameNodeConnector(string name, URI nameNodeUri, Path idPath, IList <Path> targetPaths , Configuration conf, int maxNotChangedIterations) { this.nameNodeUri = nameNodeUri; this.idPath = idPath; this.targetPaths = targetPaths == null || targetPaths.IsEmpty() ? Arrays.AsList(new Path("/")) : targetPaths; this.maxNotChangedIterations = maxNotChangedIterations; this.namenode = NameNodeProxies.CreateProxy <NamenodeProtocol>(conf, nameNodeUri). GetProxy(); this.client = NameNodeProxies.CreateProxy <ClientProtocol>(conf, nameNodeUri, fallbackToSimpleAuth ).GetProxy(); this.fs = (DistributedFileSystem)FileSystem.Get(nameNodeUri, conf); NamespaceInfo namespaceinfo = namenode.VersionRequest(); this.blockpoolID = namespaceinfo.GetBlockPoolID(); FsServerDefaults defaults = fs.GetServerDefaults(new Path("/")); this.keyManager = new KeyManager(blockpoolID, namenode, defaults.GetEncryptDataTransfer (), conf); // if it is for test, we do not create the id file @out = CheckAndMarkRunning(); if (@out == null) { // Exit if there is another one running. throw new IOException("Another " + name + " is running."); } }
/// <exception cref="Com.Google.Protobuf.ServiceException"/> public virtual HdfsProtos.VersionResponseProto VersionRequest(RpcController controller , HdfsProtos.VersionRequestProto request) { NamespaceInfo info; try { info = impl.VersionRequest(); } catch (IOException e) { throw new ServiceException(e); } return((HdfsProtos.VersionResponseProto)HdfsProtos.VersionResponseProto.NewBuilder ().SetInfo(PBHelper.Convert(info)).Build()); }
// TODO: move to a common with DataNode util class /// <exception cref="System.IO.IOException"/> /// <exception cref="Sharpen.SocketTimeoutException"/> private static NamespaceInfo Handshake(NamenodeProtocol namenode) { NamespaceInfo nsInfo; nsInfo = namenode.VersionRequest(); // throws SocketTimeoutException string errorMsg = null; // verify build version if (!nsInfo.GetBuildVersion().Equals(Storage.GetBuildVersion())) { errorMsg = "Incompatible build versions: active name-node BV = " + nsInfo.GetBuildVersion () + "; backup node BV = " + Storage.GetBuildVersion(); Log.Error(errorMsg); throw new IOException(errorMsg); } System.Diagnostics.Debug.Assert(HdfsConstants.NamenodeLayoutVersion == nsInfo.GetLayoutVersion (), "Active and backup node layout versions must be the same. Expected: " + HdfsConstants .NamenodeLayoutVersion + " actual " + nsInfo.GetLayoutVersion()); return(nsInfo); }
/// <exception cref="System.IO.IOException"/> private int DoRun() { NamenodeProtocol proxy = CreateNNProtocolProxy(); NamespaceInfo nsInfo; bool isUpgradeFinalized; try { nsInfo = proxy.VersionRequest(); isUpgradeFinalized = proxy.IsUpgradeFinalized(); } catch (IOException ioe) { Log.Fatal("Unable to fetch namespace information from active NN at " + otherIpcAddr + ": " + ioe.Message); if (Log.IsDebugEnabled()) { Log.Debug("Full exception trace", ioe); } return(ErrCodeFailedConnect); } if (!CheckLayoutVersion(nsInfo)) { Log.Fatal("Layout version on remote node (" + nsInfo.GetLayoutVersion() + ") does not match " + "this node's layout version (" + HdfsConstants.NamenodeLayoutVersion + ")"); return(ErrCodeInvalidVersion); } System.Console.Out.WriteLine("=====================================================\n" + "About to bootstrap Standby ID " + nnId + " from:\n" + " Nameservice ID: " + nsId + "\n" + " Other Namenode ID: " + otherNNId + "\n" + " Other NN's HTTP address: " + otherHttpAddr + "\n" + " Other NN's IPC address: " + otherIpcAddr + "\n" + " Namespace ID: " + nsInfo.GetNamespaceID() + "\n" + " Block pool ID: " + nsInfo.GetBlockPoolID() + "\n" + " Cluster ID: " + nsInfo.GetClusterID () + "\n" + " Layout version: " + nsInfo.GetLayoutVersion() + "\n" + " isUpgradeFinalized: " + isUpgradeFinalized + "\n" + "=====================================================" ); NNStorage storage = new NNStorage(conf, dirsToFormat, editUrisToFormat); if (!isUpgradeFinalized) { // the remote NameNode is in upgrade state, this NameNode should also // create the previous directory. First prepare the upgrade and rename // the current dir to previous.tmp. Log.Info("The active NameNode is in Upgrade. " + "Prepare the upgrade for the standby NameNode as well." ); if (!DoPreUpgrade(storage, nsInfo)) { return(ErrCodeAlreadyFormatted); } } else { if (!Format(storage, nsInfo)) { // prompt the user to format storage return(ErrCodeAlreadyFormatted); } } // download the fsimage from active namenode int download = DownloadImage(storage, proxy); if (download != 0) { return(download); } // finish the upgrade: rename previous.tmp to previous if (!isUpgradeFinalized) { DoUpgrade(storage); } return(0); }