001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master; 019 020import java.io.IOException; 021import org.apache.hadoop.conf.Configuration; 022import org.apache.hadoop.fs.FileSystem; 023import org.apache.hadoop.fs.Path; 024import org.apache.hadoop.hbase.client.Mutation; 025import org.apache.hadoop.hbase.client.RegionInfo; 026import org.apache.hadoop.hbase.client.TableDescriptor; 027import org.apache.hadoop.hbase.master.region.MasterRegionFactory; 028import org.apache.hadoop.hbase.regionserver.HRegion; 029import org.apache.hadoop.hbase.regionserver.HRegionFileSystem; 030import org.apache.hadoop.hbase.regionserver.OperationStatus; 031import org.apache.hadoop.hbase.regionserver.RegionServerServices; 032import org.apache.hadoop.hbase.testclassification.LargeTests; 033import org.apache.hadoop.hbase.testclassification.MasterTests; 034import org.apache.hadoop.hbase.wal.WAL; 035import org.junit.jupiter.api.AfterAll; 036import org.junit.jupiter.api.BeforeAll; 037import org.junit.jupiter.api.Tag; 038 039/** 040 * MasterRegion related test that ensures the operations continue even when Procedure state update 041 * encounters non-retriable IO errors. 042 */ 043@Tag(MasterTests.TAG) 044@Tag(LargeTests.TAG) 045public class TestMasterRegionMutation2 extends AbstractTestMasterRegionMutation { 046 047 @BeforeAll 048 public static void setUpBeforeClass() throws Exception { 049 AbstractTestMasterRegionMutation.setUpBeforeClass(3, TestRegion.class); 050 } 051 052 @AfterAll 053 public static void tearDownAfterClass() throws Exception { 054 AbstractTestMasterRegionMutation.tearDownAfterClass(); 055 } 056 057 public static class TestRegion extends HRegion { 058 059 public TestRegion(Path tableDir, WAL wal, FileSystem fs, Configuration confParam, 060 RegionInfo regionInfo, TableDescriptor htd, RegionServerServices rsServices) { 061 super(tableDir, wal, fs, confParam, regionInfo, htd, rsServices); 062 } 063 064 public TestRegion(HRegionFileSystem fs, WAL wal, Configuration confParam, TableDescriptor htd, 065 RegionServerServices rsServices) { 066 super(fs, wal, confParam, htd, rsServices); 067 } 068 069 @Override 070 public OperationStatus[] batchMutate(Mutation[] mutations, boolean atomic, long nonceGroup, 071 long nonce) throws IOException { 072 if ( 073 MasterRegionFactory.TABLE_NAME.equals(getTableDescriptor().getTableName()) 074 && ERROR_OUT.get() 075 ) { 076 ERROR_OUT.set(false); 077 throw new IOException("test error"); 078 } 079 return super.batchMutate(mutations, atomic, nonceGroup, nonce); 080 } 081 } 082 083}