org.apache.kafka.common.config.ConfigDef Java Examples

The following examples show how to use org.apache.kafka.common.config.ConfigDef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonSinkClickHouseConnector.java    From kafka-connectors with Apache License 2.0 6 votes vote down vote up
@Override
public Config validate(Map<String, String> connectorConfigs) {
    ConfigDef configDef = config();
    Map<String, ConfigValue> configValues = ClickHouseConfigDef.emptyValidate(connectorConfigs, configDef);
    JdbcDataSource dataSource = ClickHouseConfigDef.clickHouseConnectValidate(configValues);
    String sinkDb = connectorConfigs.get(CLICKHOUSE_SINK_DATABASE);
    ConfigValue sinkTablesVal = configValues.get(CLICKHOUSE_SINK_TABLES);
    ConfigValue sinkLocalTablesVal = configValues.get(CLICKHOUSE_SINK_LOCAL_TABLES);
    String topics = connectorConfigs.get(TOPICS);

    validateTables(sinkTablesVal, sinkLocalTablesVal, topics);

    ClickHouseConfigDef.clusterTableExist(dataSource, sinkTablesVal, sinkDb);
    ClickHouseConfigDef.localTableExist(dataSource, sinkLocalTablesVal, sinkDb);
    ClickHouseConfigDef.validateSinkDateColumns(configValues, dataSource, sinkDb, sinkTablesVal);
    ClickHouseConfigDef.validateSourceDateColumns(configValues, dataSource, sinkTablesVal);
    ClickHouseConfigDef.validateDateFormat(configValues, dataSource, sinkTablesVal);

    if (dataSource != null) {
        dataSource.close();
    }
    return new Config(new LinkedList<>(configValues.values()));
}
 
Example #2
Source File: FsSourceConnectorConfig.java    From kafka-connect-fs with Apache License 2.0 6 votes vote down vote up
public static ConfigDef conf() {
    int order = 0;
    return new ConfigDef()
            .define(
                    FS_URIS,
                    Type.LIST,
                    ConfigDef.NO_DEFAULT_VALUE,
                    Importance.HIGH,
                    FS_URIS_DOC,
                    CONNECTOR_GROUP,
                    ++order,
                    ConfigDef.Width.LONG,
                    FS_URIS_DISPLAY
            ).define(
                    TOPIC,
                    Type.STRING,
                    ConfigDef.NO_DEFAULT_VALUE,
                    Importance.HIGH,
                    TOPIC_DOC,
                    CONNECTOR_GROUP,
                    ++order,
                    ConfigDef.Width.LONG,
                    TOPIC_DISPLAY
            );
}
 
Example #3
Source File: RestSourceConnectorConfig.java    From kafka-connect-rest with Apache License 2.0 5 votes vote down vote up
private static ConfigDef getConfig() {
  Map<String, ConfigDef.ConfigKey> everything = new HashMap<>(conf().configKeys());
  ConfigDef visible = new ConfigDef();
  for (ConfigDef.ConfigKey key : everything.values()) {
    visible.define(key);
  }
  return visible;
}
 
Example #4
Source File: ZeebeSinkConnectorConfig.java    From kafka-connect-zeebe with Apache License 2.0 5 votes vote down vote up
private static ConfigDef defineConfiguration() {
  final ConfigDef definitions = new ConfigDef();
  ZeebeClientConfigDef.defineClientGroup(definitions);
  defineMessageGroup(definitions);

  return definitions;
}
 
Example #5
Source File: NoDocTestSourceConnector.java    From connect-utils with Apache License 2.0 5 votes vote down vote up
@Override
public ConfigDef config() {
  return new ConfigDef()
      .define("testing.foo", ConfigDef.Type.INT, ConfigDef.Importance.HIGH, "Lorem Ipsum is simply " +
          "dummy text fromConnector the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy " +
          "text ever since the 1500s, when an unknown printer took a galley fromConnector type and scrambled it to make a type " +
          "specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, " +
          "remaining essentially unchanged. It was popularised in the 1960s with the release fromConnector Letraset sheets " +
          "containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker " +
          "including versions fromConnector Lorem Ipsum.")
      .define("port", ConfigDef.Type.INT, 8080, ConfigDef.Range.between(1000, 65535), ConfigDef.Importance.HIGH, "This is the port number that we will listen on.");
}
 
