Search in sources :

Example 1 with RetryCounterFactory

use of org.apache.hadoop.hbase.util.RetryCounterFactory 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 2 with RetryCounterFactory

use of org.apache.hadoop.hbase.util.RetryCounterFactory in project hbase by apache.

the class RegionReplicaFlushHandler method triggerFlushInPrimaryRegion.

void triggerFlushInPrimaryRegion(final HRegion region) throws IOException {
    long pause = connection.getConfiguration().getLong(HConstants.HBASE_CLIENT_PAUSE, HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
    int maxAttempts = getRetriesCount(connection.getConfiguration());
    RetryCounter counter = new RetryCounterFactory(maxAttempts, (int) pause).create();
    if (LOG.isDebugEnabled()) {
        LOG.debug("RPC'ing to primary " + ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionNameAsString() + " from " + region.getRegionInfo().getRegionNameAsString() + " to trigger FLUSH");
    }
    while (!region.isClosing() && !region.isClosed() && !server.isAborted() && !server.isStopped()) {
        // TODO: flushRegion() is a blocking call waiting for the flush to complete. Ideally we
        // do not have to wait for the whole flush here, just initiate it.
        FlushRegionResponse response;
        try {
            response = FutureUtils.get(connection.flush(ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionName(), true));
        } catch (IOException e) {
            if (e instanceof TableNotFoundException || FutureUtils.get(connection.getAdmin().isTableDisabled(region.getRegionInfo().getTable()))) {
                return;
            }
            if (!counter.shouldRetry()) {
                throw e;
            }
            // The reason that why we need to retry here is that, the retry for asynchronous admin
            // request is much simpler than the normal operation, if we failed to locate the region once
            // then we will throw the exception out and will not try to relocate again. So here we need
            // to add some retries by ourselves to prevent shutting down the region server too
            // frequent...
            LOG.debug("Failed to trigger a flush of primary region replica {} of region {}, retry={}", ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionNameAsString(), region.getRegionInfo().getRegionNameAsString(), counter.getAttemptTimes(), e);
            try {
                counter.sleepUntilNextRetry();
            } catch (InterruptedException e1) {
                throw new InterruptedIOException(e1.getMessage());
            }
            continue;
        }
        if (response.getFlushed()) {
            // a complete flush cycle or replay a region open event
            if (LOG.isDebugEnabled()) {
                LOG.debug("Triggered flush of primary region replica " + ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionNameAsString() + " for " + region.getRegionInfo().getEncodedName() + "; now waiting and blocking reads until completes a full flush cycle");
            }
            region.setReadsEnabled(true);
            break;
        } else {
            if (response.hasWroteFlushWalMarker()) {
                if (response.getWroteFlushWalMarker()) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Triggered empty flush marker (memstore empty) on primary region replica " + ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionNameAsString() + " for " + region.getRegionInfo().getEncodedName() + "; now waiting and blocking reads until observing a flush marker");
                    }
                    region.setReadsEnabled(true);
                    break;
                } else {
                    // closing or already flushing. Retry flush again after some sleep.
                    if (!counter.shouldRetry()) {
                        throw new IOException("Cannot cause primary to flush or drop a wal marker after " + counter.getAttemptTimes() + " retries. Failing opening of this region replica " + region.getRegionInfo().getRegionNameAsString());
                    } else {
                        LOG.warn("Cannot cause primary replica {} to flush or drop a wal marker " + "for region replica {}, retry={}", ServerRegionReplicaUtil.getRegionInfoForDefaultReplica(region.getRegionInfo()).getRegionNameAsString(), region.getRegionInfo().getRegionNameAsString(), counter.getAttemptTimes());
                    }
                }
            } else {
                // nothing to do. Are we dealing with an old server?
                LOG.warn("Was not able to trigger a flush from primary region due to old server version? " + "Continuing to open the secondary region replica: " + region.getRegionInfo().getRegionNameAsString());
                break;
            }
        }
        try {
            counter.sleepUntilNextRetry();
        } catch (InterruptedException e) {
            throw new InterruptedIOException(e.getMessage());
        }
    }
    region.setReadsEnabled(true);
}
Also used : TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) InterruptedIOException(java.io.InterruptedIOException) RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) RetryCounter(org.apache.hadoop.hbase.util.RetryCounter) FlushRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse) IOException(java.io.IOException) InterruptedIOException(java.io.InterruptedIOException)

Example 3 with RetryCounterFactory

use of org.apache.hadoop.hbase.util.RetryCounterFactory in project hbase by apache.

the class HBaseClusterManager method setConf.

