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.procedure; 019 020import java.io.IOException; 021import java.util.Arrays; 022import java.util.List; 023import org.apache.hadoop.conf.Configuration; 024import org.apache.hadoop.hbase.DoNotRetryIOException; 025import org.apache.hadoop.hbase.HConstants; 026import org.apache.hadoop.hbase.TableName; 027import org.apache.hadoop.hbase.master.HMaster; 028import org.apache.hadoop.hbase.testclassification.LargeTests; 029import org.apache.hadoop.hbase.testclassification.MasterTests; 030import org.junit.jupiter.api.Tag; 031import org.junit.jupiter.api.Test; 032 033@Tag(MasterTests.TAG) 034@Tag(LargeTests.TAG) 035public class TestFlushTableProcedureWithDoNotSupportFlushTableMaster 036 extends TestFlushTableProcedureBase { 037 038 @Override 039 protected void addConfiguration(Configuration config) { 040 super.addConfiguration(config); 041 config.set(HConstants.MASTER_IMPL, DoNotSupportFlushTableMaster.class.getName()); 042 } 043 044 @Test 045 public void testFlushFallback() throws IOException { 046 assertTableMemStoreNotEmpty(); 047 TEST_UTIL.getAdmin().flush(TABLE_NAME); 048 assertTableMemStoreEmpty(); 049 } 050 051 @Test 052 public void testSingleColumnFamilyFlushFallback() throws IOException { 053 assertColumnFamilyMemStoreNotEmpty(FAMILY1); 054 TEST_UTIL.getAdmin().flush(TABLE_NAME, FAMILY1); 055 assertColumnFamilyMemStoreEmpty(FAMILY1); 056 } 057 058 @Test 059 public void testMultiColumnFamilyFlushFallback() throws IOException { 060 assertTableMemStoreNotEmpty(); 061 TEST_UTIL.getAdmin().flush(TABLE_NAME, Arrays.asList(FAMILY1, FAMILY2, FAMILY3)); 062 assertTableMemStoreEmpty(); 063 } 064 065 public static final class DoNotSupportFlushTableMaster extends HMaster { 066 067 public DoNotSupportFlushTableMaster(Configuration conf) throws IOException { 068 super(conf); 069 } 070 071 @Override 072 public long flushTable(TableName tableName, List<byte[]> columnFamilies, long nonceGroup, 073 long nonce) throws IOException { 074 throw new DoNotRetryIOException("UnsupportedOperation: flushTable"); 075 } 076 } 077}