use of org.apache.kafka.connect.util.ConnectorTaskId in project kafka by apache.
the class StandaloneHerder method taskConfigs.
@Override
public synchronized void taskConfigs(String connName, Callback<List<TaskInfo>> callback) {
if (!configState.contains(connName)) {
callback.onCompletion(new NotFoundException("Connector " + connName + " not found", null), null);
return;
}
List<TaskInfo> result = new ArrayList<>();
for (ConnectorTaskId taskId : configState.tasks(connName)) result.add(new TaskInfo(taskId, configState.rawTaskConfig(taskId)));
callback.onCompletion(null, result);
}
use of org.apache.kafka.connect.util.ConnectorTaskId in project kafka by apache.
the class KafkaStatusBackingStore method sendTaskStatus.
private void sendTaskStatus(final TaskStatus status, boolean safeWrite) {
ConnectorTaskId taskId = status.id();
CacheEntry<TaskStatus> entry = getOrAdd(taskId);
String key = TASK_STATUS_PREFIX + taskId.connector() + "-" + taskId.task();
send(key, status, entry, safeWrite);
}
use of org.apache.kafka.connect.util.ConnectorTaskId in project kafka by apache.
the class DistributedHerderTest method testDoRestartConnectorAndTasksNoAssignments.
@Test
public void testDoRestartConnectorAndTasksNoAssignments() {
ConnectorTaskId taskId = new ConnectorTaskId(CONN1, 0);
RestartRequest restartRequest = new RestartRequest(CONN1, false, true);
RestartPlan restartPlan = PowerMock.createMock(RestartPlan.class);
EasyMock.expect(restartPlan.shouldRestartConnector()).andReturn(true).anyTimes();
EasyMock.expect(restartPlan.shouldRestartTasks()).andReturn(true).anyTimes();
EasyMock.expect(restartPlan.taskIdsToRestart()).andReturn(Collections.singletonList(taskId)).anyTimes();
EasyMock.expect(herder.buildRestartPlan(restartRequest)).andReturn(Optional.of(restartPlan)).anyTimes();
PowerMock.replayAll();
herder.assignment = ExtendedAssignment.empty();
herder.doRestartConnectorAndTasks(restartRequest);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.ConnectorTaskId in project kafka by apache.
the class DistributedHerderTest method testDoRestartConnectorAndTasksBoth.
@Test
public void testDoRestartConnectorAndTasksBoth() {
ConnectorTaskId taskId = new ConnectorTaskId(CONN1, 0);
RestartRequest restartRequest = new RestartRequest(CONN1, false, true);
RestartPlan restartPlan = PowerMock.createMock(RestartPlan.class);
EasyMock.expect(restartPlan.shouldRestartConnector()).andReturn(true).anyTimes();
EasyMock.expect(restartPlan.shouldRestartTasks()).andReturn(true).anyTimes();
EasyMock.expect(restartPlan.taskIdsToRestart()).andReturn(Collections.singletonList(taskId)).anyTimes();
EasyMock.expect(restartPlan.restartTaskCount()).andReturn(1).anyTimes();
EasyMock.expect(restartPlan.totalTaskCount()).andReturn(1).anyTimes();
EasyMock.expect(herder.buildRestartPlan(restartRequest)).andReturn(Optional.of(restartPlan)).anyTimes();
herder.assignment = PowerMock.createMock(ExtendedAssignment.class);
EasyMock.expect(herder.assignment.connectors()).andReturn(Collections.singletonList(CONN1)).anyTimes();
EasyMock.expect(herder.assignment.tasks()).andReturn(Collections.singletonList(taskId)).anyTimes();
worker.stopAndAwaitConnector(CONN1);
PowerMock.expectLastCall();
Capture<Callback<TargetState>> stateCallback = newCapture();
worker.startConnector(EasyMock.eq(CONN1), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.eq(herder), EasyMock.anyObject(TargetState.class), capture(stateCallback));
herder.onRestart(CONN1);
EasyMock.expectLastCall();
worker.stopAndAwaitTasks(Collections.singletonList(taskId));
PowerMock.expectLastCall();
herder.onRestart(taskId);
EasyMock.expectLastCall();
worker.startTask(EasyMock.eq(TASK0), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.eq(herder), EasyMock.anyObject(TargetState.class));
PowerMock.expectLastCall().andReturn(true);
PowerMock.replayAll();
herder.doRestartConnectorAndTasks(restartRequest);
PowerMock.verifyAll();
}
use of org.apache.kafka.connect.util.ConnectorTaskId in project kafka by apache.
the class IncrementalCooperativeAssignorTest method testAssignConnectorsWhenImbalanced.
@Test
public void testAssignConnectorsWhenImbalanced() {
List<WorkerLoad> existingAssignment = new ArrayList<>();
existingAssignment.add(workerLoad("worker0", 0, 2, 0, 2));
existingAssignment.add(workerLoad("worker1", 2, 3, 2, 3));
existingAssignment.add(workerLoad("worker2", 5, 4, 5, 4));
existingAssignment.add(emptyWorkerLoad("worker3"));
List<String> newConnectors = newConnectors(9, 24);
List<ConnectorTaskId> newTasks = newTasks(9, 24);
assignor.assignConnectors(existingAssignment, newConnectors);
assignor.assignTasks(existingAssignment, newTasks);
for (WorkerLoad worker : existingAssignment) {
assertEquals(6, worker.connectorsSize());
assertEquals(6, worker.tasksSize());
}
}
Aggregations