Search in sources :

Example 71 with Connector

use of org.apache.kafka.connect.connector.Connector in project kafka by apache.

the class ConnectorPluginsResourceTest method testValidateConfigWithAlias.

@Test
public void testValidateConfigWithAlias() throws Throwable {
    @SuppressWarnings("unchecked") ArgumentCaptor<Callback<ConfigInfos>> configInfosCallback = ArgumentCaptor.forClass(Callback.class);
    doAnswer(invocation -> {
        ConfigDef connectorConfigDef = ConnectorConfig.configDef();
        List<ConfigValue> connectorConfigValues = connectorConfigDef.validate(PROPS);
        Connector connector = new ConnectorPluginsResourceTestConnector();
        Config config = connector.validate(PROPS);
        ConfigDef configDef = connector.config();
        Map<String, ConfigDef.ConfigKey> configKeys = configDef.configKeys();
        List<ConfigValue> configValues = config.configValues();
        Map<String, ConfigDef.ConfigKey> resultConfigKeys = new HashMap<>(configKeys);
        resultConfigKeys.putAll(connectorConfigDef.configKeys());
        configValues.addAll(connectorConfigValues);
        ConfigInfos configInfos = AbstractHerder.generateResult(ConnectorPluginsResourceTestConnector.class.getName(), resultConfigKeys, configValues, Collections.singletonList("Test"));
        configInfosCallback.getValue().onCompletion(null, configInfos);
        return null;
    }).when(herder).validateConnectorConfig(eq(PROPS), configInfosCallback.capture(), anyBoolean());
    // make a request to connector-plugins resource using a valid alias.
    ConfigInfos configInfos = connectorPluginsResource.validateConfigs("ConnectorPluginsResourceTest", PROPS);
    assertEquals(CONFIG_INFOS.name(), configInfos.name());
    assertEquals(0, configInfos.errorCount());
    assertEquals(CONFIG_INFOS.groups(), configInfos.groups());
    assertEquals(new HashSet<>(CONFIG_INFOS.values()), new HashSet<>(configInfos.values()));
    verify(herder).validateConnectorConfig(eq(PROPS), any(), anyBoolean());
}
Also used : SourceConnector(org.apache.kafka.connect.source.SourceConnector) VerifiableSourceConnector(org.apache.kafka.connect.tools.VerifiableSourceConnector) MockSinkConnector(org.apache.kafka.connect.tools.MockSinkConnector) SampleSinkConnector(org.apache.kafka.connect.runtime.SampleSinkConnector) MockSourceConnector(org.apache.kafka.connect.tools.MockSourceConnector) VerifiableSinkConnector(org.apache.kafka.connect.tools.VerifiableSinkConnector) Connector(org.apache.kafka.connect.connector.Connector) SchemaSourceConnector(org.apache.kafka.connect.tools.SchemaSourceConnector) SampleSourceConnector(org.apache.kafka.connect.runtime.SampleSourceConnector) ConfigValue(org.apache.kafka.common.config.ConfigValue) HashMap(java.util.HashMap) ConnectorConfig(org.apache.kafka.connect.runtime.ConnectorConfig) Config(org.apache.kafka.common.config.Config) Callback(org.apache.kafka.connect.util.Callback) ConfigDef(org.apache.kafka.common.config.ConfigDef) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos) Test(org.junit.Test)

Example 72 with Connector

use of org.apache.kafka.connect.connector.Connector in project kafka by apache.

the class AbstractHerderTest method testConfigValidationTransformsExtendResults.

