Search in sources :

Example 1 with MetaLocationSyncer

use of org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer in project hbase by apache.

the class HMaster method initializeZKBasedSystemTrackers.

/**
 * Initialize all ZK based system trackers. But do not include {@link RegionServerTracker}, it
 * should have already been initialized along with {@link ServerManager}.
 */
private void initializeZKBasedSystemTrackers() throws IOException, KeeperException, ReplicationException {
    if (maintenanceMode) {
        // in maintenance mode, always use MaintenanceLoadBalancer.
        conf.unset(LoadBalancer.HBASE_RSGROUP_LOADBALANCER_CLASS);
        conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, MaintenanceLoadBalancer.class, LoadBalancer.class);
    }
    this.balancer = new RSGroupBasedLoadBalancer();
    this.loadBalancerTracker = new LoadBalancerTracker(zooKeeper, this);
    this.loadBalancerTracker.start();
    this.regionNormalizerManager = RegionNormalizerFactory.createNormalizerManager(conf, zooKeeper, this);
    this.configurationManager.registerObserver(regionNormalizerManager);
    this.regionNormalizerManager.start();
    this.splitOrMergeTracker = new SplitOrMergeTracker(zooKeeper, conf, this);
    this.splitOrMergeTracker.start();
    // This is for backwards compatible. We do not need the CP for rs group now but if user want to
    // load it, we need to enable rs group.
    String[] cpClasses = conf.getStrings(MasterCoprocessorHost.MASTER_COPROCESSOR_CONF_KEY);
    if (cpClasses != null) {
        for (String cpClass : cpClasses) {
            if (RSGroupAdminEndpoint.class.getName().equals(cpClass)) {
                RSGroupUtil.enableRSGroup(conf);
                break;
            }
        }
    }
    this.rsGroupInfoManager = RSGroupInfoManager.create(this);
    this.replicationPeerManager = ReplicationPeerManager.create(zooKeeper, conf, clusterId);
    this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this, this.serverManager);
    this.drainingServerTracker.start();
    this.snapshotCleanupTracker = new SnapshotCleanupTracker(zooKeeper, this);
    this.snapshotCleanupTracker.start();
    String clientQuorumServers = conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM);
    boolean clientZkObserverMode = conf.getBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE, HConstants.DEFAULT_CLIENT_ZOOKEEPER_OBSERVER_MODE);
    if (clientQuorumServers != null && !clientZkObserverMode) {
        // we need to take care of the ZK information synchronization
        // if given client ZK are not observer nodes
        ZKWatcher clientZkWatcher = new ZKWatcher(conf, getProcessName() + ":" + rpcServices.getSocketAddress().getPort() + "-clientZK", this, false, true);
        this.metaLocationSyncer = new MetaLocationSyncer(zooKeeper, clientZkWatcher, this);
        this.metaLocationSyncer.start();
        this.masterAddressSyncer = new MasterAddressSyncer(zooKeeper, clientZkWatcher, this);
        this.masterAddressSyncer.start();
        // set cluster id is a one-go effort
        ZKClusterId.setClusterId(clientZkWatcher, fileSystemManager.getClusterId());
    }
    // 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("Active/primary master=" + this.serverName + ", sessionid=0x" + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()) + ", setting cluster-up flag (Was=" + wasUp + ")");
    // create/initialize the snapshot manager and other procedure managers
    this.snapshotManager = new SnapshotManager();
    this.mpmHost = new MasterProcedureManagerHost();
    this.mpmHost.register(this.snapshotManager);
    this.mpmHost.register(new MasterFlushTableProcedureManager());
    this.mpmHost.loadProcedures(conf);
    this.mpmHost.initialize(this, this.metricsMaster);
}
Also used : MasterFlushTableProcedureManager(org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager) MasterProcedureManagerHost(org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint) MetaLocationSyncer(org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer) SnapshotCleanupTracker(org.apache.hadoop.hbase.zookeeper.SnapshotCleanupTracker) LoadBalancerTracker(org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) RSGroupBasedLoadBalancer(org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer) MasterAddressSyncer(org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager)

