예제 #1
0
        /// <exception cref="System.IO.IOException"/>
        internal EditLogBackupOutputStream(NamenodeRegistration bnReg, JournalInfo journalInfo
                                           )
            : base()
        {
            // RPC proxy to backup node
            // backup node registration
            // active node registration
            // serialized output sent to backup node
            // backup node
            // active name-node
            this.bnRegistration = bnReg;
            this.journalInfo    = journalInfo;
            IPEndPoint bnAddress = NetUtils.CreateSocketAddr(bnRegistration.GetAddress());

            try
            {
                this.backupNode = NameNodeProxies.CreateNonHAProxy <JournalProtocol>(new HdfsConfiguration
                                                                                         (), bnAddress, UserGroupInformation.GetCurrentUser(), true).GetProxy();
            }
            catch (IOException e)
            {
                Storage.Log.Error("Error connecting to: " + bnAddress, e);
                throw;
            }
            this.doubleBuf = new EditsDoubleBuffer(DefaultBufferSize);
            this.@out      = new DataOutputBuffer(DefaultBufferSize);
        }
예제 #2
0
        public virtual void TestConvertNamenodeRegistration()
        {
            StorageInfo          info = GetStorageInfo(HdfsServerConstants.NodeType.NameNode);
            NamenodeRegistration reg  = new NamenodeRegistration("address:999", "http:1000", info
                                                                 , HdfsServerConstants.NamenodeRole.Namenode);

            HdfsProtos.NamenodeRegistrationProto regProto = PBHelper.Convert(reg);
            NamenodeRegistration reg2 = PBHelper.Convert(regProto);

            NUnit.Framework.Assert.AreEqual(reg.GetAddress(), reg2.GetAddress());
            NUnit.Framework.Assert.AreEqual(reg.GetClusterID(), reg2.GetClusterID());
            NUnit.Framework.Assert.AreEqual(reg.GetCTime(), reg2.GetCTime());
            NUnit.Framework.Assert.AreEqual(reg.GetHttpAddress(), reg2.GetHttpAddress());
            NUnit.Framework.Assert.AreEqual(reg.GetLayoutVersion(), reg2.GetLayoutVersion());
            NUnit.Framework.Assert.AreEqual(reg.GetNamespaceID(), reg2.GetNamespaceID());
            NUnit.Framework.Assert.AreEqual(reg.GetRegistrationID(), reg2.GetRegistrationID()
                                            );
            NUnit.Framework.Assert.AreEqual(reg.GetRole(), reg2.GetRole());
            NUnit.Framework.Assert.AreEqual(reg.GetVersion(), reg2.GetVersion());
        }
예제 #3
0
 public virtual bool MatchesRegistration(NamenodeRegistration bnReg)
 {
     return(bnReg.GetAddress().Equals(this.bnReg.GetAddress()));
 }
예제 #4
0
        /// <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();
        }