Example #6
Source File: ConfigDefTest.java    From kafka-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasicTypes() {
    ConfigDef def = new ConfigDef().define("a", Type.INT, 5, Range.between(0, 14), Importance.HIGH, "docs")
                                   .define("b", Type.LONG, Importance.HIGH, "docs")
                                   .define("c", Type.STRING, "hello", Importance.HIGH, "docs")
                                   .define("d", Type.LIST, Importance.HIGH, "docs")
                                   .define("e", Type.DOUBLE, Importance.HIGH, "docs")
                                   .define("f", Type.CLASS, Importance.HIGH, "docs")
                                   .define("g", Type.BOOLEAN, Importance.HIGH, "docs")
                                   .define("h", Type.BOOLEAN, Importance.HIGH, "docs")
                                   .define("i", Type.BOOLEAN, Importance.HIGH, "docs")
                                   .define("j", Type.PASSWORD, Importance.HIGH, "docs");

    Properties props = new Properties();
    props.put("a", "1   ");
    props.put("b", 2);
    props.put("d", " a , b, c");
    props.put("e", 42.5d);
    props.put("f", String.class.getName());
    props.put("g", "true");
    props.put("h", "FalSE");
    props.put("i", "TRUE");
    props.put("j", "password");

    Map<String, Object> vals = def.parse(props);
    assertEquals(1, vals.get("a"));
    assertEquals(2L, vals.get("b"));
    assertEquals("hello", vals.get("c"));
    assertEquals(asList("a", "b", "c"), vals.get("d"));
    assertEquals(42.5d, vals.get("e"));
    assertEquals(String.class, vals.get("f"));
    assertEquals(true, vals.get("g"));
    assertEquals(false, vals.get("h"));
    assertEquals(true, vals.get("i"));
    assertEquals(new Password("password"), vals.get("j"));
    assertEquals(Password.HIDDEN, vals.get("j").toString());
}
 
Example #7
Source File: ConfigDefTest.java    From kafka-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidateMissingConfigKey() {
    Map<String, ConfigValue> expected = new HashMap<>();
    String errorMessageB = "Missing required configuration \"b\" which has no default value.";
    String errorMessageC = "Missing required configuration \"c\" which has no default value.";
    String errorMessageD = "d is referred in the dependents, but not defined.";

    ConfigValue configA = new ConfigValue("a", 1, Arrays.<Object>asList(1, 2, 3), Collections.<String>emptyList());
    ConfigValue configB = new ConfigValue("b", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageB));
    ConfigValue configC = new ConfigValue("c", null, Arrays.<Object>asList(4, 5), Arrays.asList(errorMessageC));
    ConfigValue configD = new ConfigValue("d", null, Collections.emptyList(), Arrays.asList(errorMessageD));
    configD.visible(false);

    expected.put("a", configA);
    expected.put("b", configB);
    expected.put("c", configC);
    expected.put("d", configD);

    ConfigDef def = new ConfigDef()
        .define("a", Type.INT, Importance.HIGH, "docs", "group", 1, Width.SHORT, "a", Arrays.asList("b", "c", "d"), new IntegerRecommender(false))
        .define("b", Type.INT, Importance.HIGH, "docs", "group", 2, Width.SHORT, "b", new IntegerRecommender(true))
        .define("c", Type.INT, Importance.HIGH, "docs", "group", 3, Width.SHORT, "c", new IntegerRecommender(true));

    Map<String, String> props = new HashMap<>();
    props.put("a", "1");

    List<ConfigValue> configs = def.validate(props);
    for (ConfigValue config: configs) {
        String name = config.name();
        ConfigValue expectedConfig = expected.get(name);
        assertEquals(expectedConfig, config);
    }
}
 
Example #8
Source File: KafkaConfigModelGenerator.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
private static List<String> validList(ConfigDef.ConfigKey key) {
    try {
        Field f = ConfigDef.ValidList.class.getDeclaredField("validString");
        f.setAccessible(true);
        ConfigDef.ValidString itemValidator = (ConfigDef.ValidString) f.get(key.validator);
        List<String> validItems = enumer(itemValidator);
        return validItems;
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException(e);
    }
}
 
Example #9
Source File: CamelDockerSinkConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelDockerSinkConnectorConfig.conf();
}
 
