Search in sources :

Example 51 with DoNotRetryIOException

use of org.apache.hadoop.hbase.DoNotRetryIOException in project hbase by apache.

the class AbstractTestIPC method testRemoteError.

@Test
public void testRemoteError() throws IOException, ServiceException {
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try (AbstractRpcClient<?> client = createRpcClient(CONF)) {
        rpcServer.start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        stub.error(null, EmptyRequestProto.getDefaultInstance());
    } catch (ServiceException e) {
        LOG.info("Caught expected exception: " + e);
        IOException ioe = ProtobufUtil.handleRemoteException(e);
        assertTrue(ioe instanceof DoNotRetryIOException);
        assertTrue(ioe.getMessage().contains("server error!"));
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) InetSocketAddress(java.net.InetSocketAddress) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) Test(org.junit.Test)

Example 52 with DoNotRetryIOException

use of org.apache.hadoop.hbase.DoNotRetryIOException in project hbase by apache.

the class AbstractTestIPC method testAsyncRemoteError.

@Test
public void testAsyncRemoteError() throws IOException {
    AbstractRpcClient<?> client = createRpcClient(CONF);
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try {
        rpcServer.start();
        Interface stub = newStub(client, rpcServer.getListenerAddress());
        BlockingRpcCallback<EmptyResponseProto> callback = new BlockingRpcCallback<>();
        HBaseRpcController pcrc = new HBaseRpcControllerImpl();
        stub.error(pcrc, EmptyRequestProto.getDefaultInstance(), callback);
        assertNull(callback.get());
        assertTrue(pcrc.failed());
        LOG.info("Caught expected exception: " + pcrc.getFailed());
        IOException ioe = ProtobufUtil.handleRemoteException(pcrc.getFailed());
        assertTrue(ioe instanceof DoNotRetryIOException);
        assertTrue(ioe.getMessage().contains("server error!"));
    } finally {
        client.close();
        rpcServer.stop();
    }
}
Also used : BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) InetSocketAddress(java.net.InetSocketAddress) EmptyResponseProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) Interface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Test(org.junit.Test)

Example 53 with DoNotRetryIOException

use of org.apache.hadoop.hbase.DoNotRetryIOException in project hbase by apache.

the class TestNamespaceAuditor method testRegionOperations.

@Test
public void testRegionOperations() throws Exception {
    String nsp1 = prefix + "_regiontest";
    NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp1).addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "2").addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2").build();
    ADMIN.createNamespace(nspDesc);
    boolean constraintViolated = false;
    final TableName tableOne = TableName.valueOf(nsp1 + TableName.NAMESPACE_DELIM + "table1");
    byte[] columnFamily = Bytes.toBytes("info");
    HTableDescriptor tableDescOne = new HTableDescriptor(tableOne);
    tableDescOne.addFamily(new HColumnDescriptor(columnFamily));
    NamespaceTableAndRegionInfo stateInfo;
    try {
        ADMIN.createTable(tableDescOne, Bytes.toBytes("1"), Bytes.toBytes("1000"), 7);
    } catch (Exception exp) {
        assertTrue(exp instanceof DoNotRetryIOException);
        LOG.info(exp);
        constraintViolated = true;
    } finally {
        assertTrue(constraintViolated);
    }
    assertFalse(ADMIN.tableExists(tableOne));
    // This call will pass.
    ADMIN.createTable(tableDescOne);
    Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration());
    Table htable = connection.getTable(tableOne);
    UTIL.loadNumericRows(htable, Bytes.toBytes("info"), 1, 1000);
    ADMIN.flush(tableOne);
    stateInfo = getNamespaceState(nsp1);
    assertEquals(1, stateInfo.getTables().size());
    assertEquals(1, stateInfo.getRegionCount());
    restartMaster();
    HRegion actualRegion = UTIL.getHBaseCluster().getRegions(tableOne).get(0);
    CustomObserver observer = (CustomObserver) actualRegion.getCoprocessorHost().findCoprocessor(CustomObserver.class.getName());
    assertNotNull(observer);
    ADMIN.split(tableOne, Bytes.toBytes("500"));
    observer.postSplit.await();
    assertEquals(2, ADMIN.getTableRegions(tableOne).size());
    actualRegion = UTIL.getHBaseCluster().getRegions(tableOne).get(0);
    observer = (CustomObserver) actualRegion.getCoprocessorHost().findCoprocessor(CustomObserver.class.getName());
    assertNotNull(observer);
    //Before we go on split, we should remove all reference store files.
    ADMIN.compact(tableOne);
    observer.postCompact.await();
    ADMIN.split(tableOne, getSplitKey(actualRegion.getRegionInfo().getStartKey(), actualRegion.getRegionInfo().getEndKey()));
    observer.postSplit.await();
    // Make sure no regions have been added.
    List<HRegionInfo> hris = ADMIN.getTableRegions(tableOne);
    assertEquals(2, hris.size());
    htable.close();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Connection(org.apache.hadoop.hbase.client.Connection) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) QuotaExceededException(org.apache.hadoop.hbase.quotas.QuotaExceededException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) Test(org.junit.Test)

