zoukankan      html  css  js  c++  java
  • Hbase0.96源码之HMaster(三)Hmaster主要循环

    1。Master初始化

    1.1

     if (!this.stopped) {
        finishInitialization(startupStatus, false);
        loop();
      }
    

    1.2 finishInitialization()。这里主要完毕master组件components:filesystem manager,servermanager,assignmentmanager,regionservertracker, catalogtracker等
    1.2.1 设置为active master

    isActiveMaster = true;
    

    1.2.2 生成MasterFileSystem(fileSystemManager),管理一些文件系统的操作,包括deleteregion,deletetable,modifyColumn,addColumn,deleteFamilyFromFS以及splitlog,splitMetaLog等
    1.2.2.1 check rootdir以及temp文件夹都存在。且清除temp文件夹

     this.oldLogDir = createInitialFileSystemLayout();
    

    1.2.2.1.1clean tempdir

    // check if the root directory exists
    checkRootDir(this.rootdir, conf, this.fs);
    
    // check if temp directory exists and clean it
    checkTempDir(this.tempdir, conf, this.fs);
    

    1.2.2.1.2在checkRootDir()中检測meta的

        // Make sure the meta region directory exists!
        if (!FSUtils.metaRegionExists(fs, rd)) {
          bootstrap(rd, c);
        } else {
          // Migrate table descriptor files if necessary
          org.apache.hadoop.hbase.util.FSTableDescriptorMigrationToSubdir
            .migrateFSTableDescriptorsIfNecessary(fs, rd);
        }
    

    1.2.2.1.2.1 假设meta数据文件夹不存在。创建meta?

    private static void bootstrap(final Path rd, final Configuration c)
      throws IOException {
        LOG.info("BOOTSTRAP: creating hbase:meta region");
        try {
          // Bootstrapping, make sure blockcache is off.  Else, one will be
          // created here in bootstrap and it'll need to be cleaned up.  Better to
          // not make it in first place.  Turn off block caching for bootstrap.
          // Enable after.
          HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
          setInfoFamilyCachingForMeta(false);
          HRegion meta = HRegion.createHRegion(metaHRI, rd, c,
              HTableDescriptor.META_TABLEDESC);
          setInfoFamilyCachingForMeta(true);
          HRegion.closeHRegion(meta);
        } catch (IOException e) {
          e = RemoteExceptionHandler.checkIOException(e);
          LOG.error("bootstrap", e);
          throw e;
        }
      }
    

    1.2.2.2 splitLogManager的创建

    this.splitLogManager = new SplitLogManager(master.getZooKeeper(),
          master.getConfiguration(), master, services,
          master.getServerName(), masterRecovery);
    

    1.2.3 创建executorService与serverManager,当中executorService维护一个ExecutorMap,EventType与Executor。提交不正确应的EventHandler来异步处理事件;serverManager管理regionserver

    if (!masterRecovery) {
      this.executorService = new ExecutorService(getServerName().toShortString());
      this.serverManager = createServerManager(this, this);
    }
    

    1.2.4 initializeZKBasedSystemTrackers
    1.2.4.1 create CatalogTracker 监听-ROOT-和.META.的Server地址信息变化以及事件处理
    1.2.4.2 LoadBalancerTracker
    1.2.4.3 AssignmentManager管理和分配region,监听zk上关于region的event,依据event来完毕region的上下线
    1.2.4.4 RegionServerTracker watch zk中中regionSerrver的变化及事件处理。下线
    1.2.4.5 DrainingServerTracker
    1.2.4.6 SnapshotManager Snapshot快照管理祥光

      void initializeZKBasedSystemTrackers() throws IOException,
          InterruptedException, KeeperException {
        this.catalogTracker = createCatalogTracker(this.zooKeeper, this.conf, this);
        this.catalogTracker.start();
    
        this.balancer = LoadBalancerFactory.getLoadBalancer(conf);
        this.loadBalancerTracker = new LoadBalancerTracker(zooKeeper, this);
        this.loadBalancerTracker.start();
        this.assignmentManager = new AssignmentManager(this, serverManager,
          this.catalogTracker, this.balancer, this.executorService, this.metricsMaster,
          this.tableLockManager);
        zooKeeper.registerListenerFirst(assignmentManager);
    
        this.regionServerTracker = new RegionServerTracker(zooKeeper, this,
            this.serverManager);
        this.regionServerTracker.start();
    
        this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this,
          this.serverManager);
        this.drainingServerTracker.start();
    
        // Set the cluster as up.  If new RSs, they'll be waiting on this before
        // going ahead with their startup.
        boolean wasUp = this.clusterStatusTracker.isClusterUp();
        if (!wasUp) this.clusterStatusTracker.setClusterUp();
    
        LOG.info("Server active/primary master=" + this.serverName +
            ", sessionid=0x" +
            Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()) +
            ", setting cluster-up flag (Was=" + wasUp + ")");
    
        // create the snapshot manager
        this.snapshotManager = new SnapshotManager(this, this.metricsMaster);
      }
查看全文
  • 相关阅读:
    web服务器-Apache
    nginx优化
    nginx下载限速
    nginx-URL重写
    HDU 5358 First One 求和(序列求和,优化)
    HDU 5360 Hiking 登山 (优先队列,排序)
    HDU 5353 Average 糖果分配(模拟,图)
    UVALive 4128 Steam Roller 蒸汽式压路机(最短路,变形) WA中。。。。。
    HDU 5348 MZL's endless loop 给边定向(欧拉回路,最大流)
    HDU 5344 MZL's xor (水题)
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10954118.html
  • Copyright © 2011-2022 走看看