Search in sources :

Example 56 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class HMaster method balance.

public BalanceResponse balance(BalanceRequest request) throws IOException {
    checkInitialized();
    BalanceResponse.Builder responseBuilder = BalanceResponse.newBuilder();
    if (loadBalancerTracker == null || !(loadBalancerTracker.isBalancerOn() || request.isDryRun())) {
        return responseBuilder.build();
    }
    if (skipRegionManagementAction("balancer")) {
        return responseBuilder.build();
    }
    synchronized (this.balancer) {
        // Only allow one balance run at at time.
        if (this.assignmentManager.hasRegionsInTransition()) {
            List<RegionStateNode> regionsInTransition = assignmentManager.getRegionsInTransition();
            // if hbase:meta region is in transition, result of assignment cannot be recorded
            // ignore the force flag in that case
            boolean metaInTransition = assignmentManager.isMetaRegionInTransition();
            List<RegionStateNode> toPrint = regionsInTransition;
            int max = 5;
            boolean truncated = false;
            if (regionsInTransition.size() > max) {
                toPrint = regionsInTransition.subList(0, max);
                truncated = true;
            }
            if (!request.isIgnoreRegionsInTransition() || metaInTransition) {
                LOG.info("Not running balancer (ignoreRIT=false" + ", metaRIT=" + metaInTransition + ") because " + regionsInTransition.size() + " region(s) in transition: " + toPrint + (truncated ? "(truncated list)" : ""));
                return responseBuilder.build();
            }
        }
        if (this.serverManager.areDeadServersInProgress()) {
            LOG.info("Not running balancer because processing dead regionserver(s): " + this.serverManager.getDeadServers());
            return responseBuilder.build();
        }
        if (this.cpHost != null) {
            try {
                if (this.cpHost.preBalance(request)) {
                    LOG.debug("Coprocessor bypassing balancer request");
                    return responseBuilder.build();
                }
            } catch (IOException ioe) {
                LOG.error("Error invoking master coprocessor preBalance()", ioe);
                return responseBuilder.build();
            }
        }
        Map<TableName, Map<ServerName, List<RegionInfo>>> assignments = this.assignmentManager.getRegionStates().getAssignmentsForBalancer(tableStateManager, this.serverManager.getOnlineServersList());
        for (Map<ServerName, List<RegionInfo>> serverMap : assignments.values()) {
            serverMap.keySet().removeAll(this.serverManager.getDrainingServersList());
        }
        // Give the balancer the current cluster state.
        this.balancer.updateClusterMetrics(getClusterMetricsWithoutCoprocessor());
        List<RegionPlan> plans = this.balancer.balanceCluster(assignments);
        responseBuilder.setBalancerRan(true).setMovesCalculated(plans == null ? 0 : plans.size());
        if (skipRegionManagementAction("balancer")) {
            // make one last check that the cluster isn't shutting down before proceeding.
            return responseBuilder.build();
        }
        // For dry run we don't actually want to execute the moves, but we do want
        // to execute the coprocessor below
        List<RegionPlan> sucRPs = request.isDryRun() ? Collections.emptyList() : executeRegionPlansWithThrottling(plans);
        if (this.cpHost != null) {
            try {
                this.cpHost.postBalance(request, sucRPs);
            } catch (IOException ioe) {
                // balancing already succeeded so don't change the result
                LOG.error("Error invoking master coprocessor postBalance()", ioe);
            }
        }
        responseBuilder.setMovesExecuted(sucRPs.size());
    }
    // Return true indicating a success.
    return responseBuilder.build();
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) InterruptedIOException(java.io.InterruptedIOException) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint) RegionStateNode(org.apache.hadoop.hbase.master.assignment.RegionStateNode) TableName(org.apache.hadoop.hbase.TableName) BalanceResponse(org.apache.hadoop.hbase.client.BalanceResponse) ServerName(org.apache.hadoop.hbase.ServerName) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap)

Example 57 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class HMaster method isRegionOnline.

