Skip to content

HBASE-22760 : Pause/Resume/Query Snapshot Auto Cleanup Activity #619

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

Merged
merged 1 commit into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1658,4 +1658,28 @@ public enum MasterSwitchType {
* @return List of servers that not cleared
*/
List<ServerName> clearDeadServers(final List<ServerName> servers) throws IOException;


/**
* Turn on or off the auto snapshot cleanup based on TTL.
*
* @param on Set to <code>true</code> to enable, <code>false</code> to disable.
* @param synchronous If <code>true</code>, it waits until current snapshot cleanup is completed,
* if outstanding.
* @return Previous auto snapshot cleanup value
* @throws IOException if a remote or network exception occurs
*/
boolean snapshotCleanupSwitch(final boolean on, final boolean synchronous)
throws IOException;

/**
* Query the current state of the auto snapshot cleanup based on TTL.
*
* @return <code>true</code> if the auto snapshot cleanup is enabled,
* <code>false</code> otherwise.
* @throws IOException if a remote or network exception occurs
*/
boolean isSnapshotCleanupEnabled() throws IOException;


}
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,20 @@ public ListNamespacesResponse listNamespaces(RpcController controller,
return stub.listNamespaces(controller, request);
}

@Override
public MasterProtos.SetSnapshotCleanupResponse switchSnapshotCleanup(
RpcController controller, MasterProtos.SetSnapshotCleanupRequest request)
throws ServiceException {
return stub.switchSnapshotCleanup(controller, request);
}

@Override
public MasterProtos.IsSnapshotCleanupEnabledResponse isSnapshotCleanupEnabled(
RpcController controller, MasterProtos.IsSnapshotCleanupEnabledRequest request)
throws ServiceException {
return stub.isSnapshotCleanupEnabled(controller, request);
}

@Override
public ListNamespaceDescriptorsResponse listNamespaceDescriptors(RpcController controller,
ListNamespaceDescriptorsRequest request) throws ServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsProcedureDoneResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshotDoneRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshotDoneResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotCleanupEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest;
Expand All @@ -154,6 +155,7 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SecurityCapabilitiesRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetNormalizerRunningRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetSnapshotCleanupRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ShutdownRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SnapshotRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SnapshotResponse;
Expand Down Expand Up @@ -5053,4 +5055,38 @@ public List<ServerName> call(int callTimeout) throws Exception {
private RpcControllerFactory getRpcControllerFactory() {
return rpcControllerFactory;
}

@Override
public boolean snapshotCleanupSwitch(final boolean on, final boolean synchronous)
throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection()) {

@Override
public Boolean call(int callTimeout) throws Exception {
HBaseRpcController controller = rpcControllerFactory.newController();
controller.setCallTimeout(callTimeout);
SetSnapshotCleanupRequest req =
RequestConverter.buildSetSnapshotCleanupRequest(on, synchronous);
return master.switchSnapshotCleanup(controller, req).getPrevSnapshotCleanup();
}
});

}

@Override
public boolean isSnapshotCleanupEnabled() throws IOException {
return executeCallable(new MasterCallable<Boolean>(getConnection()) {

@Override
public Boolean call(int callTimeout) throws Exception {
HBaseRpcController controller = rpcControllerFactory.newController();
controller.setCallTimeout(callTimeout);
IsSnapshotCleanupEnabledRequest req =
RequestConverter.buildIsSnapshotCleanupEnabledRequest();
return master.isSnapshotCleanupEnabled(controller, req).getEnabled();
}
});

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsCleanerChoreEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsNormalizerEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos
.IsSnapshotCleanupEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
Expand All @@ -110,6 +112,7 @@
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.RunCleanerChoreRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetNormalizerRunningRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetSnapshotCleanupRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.TruncateTableRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
Expand Down Expand Up @@ -1830,4 +1833,31 @@ private static MasterProtos.MasterSwitchType convert(Admin.MasterSwitchType swit
}
throw new UnsupportedOperationException("Unsupport switch type:" + switchType);
}


/**
* Creates SetSnapshotCleanupRequest for turning on/off auto snapshot cleanup
*
* @param enabled Set to <code>true</code> to enable,
* <code>false</code> to disable.
* @param synchronous If <code>true</code>, it waits until current snapshot cleanup is completed,
* if outstanding.
* @return a SetSnapshotCleanupRequest
*/
public static SetSnapshotCleanupRequest buildSetSnapshotCleanupRequest(
final boolean enabled, final boolean synchronous) {
return SetSnapshotCleanupRequest.newBuilder().setEnabled(enabled).setSynchronous(synchronous)
.build();
}

/**
* Creates IsSnapshotCleanupEnabledRequest to determine if auto snapshot cleanup
* based on TTL expiration is turned on
*
* @return IsSnapshotCleanupEnabledRequest
*/
public static IsSnapshotCleanupEnabledRequest buildIsSnapshotCleanupEnabledRequest() {
return IsSnapshotCleanupEnabledRequest.newBuilder().build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
private String switchZNode;
// znode containing the lock for the tables
public String tableLockZNode;
// znode containing the state of the snapshot auto-cleanup
String snapshotCleanupZNode;
// znode containing the state of recovering regions
public String recoveringRegionsZNode;
// znode containing namespace descriptors
Expand All @@ -137,6 +139,7 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
}};

public final static String META_ZNODE_PREFIX = "meta-region-server";
private static final String DEFAULT_SNAPSHOT_CLEANUP_ZNODE = "snapshot-cleanup";

private final Configuration conf;

Expand Down Expand Up @@ -456,6 +459,8 @@ private void setNodeNames(Configuration conf) {
switchZNode = ZKUtil.joinZNode(baseZNode, conf.get("zookeeper.znode.switch", "switch"));
tableLockZNode = ZKUtil.joinZNode(baseZNode,
conf.get("zookeeper.znode.tableLock", "table-lock"));
snapshotCleanupZNode = ZKUtil.joinZNode(baseZNode,
conf.get("zookeeper.znode.snapshot.cleanup", DEFAULT_SNAPSHOT_CLEANUP_ZNODE));
recoveringRegionsZNode = ZKUtil.joinZNode(baseZNode,
conf.get("zookeeper.znode.recovering.regions", "recovering-regions"));
namespaceZNode = ZKUtil.joinZNode(baseZNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,6 @@ public static enum Modify {
// User defined Default TTL config key
public static final String DEFAULT_SNAPSHOT_TTL_CONFIG_KEY = "hbase.master.snapshot.ttl";

public static final String SNAPSHOT_CLEANER_DISABLE = "hbase.master.cleaner.snapshot.disable";

/**
* Configurations for master executor services.
*/
Expand Down
1 change: 1 addition & 0 deletions hbase-protocol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<include>RSGroupAdmin.proto</include>
<include>SecureBulkLoad.proto</include>
<include>Snapshot.proto</include>
<include>SnapshotCleanup.proto</include>
<include>Table.proto</include>
<include>Tracing.proto</include>
<include>VisibilityLabels.proto</include>
Expand Down
Loading