Search in sources :

Example 11 with AbstractConfig

use of org.apache.kafka.common.config.AbstractConfig in project kafka by apache.

the class JaasOptionsUtils method getSslClientConfig.

public Map<String, ?> getSslClientConfig() {
    ConfigDef sslConfigDef = new ConfigDef();
    sslConfigDef.withClientSslSupport();
    AbstractConfig sslClientConfig = new AbstractConfig(sslConfigDef, options);
    return sslClientConfig.values();
}
Also used : AbstractConfig(org.apache.kafka.common.config.AbstractConfig) ConfigDef(org.apache.kafka.common.config.ConfigDef)

Example 12 with AbstractConfig

use of org.apache.kafka.common.config.AbstractConfig in project kafka by apache.

the class FileStreamSourceConnector method start.

@Override
public void start(Map<String, String> props) {
    AbstractConfig parsedConfig = new AbstractConfig(CONFIG_DEF, props);
    filename = parsedConfig.getString(FILE_CONFIG);
    List<String> topics = parsedConfig.getList(TOPIC_CONFIG);
    if (topics.size() != 1) {
        throw new ConfigException("'topic' in FileStreamSourceConnector configuration requires definition of a single topic");
    }
    topic = topics.get(0);
    batchSize = parsedConfig.getInt(TASK_BATCH_SIZE_CONFIG);
}
Also used : AbstractConfig(org.apache.kafka.common.config.AbstractConfig) ConfigException(org.apache.kafka.common.config.ConfigException)

Example 13 with AbstractConfig

use of org.apache.kafka.common.config.AbstractConfig in project kafka by apache.

the class OAuthBearerTest method getSaslConfigs.

protected Map<String, ?> getSaslConfigs(Map<String, ?> configs) {
    ConfigDef configDef = new ConfigDef();
    configDef.withClientSaslSupport();
    AbstractConfig sslClientConfig = new AbstractConfig(configDef, configs);
    return sslClientConfig.values();
}
Also used : AbstractConfig(org.apache.kafka.common.config.AbstractConfig) ConfigDef(org.apache.kafka.common.config.ConfigDef)

Example 14 with AbstractConfig

use of org.apache.kafka.common.config.AbstractConfig in project kafka by apache.

the class SynchronizationTest method testSimultaneousUpwardAndDownwardDelegating.