/**
 * @return True if region is online and scannable else false if an error or shutdown (Otherwise
 *   we just block in here holding up all forward-progess).
 */
private boolean isRegionOnline(RegionInfo ri) {
    RetryCounter rc = null;
    while (!isStopped()) {
        RegionState rs = this.assignmentManager.getRegionStates().getRegionState(ri);
        if (rs.isOpened()) {
            if (this.getServerManager().isServerOnline(rs.getServerName())) {
                return true;
            }
        }
        // Region is not OPEN.
        Optional<Procedure<MasterProcedureEnv>> optProc = this.procedureExecutor.getProcedures().stream().filter(p -> p instanceof ServerCrashProcedure).findAny();
        // TODO: Add a page to refguide on how to do repair. Have this log message point to it.
        // Page will talk about loss of edits, how to schedule at least the meta WAL recovery, and
        // then how to assign including how to break region lock if one held.
        LOG.warn("{} is NOT online; state={}; ServerCrashProcedures={}. Master startup cannot " + "progress, in holding-pattern until region onlined.", ri.getRegionNameAsString(), rs, optProc.isPresent());
        // Check once-a-minute.
        if (rc == null) {
            rc = new RetryCounterFactory(Integer.MAX_VALUE, 1000, 60_000).create();
        }
        Threads.sleep(rc.getBackoffTimeAndIncrementAttempts());
    }
    return false;
}
Also used : DisablePeerProcedure(org.apache.hadoop.hbase.master.replication.DisablePeerProcedure) LockManager(org.apache.hadoop.hbase.master.locking.LockManager) UserProvider(org.apache.hadoop.hbase.security.UserProvider) Server(org.apache.hbase.thirdparty.org.eclipse.jetty.server.Server) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) ClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics) StringUtils(org.apache.commons.lang3.StringUtils) RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) EnableTableProcedure(org.apache.hadoop.hbase.master.procedure.EnableTableProcedure) AddPeerProcedure(org.apache.hadoop.hbase.master.replication.AddPeerProcedure) TableDescriptorChecker(org.apache.hadoop.hbase.util.TableDescriptorChecker) Future(java.util.concurrent.Future) ProcedureExecutor(org.apache.hadoop.hbase.procedure2.ProcedureExecutor) NamedQueueRecorder(org.apache.hadoop.hbase.namequeues.NamedQueueRecorder) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) MobFileCleanerChore(org.apache.hadoop.hbase.mob.MobFileCleanerChore) ZNodePaths(org.apache.hadoop.hbase.zookeeper.ZNodePaths) ModifyTableProcedure(org.apache.hadoop.hbase.master.procedure.ModifyTableProcedure) Closeables(org.apache.hbase.thirdparty.com.google.common.io.Closeables) EnumSet(java.util.EnumSet) MetaTableLocator(org.apache.hadoop.hbase.zookeeper.MetaTableLocator) Pair(org.apache.hadoop.hbase.util.Pair) MasterRegionFactory(org.apache.hadoop.hbase.master.region.MasterRegionFactory) CommonFSUtils(org.apache.hadoop.hbase.util.CommonFSUtils) CellBuilderType(org.apache.hadoop.hbase.CellBuilderType) WebAppContext(org.apache.hbase.thirdparty.org.eclipse.jetty.webapp.WebAppContext) ModifyColumnFamilyStoreFileTrackerProcedure(org.apache.hadoop.hbase.regionserver.storefiletracker.ModifyColumnFamilyStoreFileTrackerProcedure) ModifyTableStoreFileTrackerProcedure(org.apache.hadoop.hbase.regionserver.storefiletracker.ModifyTableStoreFileTrackerProcedure) AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) ExecutorType(org.apache.hadoop.hbase.executor.ExecutorType) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription) BaseLoadBalancer(org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer) RSGroupBasedLoadBalancer(org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer) ReplicationLoadSource(org.apache.hadoop.hbase.replication.ReplicationLoadSource) HBASE_SPLIT_WAL_COORDINATED_BY_ZK(org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK) Descriptors(org.apache.hbase.thirdparty.com.google.protobuf.Descriptors) Constructor(java.lang.reflect.Constructor) ProcedureStoreListener(org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureStoreListener) ReopenTableRegionsProcedure(org.apache.hadoop.hbase.master.procedure.ReopenTableRegionsProcedure) TaskMonitor(org.apache.hadoop.hbase.monitoring.TaskMonitor) ServerTask(org.apache.hadoop.hbase.ServerTask) Option(org.apache.hadoop.hbase.ClusterMetrics.Option) TableName(org.apache.hadoop.hbase.TableName) ServletHolder(org.apache.hbase.thirdparty.org.eclipse.jetty.servlet.ServletHolder) LoadBalancerTracker(org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker) Service(org.apache.hbase.thirdparty.com.google.protobuf.Service) Sets(org.apache.hbase.thirdparty.com.google.common.collect.Sets) IOException(java.io.IOException) ServerConnector(org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector) SlowLogMasterService(org.apache.hadoop.hbase.master.slowlog.SlowLogMasterService) MasterAddressSyncer(org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer) UnknownHostException(java.net.UnknownHostException) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) ExecutionException(java.util.concurrent.ExecutionException) RSGroupInfoManager(org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) RemoteProcedureException(org.apache.hadoop.hbase.procedure2.RemoteProcedureException) RegionStateStore(org.apache.hadoop.hbase.master.assignment.RegionStateStore) NoSuchColumnFamilyException(org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException) MonitoredTask(org.apache.hadoop.hbase.monitoring.MonitoredTask) SpaceQuotaSnapshotNotifier(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotNotifier) CoprocessorHost(org.apache.hadoop.hbase.coprocessor.CoprocessorHost) MasterStatusServlet(org.apache.hadoop.hbase.master.http.MasterStatusServlet) TruncateTableProcedure(org.apache.hadoop.hbase.master.procedure.TruncateTableProcedure) MASTER_HOSTNAME_KEY(org.apache.hadoop.hbase.util.DNS.MASTER_HOSTNAME_KEY) EnablePeerProcedure(org.apache.hadoop.hbase.master.replication.EnablePeerProcedure) MasterProcedureManagerHost(org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) CellBuilderFactory(org.apache.hadoop.hbase.CellBuilderFactory) MergeTableRegionsProcedure(org.apache.hadoop.hbase.master.assignment.MergeTableRegionsProcedure) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Maps(org.apache.hbase.thirdparty.com.google.common.collect.Maps) CatalogJanitor(org.apache.hadoop.hbase.master.janitor.CatalogJanitor) ReplicationPeerManager(org.apache.hadoop.hbase.master.replication.ReplicationPeerManager) Collection(java.util.Collection) HBaseInterfaceAudience(org.apache.hadoop.hbase.HBaseInterfaceAudience) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) Collectors(java.util.stream.Collectors) SnapshotQuotaObserverChore(org.apache.hadoop.hbase.quotas.SnapshotQuotaObserverChore) Objects(java.util.Objects) FutureUtils(org.apache.hadoop.hbase.util.FutureUtils) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) MasterAddressTracker(org.apache.hadoop.hbase.zookeeper.MasterAddressTracker) LogCleaner(org.apache.hadoop.hbase.master.cleaner.LogCleaner) RollingUpgradeChore(org.apache.hadoop.hbase.master.migrate.RollingUpgradeChore) MasterStoppedException(org.apache.hadoop.hbase.exceptions.MasterStoppedException) HConstants(org.apache.hadoop.hbase.HConstants) QuotaTableUtil(org.apache.hadoop.hbase.quotas.QuotaTableUtil) HBASE_MASTER_LOGCLEANER_PLUGINS(org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS) QuotaUtil(org.apache.hadoop.hbase.quotas.QuotaUtil) TransitPeerSyncReplicationStateProcedure(org.apache.hadoop.hbase.master.replication.TransitPeerSyncReplicationStateProcedure) LinkedList(java.util.LinkedList) RemovePeerProcedure(org.apache.hadoop.hbase.master.replication.RemovePeerProcedure) DeleteNamespaceProcedure(org.apache.hadoop.hbase.master.procedure.DeleteNamespaceProcedure) Threads(org.apache.hadoop.hbase.util.Threads) BalanceSwitchMode(org.apache.hadoop.hbase.master.MasterRpcServices.BalanceSwitchMode) MasterQuotaManager(org.apache.hadoop.hbase.quotas.MasterQuotaManager) Bytes(org.apache.hadoop.hbase.util.Bytes) RegionStates(org.apache.hadoop.hbase.master.assignment.RegionStates) Logger(org.slf4j.Logger) KeeperException(org.apache.zookeeper.KeeperException) DeleteTableProcedure(org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure) BalanceRequest(org.apache.hadoop.hbase.client.BalanceRequest) MasterSwitchType(org.apache.hadoop.hbase.client.MasterSwitchType) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) ProcedureSyncWait(org.apache.hadoop.hbase.master.procedure.ProcedureSyncWait) MaintenanceLoadBalancer(org.apache.hadoop.hbase.master.balancer.MaintenanceLoadBalancer) Lists(org.apache.hbase.thirdparty.com.google.common.collect.Lists) RequestConverter(org.apache.hadoop.hbase.shaded.protobuf.RequestConverter) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) ZKClusterId(org.apache.hadoop.hbase.zookeeper.ZKClusterId) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) HBaseServerBase(org.apache.hadoop.hbase.HBaseServerBase) ServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure) Comparator(java.util.Comparator) MasterDumpServlet(org.apache.hadoop.hbase.master.http.MasterDumpServlet) Arrays(java.util.Arrays) NormalizeTableFilterParams(org.apache.hadoop.hbase.client.NormalizeTableFilterParams) UpdatePeerConfigProcedure(org.apache.hadoop.hbase.master.replication.UpdatePeerConfigProcedure) ProcedureStore(org.apache.hadoop.hbase.procedure2.store.ProcedureStore) InetAddress(java.net.InetAddress) InvalidFamilyOperationException(org.apache.hadoop.hbase.InvalidFamilyOperationException) SpaceViolationPolicy(org.apache.hadoop.hbase.quotas.SpaceViolationPolicy) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler) SecurityConstants(org.apache.hadoop.hbase.security.SecurityConstants) RegionNormalizerManager(org.apache.hadoop.hbase.master.normalizer.RegionNormalizerManager) MasterProcedureConstants(org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants) Cell(org.apache.hadoop.hbase.Cell) SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) HttpServlet(javax.servlet.http.HttpServlet) ZKUtil(org.apache.hadoop.hbase.zookeeper.ZKUtil) SnapshotCleanupTracker(org.apache.hadoop.hbase.zookeeper.SnapshotCleanupTracker) Set(java.util.Set) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) ReplicationHFileCleaner(org.apache.hadoop.hbase.replication.master.ReplicationHFileCleaner) FSTableDescriptors(org.apache.hadoop.hbase.util.FSTableDescriptors) InvocationTargetException(java.lang.reflect.InvocationTargetException) IdLock(org.apache.hadoop.hbase.util.IdLock) ClusterMetricsBuilder(org.apache.hadoop.hbase.ClusterMetricsBuilder) NonceProcedureRunnable(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable) ClusterId(org.apache.hadoop.hbase.ClusterId) Superusers(org.apache.hadoop.hbase.security.Superusers) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) ServerTaskBuilder(org.apache.hadoop.hbase.ServerTaskBuilder) DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK(org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK) AbstractPeerProcedure(org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure) ServerMetrics(org.apache.hadoop.hbase.ServerMetrics) InterruptedIOException(java.io.InterruptedIOException) RegionStateNode(org.apache.hadoop.hbase.master.assignment.RegionStateNode) ArrayList(java.util.ArrayList) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) MasterProcedureUtil(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil) HFileArchiveUtil(org.apache.hadoop.hbase.util.HFileArchiveUtil) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) SnapshotManager(org.apache.hadoop.hbase.master.snapshot.SnapshotManager) InfoServer(org.apache.hadoop.hbase.http.InfoServer) JVMClusterUtil(org.apache.hadoop.hbase.util.JVMClusterUtil) ServerName(org.apache.hadoop.hbase.ServerName) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) RegionStatesCount(org.apache.hadoop.hbase.client.RegionStatesCount) Scan(org.apache.hadoop.hbase.client.Scan) HBaseFsck(org.apache.hadoop.hbase.util.HBaseFsck) HttpServer(org.apache.hadoop.hbase.http.HttpServer) BalanceResponse(org.apache.hadoop.hbase.client.BalanceResponse) MasterFlushTableProcedureManager(org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager) SpaceQuotaStatus(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot.SpaceQuotaStatus) CatalogFamilyFormat(org.apache.hadoop.hbase.CatalogFamilyFormat) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) RegionNormalizerTracker(org.apache.hadoop.hbase.zookeeper.RegionNormalizerTracker) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) MasterRedirectServlet(org.apache.hadoop.hbase.master.http.MasterRedirectServlet) HFileCleaner(org.apache.hadoop.hbase.master.cleaner.HFileCleaner) ClusterStatusChore(org.apache.hadoop.hbase.master.balancer.ClusterStatusChore) ReplicationPeerNotFoundException(org.apache.hadoop.hbase.ReplicationPeerNotFoundException) DirScanPool(org.apache.hadoop.hbase.master.cleaner.DirScanPool) RemoteProcedure(org.apache.hadoop.hbase.procedure2.RemoteProcedureDispatcher.RemoteProcedure) MetaLocationSyncer(org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer) ReplicationBarrierCleaner(org.apache.hadoop.hbase.master.cleaner.ReplicationBarrierCleaner) RegionProcedureStore(org.apache.hadoop.hbase.procedure2.store.region.RegionProcedureStore) SyncReplicationReplayWALManager(org.apache.hadoop.hbase.master.replication.SyncReplicationReplayWALManager) Path(org.apache.hadoop.fs.Path) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) CoprocessorRpcUtils(org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils) RestrictedApi(com.google.errorprone.annotations.RestrictedApi) MasterQuotasObserver(org.apache.hadoop.hbase.quotas.MasterQuotasObserver) QuotaObserverChore(org.apache.hadoop.hbase.quotas.QuotaObserverChore) InetSocketAddress(java.net.InetSocketAddress) List(java.util.List) CompactionState(org.apache.hadoop.hbase.client.CompactionState) BalancerChore(org.apache.hadoop.hbase.master.balancer.BalancerChore) PleaseRestartMasterException(org.apache.hadoop.hbase.PleaseRestartMasterException) SpaceQuotaSnapshotNotifierFactory(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotNotifierFactory) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) MetaTableAccessor(org.apache.hadoop.hbase.MetaTableAccessor) RegionInfoBuilder(org.apache.hadoop.hbase.client.RegionInfoBuilder) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) InitMetaProcedure(org.apache.hadoop.hbase.master.procedure.InitMetaProcedure) SnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription) MasterNotRunningException(org.apache.hadoop.hbase.MasterNotRunningException) ModifyRegionUtils(org.apache.hadoop.hbase.util.ModifyRegionUtils) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) HashMap(java.util.HashMap) TableState(org.apache.hadoop.hbase.client.TableState) LoadBalancerFactory(org.apache.hadoop.hbase.master.balancer.LoadBalancerFactory) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) SnapshotCleanerChore(org.apache.hadoop.hbase.master.cleaner.SnapshotCleanerChore) RegionNormalizerFactory(org.apache.hadoop.hbase.master.normalizer.RegionNormalizerFactory) RpcServer(org.apache.hadoop.hbase.ipc.RpcServer) ReplicationUtils(org.apache.hadoop.hbase.replication.ReplicationUtils) MasterRegion(org.apache.hadoop.hbase.master.region.MasterRegion) RSGroupUtil(org.apache.hadoop.hbase.rsgroup.RSGroupUtil) Iterator(java.util.Iterator) HBaseMarkers(org.apache.hadoop.hbase.log.HBaseMarkers) ProcedurePrepareLatch(org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch) VersionInfo(org.apache.hadoop.hbase.util.VersionInfo) Put(org.apache.hadoop.hbase.client.Put) FavoredNodesManager(org.apache.hadoop.hbase.favored.FavoredNodesManager) CreateTableProcedure(org.apache.hadoop.hbase.master.procedure.CreateTableProcedure) ProcedureEvent(org.apache.hadoop.hbase.procedure2.ProcedureEvent) MemoryBoundedLogMessageBuffer(org.apache.hadoop.hbase.monitoring.MemoryBoundedLogMessageBuffer) TimeUnit(java.util.concurrent.TimeUnit) ReplicationLogCleaner(org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner) DisableTableProcedure(org.apache.hadoop.hbase.master.procedure.DisableTableProcedure) Addressing(org.apache.hadoop.hbase.util.Addressing) Collections(java.util.Collections) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MobFileCompactionChore(org.apache.hadoop.hbase.mob.MobFileCompactionChore) RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) ServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure) DisablePeerProcedure(org.apache.hadoop.hbase.master.replication.DisablePeerProcedure) EnableTableProcedure(org.apache.hadoop.hbase.master.procedure.EnableTableProcedure) AddPeerProcedure(org.apache.hadoop.hbase.master.replication.AddPeerProcedure) ModifyTableProcedure(org.apache.hadoop.hbase.master.procedure.ModifyTableProcedure) ModifyColumnFamilyStoreFileTrackerProcedure(org.apache.hadoop.hbase.regionserver.storefiletracker.ModifyColumnFamilyStoreFileTrackerProcedure) ModifyTableStoreFileTrackerProcedure(org.apache.hadoop.hbase.regionserver.storefiletracker.ModifyTableStoreFileTrackerProcedure) ReopenTableRegionsProcedure(org.apache.hadoop.hbase.master.procedure.ReopenTableRegionsProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) TruncateTableProcedure(org.apache.hadoop.hbase.master.procedure.TruncateTableProcedure) EnablePeerProcedure(org.apache.hadoop.hbase.master.replication.EnablePeerProcedure) MergeTableRegionsProcedure(org.apache.hadoop.hbase.master.assignment.MergeTableRegionsProcedure) TransitPeerSyncReplicationStateProcedure(org.apache.hadoop.hbase.master.replication.TransitPeerSyncReplicationStateProcedure) RemovePeerProcedure(org.apache.hadoop.hbase.master.replication.RemovePeerProcedure) DeleteNamespaceProcedure(org.apache.hadoop.hbase.master.procedure.DeleteNamespaceProcedure) DeleteTableProcedure(org.apache.hadoop.hbase.master.procedure.DeleteTableProcedure) TransitRegionStateProcedure(org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure) ServerCrashProcedure(org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure) UpdatePeerConfigProcedure(org.apache.hadoop.hbase.master.replication.UpdatePeerConfigProcedure) AbstractPeerProcedure(org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure) RemoteProcedure(org.apache.hadoop.hbase.procedure2.RemoteProcedureDispatcher.RemoteProcedure) InitMetaProcedure(org.apache.hadoop.hbase.master.procedure.InitMetaProcedure) CreateTableProcedure(org.apache.hadoop.hbase.master.procedure.CreateTableProcedure) DisableTableProcedure(org.apache.hadoop.hbase.master.procedure.DisableTableProcedure)