Example 54 with DoNotRetryIOException

use of org.apache.hadoop.hbase.DoNotRetryIOException in project hbase by apache.

the class RequestConverter method buildNoDataRegionAction.

/**
   * Create a protocol buffer MultiRequest for row mutations that does not hold data.  Data/Cells
   * are carried outside of protobuf.  Return references to the Cells in <code>cells</code> param.
    * Does not propagate Action absolute position.  Does not set atomic action on the created
   * RegionAtomic.  Caller should do that if wanted.
   * @param regionName
   * @param rowMutations
   * @param cells Return in here a list of Cells as CellIterable.
   * @return a region mutation minus data
   * @throws IOException
   */
public static RegionAction.Builder buildNoDataRegionAction(final byte[] regionName, final RowMutations rowMutations, final List<CellScannable> cells, final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder) throws IOException {
    for (Mutation mutation : rowMutations.getMutations()) {
        MutationType type = null;
        if (mutation instanceof Put) {
            type = MutationType.PUT;
        } else if (mutation instanceof Delete) {
            type = MutationType.DELETE;
        } else {
            throw new DoNotRetryIOException("RowMutations supports only put and delete, not " + mutation.getClass().getName());
        }
        mutationBuilder.clear();
        MutationProto mp = ProtobufUtil.toMutationNoData(type, mutation, mutationBuilder);
        cells.add(mutation);
        actionBuilder.clear();
        regionActionBuilder.addAction(actionBuilder.setMutation(mp).build());
    }
    return regionActionBuilder;
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Mutation(org.apache.hadoop.hbase.client.Mutation) Put(org.apache.hadoop.hbase.client.Put) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)

Example 55 with DoNotRetryIOException

use of org.apache.hadoop.hbase.DoNotRetryIOException in project hbase by apache.

the class RequestConverter method buildRegionAction.

/**
   * Create a protocol buffer MultiRequest for row mutations.
   * Does not propagate Action absolute position.  Does not set atomic action on the created
   * RegionAtomic.  Caller should do that if wanted.
   * @param regionName
   * @param rowMutations
   * @return a data-laden RegionMutation.Builder
   * @throws IOException
   */
public static RegionAction.Builder buildRegionAction(final byte[] regionName, final RowMutations rowMutations) throws IOException {
    RegionAction.Builder builder = getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
    ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
    MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
    for (Mutation mutation : rowMutations.getMutations()) {
        MutationType mutateType = null;
        if (mutation instanceof Put) {
            mutateType = MutationType.PUT;
        } else if (mutation instanceof Delete) {
            mutateType = MutationType.DELETE;
        } else {
            throw new DoNotRetryIOException("RowMutations supports only put and delete, not " + mutation.getClass().getName());
        }
        mutationBuilder.clear();
        MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
        actionBuilder.clear();
        actionBuilder.setMutation(mp);
        builder.addAction(actionBuilder.build());
    }
    return builder;
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) Action(org.apache.hadoop.hbase.client.Action) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) Mutation(org.apache.hadoop.hbase.client.Mutation) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) Put(org.apache.hadoop.hbase.client.Put)

Aggregations

DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)77 IOException (java.io.IOException)28 Cell (org.apache.hadoop.hbase.Cell)18 ArrayList (java.util.ArrayList)12 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)12 MutationType (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType)12 TableName (org.apache.hadoop.hbase.TableName)11 InterruptedIOException (java.io.InterruptedIOException)10 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)10 Delete (org.apache.hadoop.hbase.client.Delete)10 Put (org.apache.hadoop.hbase.client.Put)10 Test (org.junit.Test)10 AccessDeniedException (org.apache.hadoop.hbase.security.AccessDeniedException)9 User (org.apache.hadoop.hbase.security.User)8 Mutation (org.apache.hadoop.hbase.client.Mutation)7 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)7 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)6 NameBytesPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair)6 ByteBufferCell (org.apache.hadoop.hbase.ByteBufferCell)5 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)5