Search in sources :

Example 1 with NotAssignedException

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

the class ConnectorsResourceTest method testRestartConnectorOwnerRedirect.

@Test
public void testRestartConnectorOwnerRedirect() throws Throwable {
    final Capture<Callback<Void>> cb = Capture.newInstance();
    herder.restartConnector(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    String ownerUrl = "http://owner:8083";
    expectAndCallbackException(cb, new NotAssignedException("not owner test", ownerUrl));
    EasyMock.expect(RestServer.httpRequest(EasyMock.eq("http://owner:8083/connectors/" + CONNECTOR_NAME + "/restart?forward=false"), EasyMock.eq("POST"), EasyMock.isNull(), EasyMock.<TypeReference>anyObject())).andReturn(new RestServer.HttpResponse<>(202, new HashMap<String, List<String>>(), null));
    PowerMock.replayAll();
    connectorsResource.restartConnector(CONNECTOR_NAME, true);
    PowerMock.verifyAll();
}
Also used : RestServer(org.apache.kafka.connect.runtime.rest.RestServer) Callback(org.apache.kafka.connect.util.Callback) HashMap(java.util.HashMap) NotAssignedException(org.apache.kafka.connect.runtime.distributed.NotAssignedException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with NotAssignedException

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

the class ConnectorsResourceTest method testRestartTaskOwnerRedirect.

@Test
public void testRestartTaskOwnerRedirect() throws Throwable {
    ConnectorTaskId taskId = new ConnectorTaskId(CONNECTOR_NAME, 0);
    final Capture<Callback<Void>> cb = Capture.newInstance();
    herder.restartTask(EasyMock.eq(taskId), EasyMock.capture(cb));
    String ownerUrl = "http://owner:8083";
    expectAndCallbackException(cb, new NotAssignedException("not owner test", ownerUrl));
    EasyMock.expect(RestServer.httpRequest(EasyMock.eq("http://owner:8083/connectors/" + CONNECTOR_NAME + "/tasks/0/restart?forward=false"), EasyMock.eq("POST"), EasyMock.isNull(), EasyMock.<TypeReference>anyObject())).andReturn(new RestServer.HttpResponse<>(202, new HashMap<String, List<String>>(), null));
    PowerMock.replayAll();
    connectorsResource.restartTask(CONNECTOR_NAME, 0, true);
    PowerMock.verifyAll();
}
Also used : RestServer(org.apache.kafka.connect.runtime.rest.RestServer) Callback(org.apache.kafka.connect.util.Callback) ConnectorTaskId(org.apache.kafka.connect.util.ConnectorTaskId) HashMap(java.util.HashMap) NotAssignedException(org.apache.kafka.connect.runtime.distributed.NotAssignedException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 NotAssignedException (org.apache.kafka.connect.runtime.distributed.NotAssignedException)2 RestServer (org.apache.kafka.connect.runtime.rest.RestServer)2 Callback (org.apache.kafka.connect.util.Callback)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ConnectorTaskId (org.apache.kafka.connect.util.ConnectorTaskId)1