use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
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.stopAndAwaitConnector(connName);
configBackingStore.removeConnectorConfig(connName);
onDeletion(connName);
callback.onCompletion(null, new Created<>(false, null));
} catch (ConnectException e) {
callback.onCompletion(e, null);
}
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class DistributedHerderTest method testRestartConnectorAndTasksUnknownConnector.
@Test
public void testRestartConnectorAndTasksUnknownConnector() throws Exception {
String connectorName = "UnknownConnector";
RestartRequest restartRequest = new RestartRequest(connectorName, false, true);
// get the initial assignment
EasyMock.expect(member.memberId()).andStubReturn("leader");
EasyMock.expect(member.currentProtocolVersion()).andStubReturn(CONNECT_PROTOCOL_V0);
expectRebalance(1, Collections.emptyList(), Collections.emptyList());
expectPostRebalanceCatchup(SNAPSHOT);
member.poll(EasyMock.anyInt());
PowerMock.expectLastCall();
// now handle the connector restart
member.wakeup();
PowerMock.expectLastCall();
member.ensureActive();
PowerMock.expectLastCall();
member.poll(EasyMock.anyInt());
PowerMock.expectLastCall();
PowerMock.replayAll();
herder.tick();
FutureCallback<ConnectorStateInfo> callback = new FutureCallback<>();
herder.restartConnectorAndTasks(restartRequest, callback);
herder.tick();
ExecutionException ee = assertThrows(ExecutionException.class, () -> callback.get(1000L, TimeUnit.MILLISECONDS));
assertTrue(ee.getCause() instanceof NotFoundException);
assertTrue(ee.getMessage().contains("Unknown connector:"));
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class StandaloneHerderTest method testRestartConnectorAndTasksUnknownConnector.
@Test
public void testRestartConnectorAndTasksUnknownConnector() {
PowerMock.replayAll();
FutureCallback<ConnectorStateInfo> restartCallback = new FutureCallback<>();
RestartRequest restartRequest = new RestartRequest("UnknownConnector", false, true);
herder.restartConnectorAndTasks(restartRequest, restartCallback);
ExecutionException ee = assertThrows(ExecutionException.class, () -> restartCallback.get(1000L, TimeUnit.MILLISECONDS));
assertTrue(ee.getCause() instanceof NotFoundException);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class StandaloneHerderTest method testDestroyConnector.
@Test
public void testDestroyConnector() throws Exception {
connector = PowerMock.createMock(BogusSourceConnector.class);
expectAdd(SourceSink.SOURCE);
Map<String, String> config = connectorConfig(SourceSink.SOURCE);
Connector connectorMock = PowerMock.createMock(SourceConnector.class);
expectConfigValidation(connectorMock, true, config);
EasyMock.expect(statusBackingStore.getAll(CONNECTOR_NAME)).andReturn(Collections.emptyList());
statusBackingStore.put(new ConnectorStatus(CONNECTOR_NAME, AbstractStatus.State.DESTROYED, WORKER_ID, 0));
statusBackingStore.put(new TaskStatus(new ConnectorTaskId(CONNECTOR_NAME, 0), TaskStatus.State.DESTROYED, WORKER_ID, 0));
expectDestroy();
PowerMock.replayAll();
herder.putConnectorConfig(CONNECTOR_NAME, config, false, createCallback);
Herder.Created<ConnectorInfo> connectorInfo = createCallback.get(1000L, TimeUnit.SECONDS);
assertEquals(createdInfo(SourceSink.SOURCE), connectorInfo.result());
FutureCallback<Herder.Created<ConnectorInfo>> deleteCallback = new FutureCallback<>();
herder.deleteConnectorConfig(CONNECTOR_NAME, deleteCallback);
deleteCallback.get(1000L, TimeUnit.MILLISECONDS);
// Second deletion should fail since the connector is gone
FutureCallback<Herder.Created<ConnectorInfo>> failedDeleteCallback = new FutureCallback<>();
herder.deleteConnectorConfig(CONNECTOR_NAME, failedDeleteCallback);
try {
failedDeleteCallback.get(1000L, TimeUnit.MILLISECONDS);
fail("Should have thrown NotFoundException");
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof NotFoundException);
}
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.errors.NotFoundException in project kafka by apache.
the class ConnectorsResourceTest method testRestartConnectorAndTasksConnectorNotFound.
@Test
public void testRestartConnectorAndTasksConnectorNotFound() {
RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, true, false);
final Capture<Callback<ConnectorStateInfo>> cb = Capture.newInstance();
herder.restartConnectorAndTasks(EasyMock.eq(restartRequest), EasyMock.capture(cb));
expectAndCallbackException(cb, new NotFoundException("not found"));
PowerMock.replayAll();
assertThrows(NotFoundException.class, () -> connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS, restartRequest.includeTasks(), restartRequest.onlyFailed(), FORWARD));
PowerMock.verifyAll();
}
Aggregations