1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.chaos.actions;
20
21 import org.apache.hadoop.hbase.HBaseTestingUtility;
22 import org.apache.hadoop.hbase.TableName;
23 import org.apache.hadoop.hbase.client.Admin;
24
25
26
27
28 public class FlushTableAction extends Action {
29 private final long sleepTime;
30 private final TableName tableName;
31
32 public FlushTableAction(TableName tableName) {
33 this(-1, tableName);
34 }
35
36 public FlushTableAction(int sleepTime, TableName tableName) {
37 this.sleepTime = sleepTime;
38 this.tableName = tableName;
39 }
40
41 @Override
42 public void perform() throws Exception {
43 HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
44 Admin admin = util.getHBaseAdmin();
45
46 LOG.info("Performing action: Flush table " + tableName);
47 try {
48 admin.flush(tableName);
49 } catch (Exception ex) {
50 LOG.warn("Flush failed, might be caused by other chaos: " + ex.getMessage());
51 }
52 if (sleepTime > 0) {
53 Thread.sleep(sleepTime);
54 }
55 }
56 }