コード例 #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 override FailoverProxyProvider.ProxyInfo <T> GetProxy()
 {
     lock (this)
     {
         // Create a non-ha proxy if not already created.
         if (nnProxyInfo == null)
         {
             try
             {
                 // Create a proxy that is not wrapped in RetryProxy
                 IPEndPoint nnAddr = NameNode.GetAddress(nameNodeUri);
                 nnProxyInfo = new FailoverProxyProvider.ProxyInfo <T>(NameNodeProxies.CreateNonHAProxy
                                                                           (conf, nnAddr, xface, UserGroupInformation.GetCurrentUser(), false).GetProxy(),
                                                                       nnAddr.ToString());
             }
             catch (IOException ioe)
             {
                 throw new RuntimeException(ioe);
             }
         }
         return(nnProxyInfo);
     }
 }
コード例 #3
0
 /// <summary>Lazily initialize the RPC proxy object.</summary>
 public override FailoverProxyProvider.ProxyInfo <T> GetProxy()
 {
     lock (this)
     {
         ConfiguredFailoverProxyProvider.AddressRpcProxyPair <T> current = proxies[currentProxyIndex
                                                                           ];
         if (current.namenode == null)
         {
             try
             {
                 current.namenode = NameNodeProxies.CreateNonHAProxy(conf, current.address, xface,
                                                                     ugi, false, fallbackToSimpleAuth).GetProxy();
             }
             catch (IOException e)
             {
                 Log.Error("Failed to create RPC proxy to NameNode", e);
                 throw new RuntimeException(e);
             }
         }
         return(new FailoverProxyProvider.ProxyInfo <T>(current.namenode, current.address.ToString
                                                            ()));
     }
 }
コード例 #4
0
ファイル: BackupNode.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.IO.IOException"/>
        private NamespaceInfo Handshake(Configuration conf)
        {
            // connect to name node
            IPEndPoint nnAddress = NameNode.GetServiceAddress(conf, true);

            this.namenode = NameNodeProxies.CreateNonHAProxy <NamenodeProtocol>(conf, nnAddress
                                                                                , UserGroupInformation.GetCurrentUser(), true).GetProxy();
            this.nnRpcAddress  = NetUtils.GetHostPortString(nnAddress);
            this.nnHttpAddress = DFSUtil.GetInfoServer(nnAddress, conf, DFSUtil.GetHttpClientScheme
                                                           (conf)).ToURL();
            // get version and id info from the name-node
            NamespaceInfo nsInfo = null;

            while (!IsStopRequested())
            {
                try
                {
                    nsInfo = Handshake(namenode);
                    break;
                }
                catch (SocketTimeoutException e)
                {
                    // name-node is busy
                    Log.Info("Problem connecting to server: " + nnAddress);
                    try
                    {
                        Sharpen.Thread.Sleep(1000);
                    }
                    catch (Exception)
                    {
                        Log.Warn("Encountered exception ", e);
                    }
                }
            }
            return(nsInfo);
        }
コード例 #5
0
 /// <exception cref="System.IO.IOException"/>
 private NamenodeProtocol CreateNNProtocolProxy()
 {
     return(NameNodeProxies.CreateNonHAProxy <NamenodeProtocol>(GetConf(), otherIpcAddr
                                                                , UserGroupInformation.GetLoginUser(), true).GetProxy());
 }
