Beispiel #1
0
        /// <exception cref="Com.Google.Protobuf.ServiceException"/>
        public virtual NamenodeProtocolProtos.IsUpgradeFinalizedResponseProto IsUpgradeFinalized
            (RpcController controller, NamenodeProtocolProtos.IsUpgradeFinalizedRequestProto
            request)
        {
            bool isUpgradeFinalized;

            try
            {
                isUpgradeFinalized = impl.IsUpgradeFinalized();
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
            return((NamenodeProtocolProtos.IsUpgradeFinalizedResponseProto)NamenodeProtocolProtos.IsUpgradeFinalizedResponseProto
                   .NewBuilder().SetIsUpgradeFinalized(isUpgradeFinalized).Build());
        }
        /// <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);
        }