use of org.apache.kafka.common.config.ConfigException in project connect-utils by jcustenborder.
the class ValidHostnameAndPortTests method ensureValidExceptions.
@Test
public void ensureValidExceptions() {
ConfigException exception = assertThrows(ConfigException.class, () -> {
validator.ensureValid("test", null);
});
assertTrue(exception.getMessage().contains("must be a string or a list."));
exception = assertThrows(ConfigException.class, () -> {
validator.ensureValid("test", "");
});
assertTrue(exception.getMessage().contains("does not match pattern"));
exception = assertThrows(ConfigException.class, () -> {
validator.ensureValid("test", "localhost:99999");
});
assertTrue(exception.getMessage().contains("Port must be between 1 and 65535"));
}
use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.
the class SessionWindowedSerializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).serializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.
the class TimeWindowedSerializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
final String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
final String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).serializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.
the class SessionWindowedDeserializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
final String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
final String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).deserializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
use of org.apache.kafka.common.config.ConfigException in project apache-kafka-on-k8s by banzaicloud.
the class RestServer method createConnector.
/**
* Creates Jetty connector according to configuration
*/
public Connector createConnector(String listener) {
Pattern listenerPattern = Pattern.compile("^(.*)://\\[?([0-9a-zA-Z\\-%._:]*)\\]?:(-?[0-9]+)");
Matcher listenerMatcher = listenerPattern.matcher(listener);
if (!listenerMatcher.matches())
throw new ConfigException("Listener doesn't have the right format (protocol://hostname:port).");
String protocol = listenerMatcher.group(1).toLowerCase(Locale.ENGLISH);
if (!PROTOCOL_HTTP.equals(protocol) && !PROTOCOL_HTTPS.equals(protocol))
throw new ConfigException(String.format("Listener protocol must be either \"%s\" or \"%s\".", PROTOCOL_HTTP, PROTOCOL_HTTPS));
String hostname = listenerMatcher.group(2);
int port = Integer.parseInt(listenerMatcher.group(3));
ServerConnector connector;
if (PROTOCOL_HTTPS.equals(protocol)) {
SslContextFactory ssl = SSLUtils.createSslContextFactory(config);
connector = new ServerConnector(jettyServer, ssl);
connector.setName(String.format("%s_%s%d", PROTOCOL_HTTPS, hostname, port));
} else {
connector = new ServerConnector(jettyServer);
connector.setName(String.format("%s_%s%d", PROTOCOL_HTTP, hostname, port));
}
if (!hostname.isEmpty())
connector.setHost(hostname);
connector.setPort(port);
return connector;
}
Aggregations