コード例 #6
0
        /// <summary>Initialize SecondaryNameNode.</summary>
        /// <exception cref="System.IO.IOException"/>
        private void Initialize(Configuration conf, SecondaryNameNode.CommandLineOpts commandLineOpts
                                )
        {
            IPEndPoint infoSocAddr     = GetHttpAddress(conf);
            string     infoBindAddress = infoSocAddr.GetHostName();

            UserGroupInformation.SetConfiguration(conf);
            if (UserGroupInformation.IsSecurityEnabled())
            {
                SecurityUtil.Login(conf, DFSConfigKeys.DfsSecondaryNamenodeKeytabFileKey, DFSConfigKeys
                                   .DfsSecondaryNamenodeKerberosPrincipalKey, infoBindAddress);
            }
            // initiate Java VM metrics
            DefaultMetricsSystem.Initialize("SecondaryNameNode");
            JvmMetrics.Create("SecondaryNameNode", conf.Get(DFSConfigKeys.DfsMetricsSessionIdKey
                                                            ), DefaultMetricsSystem.Instance());
            // Create connection to the namenode.
            shouldRun     = true;
            nameNodeAddr  = NameNode.GetServiceAddress(conf, true);
            this.conf     = conf;
            this.namenode = NameNodeProxies.CreateNonHAProxy <NamenodeProtocol>(conf, nameNodeAddr
                                                                                , UserGroupInformation.GetCurrentUser(), true).GetProxy();
            // initialize checkpoint directories
            fsName              = GetInfoServer();
            checkpointDirs      = FSImage.GetCheckpointDirs(conf, "/tmp/hadoop/dfs/namesecondary");
            checkpointEditsDirs = FSImage.GetCheckpointEditsDirs(conf, "/tmp/hadoop/dfs/namesecondary"
                                                                 );
            checkpointImage = new SecondaryNameNode.CheckpointStorage(conf, checkpointDirs, checkpointEditsDirs
                                                                      );
            checkpointImage.RecoverCreate(commandLineOpts.ShouldFormat());
            checkpointImage.DeleteTempEdits();
            namesystem = new FSNamesystem(conf, checkpointImage, true);
            // Disable quota checks
            namesystem.dir.DisableQuotaChecks();
            // Initialize other scheduling parameters from the configuration
            checkpointConf = new CheckpointConf(conf);
            IPEndPoint httpAddr        = infoSocAddr;
            string     httpsAddrString = conf.GetTrimmed(DFSConfigKeys.DfsNamenodeSecondaryHttpsAddressKey
                                                         , DFSConfigKeys.DfsNamenodeSecondaryHttpsAddressDefault);
            IPEndPoint httpsAddr = NetUtils.CreateSocketAddr(httpsAddrString);

            HttpServer2.Builder builder = DFSUtil.HttpServerTemplateForNNAndJN(conf, httpAddr
                                                                               , httpsAddr, "secondary", DFSConfigKeys.DfsSecondaryNamenodeKerberosInternalSpnegoPrincipalKey
                                                                               , DFSConfigKeys.DfsSecondaryNamenodeKeytabFileKey);
            nameNodeStatusBeanName = MBeans.Register("SecondaryNameNode", "SecondaryNameNodeInfo"
                                                     , this);
            infoServer = builder.Build();
            infoServer.SetAttribute("secondary.name.node", this);
            infoServer.SetAttribute("name.system.image", checkpointImage);
            infoServer.SetAttribute(JspHelper.CurrentConf, conf);
            infoServer.AddInternalServlet("imagetransfer", ImageServlet.PathSpec, typeof(ImageServlet
                                                                                         ), true);
            infoServer.Start();
            Log.Info("Web server init done");
            HttpConfig.Policy policy = DFSUtil.GetHttpPolicy(conf);
            int connIdx = 0;

            if (policy.IsHttpEnabled())
            {
                IPEndPoint httpAddress = infoServer.GetConnectorAddress(connIdx++);
                conf.Set(DFSConfigKeys.DfsNamenodeSecondaryHttpAddressKey, NetUtils.GetHostPortString
                             (httpAddress));
            }
            if (policy.IsHttpsEnabled())
            {
                IPEndPoint httpsAddress = infoServer.GetConnectorAddress(connIdx);
                conf.Set(DFSConfigKeys.DfsNamenodeSecondaryHttpsAddressKey, NetUtils.GetHostPortString
                             (httpsAddress));
            }
            legacyOivImageDir = conf.Get(DFSConfigKeys.DfsNamenodeLegacyOivImageDirKey);
            Log.Info("Checkpoint Period   :" + checkpointConf.GetPeriod() + " secs " + "(" +
                     checkpointConf.GetPeriod() / 60 + " min)");
            Log.Info("Log Size Trigger    :" + checkpointConf.GetTxnCount() + " txns");
        }