Search in sources :

Example 1 with AsyncClusterConnection

use of org.apache.hadoop.hbase.client.AsyncClusterConnection in project hbase by apache.

the class HBaseTestingUtil method closeConnection.

public void closeConnection() throws IOException {
    if (hbaseAdmin != null) {
        Closeables.close(hbaseAdmin, true);
        hbaseAdmin = null;
    }
    AsyncClusterConnection asyncConnection = this.asyncConnection.getAndSet(null);
    if (asyncConnection != null) {
        Closeables.close(asyncConnection, true);
    }
}
Also used : AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection)

Example 2 with AsyncClusterConnection

use of org.apache.hadoop.hbase.client.AsyncClusterConnection in project hbase by apache.

the class ReplicationSink method getConnection.

private AsyncClusterConnection getConnection() throws IOException {
    // See https://en.wikipedia.org/wiki/Double-checked_locking
    AsyncClusterConnection connection = sharedConn;
    if (connection == null) {
        synchronized (sharedConnLock) {
            connection = sharedConn;
            if (connection == null) {
                connection = ClusterConnectionFactory.createAsyncClusterConnection(conf, null, UserProvider.instantiate(conf).getCurrent());
                sharedConn = connection;
            }
        }
    }
    return connection;
}
Also used : AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection)

Example 3 with AsyncClusterConnection

use of org.apache.hadoop.hbase.client.AsyncClusterConnection in project hbase by apache.

the class TestBulkLoadHFilesSplitRecovery method testBulkLoadPhaseFailure.

/**
 * Test that shows that exception thrown from the RS side will result in an exception on the
 * LIHFile client.
 */
@Test(expected = IOException.class)
public void testBulkLoadPhaseFailure() throws Exception {
    final TableName table = TableName.valueOf(name.getMethodName());
    final AtomicInteger attemptedCalls = new AtomicInteger();
    Configuration conf = new Configuration(util.getConfiguration());
    conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
    BulkLoadHFilesTool loader = new BulkLoadHFilesTool(conf) {

        @Override
        protected void bulkLoadPhase(AsyncClusterConnection conn, TableName tableName, Deque<LoadQueueItem> queue, Multimap<ByteBuffer, LoadQueueItem> regionGroups, boolean copyFiles, Map<LoadQueueItem, ByteBuffer> item2RegionMap) throws IOException {
            AsyncClusterConnection c = attemptedCalls.incrementAndGet() == 1 ? mockAndInjectError(conn) : conn;
            super.bulkLoadPhase(c, tableName, queue, regionGroups, copyFiles, item2RegionMap);
        }
    };
    Path dir = buildBulkFiles(table, 1);
    loader.bulkLoad(table, dir);
}
Also used : Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) Multimap(org.apache.hbase.thirdparty.com.google.common.collect.Multimap) Configuration(org.apache.hadoop.conf.Configuration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection) Deque(java.util.Deque) Map(java.util.Map) Test(org.junit.Test)

Example 4 with AsyncClusterConnection

use of org.apache.hadoop.hbase.client.AsyncClusterConnection in project hbase by apache.

the class HBaseTestingUtility method closeConnection.

public void closeConnection() throws IOException {
    if (hbaseAdmin != null) {
        Closeables.close(hbaseAdmin, true);
        hbaseAdmin = null;
    }
    AsyncClusterConnection asyncConnection = this.asyncConnection.getAndSet(null);
    if (asyncConnection != null) {
        Closeables.close(asyncConnection, true);
    }
}
Also used : AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection)

Example 5 with AsyncClusterConnection

use of org.apache.hadoop.hbase.client.AsyncClusterConnection in project hbase by apache.

the class TestSecureBulkLoadManager method doBulkloadWithoutRetry.

private void doBulkloadWithoutRetry(Path dir) throws Exception {
    BulkLoadHFilesTool h = new BulkLoadHFilesTool(conf) {

        @Override
        protected void bulkLoadPhase(AsyncClusterConnection conn, TableName tableName, Deque<LoadQueueItem> queue, Multimap<ByteBuffer, LoadQueueItem> regionGroups, boolean copyFiles, Map<LoadQueueItem, ByteBuffer> item2RegionMap) throws IOException {
            super.bulkLoadPhase(conn, tableName, queue, regionGroups, copyFiles, item2RegionMap);
            // throw exception to avoid retry
            throw new MyExceptionToAvoidRetry();
        }
    };
    try {
        h.bulkLoad(TABLE, dir);
        Assert.fail("MyExceptionToAvoidRetry is expected");
    } catch (MyExceptionToAvoidRetry e) {
    // expected
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Multimap(org.apache.hbase.thirdparty.com.google.common.collect.Multimap) BulkLoadHFilesTool(org.apache.hadoop.hbase.tool.BulkLoadHFilesTool) AsyncClusterConnection(org.apache.hadoop.hbase.client.AsyncClusterConnection) Deque(java.util.Deque) Map(java.util.Map)

Aggregations

AsyncClusterConnection (org.apache.hadoop.hbase.client.AsyncClusterConnection)14 TableName (org.apache.hadoop.hbase.TableName)9 Path (org.apache.hadoop.fs.Path)8 Multimap (org.apache.hbase.thirdparty.com.google.common.collect.Multimap)8 Test (org.junit.Test)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Deque (java.util.Deque)6 Map (java.util.Map)6 IOException (java.io.IOException)2 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)2 Collection (java.util.Collection)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 Table (org.apache.hadoop.hbase.client.Table)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 BulkLoadHFilesTool (org.apache.hadoop.hbase.tool.BulkLoadHFilesTool)1 Entry (org.apache.hadoop.hbase.wal.WAL.Entry)1 WALEdit (org.apache.hadoop.hbase.wal.WALEdit)1