Esempio n. 1
0
 /// <summary>Shut down this instance of the datanode.</summary>
 /// <remarks>
 /// Shut down this instance of the datanode.
 /// Returns only after shutdown is complete.
 /// </remarks>
 public virtual void Shutdown()
 {
     shouldRun = false;
     if (checkpointThread != null)
     {
         checkpointThread.Interrupt();
         try
         {
             checkpointThread.Join(10000);
         }
         catch (Exception)
         {
             Log.Info("Interrupted waiting to join on checkpointer thread");
             Sharpen.Thread.CurrentThread().Interrupt();
         }
     }
     // maintain status
     try
     {
         if (infoServer != null)
         {
             infoServer.Stop();
             infoServer = null;
         }
     }
     catch (Exception e)
     {
         Log.Warn("Exception shutting down SecondaryNameNode", e);
     }
     if (nameNodeStatusBeanName != null)
     {
         MBeans.Unregister(nameNodeStatusBeanName);
         nameNodeStatusBeanName = null;
     }
     try
     {
         if (checkpointImage != null)
         {
             checkpointImage.Close();
             checkpointImage = null;
         }
     }
     catch (IOException e)
     {
         Log.Warn("Exception while closing CheckpointStorage", e);
     }
     if (namesystem != null)
     {
         namesystem.Shutdown();
         namesystem = null;
     }
 }
Esempio n. 2
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");
        }
Esempio n. 3
0
 internal virtual void SetFSImage(SecondaryNameNode.CheckpointStorage image)
 {
     this.checkpointImage = image;
 }