-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-24694 Support flush a single column family of table #2179
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 1 commit
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 |
|---|---|---|
|
|
@@ -302,6 +302,13 @@ CompletableFuture<Void> modifyColumnFamily(TableName tableName, | |
| */ | ||
| CompletableFuture<Void> flush(TableName tableName); | ||
|
|
||
| /** | ||
| * Flush a table. | ||
|
||
| * @param tableName table to flush | ||
| * @param columnFamily column family within a table | ||
| */ | ||
| CompletableFuture<Void> flush(TableName tableName, byte[] columnFamily); | ||
|
|
||
| /** | ||
| * Flush an individual region. | ||
| * @param regionName region to flush | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| */ | ||
| package org.apache.hadoop.hbase.procedure.flush; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.concurrent.Callable; | ||
|
|
||
|
|
@@ -28,7 +29,9 @@ | |
| import org.apache.hadoop.hbase.procedure.ProcedureMember; | ||
| import org.apache.hadoop.hbase.procedure.Subprocedure; | ||
| import org.apache.hadoop.hbase.procedure.flush.RegionServerFlushTableProcedureManager.FlushTableSubprocedurePool; | ||
| import org.apache.hadoop.hbase.regionserver.FlushLifeCycleTracker; | ||
| import org.apache.hadoop.hbase.regionserver.HRegion; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
|
|
||
| /** | ||
| * This flush region implementation uses the distributed procedure framework to flush | ||
|
|
@@ -40,23 +43,27 @@ public class FlushTableSubprocedure extends Subprocedure { | |
| private static final Logger LOG = LoggerFactory.getLogger(FlushTableSubprocedure.class); | ||
|
|
||
| private final String table; | ||
| private final String family; | ||
| private final List<HRegion> regions; | ||
| private final FlushTableSubprocedurePool taskManager; | ||
|
|
||
| public FlushTableSubprocedure(ProcedureMember member, | ||
| ForeignExceptionDispatcher errorListener, long wakeFrequency, long timeout, | ||
| List<HRegion> regions, String table, | ||
| List<HRegion> regions, String table, String family, | ||
| FlushTableSubprocedurePool taskManager) { | ||
| super(member, table, errorListener, wakeFrequency, timeout); | ||
| this.table = table; | ||
| this.family = family; | ||
| this.regions = regions; | ||
| this.taskManager = taskManager; | ||
| } | ||
|
|
||
| private static class RegionFlushTask implements Callable<Void> { | ||
| HRegion region; | ||
| RegionFlushTask(HRegion region) { | ||
| List<byte[]> families; | ||
| RegionFlushTask(HRegion region, List<byte[]> families) { | ||
| this.region = region; | ||
| this.families = families; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -65,7 +72,7 @@ public Void call() throws Exception { | |
| region.startRegionOperation(); | ||
| try { | ||
| LOG.debug("Flush region " + region.toString() + " started..."); | ||
| region.flush(true); | ||
| region.flushcache(families, false, FlushLifeCycleTracker.DUMMY); | ||
|
||
| // TODO: flush result is not checked? | ||
| } finally { | ||
| LOG.debug("Closing region operation on " + region); | ||
|
|
@@ -88,11 +95,15 @@ private void flushRegions() throws ForeignException { | |
| throw new IllegalStateException("Attempting to flush " | ||
| + table + " but we currently have outstanding tasks"); | ||
| } | ||
|
|
||
| List<byte[]> families = null; | ||
| if (family != null) { | ||
| LOG.debug("Flush regions with specified family:{}", family); | ||
wchevreuil marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| families = Arrays.asList(Bytes.toBytes(family)); | ||
| } | ||
| // Add all hfiles already existing in region. | ||
| for (HRegion region : regions) { | ||
| // submit one task per region for parallelize by region. | ||
| taskManager.submitTask(new RegionFlushTask(region)); | ||
| taskManager.submitTask(new RegionFlushTask(region, families)); | ||
| monitor.rethrowException(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,11 @@ def help | |
| Flush all regions in passed table or pass a region row to | ||
| flush an individual region or a region server name whose format | ||
| is 'host,port,startcode', to flush all its regions. | ||
| You can also flush a single column family within a region. | ||
| You can also flush a single column family within a table or region. | ||
|
||
| For example: | ||
|
|
||
| hbase> flush 'TABLENAME' | ||
| hbase> flush 'TABLENAME','FAMILYNAME' | ||
| hbase> flush 'REGIONNAME' | ||
| hbase> flush 'REGIONNAME','FAMILYNAME' | ||
| hbase> flush 'ENCODED_REGIONNAME' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should explain better how this overloaded version differs from
flush(TableName tableName).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.