@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    if (conf == null) {
        // Configured gets passed null before real conf. Why? I don't know.
        return;
    }
    sshUserName = conf.get("hbase.it.clustermanager.ssh.user", "");
    String extraSshOptions = conf.get("hbase.it.clustermanager.ssh.opts", "");
    sshOptions = System.getenv("HBASE_SSH_OPTS");
    if (!extraSshOptions.isEmpty()) {
        sshOptions = StringUtils.join(new Object[] { sshOptions, extraSshOptions }, " ");
    }
    sshOptions = (sshOptions == null) ? "" : sshOptions;
    sshUserName = (sshUserName == null) ? "" : sshUserName;
    tunnelCmd = conf.get("hbase.it.clustermanager.ssh.cmd", DEFAULT_TUNNEL_CMD);
    tunnelSudoCmd = conf.get("hbase.it.clustermanager.ssh.sudo.cmd", DEFAULT_TUNNEL_SUDO_CMD);
    // Print out ssh special config if any.
    if ((sshUserName != null && sshUserName.length() > 0) || (sshOptions != null && sshOptions.length() > 0)) {
        LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]");
    }
    this.retryCounterFactory = new RetryCounterFactory(new RetryConfig().setMaxAttempts(conf.getInt(RETRY_ATTEMPTS_KEY, DEFAULT_RETRY_ATTEMPTS)).setSleepInterval(conf.getLong(RETRY_SLEEP_INTERVAL_KEY, DEFAULT_RETRY_SLEEP_INTERVAL)));
}
Also used : RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) RetryConfig(org.apache.hadoop.hbase.util.RetryCounter.RetryConfig)

Example 4 with RetryCounterFactory

use of org.apache.hadoop.hbase.util.RetryCounterFactory in project hbase by apache.

the class RESTApiClusterManager method setConf.

@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    if (conf == null) {
        // `Configured()` constructor calls `setConf(null)` before calling again with a real value.
        return;
    }
    final Class<? extends ClusterManager> clazz = conf.getClass(REST_API_DELEGATE_CLUSTER_MANAGER, HBaseClusterManager.class, ClusterManager.class);
    hBaseClusterManager = ReflectionUtils.newInstance(clazz, conf);
    serverHostname = conf.get(REST_API_CLUSTER_MANAGER_HOSTNAME, DEFAULT_SERVER_HOSTNAME);
    clusterName = conf.get(REST_API_CLUSTER_MANAGER_CLUSTER_NAME, DEFAULT_CLUSTER_NAME);
    // Add filter to Client instance to enable server authentication.
    String serverUsername = conf.get(REST_API_CLUSTER_MANAGER_USERNAME, DEFAULT_SERVER_USERNAME);
    String serverPassword = conf.get(REST_API_CLUSTER_MANAGER_PASSWORD, DEFAULT_SERVER_PASSWORD);
    client.register(HttpAuthenticationFeature.basic(serverUsername, serverPassword));
    this.retryCounterFactory = new RetryCounterFactory(new RetryConfig().setMaxAttempts(conf.getInt(RETRY_ATTEMPTS_KEY, DEFAULT_RETRY_ATTEMPTS)).setSleepInterval(conf.getLong(RETRY_SLEEP_INTERVAL_KEY, DEFAULT_RETRY_SLEEP_INTERVAL)));
}
Also used : RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) RetryConfig(org.apache.hadoop.hbase.util.RetryCounter.RetryConfig)

Example 5 with RetryCounterFactory

use of org.apache.hadoop.hbase.util.RetryCounterFactory in project hbase by apache.

the class ChaosAgent method initChaosAgent.

/**
 * sets global params and initiates connection with ZooKeeper then does registration.
 * @param conf initial configuration to use
 * @param quorum ZK Quorum
 * @param agentName AgentName to use
 */
private void initChaosAgent(Configuration conf, String quorum, String agentName) {
    this.conf = conf;
    this.quorum = quorum;
    this.agentName = agentName;
    this.retryCounterFactory = new RetryCounterFactory(new RetryCounter.RetryConfig().setMaxAttempts(conf.getInt(ChaosConstants.RETRY_ATTEMPTS_KEY, ChaosConstants.DEFAULT_RETRY_ATTEMPTS)).setSleepInterval(conf.getLong(ChaosConstants.RETRY_SLEEP_INTERVAL_KEY, ChaosConstants.DEFAULT_RETRY_SLEEP_INTERVAL)));
    try {
        this.createZKConnection(null);
        this.register();
    } catch (IOException e) {
        LOG.error("Error Creating Connection: " + e);
    }
}
Also used : RetryCounterFactory(org.apache.hadoop.hbase.util.RetryCounterFactory) IOException(java.io.IOException)

Aggregations

RetryCounterFactory (org.apache.hadoop.hbase.util.RetryCounterFactory)6 IOException (java.io.IOException)3 RetryCounter (org.apache.hadoop.hbase.util.RetryCounter)3 InterruptedIOException (java.io.InterruptedIOException)2 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)2 RetryConfig (org.apache.hadoop.hbase.util.RetryCounter.RetryConfig)2 RestrictedApi (com.google.errorprone.annotations.RestrictedApi)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1