Java Code Examples for org.apache.kafka.common.config.ConfigDef#Type

The following examples show how to use org.apache.kafka.common.config.ConfigDef#Type . 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: Cli.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 5 votes vote down vote up
private ConfigDef.Type parseProducerProperty(String parsedProperty) {
  ConfigDef.Type type;
  ConfigDef.ConfigKey configKey = PRODUCER_CONFIG_DEF.configKeys().get(parsedProperty);
  if (configKey == null) {
    throw new IllegalArgumentException(String.format(
        "Invalid producer property: '%s'",
        parsedProperty
    ));
  }
  type = configKey.type;
  return type;
}
 
Example 2
Source File: Cli.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 5 votes vote down vote up
private ConfigDef.Type parseConsumerProperty(String parsedProperty) {
  ConfigDef.Type type;
  ConfigDef.ConfigKey configKey = CONSUMER_CONFIG_DEF.configKeys().get(parsedProperty);
  if (configKey == null) {
    throw new IllegalArgumentException(String.format(
        "Invalid consumer property: '%s'",
        parsedProperty
    ));
  }
  type = configKey.type;
  return type;
}
 
Example 3
Source File: KafkaConfigProxyFactory.java    From kafka-connect-couchbase with Apache License 2.0 5 votes vote down vote up
protected ConfigDef.Type getKafkaType(Method method) {
  Class<?> returnType = method.getReturnType();

  ConfigDef.Type kafkaType = javaClassToKafkaType.get(returnType);
  if (kafkaType != null) {
    return kafkaType;
  }

  if (returnType.isEnum()) {
    return ConfigDef.Type.STRING;
  }

  throw new RuntimeException("Method " + method + " has unsupported return type.");
}
 
Example 4
Source File: Cli.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 4 votes vote down vote up
private void setProperty(String property, String value) {
  String parsedProperty;
  ConfigDef.Type type;
  if (StreamsConfig.configDef().configKeys().containsKey(property)) {
    type = StreamsConfig.configDef().configKeys().get(property).type;
    parsedProperty = property;
  } else if (CONSUMER_CONFIG_DEF.configKeys().containsKey(property)) {
    type = CONSUMER_CONFIG_DEF.configKeys().get(property).type;
    parsedProperty = property;
  } else if (PRODUCER_CONFIG_DEF.configKeys().containsKey(property)) {
    type = PRODUCER_CONFIG_DEF.configKeys().get(property).type;
    parsedProperty = property;
  } else if (property.startsWith(StreamsConfig.CONSUMER_PREFIX)) {
    parsedProperty = property.substring(StreamsConfig.CONSUMER_PREFIX.length());
    type = parseConsumerProperty(parsedProperty);
  } else if (property.startsWith(StreamsConfig.PRODUCER_PREFIX)) {
    parsedProperty = property.substring(StreamsConfig.PRODUCER_PREFIX.length());
    type = parseProducerProperty(parsedProperty);
  } else if (property.equalsIgnoreCase(DdlConfig.AVRO_SCHEMA)) {
    restClient.setProperty(property, value);
    return;
  } else if (property.equalsIgnoreCase(KsqlConstants.RUN_SCRIPT_STATEMENTS_CONTENT)) {
    restClient.setProperty(property, value);
    return;
  } else if (property.startsWith(KsqlConfig.KSQL_CONFIG_PROPERTY_PREFIX)) {
    restClient.setProperty(property, value);
    return;
  } else {
    throw new IllegalArgumentException(String.format(
        "Not recognizable as ksql, streams, consumer, or producer property: '%s'",
        property
    ));
  }

  if (KsqlEngine.getImmutableProperties().contains(parsedProperty)) {
    throw new IllegalArgumentException(String.format(
        "Cannot override property '%s'",
        property
    ));
  }

  Object parsedValue = ConfigDef.parseType(parsedProperty, value, type);
  Object priorValue = restClient.setProperty(property, parsedValue);

  terminal.writer().printf(
      "Successfully changed local property '%s' from '%s' to '%s'%n",
      property,
      priorValue,
      parsedValue
  );
  terminal.flush();
}
 
Example 5
Source File: ConfigKeyBuilder.java    From connect-utils with Apache License 2.0 4 votes vote down vote up
private ConfigKeyBuilder(String group, String name, ConfigDef.Type type) {
  this(name, type);
  this.group = group;
}
 
Example 6
Source File: ConfigKeyBuilder.java    From connect-utils with Apache License 2.0 4 votes vote down vote up
private ConfigKeyBuilder(String name, ConfigDef.Type type) {
  this.name = name;
  this.displayName = name;
  this.type = type;
}
 
Example 7
Source File: ConfigKeyBuilder.java    From connect-utils with Apache License 2.0 4 votes vote down vote up
public static ConfigKeyBuilder of(String group, String name, ConfigDef.Type type) {
  return new ConfigKeyBuilder(group, name, type);
}
 
Example 8
Source File: ConfigKeyBuilder.java    From connect-utils with Apache License 2.0 4 votes vote down vote up
public static ConfigKeyBuilder of(String name, ConfigDef.Type type) {
  return new ConfigKeyBuilder(name, type);
}
 
Example 9
Source File: ConfigKeyBuilder.java    From connect-utils with Apache License 2.0 4 votes vote down vote up
public ConfigDef.Type type() {
  return this.type;
}
 
Example 10
Source File: Plugin.java    From connect-utils with Apache License 2.0 votes vote down vote up
ConfigDef.Type getType();