// If the test times out, then there's a deadlock in the test but not necessarily the code
@Test(timeout = 15000L)
public void testSimultaneousUpwardAndDownwardDelegating() throws Exception {
    String t1Class = TestPlugins.SAMPLING_CONVERTER;
    // Grab a reference to the target PluginClassLoader before activating breakpoints
    ClassLoader connectorLoader = plugins.delegatingLoader().connectorLoader(t1Class);
    // THREAD 1: loads a class by delegating downward starting from the DelegatingClassLoader
    // DelegatingClassLoader breakpoint will only trigger on this thread
    dclBreakpoint.set(t1Class::equals);
    Runnable thread1 = () -> {
        // Use the DelegatingClassLoader as the current context loader
        ClassLoader savedLoader = Plugins.compareAndSwapLoaders(plugins.delegatingLoader());
        // Load an isolated plugin from the delegating classloader, which will
        // 1. Enter the DelegatingClassLoader
        // 2. Wait on dclBreakpoint for test to continue
        // 3. Enter the PluginClassLoader
        // 4. Load the isolated plugin class and return
        new AbstractConfig(new ConfigDef().define("a.class", Type.CLASS, Importance.HIGH, ""), Collections.singletonMap("a.class", t1Class));
        Plugins.compareAndSwapLoaders(savedLoader);
    };
    // THREAD 2: loads a class by delegating upward starting from the PluginClassLoader
    String t2Class = JsonConverter.class.getName();
    // PluginClassLoader breakpoint will only trigger on this thread
    pclBreakpoint.set(t2Class::equals);
    Runnable thread2 = () -> {
        // Use the PluginClassLoader as the current context loader
        ClassLoader savedLoader = Plugins.compareAndSwapLoaders(connectorLoader);
        // Load a non-isolated class from the plugin classloader, which will
        // 1. Enter the PluginClassLoader
        // 2. Wait for the test to continue
        // 3. Enter the DelegatingClassLoader
        // 4. Load the non-isolated class and return
        new AbstractConfig(new ConfigDef().define("a.class", Type.CLASS, Importance.HIGH, ""), Collections.singletonMap("a.class", t2Class));
        Plugins.compareAndSwapLoaders(savedLoader);
    };
    // STEP 1: Have T1 enter the DelegatingClassLoader and pause
    exec.submit(thread1);
    // T1 enters ConfigDef::parseType
    // T1 enters DelegatingClassLoader::loadClass
    dclBreakpoint.testAwait();
    dclBreakpoint.testAwait();
    // T1 exits DelegatingClassLoader::loadClass
    // T1 enters Class::forName
    // T1 enters DelegatingClassLoader::loadClass
    dclBreakpoint.testAwait();
    // T1 waits in the delegating classloader while we set up the other thread
    dumpThreads("step 1, T1 waiting in DelegatingClassLoader");
    // STEP 2: Have T2 enter PluginClassLoader, delegate upward to the Delegating classloader
    exec.submit(thread2);
    // T2 enters PluginClassLoader::loadClass
    pclBreakpoint.testAwait();
    // T2 falls through to ClassLoader::loadClass
    pclBreakpoint.testAwait();
    // T2 delegates upwards to DelegatingClassLoader::loadClass
    // T2 enters ClassLoader::loadClass and loads the class from the parent (CLASSPATH)
    dumpThreads("step 2, T2 entered DelegatingClassLoader and is loading class from parent");
    // STEP 3: Resume T1 and have it enter the PluginClassLoader
    dclBreakpoint.testAwait();
    // T1 enters PluginClassLoader::loadClass
    dumpThreads("step 3, T1 entered PluginClassLoader and is/was loading class from isolated jar");
    // If the DelegatingClassLoader and PluginClassLoader are both not parallel capable, then this test will deadlock
    // Otherwise, T1 should be able to complete it's load from the PluginClassLoader concurrently with T2,
    // before releasing the DelegatingClassLoader and allowing T2 to complete.
    // As the DelegatingClassLoader is not parallel capable, it must be the case that PluginClassLoader is.
    assertNoDeadlocks();
}
Also used : AbstractConfig(org.apache.kafka.common.config.AbstractConfig) ConfigDef(org.apache.kafka.common.config.ConfigDef) Test(org.junit.Test)

Example 15 with AbstractConfig

use of org.apache.kafka.common.config.AbstractConfig in project kafka by apache.

the class PluginsTest method newPluginShouldServiceLoadWithPluginClassLoader.

@Test
public void newPluginShouldServiceLoadWithPluginClassLoader() {
    TestPlugins.assertAvailable();
    Converter plugin = plugins.newPlugin(TestPlugins.SERVICE_LOADER, new AbstractConfig(new ConfigDef(), Collections.emptyMap()), Converter.class);
    assertInstanceOf(SamplingTestPlugin.class, plugin, "Cannot collect samples");
    Map<String, SamplingTestPlugin> samples = ((SamplingTestPlugin) plugin).flatten();
    // Assert that the service loaded subclass is found in both environments
    assertTrue(samples.containsKey("ServiceLoadedSubclass.static"));
    assertTrue(samples.containsKey("ServiceLoadedSubclass.dynamic"));
    assertPluginClassLoaderAlwaysActive(samples);
}
Also used : AbstractConfig(org.apache.kafka.common.config.AbstractConfig) HeaderConverter(org.apache.kafka.connect.storage.HeaderConverter) Converter(org.apache.kafka.connect.storage.Converter) SimpleHeaderConverter(org.apache.kafka.connect.storage.SimpleHeaderConverter) JsonConverter(org.apache.kafka.connect.json.JsonConverter) ConfigDef(org.apache.kafka.common.config.ConfigDef) Test(org.junit.Test)

Aggregations

AbstractConfig (org.apache.kafka.common.config.AbstractConfig)18 ConfigDef (org.apache.kafka.common.config.ConfigDef)9 Test (org.junit.Test)6 JsonConverter (org.apache.kafka.connect.json.JsonConverter)4 Converter (org.apache.kafka.connect.storage.Converter)4 HeaderConverter (org.apache.kafka.connect.storage.HeaderConverter)4 SimpleHeaderConverter (org.apache.kafka.connect.storage.SimpleHeaderConverter)4 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConfigException (org.apache.kafka.common.config.ConfigException)2 PooledPlcDriverManager (org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager)2 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 SecureRandom (java.security.SecureRandom)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1