Skip to content

Commit b1b3bbe

Browse files
author
Vladimir Rodionov
committed
HBASE-22749: Distributed MOB compactions
1 parent 1dcc8ee commit b1b3bbe

33 files changed

+2106
-4468
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,8 @@ public void run() {
394394
private LogCleaner logCleaner;
395395
private HFileCleaner hfileCleaner;
396396
private ReplicationBarrierCleaner replicationBarrierCleaner;
397-
private ExpiredMobFileCleanerChore expiredMobFileCleanerChore;
398-
private MobCompactionChore mobCompactChore;
399-
private MasterMobCompactionThread mobCompactThread;
397+
private MobFileCleanerChore mobFileCleanerChore;
398+
private MobFileCompactionChore mobFileCompactionChore;
400399
// used to synchronize the mobCompactionStates
401400
private final IdLock mobCompactionLock = new IdLock();
402401
// save the information of mob compactions in tables.
@@ -1299,19 +1298,18 @@ public void updateConfigurationForQuotasObserver(Configuration conf) {
12991298
}
13001299

13011300
private void initMobCleaner() {
1302-
this.expiredMobFileCleanerChore = new ExpiredMobFileCleanerChore(this);
1303-
getChoreService().scheduleChore(expiredMobFileCleanerChore);
1301+
this.mobFileCleanerChore = new MobFileCleanerChore(this);
1302+
getChoreService().scheduleChore(mobFileCleanerChore);
13041303

13051304
int mobCompactionPeriod = conf.getInt(MobConstants.MOB_COMPACTION_CHORE_PERIOD,
13061305
MobConstants.DEFAULT_MOB_COMPACTION_CHORE_PERIOD);
13071306
if (mobCompactionPeriod > 0) {
1308-
this.mobCompactChore = new MobCompactionChore(this, mobCompactionPeriod);
1309-
getChoreService().scheduleChore(mobCompactChore);
1307+
this.mobFileCompactionChore = new MobFileCompactionChore(this);
1308+
getChoreService().scheduleChore(mobFileCompactionChore);
13101309
} else {
13111310
LOG
13121311
.info("The period is " + mobCompactionPeriod + " seconds, MobCompactionChore is disabled");
13131312
}
1314-
this.mobCompactThread = new MasterMobCompactionThread(this);
13151313
}
13161314

13171315
/**
@@ -1499,9 +1497,7 @@ protected void stopServiceThreads() {
14991497
}
15001498
}
15011499
stopChores();
1502-
if (this.mobCompactThread != null) {
1503-
this.mobCompactThread.close();
1504-
}
1500+
15051501
super.stopServiceThreads();
15061502
if (cleanerPool != null) {
15071503
cleanerPool.shutdownNow();
@@ -1622,8 +1618,8 @@ private void stopProcedureExecutor() {
16221618
private void stopChores() {
16231619
ChoreService choreService = getChoreService();
16241620
if (choreService != null) {
1625-
choreService.cancelChore(this.expiredMobFileCleanerChore);
1626-
choreService.cancelChore(this.mobCompactChore);
1621+
choreService.cancelChore(this.mobFileCleanerChore);
1622+
choreService.cancelChore(this.mobFileCompactionChore);
16271623
choreService.cancelChore(this.balancerChore);
16281624
choreService.cancelChore(this.normalizerChore);
16291625
choreService.cancelChore(this.clusterStatusChore);
@@ -3430,17 +3426,6 @@ public void reportMobCompactionEnd(TableName tableName) throws IOException {
34303426
}
34313427
}
34323428

3433-
/**
3434-
* Requests mob compaction.
3435-
* @param tableName The table the compact.
3436-
* @param columns The compacted columns.
3437-
* @param allFiles Whether add all mob files into the compaction.
3438-
*/
3439-
public void requestMobCompaction(TableName tableName,
3440-
List<ColumnFamilyDescriptor> columns, boolean allFiles) throws IOException {
3441-
mobCompactThread.requestMobCompaction(conf, fs, tableName, columns, allFiles);
3442-
}
3443-
34443429
/**
34453430
* Queries the state of the {@link LoadBalancerTracker}. If the balancer is not initialized,
34463431
* false is returned.

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterMobCompactionThread.java

Lines changed: 0 additions & 181 deletions
This file was deleted.

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java

Lines changed: 20 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Map.Entry;
3333
import java.util.Set;
3434
import java.util.stream.Collectors;
35+
3536
import org.apache.hadoop.conf.Configuration;
3637
import org.apache.hadoop.fs.Path;
3738
import org.apache.hadoop.hbase.ClusterMetricsBuilder;
@@ -45,7 +46,6 @@
4546
import org.apache.hadoop.hbase.ServerName;
4647
import org.apache.hadoop.hbase.TableName;
4748
import org.apache.hadoop.hbase.UnknownRegionException;
48-
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
4949
import org.apache.hadoop.hbase.client.MasterSwitchType;
5050
import org.apache.hadoop.hbase.client.RegionInfo;
5151
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
@@ -103,23 +103,6 @@
103103
import org.apache.hadoop.hbase.security.access.ShadedAccessControlUtil;
104104
import org.apache.hadoop.hbase.security.access.UserPermission;
105105
import org.apache.hadoop.hbase.security.visibility.VisibilityController;
106-
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
107-
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
108-
import org.apache.hadoop.hbase.util.Bytes;
109-
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
110-
import org.apache.hadoop.hbase.util.ForeignExceptionUtil;
111-
import org.apache.hadoop.hbase.util.Pair;
112-
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
113-
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
114-
import org.apache.yetus.audience.InterfaceAudience;
115-
import org.apache.zookeeper.KeeperException;
116-
import org.slf4j.Logger;
117-
import org.slf4j.LoggerFactory;
118-
119-
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
120-
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
121-
import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations;
122-
123106
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
124107
import org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter;
125108
import org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos;
@@ -342,6 +325,21 @@
342325
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.UpdateReplicationPeerConfigRequest;
343326
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.UpdateReplicationPeerConfigResponse;
344327
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
328+
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
329+
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
330+
import org.apache.hadoop.hbase.util.Bytes;
331+
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
332+
import org.apache.hadoop.hbase.util.ForeignExceptionUtil;
333+
import org.apache.hadoop.hbase.util.Pair;
334+
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
335+
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
336+
import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
337+
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
338+
import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations;
339+
import org.apache.yetus.audience.InterfaceAudience;
340+
import org.apache.zookeeper.KeeperException;
341+
import org.slf4j.Logger;
342+
import org.slf4j.LoggerFactory;
345343

346344
/**
347345
* Implements the master RPC services.
@@ -1744,10 +1742,13 @@ public CompactRegionResponse compactRegion(final RpcController controller,
17441742
master.checkInitialized();
17451743
byte[] regionName = request.getRegion().getValue().toByteArray();
17461744
TableName tableName = RegionInfo.getTable(regionName);
1745+
// TODO: support CompactType.MOB
17471746
// if the region is a mob region, do the mob file compaction.
17481747
if (MobUtils.isMobRegionName(tableName, regionName)) {
17491748
checkHFileFormatVersionForMob();
1750-
return compactMob(request, tableName);
1749+
//return compactMob(request, tableName);
1750+
//TODO: support CompactType.MOB
1751+
return super.compactRegion(controller, request);
17511752
} else {
17521753
return super.compactRegion(controller, request);
17531754
}
@@ -1790,57 +1791,6 @@ public GetRegionInfoResponse getRegionInfo(final RpcController controller,
17901791
}
17911792
}
17921793

1793-
/**
1794-
* Compacts the mob files in the current table.
1795-
* @param request the request.
1796-
* @param tableName the current table name.
1797-
* @return The response of the mob file compaction.
1798-
* @throws IOException
1799-
*/
1800-
private CompactRegionResponse compactMob(final CompactRegionRequest request,
1801-
TableName tableName) throws IOException {
1802-
if (!master.getTableStateManager().isTableState(tableName, TableState.State.ENABLED)) {
1803-
throw new DoNotRetryIOException("Table " + tableName + " is not enabled");
1804-
}
1805-
boolean allFiles = false;
1806-
List<ColumnFamilyDescriptor> compactedColumns = new ArrayList<>();
1807-
ColumnFamilyDescriptor[] hcds = master.getTableDescriptors().get(tableName).getColumnFamilies();
1808-
byte[] family = null;
1809-
if (request.hasFamily()) {
1810-
family = request.getFamily().toByteArray();
1811-
for (ColumnFamilyDescriptor hcd : hcds) {
1812-
if (Bytes.equals(family, hcd.getName())) {
1813-
if (!hcd.isMobEnabled()) {
1814-
LOG.error("Column family " + hcd.getNameAsString() + " is not a mob column family");
1815-
throw new DoNotRetryIOException("Column family " + hcd.getNameAsString()
1816-
+ " is not a mob column family");
1817-
}
1818-
compactedColumns.add(hcd);
1819-
}
1820-
}
1821-
} else {
1822-
for (ColumnFamilyDescriptor hcd : hcds) {
1823-
if (hcd.isMobEnabled()) {
1824-
compactedColumns.add(hcd);
1825-
}
1826-
}
1827-
}
1828-
if (compactedColumns.isEmpty()) {
1829-
LOG.error("No mob column families are assigned in the mob compaction");
1830-
throw new DoNotRetryIOException(
1831-
"No mob column families are assigned in the mob compaction");
1832-
}
1833-
if (request.hasMajor() && request.getMajor()) {
1834-
allFiles = true;
1835-
}
1836-
String familyLogMsg = (family != null) ? Bytes.toString(family) : "";
1837-
if (LOG.isTraceEnabled()) {
1838-
LOG.trace("User-triggered mob compaction requested for table: "
1839-
+ tableName.getNameAsString() + " for column family: " + familyLogMsg);
1840-
}
1841-
master.requestMobCompaction(tableName, compactedColumns, allFiles);
1842-
return CompactRegionResponse.newBuilder().build();
1843-
}
18441794

18451795
@Override
18461796
public IsBalancerEnabledResponse isBalancerEnabled(RpcController controller,

0 commit comments

Comments
 (0)