Search in sources :

Example 1 with RebalanceNeededException

use of org.apache.kafka.connect.runtime.distributed.RebalanceNeededException in project kafka by apache.

the class ConnectorsResourceTest method testRestartConnectorAndTasksRebalanceNeeded.

@Test
public void testRestartConnectorAndTasksRebalanceNeeded() {
    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 RebalanceNeededException("Request cannot be completed because a rebalance is expected"));
    PowerMock.replayAll();
    ConnectRestException ex = assertThrows(ConnectRestException.class, () -> connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS, restartRequest.includeTasks(), restartRequest.onlyFailed(), FORWARD));
    assertEquals(Response.Status.CONFLICT.getStatusCode(), ex.statusCode());
    PowerMock.verifyAll();
}
Also used : ConnectRestException(org.apache.kafka.connect.runtime.rest.errors.ConnectRestException) Callback(org.apache.kafka.connect.util.Callback) RebalanceNeededException(org.apache.kafka.connect.runtime.distributed.RebalanceNeededException) RestartRequest(org.apache.kafka.connect.runtime.RestartRequest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

RestartRequest (org.apache.kafka.connect.runtime.RestartRequest)1 RebalanceNeededException (org.apache.kafka.connect.runtime.distributed.RebalanceNeededException)1 ConnectRestException (org.apache.kafka.connect.runtime.rest.errors.ConnectRestException)1 Callback (org.apache.kafka.connect.util.Callback)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1