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;
}
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);
}
}
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);
}
Aggregations