Search in sources :

Example 1 with KafkaConnectConfigs

use of org.apache.hudi.connect.writers.KafkaConnectConfigs in project hudi by apache.

the class KafkaConnectUtils method getDefaultHadoopConf.

/**
 * Returns the default Hadoop Configuration.
 *
 * @return
 */
public static Configuration getDefaultHadoopConf(KafkaConnectConfigs connectConfigs) {
    Configuration hadoopConf = new Configuration();
    // add hadoop config files
    if (!StringUtils.isNullOrEmpty(connectConfigs.getHadoopConfDir()) || !StringUtils.isNullOrEmpty(connectConfigs.getHadoopConfHome())) {
        try {
            List<Path> configFiles = getHadoopConfigFiles(connectConfigs.getHadoopConfDir(), connectConfigs.getHadoopConfHome());
            configFiles.forEach(f -> hadoopConf.addResource(new org.apache.hadoop.fs.Path(f.toAbsolutePath().toUri())));
        } catch (Exception e) {
            throw new HoodieException("Failed to read hadoop configuration!", e);
        }
    } else {
        DEFAULT_HADOOP_CONF_FILES.forEach(f -> hadoopConf.addResource(new org.apache.hadoop.fs.Path(f.toAbsolutePath().toUri())));
    }
    connectConfigs.getProps().keySet().stream().filter(prop -> {
        // configuration items before passing to hadoop/hive configs
        return !prop.toString().startsWith(HOODIE_CONF_PREFIX);
    }).forEach(prop -> {
        hadoopConf.set(prop.toString(), connectConfigs.getProps().get(prop.toString()).toString());
    });
    return hadoopConf;
}
Also used : Path(java.nio.file.Path) Arrays(java.util.Arrays) CustomKeyGenerator(org.apache.hudi.keygen.CustomKeyGenerator) MessageDigest(java.security.MessageDigest) HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) HoodieException(org.apache.hudi.exception.HoodieException) Option(org.apache.hudi.common.util.Option) SlashEncodedDayPartitionValueExtractor(org.apache.hudi.hive.SlashEncodedDayPartitionValueExtractor) BaseKeyGenerator(org.apache.hudi.keygen.BaseKeyGenerator) ArrayList(java.util.ArrayList) AdminClient(org.apache.kafka.clients.admin.AdminClient) Logger(org.apache.log4j.Logger) HoodieTableType(org.apache.hudi.common.model.HoodieTableType) StringUtils(org.apache.hudi.common.util.StringUtils) KeyGenerator(org.apache.hudi.keygen.KeyGenerator) DescribeTopicsResult(org.apache.kafka.clients.admin.DescribeTopicsResult) HoodieTableMetaClient(org.apache.hudi.common.table.HoodieTableMetaClient) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map) TopicDescription(org.apache.kafka.clients.admin.TopicDescription) CustomAvroKeyGenerator(org.apache.hudi.keygen.CustomAvroKeyGenerator) SerializationUtils(org.apache.hudi.common.util.SerializationUtils) Path(java.nio.file.Path) HoodieActiveTimeline(org.apache.hudi.common.table.timeline.HoodieActiveTimeline) HoodieTimeline(org.apache.hudi.common.table.timeline.HoodieTimeline) Properties(java.util.Properties) TypedProperties(org.apache.hudi.common.config.TypedProperties) Files(java.nio.file.Files) ControlMessage(org.apache.hudi.connect.ControlMessage) HiveSyncConfig(org.apache.hudi.hive.HiveSyncConfig) KeyGeneratorOptions(org.apache.hudi.keygen.constant.KeyGeneratorOptions) HoodieCommitMetadata(org.apache.hudi.common.model.HoodieCommitMetadata) IOException(java.io.IOException) KafkaFuture(org.apache.kafka.common.KafkaFuture) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) ByteString(com.google.protobuf.ByteString) Objects(java.util.Objects) WriteStatus(org.apache.hudi.client.WriteStatus) List(java.util.List) FileVisitOption(java.nio.file.FileVisitOption) Paths(java.nio.file.Paths) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) LogManager(org.apache.log4j.LogManager) Collections(java.util.Collections) KafkaConnectConfigs(org.apache.hudi.connect.writers.KafkaConnectConfigs) Configuration(org.apache.hadoop.conf.Configuration) HoodieException(org.apache.hudi.exception.HoodieException) HoodieException(org.apache.hudi.exception.HoodieException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with KafkaConnectConfigs

use of org.apache.hudi.connect.writers.KafkaConnectConfigs in project hudi by apache.

the class TestHdfsConfiguration method testKafkaConfig.

@Test
public void testKafkaConfig() throws Exception {
    KafkaConnectConfigs connectConfigs = KafkaConnectConfigs.newBuilder().withHadoopHome("src/test/resources/hadoop_home").build();
    List<Path> paths = KafkaConnectUtils.getHadoopConfigFiles(connectConfigs.getHadoopConfDir(), connectConfigs.getHadoopConfHome());
    assertEquals(paths.size(), 2);
    assertTrue(checkFiles(paths));
}
Also used : Path(java.nio.file.Path) KafkaConnectConfigs(org.apache.hudi.connect.writers.KafkaConnectConfigs) Test(org.junit.jupiter.api.Test)

Aggregations

Path (java.nio.file.Path)2 KafkaConnectConfigs (org.apache.hudi.connect.writers.KafkaConnectConfigs)2 ByteString (com.google.protobuf.ByteString)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 FileVisitOption (java.nio.file.FileVisitOption)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 Configuration (org.apache.hadoop.conf.Configuration)1 WriteStatus (org.apache.hudi.client.WriteStatus)1