@Test()
public void testConfigValidationTransformsExtendResults() {
    AbstractHerder herder = createConfigValidationHerder(SampleSourceConnector.class, noneConnectorClientConfigOverridePolicy);
    // 2 transform aliases defined -> 2 plugin lookups
    Set<PluginDesc<Transformation<?>>> transformations = new HashSet<>();
    transformations.add(transformationPluginDesc());
    EasyMock.expect(plugins.transformations()).andReturn(transformations).times(2);
    replayAll();
    // Define 2 transformations. One has a class defined and so can get embedded configs, the other is missing
    // class info that should generate an error.
    Map<String, String> config = new HashMap<>();
    config.put(ConnectorConfig.CONNECTOR_CLASS_CONFIG, SampleSourceConnector.class.getName());
    config.put(ConnectorConfig.NAME_CONFIG, "connector-name");
    config.put(ConnectorConfig.TRANSFORMS_CONFIG, "xformA,xformB");
    config.put(ConnectorConfig.TRANSFORMS_CONFIG + ".xformA.type", SampleTransformation.class.getName());
    // connector required config
    config.put("required", "value");
    ConfigInfos result = herder.validateConnectorConfig(config, false);
    assertEquals(herder.connectorTypeForClass(config.get(ConnectorConfig.CONNECTOR_CLASS_CONFIG)), ConnectorType.SOURCE);
    // We expect there to be errors due to the missing name and .... Note that these assertions depend heavily on
    // the config fields for SourceConnectorConfig, but we expect these to change rarely.
    assertEquals(SampleSourceConnector.class.getName(), result.name());
    // Each transform also gets its own group
    List<String> expectedGroups = Arrays.asList(ConnectorConfig.COMMON_GROUP, ConnectorConfig.TRANSFORMS_GROUP, ConnectorConfig.PREDICATES_GROUP, ConnectorConfig.ERROR_GROUP, SourceConnectorConfig.TOPIC_CREATION_GROUP, SourceConnectorConfig.EXACTLY_ONCE_SUPPORT_GROUP, SourceConnectorConfig.OFFSETS_TOPIC_GROUP, "Transforms: xformA", "Transforms: xformB");
    assertEquals(expectedGroups, result.groups());
    assertEquals(2, result.errorCount());
    Map<String, ConfigInfo> infos = result.values().stream().collect(Collectors.toMap(info -> info.configKey().name(), Function.identity()));
    assertEquals(26, infos.size());
    // Should get 2 type fields from the transforms, first adds its own config since it has a valid class
    assertEquals("transforms.xformA.type", infos.get("transforms.xformA.type").configValue().name());
    assertTrue(infos.get("transforms.xformA.type").configValue().errors().isEmpty());
    assertEquals("transforms.xformA.subconfig", infos.get("transforms.xformA.subconfig").configValue().name());
    assertEquals("transforms.xformB.type", infos.get("transforms.xformB.type").configValue().name());
    assertFalse(infos.get("transforms.xformB.type").configValue().errors().isEmpty());
    verifyAll();
}
Also used : Arrays(java.util.Arrays) EasyMock.strictMock(org.easymock.EasyMock.strictMock) Plugins(org.apache.kafka.connect.runtime.isolation.Plugins) Transformation(org.apache.kafka.connect.transforms.Transformation) MockStrict(org.powermock.api.easymock.annotation.MockStrict) SourceConnector(org.apache.kafka.connect.source.SourceConnector) AllConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.AllConnectorClientConfigOverridePolicy) Map(java.util.Map) ConnectorType(org.apache.kafka.connect.runtime.rest.entities.ConnectorType) PowerMock.replayAll(org.powermock.api.easymock.PowerMock.replayAll) ConfigDef(org.apache.kafka.common.config.ConfigDef) PrincipalConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.PrincipalConnectorClientConfigOverridePolicy) CommonClientConfigs(org.apache.kafka.clients.CommonClientConfigs) Collection(java.util.Collection) Set(java.util.Set) DirectoryConfigProvider(org.apache.kafka.common.config.provider.DirectoryConfigProvider) ConfigValue(org.apache.kafka.common.config.ConfigValue) PowerMock(org.powermock.api.easymock.PowerMock) Collectors(java.util.stream.Collectors) EasyMock.partialMockBuilder(org.easymock.EasyMock.partialMockBuilder) ConfigValueInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigValueInfo) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) ConfigInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigInfo) List(java.util.List) Predicate(org.apache.kafka.connect.transforms.predicates.Predicate) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) BadRequestException(org.apache.kafka.connect.runtime.rest.errors.BadRequestException) ConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy) SourceTask(org.apache.kafka.connect.source.SourceTask) ConfigKeyInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo) Connector(org.apache.kafka.connect.connector.Connector) ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) ConfigBackingStore(org.apache.kafka.connect.storage.ConfigBackingStore) Function(java.util.function.Function) NoneConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.NoneConnectorClientConfigOverridePolicy) PluginDesc(org.apache.kafka.connect.runtime.isolation.PluginDesc) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PowerMock.verifyAll(org.powermock.api.easymock.PowerMock.verifyAll) SaslConfigs(org.apache.kafka.common.config.SaslConfigs) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) ProducerConfig(org.apache.kafka.clients.producer.ProducerConfig) Capture(org.easymock.Capture) AbstractHerder.keysWithVariableValues(org.apache.kafka.connect.runtime.AbstractHerder.keysWithVariableValues) EasyMock.anyString(org.easymock.EasyMock.anyString) Assert.assertNotNull(org.junit.Assert.assertNotNull) ClusterConfigState(org.apache.kafka.connect.runtime.distributed.ClusterConfigState) ConfigTransformer(org.apache.kafka.common.config.ConfigTransformer) Mock(org.powermock.api.easymock.annotation.Mock) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) ConfigException(org.apache.kafka.common.config.ConfigException) StatusBackingStore(org.apache.kafka.connect.storage.StatusBackingStore) OAuthBearerUnsecuredLoginCallbackHandler(org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerUnsecuredLoginCallbackHandler) Assert.assertNull(org.junit.Assert.assertNull) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) EasyMock.anyString(org.easymock.EasyMock.anyString) ConfigInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigInfo) PluginDesc(org.apache.kafka.connect.runtime.isolation.PluginDesc) HashSet(java.util.HashSet) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 73 with Connector

