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.regionserver.wal; 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.HBaseClassTestRule; 025import org.apache.hadoop.hbase.HConstants; 026import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor; 027import org.apache.hadoop.hbase.testclassification.MediumTests; 028import org.apache.hadoop.hbase.testclassification.RegionServerTests; 029import org.apache.hadoop.hbase.util.Threads; 030import org.apache.hadoop.hbase.wal.WAL; 031import org.apache.hadoop.hbase.wal.WALFactory; 032import org.junit.AfterClass; 033import org.junit.BeforeClass; 034import org.junit.ClassRule; 035import org.junit.experimental.categories.Category; 036 037import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; 038import org.apache.hbase.thirdparty.io.netty.channel.Channel; 039import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; 040import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; 041import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; 042 043@Category({ RegionServerTests.class, MediumTests.class }) 044public class TestAsyncWALReplay extends AbstractTestWALReplay { 045 046 @ClassRule 047 public static final HBaseClassTestRule CLASS_RULE = 048 HBaseClassTestRule.forClass(TestAsyncWALReplay.class); 049 050 private static EventLoopGroup GROUP; 051 052 private static Class<? extends Channel> CHANNEL_CLASS; 053 054 @BeforeClass 055 public static void setUpBeforeClass() throws Exception { 056 GROUP = new NioEventLoopGroup(1, 057 new ThreadFactoryBuilder().setNameFormat("TestAsyncWALReplay-pool-%d").setDaemon(true) 058 .setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build()); 059 CHANNEL_CLASS = NioSocketChannel.class; 060 Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); 061 conf.set(WALFactory.WAL_PROVIDER, "asyncfs"); 062 AbstractTestWALReplay.setUpBeforeClass(); 063 } 064 065 @AfterClass 066 public static void tearDownAfterClass() throws Exception { 067 AbstractTestWALReplay.tearDownAfterClass(); 068 GROUP.shutdownGracefully(); 069 } 070 071 @Override 072 protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { 073 AsyncFSWAL wal = new AsyncFSWAL(FileSystem.get(c), null, hbaseRootDir, logName, 074 HConstants.HREGION_OLDLOGDIR_NAME, c, null, true, null, null, null, null, GROUP, 075 CHANNEL_CLASS, StreamSlowMonitor.create(c, "monitor")); 076 wal.init(); 077 return wal; 078 } 079}