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