1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.wal;
21
22 import java.io.IOException;
23 import java.util.List;
24 import java.util.UUID;
25 import java.util.concurrent.atomic.AtomicLong;
26
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28 import org.apache.hadoop.conf.Configuration;
29 import org.apache.hadoop.fs.FileSystem;
30 import org.apache.hadoop.fs.Path;
31 import org.apache.hadoop.hbase.Cell;
32 import org.apache.hadoop.hbase.HRegionInfo;
33 import org.apache.hadoop.hbase.HTableDescriptor;
34 import org.apache.hadoop.hbase.TableName;
35
36
37 import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
38 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
39
40
41
42
43 @InterfaceAudience.Private
44 public class FaultyFSLog extends FSHLog {
45 public enum FailureType {
46 NONE, APPEND, SYNC
47 }
48 FailureType ft = FailureType.NONE;
49
50 public FaultyFSLog(FileSystem fs, Path rootDir, String logName, Configuration conf)
51 throws IOException {
52 super(fs, rootDir, logName, conf);
53 }
54
55 public void setFailureType(FailureType fType) {
56 this.ft = fType;
57 }
58
59 @Override
60 public void sync(long txid) throws IOException {
61 if (this.ft == FailureType.SYNC) {
62 throw new IOException("sync");
63 }
64 super.sync(txid);
65 }
66
67 @Override
68 public long append(HTableDescriptor htd, HRegionInfo info, WALKey key, WALEdit edits,
69 boolean inMemstore) throws IOException {
70 if (this.ft == FailureType.APPEND) {
71 throw new IOException("append");
72 }
73 return super.append(htd, info, key, edits, inMemstore);
74 }
75 }
76