use of org.apache.kafka.connect.connector.Connector in project kafka by apache.

the class AbstractHerderTest method testConfigValidationPredicatesExtendResults.

@Test()
public void testConfigValidationPredicatesExtendResults() {
    AbstractHerder herder = createConfigValidationHerder(SampleSourceConnector.class, noneConnectorClientConfigOverridePolicy);
    // 2 transform aliases defined -> 2 plugin lookups
    Set<PluginDesc<Transformation<?>>> transformations = new HashSet<>();
    transformations.add(transformationPluginDesc());
    EasyMock.expect(plugins.transformations()).andReturn(transformations).times(1);
    Set<PluginDesc<Predicate<?>>> predicates = new HashSet<>();
    predicates.add(predicatePluginDesc());
    EasyMock.expect(plugins.predicates()).andReturn(predicates).times(2);
    replayAll();
    // Define 2 transformations. One has a class defined and so can get embedded configs, the other is missing
    // class info that should generate an error.
    Map<String, String> config = new HashMap<>();
    config.put(ConnectorConfig.CONNECTOR_CLASS_CONFIG, SampleSourceConnector.class.getName());
    config.put(ConnectorConfig.NAME_CONFIG, "connector-name");
    config.put(ConnectorConfig.TRANSFORMS_CONFIG, "xformA");
    config.put(ConnectorConfig.TRANSFORMS_CONFIG + ".xformA.type", SampleTransformation.class.getName());
    config.put(ConnectorConfig.TRANSFORMS_CONFIG + ".xformA.predicate", "predX");
    config.put(ConnectorConfig.PREDICATES_CONFIG, "predX,predY");
    config.put(ConnectorConfig.PREDICATES_CONFIG + ".predX.type", SamplePredicate.class.getName());
    // connector required config
    config.put("required", "value");
    ConfigInfos result = herder.validateConnectorConfig(config, false);
    assertEquals(herder.connectorTypeForClass(config.get(ConnectorConfig.CONNECTOR_CLASS_CONFIG)), ConnectorType.SOURCE);
    // We expect there to be errors due to the missing name and .... Note that these assertions depend heavily on
    // the config fields for SourceConnectorConfig, but we expect these to change rarely.
    assertEquals(SampleSourceConnector.class.getName(), result.name());
    // Each transform also gets its own group
    List<String> expectedGroups = Arrays.asList(ConnectorConfig.COMMON_GROUP, ConnectorConfig.TRANSFORMS_GROUP, ConnectorConfig.PREDICATES_GROUP, ConnectorConfig.ERROR_GROUP, SourceConnectorConfig.TOPIC_CREATION_GROUP, SourceConnectorConfig.EXACTLY_ONCE_SUPPORT_GROUP, SourceConnectorConfig.OFFSETS_TOPIC_GROUP, "Transforms: xformA", "Predicates: predX", "Predicates: predY");
    assertEquals(expectedGroups, result.groups());
    assertEquals(2, result.errorCount());
    Map<String, ConfigInfo> infos = result.values().stream().collect(Collectors.toMap(info -> info.configKey().name(), Function.identity()));
    assertEquals(28, infos.size());
    // Should get 2 type fields from the transforms, first adds its own config since it has a valid class
    assertEquals("transforms.xformA.type", infos.get("transforms.xformA.type").configValue().name());
    assertTrue(infos.get("transforms.xformA.type").configValue().errors().isEmpty());
    assertEquals("transforms.xformA.subconfig", infos.get("transforms.xformA.subconfig").configValue().name());
    assertEquals("transforms.xformA.predicate", infos.get("transforms.xformA.predicate").configValue().name());
    assertTrue(infos.get("transforms.xformA.predicate").configValue().errors().isEmpty());
    assertEquals("transforms.xformA.negate", infos.get("transforms.xformA.negate").configValue().name());
    assertTrue(infos.get("transforms.xformA.negate").configValue().errors().isEmpty());
    assertEquals("predicates.predX.type", infos.get("predicates.predX.type").configValue().name());
    assertEquals("predicates.predX.predconfig", infos.get("predicates.predX.predconfig").configValue().name());
    assertEquals("predicates.predY.type", infos.get("predicates.predY.type").configValue().name());
    assertFalse(infos.get("predicates.predY.type").configValue().errors().isEmpty());
    verifyAll();
}
Also used : Arrays(java.util.Arrays) EasyMock.strictMock(org.easymock.EasyMock.strictMock) Plugins(org.apache.kafka.connect.runtime.isolation.Plugins) Transformation(org.apache.kafka.connect.transforms.Transformation) MockStrict(org.powermock.api.easymock.annotation.MockStrict) SourceConnector(org.apache.kafka.connect.source.SourceConnector) AllConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.AllConnectorClientConfigOverridePolicy) Map(java.util.Map) ConnectorType(org.apache.kafka.connect.runtime.rest.entities.ConnectorType) PowerMock.replayAll(org.powermock.api.easymock.PowerMock.replayAll) ConfigDef(org.apache.kafka.common.config.ConfigDef) PrincipalConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.PrincipalConnectorClientConfigOverridePolicy) CommonClientConfigs(org.apache.kafka.clients.CommonClientConfigs) Collection(java.util.Collection) Set(java.util.Set) DirectoryConfigProvider(org.apache.kafka.common.config.provider.DirectoryConfigProvider) ConfigValue(org.apache.kafka.common.config.ConfigValue) PowerMock(org.powermock.api.easymock.PowerMock) Collectors(java.util.stream.Collectors) EasyMock.partialMockBuilder(org.easymock.EasyMock.partialMockBuilder) ConfigValueInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigValueInfo) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) ConfigInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigInfo) List(java.util.List) Predicate(org.apache.kafka.connect.transforms.predicates.Predicate) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) BadRequestException(org.apache.kafka.connect.runtime.rest.errors.BadRequestException) ConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy) SourceTask(org.apache.kafka.connect.source.SourceTask) ConfigKeyInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo) Connector(org.apache.kafka.connect.connector.Connector) ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) ConfigBackingStore(org.apache.kafka.connect.storage.ConfigBackingStore) Function(java.util.function.Function) NoneConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.NoneConnectorClientConfigOverridePolicy) PluginDesc(org.apache.kafka.connect.runtime.isolation.PluginDesc) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PowerMock.verifyAll(org.powermock.api.easymock.PowerMock.verifyAll) SaslConfigs(org.apache.kafka.common.config.SaslConfigs) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) ProducerConfig(org.apache.kafka.clients.producer.ProducerConfig) Capture(org.easymock.Capture) AbstractHerder.keysWithVariableValues(org.apache.kafka.connect.runtime.AbstractHerder.keysWithVariableValues) EasyMock.anyString(org.easymock.EasyMock.anyString) Assert.assertNotNull(org.junit.Assert.assertNotNull) ClusterConfigState(org.apache.kafka.connect.runtime.distributed.ClusterConfigState) ConfigTransformer(org.apache.kafka.common.config.ConfigTransformer) Mock(org.powermock.api.easymock.annotation.Mock) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) ConfigException(org.apache.kafka.common.config.ConfigException) StatusBackingStore(org.apache.kafka.connect.storage.StatusBackingStore) OAuthBearerUnsecuredLoginCallbackHandler(org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerUnsecuredLoginCallbackHandler) Assert.assertNull(org.junit.Assert.assertNull) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) EasyMock.anyString(org.easymock.EasyMock.anyString) ConfigInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigInfo) PluginDesc(org.apache.kafka.connect.runtime.isolation.PluginDesc) HashSet(java.util.HashSet) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 74 with Connector

