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"));
}
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);
}
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());
}
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"));
}
Aggregations