-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-24408 Introduce a general 'local region' to store data on master #1753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,7 @@ | |
| import org.apache.hadoop.hbase.master.replication.UpdatePeerConfigProcedure; | ||
| import org.apache.hadoop.hbase.master.slowlog.SlowLogMasterService; | ||
| import org.apache.hadoop.hbase.master.snapshot.SnapshotManager; | ||
| import org.apache.hadoop.hbase.master.store.LocalStore; | ||
| import org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer; | ||
| import org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer; | ||
| import org.apache.hadoop.hbase.mob.MobFileCleanerChore; | ||
|
|
@@ -449,6 +450,9 @@ public void run() { | |
| private ProcedureExecutor<MasterProcedureEnv> procedureExecutor; | ||
| private ProcedureStore procedureStore; | ||
|
|
||
| // the master local storage to store procedure data, etc. | ||
| private LocalStore localStore; | ||
|
|
||
| // handle table states | ||
| private TableStateManager tableStateManager; | ||
|
|
||
|
|
@@ -913,7 +917,8 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc | |
| this.masterActiveTime = System.currentTimeMillis(); | ||
| // TODO: Do this using Dependency Injection, using PicoContainer, Guice or Spring. | ||
|
|
||
| // always initialize the MemStoreLAB as we use a region to store procedure now. | ||
| // always initialize the MemStoreLAB as we use a region to store data in master now, see | ||
| // localStore. | ||
| initializeMemStoreChunkCreator(); | ||
| this.fileSystemManager = new MasterFileSystem(conf); | ||
| this.walManager = new MasterWalManager(this); | ||
|
|
@@ -959,6 +964,9 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc | |
| DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK)) { | ||
| this.splitWALManager = new SplitWALManager(this); | ||
| } | ||
|
|
||
| // initialize local store | ||
| localStore = LocalStore.create(this); | ||
| createProcedureExecutor(); | ||
| Map<Class<?>, List<Procedure<MasterProcedureEnv>>> procsByType = | ||
| procedureExecutor.getActiveProceduresNoCopy().stream() | ||
|
|
@@ -1447,6 +1455,8 @@ private void startServiceThreads() throws IOException { | |
| this.executorService.startExecutorService(ExecutorType.MASTER_TABLE_OPERATIONS, 1); | ||
| startProcedureExecutor(); | ||
|
|
||
| // Create cleaner thread pool | ||
| cleanerPool = new DirScanPool(conf); | ||
| // Start log cleaner thread | ||
| int cleanerInterval = | ||
| conf.getInt(HBASE_MASTER_CLEANER_INTERVAL, DEFAULT_HBASE_MASTER_CLEANER_INTERVAL); | ||
|
|
@@ -1534,6 +1544,9 @@ protected void stopServiceThreads() { | |
|
|
||
| stopProcedureExecutor(); | ||
|
|
||
| if (localStore != null) { | ||
| localStore.close(isAborted()); | ||
| } | ||
| if (this.walManager != null) { | ||
| this.walManager.stop(); | ||
| } | ||
|
|
@@ -1550,10 +1563,8 @@ protected void stopServiceThreads() { | |
|
|
||
| private void createProcedureExecutor() throws IOException { | ||
| MasterProcedureEnv procEnv = new MasterProcedureEnv(this); | ||
| // Create cleaner thread pool | ||
| cleanerPool = new DirScanPool(conf); | ||
| procedureStore = new RegionProcedureStore(this, cleanerPool, | ||
| new MasterProcedureEnv.FsUtilsLeaseRecovery(this)); | ||
| procedureStore = | ||
| new RegionProcedureStore(this, localStore, new MasterProcedureEnv.FsUtilsLeaseRecovery(this)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The passing of an already initialized localregion is what is nice. |
||
| procedureStore.registerListener(new ProcedureStoreListener() { | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hbase.master.cleaner; | ||
|
|
||
| import java.time.Instant; | ||
| import java.time.ZoneOffset; | ||
| import java.time.format.DateTimeFormatter; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileStatus; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Base class for time to live file cleaner. | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public abstract class BaseTimeToLiveFileCleaner extends BaseLogCleanerDelegate { | ||
|
|
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(BaseTimeToLiveFileCleaner.class.getName()); | ||
|
|
||
| private static final DateTimeFormatter FORMATTER = | ||
| DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneOffset.systemDefault()); | ||
|
|
||
| // Configured time a log can be kept after it was closed | ||
| private long ttlMs; | ||
|
|
||
| private volatile boolean stopped = false; | ||
|
|
||
| @Override | ||
| public final void setConf(Configuration conf) { | ||
| super.setConf(conf); | ||
| this.ttlMs = getTtlMs(conf); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFileDeletable(FileStatus status) { | ||
| // Files are validated for the second time here, | ||
| // if it causes a bottleneck this logic needs refactored | ||
| if (!valiateFilename(status.getPath())) { | ||
saintstack marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return true; | ||
| } | ||
| long currentTime = EnvironmentEdgeManager.currentTime(); | ||
| long time = status.getModificationTime(); | ||
| long life = currentTime - time; | ||
|
|
||
| if (LOG.isTraceEnabled()) { | ||
| LOG.trace("File life:{}ms, ttl:{}ms, current:{}, from{}", life, ttlMs, | ||
| FORMATTER.format(Instant.ofEpochMilli(currentTime)), | ||
| FORMATTER.format(Instant.ofEpochMilli(time))); | ||
| } | ||
| if (life < 0) { | ||
| LOG.warn("Found a file ({}) newer than current time ({} < {}), probably a clock skew", | ||
| status.getPath(), FORMATTER.format(Instant.ofEpochMilli(currentTime)), | ||
| FORMATTER.format(Instant.ofEpochMilli(time))); | ||
| return false; | ||
| } | ||
| return life > ttlMs; | ||
| } | ||
|
|
||
| @Override | ||
| public void stop(String why) { | ||
| this.stopped = true; | ||
Apache9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean isStopped() { | ||
| return this.stopped; | ||
| } | ||
|
|
||
| protected abstract long getTtlMs(Configuration conf); | ||
|
|
||
| protected abstract boolean valiateFilename(Path file); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.apache.hadoop.hbase.Stoppable; | ||
| import org.apache.hadoop.hbase.conf.ConfigurationObserver; | ||
| import org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil; | ||
| import org.apache.hadoop.hbase.master.store.LocalStore; | ||
| import org.apache.hadoop.hbase.wal.AbstractFSWALProvider; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
| import org.slf4j.Logger; | ||
|
|
@@ -86,8 +87,9 @@ public LogCleaner(final int period, final Stoppable stopper, Configuration conf, | |
|
|
||
| @Override | ||
| protected boolean validate(Path file) { | ||
| return AbstractFSWALProvider.validateWALFilename(file.getName()) | ||
| || MasterProcedureUtil.validateProcedureWALFilename(file.getName()); | ||
| return AbstractFSWALProvider.validateWALFilename(file.getName()) || | ||
| MasterProcedureUtil.validateProcedureWALFilename(file.getName()) || | ||
| file.getName().endsWith(LocalStore.ARCHIVED_WAL_SUFFIX); | ||
| } | ||
|
|
||
| @Override | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Man, we should have called this file the WALCleaner, not LogCleaner. Not your fault.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it is safe to change the name. Can be another issue?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Of course. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.