Example #10
Source File: CamelSyslogSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelSyslogSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #11
Source File: CloudSolrSinkConnectorConfig.java    From kafka-connect-solr with Apache License 2.0 4 votes vote down vote up
public static ConfigDef config() {
  return SolrSinkConnectorConfig.config()
      .define(
          ConfigKeyBuilder.of(ZOOKEEPER_HOSTS_CONFIG, ConfigDef.Type.LIST)
          .importance(ConfigDef.Importance.HIGH)
          .documentation(ZOOKEEPER_HOSTS_DOC)
          .group(CONNECTION_GROUP)
          .build()
      ).define(
          ConfigKeyBuilder.of(ZOOKEEPER_CHROOT_CONFIG, ConfigDef.Type.STRING)
              .importance(ConfigDef.Importance.HIGH)
              .documentation(ZOOKEEPER_CHROOT_DOC)
              .group(CONNECTION_GROUP)
              .defaultValue(null)
              .build()
      ).define(
          ConfigKeyBuilder.of(ZOOKEEPER_CONNECT_TIMEOUT_CONFIG, ConfigDef.Type.INT)
              .importance(ConfigDef.Importance.LOW)
              .documentation(ZOOKEEPER_CONNECT_TIMEOUT_DOC)
              .group(CONNECTION_GROUP)
              .defaultValue(15000)
              .build()
      ).define(
          ConfigKeyBuilder.of(ZOOKEEPER_CLIENT_TIMEOUT_CONFIG, ConfigDef.Type.INT)
              .importance(ConfigDef.Importance.LOW)
              .documentation(ZOOKEEPER_CLIENT_TIMEOUT_DOC)
              .group(CONNECTION_GROUP)
              .defaultValue(45000)
              .build()
      ).define(
          ConfigKeyBuilder.of(ZOOKEEPER_RETRY_EXPIRY_TIME_CONFIG, ConfigDef.Type.INT)
              .importance(ConfigDef.Importance.LOW)
              .documentation(ZOOKEEPER_RETRY_EXPIRY_TIME_DOC)
              .group(CONNECTION_GROUP)
              .defaultValue(3000)
              .build()
      ).define(
           ConfigKeyBuilder.of(SOLR_CONNECT_TIMEOUT_CONFIG, ConfigDef.Type.INT)
               .importance(ConfigDef.Importance.LOW)
               .documentation(SOLR_CONNECT_TIMEOUT_DOC)
               .group(CONNECTION_GROUP)
               .defaultValue(15000)
               .build()
      ).define(
           ConfigKeyBuilder.of(SOLR_SOCKET_TIMEOUT_CONFIG, ConfigDef.Type.INT)
               .importance(ConfigDef.Importance.LOW)
               .documentation(SOLR_SOCKET_TIMEOUT_DOC)
               .group(CONNECTION_GROUP)
               .defaultValue(120000)
               .build()
      );
}
 
Example #12
Source File: CamelNatsSourceConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelNatsSourceConnectorConfig.conf();
}
 
Example #13
Source File: CamelAtomixmapSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelAtomixmapSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #14
Source File: CamelCmsmsSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelCmsmsSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #15
Source File: CamelDisruptorvmSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelDisruptorvmSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #16
Source File: CamelPgreplicationslotSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelPgreplicationslotSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #17
Source File: CamelAwssnsSinkConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelAwssnsSinkConnectorConfig.conf();
}
 
Example #18
Source File: CamelEtcdstatsSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelEtcdstatsSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #19
Source File: CamelIgnitecomputeSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelIgnitecomputeSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #20
Source File: CamelInfinispanSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelInfinispanSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #21
Source File: CamelAws2sqsSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelAws2sqsSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #22
Source File: CamelAwssqsSinkConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelAwssqsSinkConnectorConfig.conf();
}
 
Example #23
Source File: CamelAws2ddbSinkConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelAws2ddbSinkConnectorConfig.conf();
}
 
Example #24
Source File: CamelVmSinkConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelVmSinkConnectorConfig.conf();
}
 
Example #25
Source File: CamelBeanstalkSinkConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelBeanstalkSinkConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #26
Source File: CamelGrpcSourceConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelGrpcSourceConnectorConfig.conf();
}
 
Example #27
Source File: CamelIgnitemessagingSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelIgnitemessagingSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #28
Source File: CamelIgnitemessagingSourceConnector.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
@Override
public ConfigDef config() {
    return CamelIgnitemessagingSourceConnectorConfig.conf();
}
 
Example #29
Source File: CamelMiloclientSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelMiloclientSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}
 
Example #30
Source File: CamelZendeskSourceConnectorConfig.java    From camel-kafka-connector with Apache License 2.0 4 votes vote down vote up
public CamelZendeskSourceConnectorConfig(
        ConfigDef config,
        Map<String, String> parsedConfig) {
    super(config, parsedConfig);
}