Example 58 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class HbckChore method scanForMergedParentRegions.

/**
 * Scan hbase:meta to get set of merged parent regions, this is a very heavy scan.
 *
 * @return Return generated {@link HashSet}
 */
private HashSet<String> scanForMergedParentRegions() throws IOException {
    HashSet<String> mergedParentRegions = new HashSet<>();
    // Null tablename means scan all of meta.
    MetaTableAccessor.scanMetaForTableRegions(this.master.getConnection(), r -> {
        List<RegionInfo> mergeParents = CatalogFamilyFormat.getMergeRegions(r.rawCells());
        if (mergeParents != null) {
            for (RegionInfo mergeRegion : mergeParents) {
                if (mergeRegion != null) {
                    // This region is already being merged
                    mergedParentRegions.add(mergeRegion.getEncodedName());
                }
            }
        }
        return true;
    }, null);
    return mergedParentRegions;
}
Also used : HbckRegionInfo(org.apache.hadoop.hbase.util.HbckRegionInfo) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HashSet(java.util.HashSet)

Example 59 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class HbckChore method loadRegionsFromInMemoryState.

private void loadRegionsFromInMemoryState() {
    List<RegionState> regionStates = master.getAssignmentManager().getRegionStates().getRegionStates();
    for (RegionState regionState : regionStates) {
        RegionInfo regionInfo = regionState.getRegion();
        if (master.getTableStateManager().isTableState(regionInfo.getTable(), TableState.State.DISABLED)) {
            disabledTableRegions.add(regionInfo.getRegionNameAsString());
        }
        // Check both state and regioninfo for split status, see HBASE-26383
        if (regionState.isSplit() || regionInfo.isSplit()) {
            splitParentRegions.add(regionInfo.getRegionNameAsString());
        }
        HbckRegionInfo.MetaEntry metaEntry = new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(), regionState.getStamp());
        regionInfoMap.put(regionInfo.getEncodedName(), new HbckRegionInfo(metaEntry));
    }
    LOG.info("Loaded {} regions ({} disabled, {} split parents) from in-memory state", regionStates.size(), disabledTableRegions.size(), splitParentRegions.size());
    if (LOG.isDebugEnabled()) {
        Map<RegionState.State, Integer> stateCountMap = new HashMap<>();
        for (RegionState regionState : regionStates) {
            stateCountMap.compute(regionState.getState(), (k, v) -> (v == null) ? 1 : v + 1);
        }
        StringBuffer sb = new StringBuffer();
        sb.append("Regions by state: ");
        stateCountMap.entrySet().forEach(e -> {
            sb.append(e.getKey());
            sb.append('=');
            sb.append(e.getValue());
            sb.append(' ');
        });
        LOG.debug(sb.toString());
    }
    if (LOG.isTraceEnabled()) {
        for (RegionState regionState : regionStates) {
            LOG.trace("{}: {}, serverName=", regionState.getRegion(), regionState.getState(), regionState.getServerName());
        }
    }
}
Also used : HashMap(java.util.HashMap) TableState(org.apache.hadoop.hbase.client.TableState) HbckRegionInfo(org.apache.hadoop.hbase.util.HbckRegionInfo) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) HbckRegionInfo(org.apache.hadoop.hbase.util.HbckRegionInfo)