Example 2 with MetaLocationSyncer

use of org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer in project hbase by apache.

the class ModifyTableProcedure method executeFromState.

@Override
protected Flow executeFromState(final MasterProcedureEnv env, final ModifyTableState state) throws InterruptedException {
    LOG.trace("{} execute state={}", this, state);
    try {
        switch(state) {
            case MODIFY_TABLE_PREPARE:
                prepareModify(env);
                setNextState(ModifyTableState.MODIFY_TABLE_PRE_OPERATION);
                break;
            case MODIFY_TABLE_PRE_OPERATION:
                preModify(env, state);
                setNextState(ModifyTableState.MODIFY_TABLE_CLOSE_EXCESS_REPLICAS);
                break;
            case MODIFY_TABLE_CLOSE_EXCESS_REPLICAS:
                if (isTableEnabled(env)) {
                    closeExcessReplicasIfNeeded(env);
                }
                setNextState(ModifyTableState.MODIFY_TABLE_UPDATE_TABLE_DESCRIPTOR);
                break;
            case MODIFY_TABLE_UPDATE_TABLE_DESCRIPTOR:
                updateTableDescriptor(env);
                setNextState(ModifyTableState.MODIFY_TABLE_REMOVE_REPLICA_COLUMN);
                break;
            case MODIFY_TABLE_REMOVE_REPLICA_COLUMN:
                removeReplicaColumnsIfNeeded(env);
                setNextState(ModifyTableState.MODIFY_TABLE_POST_OPERATION);
                break;
            case MODIFY_TABLE_POST_OPERATION:
                postModify(env, state);
                setNextState(ModifyTableState.MODIFY_TABLE_REOPEN_ALL_REGIONS);
                break;
            case MODIFY_TABLE_REOPEN_ALL_REGIONS:
                if (isTableEnabled(env)) {
                    addChildProcedure(new ReopenTableRegionsProcedure(getTableName()));
                }
                setNextState(ModifyTableState.MODIFY_TABLE_ASSIGN_NEW_REPLICAS);
                break;
            case MODIFY_TABLE_ASSIGN_NEW_REPLICAS:
                assignNewReplicasIfNeeded(env);
                if (TableName.isMetaTableName(getTableName())) {
                    MetaLocationSyncer syncer = env.getMasterServices().getMetaLocationSyncer();
                    if (syncer != null) {
                        syncer.setMetaReplicaCount(modifiedTableDescriptor.getRegionReplication());
                    }
                }
                if (deleteColumnFamilyInModify) {
                    setNextState(ModifyTableState.MODIFY_TABLE_DELETE_FS_LAYOUT);
                } else {
                    return Flow.NO_MORE_STATE;
                }
                break;
            case MODIFY_TABLE_DELETE_FS_LAYOUT:
                deleteFromFs(env, unmodifiedTableDescriptor, modifiedTableDescriptor);
                return Flow.NO_MORE_STATE;
            default:
                throw new UnsupportedOperationException("unhandled state=" + state);
        }
    } catch (IOException e) {
        if (isRollbackSupported(state)) {
            setFailure("master-modify-table", e);
        } else {
            LOG.warn("Retriable error trying to modify table={} (in state={})", getTableName(), state, e);
        }
    }
    return Flow.HAS_MORE_STATE;
}
Also used : MetaLocationSyncer(org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException)

Aggregations

MetaLocationSyncer (org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer)2 IOException (java.io.IOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 SnapshotManager (org.apache.hadoop.hbase.master.snapshot.SnapshotManager)1 MasterAddressSyncer (org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer)1 MasterProcedureManagerHost (org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost)1 MasterFlushTableProcedureManager (org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager)1 RSGroupAdminEndpoint (org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)1 RSGroupBasedLoadBalancer (org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer)1 LoadBalancerTracker (org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker)1 SnapshotCleanupTracker (org.apache.hadoop.hbase.zookeeper.SnapshotCleanupTracker)1 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)1