use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project kafka by apache.
the class AgentTest method testAgentFinishesTasks.
@Test
public void testAgentFinishesTasks() throws Exception {
long startTimeMs = 2000;
MockTime time = new MockTime(0, startTimeMs, 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(startTimeMs, 2);
long fooSpecStartTimeMs = startTimeMs;
client.createWorker(new CreateWorkerRequest(0, "foo", fooSpec));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, startTimeMs, new TextNode("active"))).build()).waitFor(client);
time.sleep(1);
long barSpecWorkerId = 1;
long barSpecStartTimeMs = startTimeMs + 1;
final NoOpTaskSpec barSpec = new NoOpTaskSpec(startTimeMs, 900000);
client.createWorker(new CreateWorkerRequest(barSpecWorkerId, "bar", barSpec));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerRunning("foo", fooSpec, fooSpecStartTimeMs, new TextNode("active"))).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning("bar", barSpec, barSpecStartTimeMs, new TextNode("active"))).build()).waitFor(client);
time.sleep(1);
// foo task expired
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec, fooSpecStartTimeMs, fooSpecStartTimeMs + 2, new TextNode("done"), "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerRunning("bar", barSpec, barSpecStartTimeMs, new TextNode("active"))).build()).waitFor(client);
time.sleep(5);
client.stopWorker(new StopWorkerRequest(barSpecWorkerId));
new ExpectedTasks().addTask(new ExpectedTaskBuilder("foo").workerState(new WorkerDone("foo", fooSpec, fooSpecStartTimeMs, fooSpecStartTimeMs + 2, new TextNode("done"), "")).build()).addTask(new ExpectedTaskBuilder("bar").workerState(new WorkerDone("bar", barSpec, barSpecStartTimeMs, startTimeMs + 7, new TextNode("done"), "")).build()).waitFor(client);
agent.beginShutdown();
agent.waitForShutdown();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project kafka by apache.
the class DegradedNetworkFaultWorker method start.
@Override
public void start(Platform platform, WorkerStatusTracker status, KafkaFutureImpl<String> haltFuture) throws Exception {
log.info("Activating DegradedNetworkFaultWorker {}.", id);
this.status = status;
this.status.update(new TextNode("enabling traffic control " + id));
Node curNode = platform.curNode();
DegradedNetworkFaultSpec.NodeDegradeSpec nodeSpec = nodeSpecs.get(curNode.name());
if (nodeSpec != null) {
for (String device : devicesForSpec(nodeSpec)) {
if (nodeSpec.latencyMs() < 0 || nodeSpec.rateLimitKbit() < 0) {
throw new RuntimeException("Expected non-negative values for latencyMs and rateLimitKbit, but got " + nodeSpec);
} else {
enableTrafficControl(platform, device, nodeSpec.latencyMs(), nodeSpec.rateLimitKbit());
}
}
}
this.status.update(new TextNode("enabled traffic control " + id));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project kafka by apache.
the class KiboshFaultWorker method start.
@Override
public void start(Platform platform, WorkerStatusTracker status, KafkaFutureImpl<String> errorFuture) throws Exception {
log.info("Activating {} {}: {}.", spec.getClass().getSimpleName(), id, spec);
this.status = status;
this.status.update(new TextNode("Adding fault " + id));
Kibosh.INSTANCE.addFault(mountPath, spec);
this.status.update(new TextNode("Added fault " + id));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project kafka by apache.
the class KiboshFaultWorker method stop.
@Override
public void stop(Platform platform) throws Exception {
log.info("Deactivating {} {}: {}.", spec.getClass().getSimpleName(), id, spec);
this.status.update(new TextNode("Removing fault " + id));
Kibosh.INSTANCE.removeFault(mountPath, spec);
this.status.update(new TextNode("Removed fault " + id));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project kafka by apache.
the class ExternalCommandWorker method start.
@Override
public void start(Platform platform, WorkerStatusTracker status, KafkaFutureImpl<String> doneFuture) throws Exception {
if (!running.compareAndSet(false, true)) {
throw new IllegalStateException("ConsumeBenchWorker is already running.");
}
log.info("{}: Activating ExternalCommandWorker with {}", id, spec);
this.status = status;
this.doneFuture = doneFuture;
this.executor = Executors.newCachedThreadPool(ThreadUtils.createThreadFactory("ExternalCommandWorkerThread%d", false));
Process process = null;
try {
process = startProcess();
} catch (Throwable t) {
log.error("{}: Unable to start process", id, t);
executor.shutdown();
doneFuture.complete("Unable to start process: " + t.getMessage());
return;
}
Future<?> stdoutFuture = executor.submit(new StdoutMonitor(process));
Future<?> stderrFuture = executor.submit(new StderrMonitor(process));
executor.submit(new StdinWriter(process));
Future<?> terminatorFuture = executor.submit(new Terminator(process));
executor.submit(new ExitMonitor(process, stdoutFuture, stderrFuture, terminatorFuture));
ObjectNode startMessage = new ObjectNode(JsonNodeFactory.instance);
startMessage.set("id", new TextNode(id));
startMessage.set("workload", spec.workload());
stdinQueue.add(Optional.of(startMessage));
}
Aggregations