Example 60 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class TableSnapshotInputFormatImpl method getSplits.

public static List<InputSplit> getSplits(Scan scan, SnapshotManifest manifest, List<RegionInfo> regionManifests, Path restoreDir, Configuration conf, RegionSplitter.SplitAlgorithm sa, int numSplits) throws IOException {
    // load table descriptor
    TableDescriptor htd = manifest.getTableDescriptor();
    Path tableDir = CommonFSUtils.getTableDir(restoreDir, htd.getTableName());
    boolean localityEnabled = conf.getBoolean(SNAPSHOT_INPUTFORMAT_LOCALITY_ENABLED_KEY, SNAPSHOT_INPUTFORMAT_LOCALITY_ENABLED_DEFAULT);
    boolean scanMetricsEnabled = conf.getBoolean(SNAPSHOT_INPUTFORMAT_SCAN_METRICS_ENABLED, SNAPSHOT_INPUTFORMAT_SCAN_METRICS_ENABLED_DEFAULT);
    scan.setScanMetricsEnabled(scanMetricsEnabled);
    boolean useRegionLoc = conf.getBoolean(SNAPSHOT_INPUTFORMAT_LOCALITY_BY_REGION_LOCATION, SNAPSHOT_INPUTFORMAT_LOCALITY_BY_REGION_LOCATION_DEFAULT);
    Connection connection = null;
    RegionLocator regionLocator = null;
    if (localityEnabled && useRegionLoc) {
        Configuration newConf = new Configuration(conf);
        newConf.setInt("hbase.hconnection.threads.max", 1);
        try {
            connection = ConnectionFactory.createConnection(newConf);
            regionLocator = connection.getRegionLocator(htd.getTableName());
            /* Get all locations for the table and cache it */
            regionLocator.getAllRegionLocations();
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
    }
    List<InputSplit> splits = new ArrayList<>();
    for (RegionInfo hri : regionManifests) {
        // load region descriptor
        List<String> hosts = null;
        if (localityEnabled) {
            if (regionLocator != null) {
                /* Get Location from the local cache */
                HRegionLocation location = regionLocator.getRegionLocation(hri.getStartKey(), false);
                hosts = new ArrayList<>(1);
                hosts.add(location.getHostname());
            } else {
                hosts = calculateLocationsForInputSplit(conf, htd, hri, tableDir);
            }
        }
        if (numSplits > 1) {
            byte[][] sp = sa.split(hri.getStartKey(), hri.getEndKey(), numSplits, true);
            for (int i = 0; i < sp.length - 1; i++) {
                if (PrivateCellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(), sp[i], sp[i + 1])) {
                    Scan boundedScan = new Scan(scan);
                    if (scan.getStartRow().length == 0) {
                        boundedScan.withStartRow(sp[i]);
                    } else {
                        boundedScan.withStartRow(Bytes.compareTo(scan.getStartRow(), sp[i]) > 0 ? scan.getStartRow() : sp[i]);
                    }
                    if (scan.getStopRow().length == 0) {
                        boundedScan.withStopRow(sp[i + 1]);
                    } else {
                        boundedScan.withStopRow(Bytes.compareTo(scan.getStopRow(), sp[i + 1]) < 0 ? scan.getStopRow() : sp[i + 1]);
                    }
                    splits.add(new InputSplit(htd, hri, hosts, boundedScan, restoreDir));
                }
            }
        } else {
            if (PrivateCellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(), hri.getStartKey(), hri.getEndKey())) {
                splits.add(new InputSplit(htd, hri, hosts, scan, restoreDir));
            }
        }
    }
    return splits;
}
Also used : Path(org.apache.hadoop.fs.Path) RegionLocator(org.apache.hadoop.hbase.client.RegionLocator) Configuration(org.apache.hadoop.conf.Configuration) Connection(org.apache.hadoop.hbase.client.Connection) ArrayList(java.util.ArrayList) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) Scan(org.apache.hadoop.hbase.client.Scan)

Aggregations

RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)824 Test (org.junit.Test)416 TableName (org.apache.hadoop.hbase.TableName)311 ServerName (org.apache.hadoop.hbase.ServerName)191 ArrayList (java.util.ArrayList)175 IOException (java.io.IOException)174 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)174 Path (org.apache.hadoop.fs.Path)141 List (java.util.List)118 HashMap (java.util.HashMap)90 Table (org.apache.hadoop.hbase.client.Table)90 Map (java.util.Map)81 Put (org.apache.hadoop.hbase.client.Put)81 Configuration (org.apache.hadoop.conf.Configuration)80 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)67 TreeMap (java.util.TreeMap)66 Result (org.apache.hadoop.hbase.client.Result)59 FileSystem (org.apache.hadoop.fs.FileSystem)58 Cell (org.apache.hadoop.hbase.Cell)50 Scan (org.apache.hadoop.hbase.client.Scan)46