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
47 if (context.isStopping()) {
48 return;
49 }
50
51 LOG.info("Performing action: Flush table " + tableName);
52 try {
53 admin.flush(tableName);
54 } catch (Exception ex) {
55 LOG.warn("Flush failed, might be caused by other chaos: " + ex.getMessage());
56 }
57 if (sleepTime > 0) {
58 Thread.sleep(sleepTime);
59 }
60 }
61 }