use of org.apache.kafka.connect.connector.Connector in project kafka by apache.

the class AbstractHerderTest method createConfigValidationHerder.

private AbstractHerder createConfigValidationHerder(Class<? extends Connector> connectorClass, ConnectorClientConfigOverridePolicy connectorClientConfigOverridePolicy, int countOfCallingNewConnector) {
    ConfigBackingStore configStore = strictMock(ConfigBackingStore.class);
    StatusBackingStore statusStore = strictMock(StatusBackingStore.class);
    AbstractHerder herder = partialMockBuilder(AbstractHerder.class).withConstructor(Worker.class, String.class, String.class, StatusBackingStore.class, ConfigBackingStore.class, ConnectorClientConfigOverridePolicy.class).withArgs(worker, workerId, kafkaClusterId, statusStore, configStore, connectorClientConfigOverridePolicy).addMockedMethod("generation").createMock();
    EasyMock.expect(herder.generation()).andStubReturn(generation);
    // Call to validateConnectorConfig
    EasyMock.expect(worker.configTransformer()).andReturn(transformer).times(2);
    final Capture<Map<String, String>> configCapture = EasyMock.newCapture();
    EasyMock.expect(transformer.transform(EasyMock.capture(configCapture))).andAnswer(configCapture::getValue);
    EasyMock.expect(worker.getPlugins()).andStubReturn(plugins);
    final Connector connector;
    try {
        connector = connectorClass.getConstructor().newInstance();
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException("Couldn't create connector", e);
    }
    if (countOfCallingNewConnector > 0) {
        EasyMock.expect(plugins.newConnector(connectorClass.getName())).andReturn(connector).times(countOfCallingNewConnector);
        EasyMock.expect(plugins.compareAndSwapLoaders(connector)).andReturn(classLoader).times(countOfCallingNewConnector);
    }
    return herder;
}
Also used : StatusBackingStore(org.apache.kafka.connect.storage.StatusBackingStore) SourceConnector(org.apache.kafka.connect.source.SourceConnector) Connector(org.apache.kafka.connect.connector.Connector) EasyMock.anyString(org.easymock.EasyMock.anyString) AllConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.AllConnectorClientConfigOverridePolicy) PrincipalConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.PrincipalConnectorClientConfigOverridePolicy) ConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy) NoneConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.NoneConnectorClientConfigOverridePolicy) Map(java.util.Map) HashMap(java.util.HashMap) ConfigBackingStore(org.apache.kafka.connect.storage.ConfigBackingStore)

