use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSnapshotCleanupRequest in project hbase by apache.
the class TestSnapshotFromMaster method testSnapshotCleanupStatus.
@Test
public void testSnapshotCleanupStatus() throws Exception {
// Enable auto snapshot cleanup for the cluster
SetSnapshotCleanupRequest setSnapshotCleanupRequest = SetSnapshotCleanupRequest.newBuilder().setEnabled(true).build();
master.getMasterRpcServices().switchSnapshotCleanup(null, setSnapshotCleanupRequest);
// Check if auto snapshot cleanup is enabled
IsSnapshotCleanupEnabledRequest isSnapshotCleanupEnabledRequest = IsSnapshotCleanupEnabledRequest.newBuilder().build();
IsSnapshotCleanupEnabledResponse isSnapshotCleanupEnabledResponse = master.getMasterRpcServices().isSnapshotCleanupEnabled(null, isSnapshotCleanupEnabledRequest);
Assert.assertTrue(isSnapshotCleanupEnabledResponse.getEnabled());
// Disable auto snapshot cleanup for the cluster
setSnapshotCleanupRequest = SetSnapshotCleanupRequest.newBuilder().setEnabled(false).build();
master.getMasterRpcServices().switchSnapshotCleanup(null, setSnapshotCleanupRequest);
// Check if auto snapshot cleanup is disabled
isSnapshotCleanupEnabledRequest = IsSnapshotCleanupEnabledRequest.newBuilder().build();
isSnapshotCleanupEnabledResponse = master.getMasterRpcServices().isSnapshotCleanupEnabled(null, isSnapshotCleanupEnabledRequest);
Assert.assertFalse(isSnapshotCleanupEnabledResponse.getEnabled());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSnapshotCleanupRequest in project hbase by apache.
the class TestSnapshotFromMaster method testGetCompletedSnapshotsWithCleanup.
@Test
public void testGetCompletedSnapshotsWithCleanup() throws Exception {
// Enable auto snapshot cleanup for the cluster
SetSnapshotCleanupRequest setSnapshotCleanupRequest = SetSnapshotCleanupRequest.newBuilder().setEnabled(true).build();
master.getMasterRpcServices().switchSnapshotCleanup(null, setSnapshotCleanupRequest);
// first check when there are no snapshots
GetCompletedSnapshotsRequest request = GetCompletedSnapshotsRequest.newBuilder().build();
GetCompletedSnapshotsResponse response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 0, response.getSnapshotsCount());
// NOTE: This is going to be flakey. Its timing based. For now made it more coarse
// so more likely to pass though we have to hang around longer.
// write one snapshot to the fs
createSnapshotWithTtl("snapshot_01", 5L);
createSnapshotWithTtl("snapshot_02", 100L);
// check that we get one snapshot
response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());
// Check that 1 snapshot is auto cleaned after 5 sec of TTL expiration. Wait 10 seconds
// just in case.
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 1, response.getSnapshotsCount());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSnapshotCleanupRequest in project hbase by apache.
the class TestSnapshotFromMaster method testGetCompletedSnapshotsWithoutCleanup.
@Test
public void testGetCompletedSnapshotsWithoutCleanup() throws Exception {
// Disable auto snapshot cleanup for the cluster
SetSnapshotCleanupRequest setSnapshotCleanupRequest = SetSnapshotCleanupRequest.newBuilder().setEnabled(false).build();
master.getMasterRpcServices().switchSnapshotCleanup(null, setSnapshotCleanupRequest);
// first check when there are no snapshots
GetCompletedSnapshotsRequest request = GetCompletedSnapshotsRequest.newBuilder().build();
GetCompletedSnapshotsResponse response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 0, response.getSnapshotsCount());
// write one snapshot to the fs
createSnapshotWithTtl("snapshot_02", 1L);
createSnapshotWithTtl("snapshot_03", 1L);
// check that we get one snapshot
response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());
// check that no snapshot is auto cleaned even after 1 sec of TTL expiration
Uninterruptibles.sleepUninterruptibly(2, TimeUnit.SECONDS);
response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());
}
Aggregations