Search in sources :

Example 1 with BadConfigurationException

use of org.apache.parquet.hadoop.BadConfigurationException in project parquet-mr by apache.

the class KeyToolkit method createAndInitKmsClient.

private static KmsClient createAndInitKmsClient(Configuration configuration, String kmsInstanceID, String kmsInstanceURL, String accessToken) {
    Class<?> kmsClientClass = null;
    KmsClient kmsClient = null;
    try {
        kmsClientClass = ConfigurationUtil.getClassFromConfig(configuration, KMS_CLIENT_CLASS_PROPERTY_NAME, KmsClient.class);
        if (null == kmsClientClass) {
            throw new ParquetCryptoRuntimeException("Unspecified " + KMS_CLIENT_CLASS_PROPERTY_NAME);
        }
        kmsClient = (KmsClient) kmsClientClass.newInstance();
    } catch (InstantiationException | IllegalAccessException | BadConfigurationException e) {
        throw new ParquetCryptoRuntimeException("Could not instantiate KmsClient class: " + kmsClientClass, e);
    }
    kmsClient.initialize(configuration, kmsInstanceID, kmsInstanceURL, accessToken);
    return kmsClient;
}
Also used : ParquetCryptoRuntimeException(org.apache.parquet.crypto.ParquetCryptoRuntimeException) BadConfigurationException(org.apache.parquet.hadoop.BadConfigurationException)

Example 2 with BadConfigurationException

use of org.apache.parquet.hadoop.BadConfigurationException in project parquet-mr by apache.

the class TupleToThriftWriteSupport method init.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public WriteContext init(Configuration configuration) {
    try {
        Class<?> clazz = configuration.getClassByName(className).asSubclass(TBase.class);
        thriftWriteSupport = new ThriftWriteSupport(clazz);
        pigToThrift = new PigToThrift(clazz);
        return thriftWriteSupport.init(configuration);
    } catch (ClassNotFoundException e) {
        throw new BadConfigurationException("The thrift class name was not found: " + className, e);
    } catch (ClassCastException e) {
        throw new BadConfigurationException("The thrift class name should extend TBase: " + className, e);
    }
}
Also used : ThriftWriteSupport(org.apache.parquet.hadoop.thrift.ThriftWriteSupport) BadConfigurationException(org.apache.parquet.hadoop.BadConfigurationException) PigToThrift(com.twitter.elephantbird.pig.util.PigToThrift)

Example 3 with BadConfigurationException

use of org.apache.parquet.hadoop.BadConfigurationException in project parquet-mr by apache.

the class ProtoWriteSupport method init.

@Override
public WriteContext init(Configuration configuration) {
    // if no protobuf descriptor was given in constructor, load descriptor from configuration (set with setProtobufClass)
    if (protoMessage == null) {
        Class<? extends Message> pbClass = configuration.getClass(PB_CLASS_WRITE, null, Message.class);
        if (pbClass != null) {
            protoMessage = pbClass;
        } else {
            String msg = "Protocol buffer class not specified.";
            String hint = " Please use method ProtoParquetOutputFormat.setProtobufClass(...) or other similar method.";
            throw new BadConfigurationException(msg + hint);
        }
    }
    writeSpecsCompliant = configuration.getBoolean(PB_SPECS_COMPLIANT_WRITE, writeSpecsCompliant);
    MessageType rootSchema = new ProtoSchemaConverter(writeSpecsCompliant).convert(protoMessage);
    Descriptor messageDescriptor = Protobufs.getMessageDescriptor(protoMessage);
    validatedMapping(messageDescriptor, rootSchema);
    this.messageWriter = new MessageWriter(messageDescriptor, rootSchema);
    Map<String, String> extraMetaData = new HashMap<>();
    extraMetaData.put(ProtoReadSupport.PB_CLASS, protoMessage.getName());
    extraMetaData.put(ProtoReadSupport.PB_DESCRIPTOR, messageDescriptor.toProto().toString());
    extraMetaData.put(PB_SPECS_COMPLIANT_WRITE, String.valueOf(writeSpecsCompliant));
    return new WriteContext(rootSchema, extraMetaData);
}
Also used : BadConfigurationException(org.apache.parquet.hadoop.BadConfigurationException) Descriptor(com.google.protobuf.Descriptors.Descriptor) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor)

Aggregations

BadConfigurationException (org.apache.parquet.hadoop.BadConfigurationException)3 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 PigToThrift (com.twitter.elephantbird.pig.util.PigToThrift)1 ParquetCryptoRuntimeException (org.apache.parquet.crypto.ParquetCryptoRuntimeException)1 ThriftWriteSupport (org.apache.parquet.hadoop.thrift.ThriftWriteSupport)1