Search in sources :

Example 1 with NotFoundException

use of org.apache.kafka.connect.errors.NotFoundException in project apache-kafka-on-k8s by banzaicloud.

the class StandaloneHerder method deleteConnectorConfig.

@Override
public synchronized void deleteConnectorConfig(String connName, Callback<Created<ConnectorInfo>> callback) {
    try {
        if (!configState.contains(connName)) {
            // Deletion, must already exist
            callback.onCompletion(new NotFoundException("Connector " + connName + " not found", null), null);
            return;
        }
        removeConnectorTasks(connName);
        worker.stopConnector(connName);
        configBackingStore.removeConnectorConfig(connName);
        onDeletion(connName);
        callback.onCompletion(null, new Created<ConnectorInfo>(false, null));
    } catch (ConnectException e) {
        callback.onCompletion(e, null);
    }
}
Also used : ConnectorInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) ConnectException(org.apache.kafka.connect.errors.ConnectException)

Example 2 with NotFoundException

use of org.apache.kafka.connect.errors.NotFoundException in project apache-kafka-on-k8s by banzaicloud.

the class StandaloneHerder method taskConfigs.

@Override
public synchronized void taskConfigs(String connName, Callback<List<TaskInfo>> callback) {
    if (!configState.contains(connName)) {
        callback.onCompletion(new NotFoundException("Connector " + connName + " not found", null), null);
        return;
    }
    List<TaskInfo> result = new ArrayList<>();
    for (ConnectorTaskId taskId : configState.tasks(connName)) result.add(new TaskInfo(taskId, configState.taskConfig(taskId)));
    callback.onCompletion(null, result);
}
Also used : TaskInfo(org.apache.kafka.connect.runtime.rest.entities.TaskInfo) ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) ArrayList(java.util.ArrayList) NotFoundException(org.apache.kafka.connect.errors.NotFoundException)

Example 3 with NotFoundException

use of org.apache.kafka.connect.errors.NotFoundException in project apache-kafka-on-k8s by banzaicloud.

the class ConnectorsResourceTest method testGetConnectorTaskConfigsConnectorNotFound.

@Test(expected = NotFoundException.class)
public void testGetConnectorTaskConfigsConnectorNotFound() throws Throwable {
    final Capture<Callback<List<TaskInfo>>> cb = Capture.newInstance();
    herder.taskConfigs(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    expectAndCallbackException(cb, new NotFoundException("connector not found"));
    PowerMock.replayAll();
    connectorsResource.getTaskConfigs(CONNECTOR_NAME, FORWARD);
    PowerMock.verifyAll();
}
Also used : TaskInfo(org.apache.kafka.connect.runtime.rest.entities.TaskInfo) Callback(org.apache.kafka.connect.util.Callback) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with NotFoundException

use of org.apache.kafka.connect.errors.NotFoundException in project apache-kafka-on-k8s by banzaicloud.

the class ConnectorsResourceTest method testGetConnectorConfigConnectorNotFound.

@Test(expected = NotFoundException.class)
public void testGetConnectorConfigConnectorNotFound() throws Throwable {
    final Capture<Callback<Map<String, String>>> cb = Capture.newInstance();
    herder.connectorConfig(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    expectAndCallbackException(cb, new NotFoundException("not found"));
    PowerMock.replayAll();
    connectorsResource.getConnectorConfig(CONNECTOR_NAME, FORWARD);
    PowerMock.verifyAll();
}
Also used : Callback(org.apache.kafka.connect.util.Callback) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with NotFoundException

use of org.apache.kafka.connect.errors.NotFoundException in project apache-kafka-on-k8s by banzaicloud.

the class ConnectorsResourceTest method testRestartConnectorNotFound.

@Test(expected = NotFoundException.class)
public void testRestartConnectorNotFound() throws Throwable {
    final Capture<Callback<Void>> cb = Capture.newInstance();
    herder.restartConnector(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    expectAndCallbackException(cb, new NotFoundException("not found"));
    PowerMock.replayAll();
    connectorsResource.restartConnector(CONNECTOR_NAME, FORWARD);
    PowerMock.verifyAll();
}
Also used : Callback(org.apache.kafka.connect.util.Callback) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

NotFoundException (org.apache.kafka.connect.errors.NotFoundException)48 Test (org.junit.Test)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 Callback (org.apache.kafka.connect.util.Callback)14 ConnectorTaskId (org.apache.kafka.connect.util.ConnectorTaskId)11 ConnectException (org.apache.kafka.connect.errors.ConnectException)9 ExecutionException (java.util.concurrent.ExecutionException)8 FutureCallback (org.apache.kafka.connect.util.FutureCallback)8 ArrayList (java.util.ArrayList)7 ConnectorInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo)7 ConnectorStateInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo)6 TaskInfo (org.apache.kafka.connect.runtime.rest.entities.TaskInfo)6 NoSuchElementException (java.util.NoSuchElementException)5 TimeoutException (java.util.concurrent.TimeoutException)5 WakeupException (org.apache.kafka.common.errors.WakeupException)5 AlreadyExistsException (org.apache.kafka.connect.errors.AlreadyExistsException)5 RestartRequest (org.apache.kafka.connect.runtime.RestartRequest)5 Herder (org.apache.kafka.connect.runtime.Herder)4 BadRequestException (org.apache.kafka.connect.runtime.rest.errors.BadRequestException)4 Connector (org.apache.kafka.connect.connector.Connector)3