use of org.apache.kafka.trogdor.rest.CreateWorkerRequest in project kafka by apache.
the class AgentTest method testDestroyWorkers.
@Test
public void testDestroyWorkers() throws Exception {
MockTime time = new MockTime(0, 0, 0);
MockScheduler scheduler = new MockScheduler(time);
Agent agent = createAgent(scheduler);
AgentClient client = new AgentClient.Builder().maxTries(10).target("localhost", agent.port()).build();
new ExpectedTasks().waitFor(client);
final NoOpTaskSpec fooSpec = new NoOpTaskSpec(0, 5);
client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, 0, new TextNode("active"))).build()).waitFor(client);
time.sleep(1);
client.destroyWorker(new DestroyWorkerRequest(0));
client.destroyWorker(new DestroyWorkerRequest(0));
client.destroyWorker(new DestroyWorkerRequest(1));
new ExpectedTasks().waitFor(client);
time.sleep(1);
final NoOpTaskSpec fooSpec2 = new NoOpTaskSpec(2, 1);
client.createWorker(new CreateWorkerRequest(1, "foo", fooSpec2));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec2, 2, new TextNode("active"))).build()).waitFor(client);
time.sleep(2);
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec2, 2, 4, new TextNode("done"), "")).build()).waitFor(client);
time.sleep(1);
client.destroyWorker(new DestroyWorkerRequest(1));
new ExpectedTasks().waitFor(client);
agent.beginShutdown();
agent.waitForShutdown();
}
Aggregations