Search in sources :

Example 11 with FutureCallback

use of org.apache.kafka.connect.util.FutureCallback 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);
    expectConfigValidation(config);
    EasyMock.expect(statusBackingStore.getAll(CONNECTOR_NAME)).andReturn(Collections.<TaskStatus>emptyList());
    statusBackingStore.put(new ConnectorStatus(CONNECTOR_NAME, AbstractStatus.State.DESTROYED, WORKER_ID, 0));
    expectDestroy();
    PowerMock.replayAll();
    herder.putConnectorConfig(CONNECTOR_NAME, config, false, createCallback);
    FutureCallback<Herder.Created<ConnectorInfo>> futureCb = new FutureCallback<>();
    herder.deleteConnectorConfig(CONNECTOR_NAME, futureCb);
    futureCb.get(1000L, TimeUnit.MILLISECONDS);
    // Second deletion should fail since the connector is gone
    futureCb = new FutureCallback<>();
    herder.deleteConnectorConfig(CONNECTOR_NAME, futureCb);
    try {
        futureCb.get(1000L, TimeUnit.MILLISECONDS);
        fail("Should have thrown NotFoundException");
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof NotFoundException);
    }
    PowerMock.verifyAll();
}
Also used : ConnectorStatus(org.apache.kafka.connect.runtime.ConnectorStatus) NotFoundException(org.apache.kafka.connect.errors.NotFoundException) ExecutionException(java.util.concurrent.ExecutionException) FutureCallback(org.apache.kafka.connect.util.FutureCallback) Test(org.junit.Test)

Aggregations

FutureCallback (org.apache.kafka.connect.util.FutureCallback)11 ConnectorInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo)6 Test (org.junit.Test)6 Herder (org.apache.kafka.connect.runtime.Herder)5 HashMap (java.util.HashMap)4 ConnectorTaskId (org.apache.kafka.connect.util.ConnectorTaskId)4 Map (java.util.Map)3 ExecutionException (java.util.concurrent.ExecutionException)3 StandaloneHerder (org.apache.kafka.connect.runtime.standalone.StandaloneHerder)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Path (javax.ws.rs.Path)2 IgnitePredicate (org.apache.ignite.lang.IgnitePredicate)2 NotFoundException (org.apache.kafka.connect.errors.NotFoundException)2 ConnectorFactory (org.apache.kafka.connect.runtime.ConnectorFactory)2 URI (java.net.URI)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1