Example 75 with Connector

use of org.apache.kafka.connect.connector.Connector in project kafka by apache.

the class DistributedHerder method startConnector.

// Helper for starting a connector with the given name, which will extract & parse the config, generate connector
// context and add to the worker. This needs to be called from within the main worker thread for this herder.
// The callback is invoked after the connector has finished startup and generated task configs, or failed in the process.
private void startConnector(String connectorName, Callback<Void> callback) {
    log.info("Starting connector {}", connectorName);
    final Map<String, String> configProps = configState.connectorConfig(connectorName);
    final CloseableConnectorContext ctx = new HerderConnectorContext(this, connectorName);
    final TargetState initialState = configState.targetState(connectorName);
    final Callback<TargetState> onInitialStateChange = (error, newState) -> {
        if (error != null) {
            callback.onCompletion(new ConnectException("Failed to start connector: " + connectorName, error), null);
            return;
        }
        // Use newState here in case the connector has been paused right after being created
        if (newState == TargetState.STARTED) {
            addRequest(() -> {
                // Request configuration since this could be a brand new connector. However, also only update those
                // task configs if they are actually different from the existing ones to avoid unnecessary updates when this is
                // just restoring an existing connector.
                reconfigureConnectorTasksWithRetry(time.milliseconds(), connectorName);
                callback.onCompletion(null, null);
                return null;
            }, forwardErrorCallback(callback));
        } else {
            callback.onCompletion(null, null);
        }
    };
    worker.startConnector(connectorName, configProps, ctx, this, initialState, onInitialStateChange);
}
Also used : TargetState(org.apache.kafka.connect.runtime.TargetState) Worker(org.apache.kafka.connect.runtime.Worker) SinkUtils(org.apache.kafka.connect.util.SinkUtils) Arrays(java.util.Arrays) TimeoutException(java.util.concurrent.TimeoutException) AlreadyExistsException(org.apache.kafka.connect.errors.AlreadyExistsException) KeyGenerator(javax.crypto.KeyGenerator) SessionKey(org.apache.kafka.connect.runtime.SessionKey) ConnectorInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo) RestartRequest(org.apache.kafka.connect.runtime.RestartRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LogContext(org.apache.kafka.common.utils.LogContext) Map(java.util.Map) UriBuilder(javax.ws.rs.core.UriBuilder) ThreadUtils(org.apache.kafka.common.utils.ThreadUtils) RestClient(org.apache.kafka.connect.runtime.rest.RestClient) ConfigDef(org.apache.kafka.common.config.ConfigDef) CommonClientConfigs(org.apache.kafka.clients.CommonClientConfigs) Sensor(org.apache.kafka.common.metrics.Sensor) Time(org.apache.kafka.common.utils.Time) WakeupException(org.apache.kafka.common.errors.WakeupException) Collection(java.util.Collection) CumulativeSum(org.apache.kafka.common.metrics.stats.CumulativeSum) Set(java.util.Set) NavigableSet(java.util.NavigableSet) ConfigValue(org.apache.kafka.common.config.ConfigValue) Collectors(java.util.stream.Collectors) AbstractHerder(org.apache.kafka.connect.runtime.AbstractHerder) Executors(java.util.concurrent.Executors) Objects(java.util.Objects) CONNECT_PROTOCOL_V0(org.apache.kafka.connect.runtime.distributed.ConnectProtocol.CONNECT_PROTOCOL_V0) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) CloseableConnectorContext(org.apache.kafka.connect.runtime.CloseableConnectorContext) List(java.util.List) EAGER(org.apache.kafka.connect.runtime.distributed.ConnectProtocolCompatibility.EAGER) ConnectMetrics(org.apache.kafka.connect.runtime.ConnectMetrics) SourceConnectorConfig(org.apache.kafka.connect.runtime.SourceConnectorConfig) Response(javax.ws.rs.core.Response) Optional(java.util.Optional) TargetState(org.apache.kafka.connect.runtime.TargetState) SecretKey(javax.crypto.SecretKey) BadRequestException(org.apache.kafka.connect.runtime.rest.errors.BadRequestException) ConnectorClientConfigOverridePolicy(org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy) ConnectorConfig(org.apache.kafka.connect.runtime.ConnectorConfig) TaskStatus(org.apache.kafka.connect.runtime.TaskStatus) Max(org.apache.kafka.common.metrics.stats.Max) Connector(org.apache.kafka.connect.connector.Connector) Exit(org.apache.kafka.common.utils.Exit) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) ConfigBackingStore(org.apache.kafka.connect.storage.ConfigBackingStore) AtomicReference(java.util.concurrent.atomic.AtomicReference) TOPIC_TRACKING_ENABLE_CONFIG(org.apache.kafka.connect.runtime.WorkerConfig.TOPIC_TRACKING_ENABLE_CONFIG) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CONNECT_PROTOCOL_V2(org.apache.kafka.connect.runtime.distributed.IncrementalCooperativeConnectProtocol.CONNECT_PROTOCOL_V2) CONNECT_PROTOCOL_V1(org.apache.kafka.connect.runtime.distributed.IncrementalCooperativeConnectProtocol.CONNECT_PROTOCOL_V1) MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) SinkConnector(org.apache.kafka.connect.sink.SinkConnector) Utils(org.apache.kafka.common.utils.Utils) HerderConnectorContext(org.apache.kafka.connect.runtime.HerderConnectorContext) Callback(org.apache.kafka.connect.util.Callback) RestartPlan(org.apache.kafka.connect.runtime.RestartPlan) Logger(org.slf4j.Logger) InternalRequestSignature(org.apache.kafka.connect.runtime.rest.InternalRequestSignature) HerderRequest(org.apache.kafka.connect.runtime.HerderRequest) SinkConnectorConfig(org.apache.kafka.connect.runtime.SinkConnectorConfig) ConnectRestException(org.apache.kafka.connect.runtime.rest.errors.ConnectRestException) ConnectMetricsRegistry(org.apache.kafka.connect.runtime.ConnectMetricsRegistry) TaskInfo(org.apache.kafka.connect.runtime.rest.entities.TaskInfo) StatusBackingStore(org.apache.kafka.connect.storage.StatusBackingStore) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) Avg(org.apache.kafka.common.metrics.stats.Avg) ConnectException(org.apache.kafka.connect.errors.ConnectException) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) Collections(java.util.Collections) CloseableConnectorContext(org.apache.kafka.connect.runtime.CloseableConnectorContext) HerderConnectorContext(org.apache.kafka.connect.runtime.HerderConnectorContext) ConnectException(org.apache.kafka.connect.errors.ConnectException)

Aggregations

Connector (org.apache.kafka.connect.connector.Connector)76 SourceConnector (org.apache.kafka.connect.source.SourceConnector)62 Test (org.junit.Test)54 SinkConnector (org.apache.kafka.connect.sink.SinkConnector)50 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)48 ConfigDef (org.apache.kafka.common.config.ConfigDef)35 HashMap (java.util.HashMap)34 WorkerConnector (org.apache.kafka.connect.runtime.WorkerConnector)31 ConnectorInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo)31 ConfigValue (org.apache.kafka.common.config.ConfigValue)30 Herder (org.apache.kafka.connect.runtime.Herder)27 Map (java.util.Map)26 Config (org.apache.kafka.common.config.Config)26 ConnectorConfig (org.apache.kafka.connect.runtime.ConnectorConfig)24 ArrayList (java.util.ArrayList)21 ConnectorTaskId (org.apache.kafka.connect.util.ConnectorTaskId)20 BadRequestException (org.apache.kafka.connect.runtime.rest.errors.BadRequestException)19 FutureCallback (org.apache.kafka.connect.util.FutureCallback)18 List (java.util.List)15 TaskConfig (org.apache.kafka.connect.runtime.TaskConfig)15