hbase1.1.3 启动一

原创 2016年06月01日 19:18:22

1. HMaster中有个main方法,这是HMaster启动的开始的地方

  /**
   * @see org.apache.hadoop.hbase.master.HMasterCommandLine
   */
  public static void main(String [] args) {
    VersionInfo.logVersion();
    new HMasterCommandLine(HMaster.class).doMain(args);
  }
  
2. 接下来我们来看看HMasterCommandLine的doMain方法所进行的工作

  /**
   * Parse and run the given command line. This may exit the JVM if
   * a nonzero exit code is returned from <code>run()</code>.
   */
  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) {
      conf = new Configuration();
    }
    GenericOptionsParser parser = new GenericOptionsParser(conf, args);
    //set the configuration back, so that Tool can configure itself
    tool.setConf(conf);
    
    //get the args w/o generic hadoop args
    String[] toolArgs = parser.getRemainingArgs();
    return tool.run(toolArgs);
  }

上面run方法的tool参数为HMasterCommandLine实例,调用了HMasterCommandLine的run来启动hbase.
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 command: " + command);
    return 1;
}

--具体启动的函数HMasterCommandLine.startMaster
  private int startMaster() {
    Configuration conf = getConf();
    try {
      // If 'local', defer to LocalHBaseCluster instance.  Starts master
      // and regionserver both in the one JVM.
      if (LocalHBaseCluster.isLocal(conf)) {
        DefaultMetricsSystem.setMiniClusterMode(true);
        final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
        File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));


        // find out the default client port
        int zkClientPort = 0;


        // If the zookeeper client port is specified in server quorum, use it.
        String zkserver = conf.get(HConstants.ZOOKEEPER_QUORUM);
        if (zkserver != null) {
          String[] zkservers = zkserver.split(",");


          if (zkservers.length > 1) {
            // In local mode deployment, we have the master + a region server and zookeeper server
            // started in the same process. Therefore, we only support one zookeeper server.
            String errorMsg = "Could not start ZK with " + zkservers.length +
                " ZK servers in local mode deployment. Aborting as clients (e.g. shell) will not "
                + "be able to find this ZK quorum.";
              System.err.println(errorMsg);
              throw new IOException(errorMsg);
          }


          String[] parts = zkservers[0].split(":");


          if (parts.length == 2) {
            // the second part is the client port
            zkClientPort = Integer.parseInt(parts [1]);
          }
        }
        // If the client port could not be find in server quorum conf, try another conf
        if (zkClientPort == 0) {
          zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
          // The client port has to be set by now; if not, throw exception.
          if (zkClientPort == 0) {
            throw new IOException("No config value for " + HConstants.ZOOKEEPER_CLIENT_PORT);
          }
        }
        zooKeeperCluster.setDefaultClientPort(zkClientPort);
        // set the ZK tick time if specified
        int zkTickTime = conf.getInt(HConstants.ZOOKEEPER_TICK_TIME, 0);
        if (zkTickTime > 0) {
          zooKeeperCluster.setTickTime(zkTickTime);
        }


        // login the zookeeper server principal (if using security)
        ZKUtil.loginServer(conf, HConstants.ZK_SERVER_KEYTAB_FILE,
          HConstants.ZK_SERVER_KERBEROS_PRINCIPAL, null);
        int localZKClusterSessionTimeout =
          conf.getInt(HConstants.ZK_SESSION_TIMEOUT + ".localHBaseCluster", 10*1000);
        conf.setInt(HConstants.ZK_SESSION_TIMEOUT, localZKClusterSessionTimeout);
        LOG.info("Starting a zookeeper cluster");
        int clientPort = zooKeeperCluster.startup(zkDataPath);
        if (clientPort != zkClientPort) {
          String errorMsg = "Could not start ZK at requested port of " +
            zkClientPort + ".  ZK was started at port: " + clientPort +
            ".  Aborting as clients (e.g. shell) will not be able to find " +
            "this ZK quorum.";
          System.err.println(errorMsg);
          throw new IOException(errorMsg);
        }
        conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));


        // Need to have the zk cluster shutdown when master is shutdown.
        // Run a subclass that does the zk cluster shutdown on its way out.
        int mastersCount = conf.getInt("hbase.masters", 1);
        int regionServersCount = conf.getInt("hbase.regionservers", 1);
        LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount +
          ", regionserversCount=" + regionServersCount);
        LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount,
          LocalHMaster.class, HRegionServer.class);
        ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
        cluster.startup();
        waitOnMasterThreads(cluster);
      } else {
        logProcessInfo(getConf());
        CoordinatedStateManager csm =
          CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
        HMaster master = HMaster.constructMaster(masterClass, conf, csm);
        if (master.isStopped()) {
          LOG.info("Won't bring the Master up as a shutdown is requested");
          return 1;
        }
        master.start();
        master.join();
        if(master.isAborted())
          throw new RuntimeException("HMaster Aborted");
      }
    } catch (Throwable t) {
      LOG.error("Master exiting", t);
      return 1;
    }
    return 0;
  }





  
  
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Ubuntu14.0.4下Hbase1.1.3伪分布模式部署

Hbase运行伪分布模式或完全分布模式需要依赖底层的分布式文件系统,如Hadoop、S3等,本文采用Hadoop分布式文件系统作为Hbase的底层文件系统。因为Hbase本身不支持备件的分布式存储、冗...

Eclipse的Hbase1.1.3开发环境搭建

Hbase是用Java开发的,Hbase提供的API当然也是,Hbase并没有指定特定的语言(例如Oracle的SQL语言),Hbase都是通过API来实现Hbase应用的。由于这种方便性,通过Jav...

Ubuntu14.0.4下Hbase1.1.3单机模式部署

学习Hbase1.1.3的初级教程,在ubuntu14.0.4下,搭建Hbase1.1.3的单机模式。

hbase1.1.3+snappy 安装

hbase安装以及snappy压缩算法的配置安装

hbase介绍,运行,启动等

  • 2012-04-06 15:08
  • 1.80MB
  • 下载

Marlin-1.1.3固件Configuration.h文件解析

/**  * Configuration.h  *  * 基本设置如:  *  * - 电子元器件类型   * - 温度传感器类型   * - 打印机尺寸  * - 限位开关配置 &...

[USACO 1.1.3] Friday the Thirteenth

[题目描述] Friday the Thirteenth 黑色星期五 13号又是星期五是一个不寻常的日子吗?13号在星期五比在其他日少吗?为了回答这个问题,写一个程序来计算在n年里13日落在...

数据结构笔记--1.1.3关于算法效率 计算多项式值

秦九韶算法 f(x)=a[n]x^n+a[n-1]x^(n-1)+…+a[1]x+a[0] f(x)=(…((a[n]x+a[n-1])x+a[n-2])x+…+a[1])x+a[0].   cloc...

OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五

题目要求: 输入代码: #include #include #include using namespace std; int month[13]= {0,31,28,31,30,...

JAVA(学习笔记1.1.3)——API与DULL文件

API(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)