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.io.asyncfs; 019 020import java.io.IOException; 021import java.util.concurrent.ExecutionException; 022import org.apache.hadoop.fs.FileSystem; 023import org.apache.hadoop.fs.Path; 024import org.apache.hadoop.hbase.HBaseClassTestRule; 025import org.apache.hadoop.hbase.HBaseCommonTestingUtility; 026import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor; 027import org.apache.hadoop.hbase.testclassification.MiscTests; 028import org.apache.hadoop.hbase.testclassification.SmallTests; 029import org.apache.hadoop.hbase.util.CommonFSUtils; 030import org.junit.AfterClass; 031import org.junit.ClassRule; 032import org.junit.Test; 033import org.junit.experimental.categories.Category; 034 035import org.apache.hbase.thirdparty.io.netty.channel.Channel; 036import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; 037import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; 038import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; 039 040@Category({ MiscTests.class, SmallTests.class }) 041public class TestLocalAsyncOutput { 042 043 @ClassRule 044 public static final HBaseClassTestRule CLASS_RULE = 045 HBaseClassTestRule.forClass(TestLocalAsyncOutput.class); 046 047 private static EventLoopGroup GROUP = new NioEventLoopGroup(); 048 049 private static Class<? extends Channel> CHANNEL_CLASS = NioSocketChannel.class; 050 051 private static final HBaseCommonTestingUtility TEST_UTIL = new HBaseCommonTestingUtility(); 052 053 private static StreamSlowMonitor MONITOR; 054 055 @AfterClass 056 public static void tearDownAfterClass() throws Exception { 057 TEST_UTIL.cleanupTestDir(); 058 GROUP.shutdownGracefully().get(); 059 MONITOR = StreamSlowMonitor.create(TEST_UTIL.getConfiguration(), "testMonitor"); 060 } 061 062 @Test 063 public void test() throws IOException, InterruptedException, ExecutionException, 064 CommonFSUtils.StreamLacksCapabilityException { 065 Path f = new Path(TEST_UTIL.getDataTestDir(), "test"); 066 FileSystem fs = FileSystem.getLocal(TEST_UTIL.getConfiguration()); 067 AsyncFSOutput out = AsyncFSOutputHelper.createOutput(fs, f, false, true, 068 fs.getDefaultReplication(f), fs.getDefaultBlockSize(f), GROUP, CHANNEL_CLASS, MONITOR, true); 069 TestFanOutOneBlockAsyncDFSOutput.writeAndVerify(fs, f, out); 070 } 071}