Search in sources :

Example 6 with EventLoop

use of org.apache.hbase.thirdparty.io.netty.channel.EventLoop in project hbase by apache.

the class TestFanOutOneBlockAsyncDFSOutput method testHeartbeat.

@Test
public void testHeartbeat() throws IOException, InterruptedException, ExecutionException {
    Path f = new Path("/" + name.getMethodName());
    EventLoop eventLoop = EVENT_LOOP_GROUP.next();
    FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR);
    Thread.sleep(READ_TIMEOUT_MS * 2);
    // the connection to datanode should still alive.
    writeAndVerify(FS, f, out);
}
Also used : Path(org.apache.hadoop.fs.Path) EventLoop(org.apache.hbase.thirdparty.io.netty.channel.EventLoop) Test(org.junit.Test)

Example 7 with EventLoop

use of org.apache.hbase.thirdparty.io.netty.channel.EventLoop in project hbase by apache.

the class AsyncFSWAL method doShutdown.

@Override
protected void doShutdown() throws IOException {
    waitForSafePoint();
    closeWriter(this.writer, getOldPath());
    this.writer = null;
    closeExecutor.shutdown();
    try {
        if (!closeExecutor.awaitTermination(waitOnShutdownInSeconds, TimeUnit.SECONDS)) {
            LOG.error("We have waited " + waitOnShutdownInSeconds + " seconds but" + " the close of async writer doesn't complete." + "Please check the status of underlying filesystem" + " or increase the wait time by the config \"" + ASYNC_WAL_WAIT_ON_SHUTDOWN_IN_SECONDS + "\"");
        }
    } catch (InterruptedException e) {
        LOG.error("The wait for close of async writer is interrupted");
        Thread.currentThread().interrupt();
    }
    IOException error = new IOException("WAL has been closed");
    long nextCursor = waitingConsumePayloadsGatingSequence.get() + 1;
    // drain all the pending sync requests
    for (long cursorBound = waitingConsumePayloads.getCursor(); nextCursor <= cursorBound; nextCursor++) {
        if (!waitingConsumePayloads.isPublished(nextCursor)) {
            break;
        }
        RingBufferTruck truck = waitingConsumePayloads.get(nextCursor);
        switch(truck.type()) {
            case SYNC:
                syncFutures.add(truck.unloadSync());
                break;
            default:
                break;
        }
    }
    // and fail them
    syncFutures.forEach(f -> markFutureDoneAndOffer(f, f.getTxid(), error));
    if (!(consumeExecutor instanceof EventLoop)) {
        consumeExecutor.shutdown();
    }
}
Also used : EventLoop(org.apache.hbase.thirdparty.io.netty.channel.EventLoop) IOException(java.io.IOException)

Example 8 with EventLoop

use of org.apache.hbase.thirdparty.io.netty.channel.EventLoop in project hbase by apache.

the class TestFanOutOneBlockAsyncDFSOutput method testExcludeFailedConnectToDatanode.

@Test
public void testExcludeFailedConnectToDatanode() throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InterruptedException, NoSuchFieldException {
    Field xceiverServerDaemonField = DataNode.class.getDeclaredField("dataXceiverServer");
    xceiverServerDaemonField.setAccessible(true);
    Class<?> xceiverServerClass = Class.forName("org.apache.hadoop.hdfs.server.datanode.DataXceiverServer");
    Method numPeersMethod = xceiverServerClass.getDeclaredMethod("getNumPeers");
    numPeersMethod.setAccessible(true);
    // make one datanode broken
    DataNodeProperties dnProp = CLUSTER.stopDataNode(0);
    Path f = new Path("/test");
    EventLoop eventLoop = EVENT_LOOP_GROUP.next();
    ExcludeDatanodeManager excludeDatanodeManager = new ExcludeDatanodeManager(HBaseConfiguration.create());
    StreamSlowMonitor streamSlowDNsMonitor = excludeDatanodeManager.getStreamSlowMonitor("testMonitor");
    assertEquals(0, excludeDatanodeManager.getExcludeDNs().size());
    try (FanOutOneBlockAsyncDFSOutput output = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, streamSlowDNsMonitor)) {
        // should exclude the dead dn when retry so here we only have 2 DNs in pipeline
        assertEquals(2, output.getPipeline().length);
        assertEquals(1, excludeDatanodeManager.getExcludeDNs().size());
    } finally {
        CLUSTER.restartDataNode(dnProp);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Field(java.lang.reflect.Field) EventLoop(org.apache.hbase.thirdparty.io.netty.channel.EventLoop) StreamSlowMonitor(org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor) DataNodeProperties(org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties) Method(java.lang.reflect.Method) ExcludeDatanodeManager(org.apache.hadoop.hbase.io.asyncfs.monitor.ExcludeDatanodeManager) Test(org.junit.Test)

Example 9 with EventLoop

use of org.apache.hbase.thirdparty.io.netty.channel.EventLoop in project hbase by apache.

the class TestFanOutOneBlockAsyncDFSOutput method testWriteLargeChunk.

@Test
public void testWriteLargeChunk() throws IOException, InterruptedException, ExecutionException {
    Path f = new Path("/" + name.getMethodName());
    EventLoop eventLoop = EVENT_LOOP_GROUP.next();
    FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3, 1024 * 1024 * 1024, eventLoop, CHANNEL_CLASS, MONITOR);
    byte[] b = new byte[50 * 1024 * 1024];
    ThreadLocalRandom.current().nextBytes(b);
    out.write(b);
    out.flush(false);
    assertEquals(b.length, out.flush(false).get().longValue());
    out.close();
    assertEquals(b.length, FS.getFileStatus(f).getLen());
    byte[] actual = new byte[b.length];
    try (FSDataInputStream in = FS.open(f)) {
        in.readFully(actual);
    }
    assertArrayEquals(b, actual);
}
Also used : Path(org.apache.hadoop.fs.Path) EventLoop(org.apache.hbase.thirdparty.io.netty.channel.EventLoop) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) Test(org.junit.Test)

Example 10 with EventLoop

use of org.apache.hbase.thirdparty.io.netty.channel.EventLoop in project hbase by apache.

the class TestFanOutOneBlockAsyncDFSOutput method test.

@Test
public void test() throws IOException, InterruptedException, ExecutionException {
    Path f = new Path("/" + name.getMethodName());
    EventLoop eventLoop = EVENT_LOOP_GROUP.next();
    FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR);
    writeAndVerify(FS, f, out);
}
Also used : Path(org.apache.hadoop.fs.Path) EventLoop(org.apache.hbase.thirdparty.io.netty.channel.EventLoop) Test(org.junit.Test)

Aggregations

EventLoop (org.apache.hbase.thirdparty.io.netty.channel.EventLoop)11 Path (org.apache.hadoop.fs.Path)8 Test (org.junit.Test)8 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)2 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)2 DataNodeProperties (org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)1 ExcludeDatanodeManager (org.apache.hadoop.hbase.io.asyncfs.monitor.ExcludeDatanodeManager)1 StreamSlowMonitor (org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1 DefaultEventLoop (org.apache.hbase.thirdparty.io.netty.channel.DefaultEventLoop)1 NioEventLoopGroup (org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup)1 BeforeClass (org.junit.BeforeClass)1