HBase1.0.0 version of the source analysis Hmaster Start Code Analysis (1)

Source: Internet
Author: User

In fact, this article is not really a start-up code parsing, this article is mainly from the start-up process analysis to the Starthmaster part, for the first time this article will be about HBase pseudo-distributed debugging methods related to the introduction.

After we pour the source into the IntelliJ IDE, we get the following code structure:

Here we go into the hbase-server and add hadoop-metrics2-hbase.properties,hbase-site.xml to the resources under Src/main, Log4j.properties and other files and the corresponding configuration, in addition to hbase-site.xml files can be copied directly from the Conf directory, my hbase-site.xml simple configuration is as follows FYI:

< property> <name>hbase.cluster.distributed</name> <value>true</value> </prop erty> <property> <name>hbase.rootdir</name> <value>hdfs://localhost:9000/hbase        </value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/opt/zookeeper/data</value> </property> <property> <name>hbase.zoo        keeper.property.clientport</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>localhost</value> </property> &    Lt;property> <name>hbase.defaults.for.version.skip</name> <value>true</value> </property> 
After the configuration is complete, you can start Hmaster and hregionserver to debug your code. The source of the configuration of the pre-commissioning work on the introduction of this.

Before we introduce the start-up process for Hmaster, let's start by looking at the dependencies between the key classes that involve process initiation, as shown in the following:


There is a main method in 1.HMaster, which is where the start of Hmaster starts, as shown below:

  public static void Main (String [] args) {    versioninfo.logversion ();    System.out.println ("####################################### #HMaster started!");    New Hmastercommandline (Hmaster.class). DoMain (args);    System.out.println ("Hmaster stoped!");  }

as you can see from the code, you need to pass in the parameters that are required for the startup, which is used as follows:

[OPTs] Start|stop|clear
Start: Start master, and if it is local mode, start Mater and Regionserver on the same JVM
STOP: Start shutdown cluster, Master sends shutdown signal to Regionserver
Clear: Delete nodes in zookeeper after master crashes
[opts]:--minregionservers=<servers> can accommodate at least regionservers number of user tables,
--localregionservers=<servers> in local mode, the number of regionsrevers started in the master process
The number of master in the--masters=<servers> process
--backup Backup mode Startup

2. Next, let's look at the work done by Hmastercommandline's domain method, as follows:

  public void DoMain (String args[]) {    try {      int ret = Toolrunner.run (Hbaseconfiguration.create (), this, args);      if (ret! = 0) {        system.exit (ret);      }    } catch (Exception e) {      log.error ("Failed to Run", e);      System.exit ( -1);    }  }
  public static int Run (Configuration conf, tool tool, string[] args)     throws exception{    if (conf = null) {      CO NF = new Configuration ();    }    Genericoptionsparser parser = new Genericoptionsparser (conf, args);    Set the configuration back, so the Tool can configure itself    tool.setconf (conf);        Get the args w/o generic Hadoop args    string[] Toolargs = Parser.getremainingargs ();    Return Tool.run (Toolargs);  }
CommandLine method calls the Toolrunner's Run method, then the method carries out some command parameter parsing and calls the Hmasercommandline implementation of the Run method, the method mainly to do some configuration and parsing parameters, and invoke different processing methods on the arguments passed in, as follows:
        String command = remainingargs.get (0);        if ("Start". Equals (command)) {            return startmaster ();        } else if ("Stop". Equals command) {            return Stopmaster ();        } else if ("clear". Equals (command)) {            return (Znodeclearer.clear (getconf ()) 0:1);        } else {            usage ("Invalid c Ommand: "+ command");            return 1;        }

so far we can see the specific master start-up call, the Startmaster startup code is more complex, and I'll cover it in the next article.


HBase1.0.0 version of the source analysis Hmaster Start Code Analysis (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.