HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / wal / FaultyFSLog.java
blob3afafa16982ed7d0cf169fbe1b00d02704c33ed4
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 package org.apache.hadoop.hbase.wal;
22 import java.io.IOException;
23 import org.apache.hadoop.conf.Configuration;
24 import org.apache.hadoop.fs.FileSystem;
25 import org.apache.hadoop.fs.Path;
26 import org.apache.hadoop.hbase.client.RegionInfo;
27 import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
28 import org.apache.yetus.audience.InterfaceAudience;
30 // imports for things that haven't moved yet
32 /**
33 * This is a utility class, used by tests, which fails operation specified by FailureType enum
35 @InterfaceAudience.Private
36 public class FaultyFSLog extends FSHLog {
37 public enum FailureType {
38 NONE, APPEND, SYNC
40 FailureType ft = FailureType.NONE;
42 public FaultyFSLog(FileSystem fs, Path rootDir, String logName, Configuration conf)
43 throws IOException {
44 super(fs, rootDir, logName, conf);
47 public void setFailureType(FailureType fType) {
48 this.ft = fType;
51 @Override
52 protected void doSync(long txid, boolean forceSync) throws IOException {
53 if (this.ft == FailureType.SYNC) {
54 throw new IOException("sync");
56 super.doSync(txid, forceSync);
59 @Override
60 protected long append(RegionInfo info, WALKeyImpl key, WALEdit edits, boolean inMemstore)
61 throws IOException {
62 if (this.ft == FailureType.APPEND) {
63 throw new IOException("append");
65 return super.append(info, key, edits, inMemstore);