Search in sources :

Example 36 with DoNotRetryIOException

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

the class TestCreateTableProcedure method testCreateWithoutColumnFamily.

@Test(timeout = 60000)
public void testCreateWithoutColumnFamily() throws Exception {
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    final TableName tableName = TableName.valueOf(name.getMethodName());
    // create table with 0 families will fail
    final HTableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName);
    // disable sanity check
    htd.setConfiguration("hbase.table.sanity.checks", Boolean.FALSE.toString());
    final HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, null);
    long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
    final ProcedureInfo result = procExec.getResult(procId);
    assertEquals(true, result.isFailed());
    Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
    assertTrue("expected DoNotRetryIOException, got " + cause, cause instanceof DoNotRetryIOException);
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) Test(org.junit.Test)

Example 37 with DoNotRetryIOException

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

the class TestSplitTableRegionProcedure method testInvalidSplitKey.

@Test(timeout = 60000)
public void testInvalidSplitKey() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    HRegionInfo[] regions = MasterProcedureTestingUtility.createTable(procExec, tableName, null, ColumnFamilyName1, ColumnFamilyName2);
    insertData(tableName);
    assertTrue("not able to find a splittable region", regions != null);
    assertTrue("not able to find a splittable region", regions.length == 1);
    // Split region of the table with null split key
    try {
        long procId1 = procExec.submitProcedure(new SplitTableRegionProcedure(procExec.getEnvironment(), regions[0], null));
        ProcedureTestingUtility.waitProcedure(procExec, procId1);
        fail("unexpected procedure start with invalid split-key");
    } catch (DoNotRetryIOException e) {
        LOG.debug("Expected Split procedure construction failure: " + e.getMessage());
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Test(org.junit.Test)

Example 38 with DoNotRetryIOException

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

the class BaseScannerRegionObserver method throwIfScanOutOfRegion.

private static void throwIfScanOutOfRegion(Scan scan, Region region) throws DoNotRetryIOException {
    boolean isLocalIndex = ScanUtil.isLocalIndex(scan);
    byte[] lowerInclusiveScanKey = scan.getStartRow();
    byte[] upperExclusiveScanKey = scan.getStopRow();
    byte[] lowerInclusiveRegionKey = region.getRegionInfo().getStartKey();
    byte[] upperExclusiveRegionKey = region.getRegionInfo().getEndKey();
    boolean isStaleRegionBoundaries;
    if (isLocalIndex) {
        byte[] expectedUpperRegionKey = scan.getAttribute(EXPECTED_UPPER_REGION_KEY) == null ? scan.getStopRow() : scan.getAttribute(EXPECTED_UPPER_REGION_KEY);
        isStaleRegionBoundaries = expectedUpperRegionKey != null && Bytes.compareTo(upperExclusiveRegionKey, expectedUpperRegionKey) != 0;
    } else {
        isStaleRegionBoundaries = Bytes.compareTo(lowerInclusiveScanKey, lowerInclusiveRegionKey) < 0 || (Bytes.compareTo(upperExclusiveScanKey, upperExclusiveRegionKey) > 0 && upperExclusiveRegionKey.length != 0) || (upperExclusiveRegionKey.length != 0 && upperExclusiveScanKey.length == 0);
    }
    if (isStaleRegionBoundaries) {
        Exception cause = new StaleRegionBoundaryCacheException(region.getRegionInfo().getTable().getNameAsString());
        throw new DoNotRetryIOException(cause.getMessage(), cause);
    }
    if (isLocalIndex) {
        ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey);
    }
}
Also used : DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) StaleRegionBoundaryCacheException(org.apache.phoenix.schema.StaleRegionBoundaryCacheException) StaleRegionBoundaryCacheException(org.apache.phoenix.schema.StaleRegionBoundaryCacheException) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException)

Example 39 with DoNotRetryIOException

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

the class MetaDataEndpointImpl method getVersion.

@Override
public void getVersion(RpcController controller, GetVersionRequest request, RpcCallback<GetVersionResponse> done) {
    GetVersionResponse.Builder builder = GetVersionResponse.newBuilder();
    Configuration config = env.getConfiguration();
    boolean isTablesMappingEnabled = SchemaUtil.isNamespaceMappingEnabled(PTableType.TABLE, new ReadOnlyProps(config.iterator()));
    if (isTablesMappingEnabled && PhoenixDatabaseMetaData.MIN_NAMESPACE_MAPPED_PHOENIX_VERSION > request.getClientVersion()) {
        logger.error("Old client is not compatible when" + " system tables are upgraded to map to namespace");
        ProtobufUtil.setControllerException(controller, ServerUtil.createIOException(SchemaUtil.getPhysicalHBaseTableName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, isTablesMappingEnabled, PTableType.SYSTEM).getString(), new DoNotRetryIOException("Old client is not compatible when" + " system tables are upgraded to map to namespace")));
    }
    long version = MetaDataUtil.encodeVersion(env.getHBaseVersion(), config);
    builder.setVersion(version);
    done.run(builder.build());
}
Also used : ReadOnlyProps(org.apache.phoenix.util.ReadOnlyProps) Configuration(org.apache.hadoop.conf.Configuration) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) GetVersionResponse(org.apache.phoenix.coprocessor.generated.MetaDataProtos.GetVersionResponse)

Example 40 with DoNotRetryIOException

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

the class TupleUtil method getConcatenatedValue.

/** Concatenate results evaluated against a list of expressions
     * 
     * @param result the tuple for expression evaluation
     * @param expressions
     * @return the concatenated byte array as ImmutableBytesWritable
     * @throws IOException
     */
public static ImmutableBytesPtr getConcatenatedValue(Tuple result, List<Expression> expressions) throws IOException {
    ImmutableBytesPtr value = new ImmutableBytesPtr(ByteUtil.EMPTY_BYTE_ARRAY);
    Expression expression = expressions.get(0);
    boolean evaluated = expression.evaluate(result, value);
    if (expressions.size() == 1) {
        if (!evaluated) {
            value.set(ByteUtil.EMPTY_BYTE_ARRAY);
        }
        return value;
    } else {
        TrustedByteArrayOutputStream output = new TrustedByteArrayOutputStream(value.getLength() * expressions.size());
        try {
            if (evaluated) {
                output.write(value.get(), value.getOffset(), value.getLength());
            }
            for (int i = 1; i < expressions.size(); i++) {
                if (!expression.getDataType().isFixedWidth()) {
                    output.write(SchemaUtil.getSeparatorByte(true, value.getLength() == 0, expression));
                }
                expression = expressions.get(i);
                if (expression.evaluate(result, value)) {
                    output.write(value.get(), value.getOffset(), value.getLength());
                } else if (i < expressions.size() - 1 && expression.getDataType().isFixedWidth()) {
                    // converted to a variable length type (i.e. DECIMAL) to allow an empty byte array to represent null.
                    throw new DoNotRetryIOException("Non terminating null value found for fixed width expression (" + expression + ") in row: " + result);
                }
            }
            // Write trailing separator if last expression was variable length and descending
            if (!expression.getDataType().isFixedWidth() && SchemaUtil.getSeparatorByte(true, value.getLength() == 0, expression) == QueryConstants.DESC_SEPARATOR_BYTE) {
                output.write(QueryConstants.DESC_SEPARATOR_BYTE);
            }
            byte[] outputBytes = output.getBuffer();
            value.set(outputBytes, 0, output.size());
            return value;
        } finally {
            output.close();
        }
    }
}
Also used : Expression(org.apache.phoenix.expression.Expression) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ImmutableBytesPtr(org.apache.phoenix.hbase.index.util.ImmutableBytesPtr)

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