Search in sources :

Example 1 with TaskState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState in project kafka by apache.

the class RestartPlanTest method testRestartPlan.

@Test
public void testRestartPlan() {
    ConnectorStateInfo.ConnectorState state = new ConnectorStateInfo.ConnectorState(AbstractStatus.State.RESTARTING.name(), "foo", null);
    List<TaskState> tasks = new ArrayList<>();
    tasks.add(new TaskState(1, AbstractStatus.State.RUNNING.name(), "worker1", null));
    tasks.add(new TaskState(2, AbstractStatus.State.PAUSED.name(), "worker1", null));
    tasks.add(new TaskState(3, AbstractStatus.State.RESTARTING.name(), "worker1", null));
    tasks.add(new TaskState(4, AbstractStatus.State.DESTROYED.name(), "worker1", null));
    tasks.add(new TaskState(5, AbstractStatus.State.RUNNING.name(), "worker1", null));
    tasks.add(new TaskState(6, AbstractStatus.State.RUNNING.name(), "worker1", null));
    ConnectorStateInfo connectorStateInfo = new ConnectorStateInfo(CONNECTOR_NAME, state, tasks, ConnectorType.SOURCE);
    RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, false, true);
    RestartPlan restartPlan = new RestartPlan(restartRequest, connectorStateInfo);
    assertTrue(restartPlan.shouldRestartConnector());
    assertTrue(restartPlan.shouldRestartTasks());
    assertEquals(1, restartPlan.taskIdsToRestart().size());
    assertEquals(3, restartPlan.taskIdsToRestart().iterator().next().task());
    assertTrue(restartPlan.toString().contains("plan to restart connector"));
}
Also used : ArrayList(java.util.ArrayList) TaskState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) Test(org.junit.Test)

Example 2 with TaskState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState in project ksql by confluentinc.

the class ConsoleTest method testPrintConnectorDescription.

@Test
public void testPrintConnectorDescription() {
    // Given:
    final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new ConnectorDescription("STATEMENT", "io.confluent.Connector", new ConnectorStateInfo("name", new ConnectorState("state", "worker", "msg"), ImmutableList.of(new TaskState(0, "task", "worker", "task_msg")), ConnectorType.SOURCE), ImmutableList.of(sourceDescription), ImmutableList.of("a-jdbc-topic"), ImmutableList.of())));
    // When:
    console.printKsqlEntityList(entityList);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) ConnectorState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState) ConnectorDescription(io.confluent.ksql.rest.entity.ConnectorDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) TaskState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) Test(org.junit.Test)

Example 3 with TaskState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState in project kafka by apache.

the class RestartPlanTest method testRestartsOnlyConnector.

@Test
public void testRestartsOnlyConnector() {
    ConnectorStateInfo.ConnectorState state = new ConnectorStateInfo.ConnectorState(AbstractStatus.State.RESTARTING.name(), "foo", null);
    List<TaskState> tasks = new ArrayList<>();
    tasks.add(new TaskState(1, AbstractStatus.State.RUNNING.name(), "worker1", null));
    tasks.add(new TaskState(2, AbstractStatus.State.PAUSED.name(), "worker1", null));
    ConnectorStateInfo connectorStateInfo = new ConnectorStateInfo(CONNECTOR_NAME, state, tasks, ConnectorType.SOURCE);
    RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, false, true);
    RestartPlan restartPlan = new RestartPlan(restartRequest, connectorStateInfo);
    assertTrue(restartPlan.shouldRestartConnector());
    assertFalse(restartPlan.shouldRestartTasks());
    assertEquals(0, restartPlan.taskIdsToRestart().size());
}
Also used : ArrayList(java.util.ArrayList) TaskState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) Test(org.junit.Test)

Example 4 with TaskState

use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState in project kafka by apache.

the class RestartPlanTest method testNoRestartsPlan.

@Test
public void testNoRestartsPlan() {
    ConnectorStateInfo.ConnectorState state = new ConnectorStateInfo.ConnectorState(AbstractStatus.State.RUNNING.name(), "foo", null);
    List<TaskState> tasks = new ArrayList<>();
    tasks.add(new TaskState(1, AbstractStatus.State.RUNNING.name(), "worker1", null));
    tasks.add(new TaskState(2, AbstractStatus.State.PAUSED.name(), "worker1", null));
    ConnectorStateInfo connectorStateInfo = new ConnectorStateInfo(CONNECTOR_NAME, state, tasks, ConnectorType.SOURCE);
    RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, false, true);
    RestartPlan restartPlan = new RestartPlan(restartRequest, connectorStateInfo);
    assertFalse(restartPlan.shouldRestartConnector());
    assertFalse(restartPlan.shouldRestartTasks());
    assertEquals(0, restartPlan.taskIdsToRestart().size());
    assertTrue(restartPlan.toString().contains("plan to restart 0 of"));
}
Also used : ArrayList(java.util.ArrayList) TaskState(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState) ConnectorStateInfo(org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo) Test(org.junit.Test)

Aggregations

ConnectorStateInfo (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo)4 TaskState (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.TaskState)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ConnectorDescription (io.confluent.ksql.rest.entity.ConnectorDescription)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 ConnectorState (org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo.ConnectorState)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1