use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo in project kafka by apache.
the class AbstractHerderTest method connectorStatus.
@Test
public void connectorStatus() {
Worker worker = null;
String workerId = "workerId";
String connector = "connector";
int generation = 5;
ConnectorTaskId taskId = new ConnectorTaskId(connector, 0);
ConfigBackingStore configStore = strictMock(ConfigBackingStore.class);
StatusBackingStore statusStore = strictMock(StatusBackingStore.class);
AbstractHerder herder = partialMockBuilder(AbstractHerder.class).withConstructor(Worker.class, String.class, StatusBackingStore.class, ConfigBackingStore.class).withArgs(worker, workerId, statusStore, configStore).addMockedMethod("generation").createMock();
EasyMock.expect(herder.generation()).andStubReturn(generation);
EasyMock.expect(statusStore.get(connector)).andReturn(new ConnectorStatus(connector, AbstractStatus.State.RUNNING, workerId, generation));
EasyMock.expect(statusStore.getAll(connector)).andReturn(Collections.singletonList(new TaskStatus(taskId, AbstractStatus.State.UNASSIGNED, workerId, generation)));
replayAll();
ConnectorStateInfo state = herder.connectorStatus(connector);
assertEquals(connector, state.name());
assertEquals("RUNNING", state.connector().state());
assertEquals(1, state.tasks().size());
assertEquals(workerId, state.connector().workerId());
ConnectorStateInfo.TaskState taskState = state.tasks().get(0);
assertEquals(0, taskState.id());
assertEquals("UNASSIGNED", taskState.state());
assertEquals(workerId, taskState.workerId());
verifyAll();
}
use of org.apache.kafka.connect.runtime.rest.entities.ConnectorStateInfo in project kafka by apache.
the class AbstractHerder method connectorStatus.
@Override
public ConnectorStateInfo connectorStatus(String connName) {
ConnectorStatus connector = statusBackingStore.get(connName);
if (connector == null)
throw new NotFoundException("No status found for connector " + connName);
Collection<TaskStatus> tasks = statusBackingStore.getAll(connName);
ConnectorStateInfo.ConnectorState connectorState = new ConnectorStateInfo.ConnectorState(connector.state().toString(), connector.workerId(), connector.trace());
List<ConnectorStateInfo.TaskState> taskStates = new ArrayList<>();
for (TaskStatus status : tasks) {
taskStates.add(new ConnectorStateInfo.TaskState(status.id().task(), status.state().toString(), status.workerId(), status.trace()));
}
Collections.sort(taskStates);
return new ConnectorStateInfo(connName, connectorState, taskStates);
}
Aggregations