Search in sources :

Example 6 with TasksResponse

use of org.apache.kafka.trogdor.rest.TasksResponse in project kafka by apache.

the class CoordinatorRestResource method tasks.

@GET
@Path("/tasks/")
public Response tasks(@QueryParam("taskId") List<String> taskId, @DefaultValue("0") @QueryParam("firstStartMs") long firstStartMs, @DefaultValue("0") @QueryParam("lastStartMs") long lastStartMs, @DefaultValue("0") @QueryParam("firstEndMs") long firstEndMs, @DefaultValue("0") @QueryParam("lastEndMs") long lastEndMs, @DefaultValue("") @QueryParam("state") String state) throws Throwable {
    boolean isEmptyState = state.equals("");
    if (!isEmptyState && !TaskStateType.Constants.VALUES.contains(state)) {
        return Response.status(400).entity(String.format("State %s is invalid. Must be one of %s", state, TaskStateType.Constants.VALUES)).build();
    }
    Optional<TaskStateType> givenState = Optional.ofNullable(isEmptyState ? null : TaskStateType.valueOf(state));
    TasksResponse resp = coordinator().tasks(new TasksRequest(taskId, firstStartMs, lastStartMs, firstEndMs, lastEndMs, givenState));
    return Response.status(200).entity(resp).build();
}
Also used : TasksResponse(org.apache.kafka.trogdor.rest.TasksResponse) TasksRequest(org.apache.kafka.trogdor.rest.TasksRequest) TaskStateType(org.apache.kafka.trogdor.rest.TaskStateType) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 7 with TasksResponse

use of org.apache.kafka.trogdor.rest.TasksResponse in project kafka by apache.

the class JsonSerializationTest method testDeserializationDoesNotProduceNulls.

@Test
public void testDeserializationDoesNotProduceNulls() throws Exception {
    verify(new FilesUnreadableFaultSpec(0, 0, null, null, null, 0));
    verify(new Kibosh.KiboshControlFile(null));
    verify(new NetworkPartitionFaultSpec(0, 0, null));
    verify(new ProcessStopFaultSpec(0, 0, null, null));
    verify(new AgentStatusResponse(0, null));
    verify(new TasksResponse(null));
    verify(new WorkerDone(null, null, 0, 0, null, null));
    verify(new WorkerRunning(null, null, 0, null));
    verify(new WorkerStopping(null, null, 0, null));
    verify(new ProduceBenchSpec(0, 0, null, null, 0, 0, null, null, Optional.empty(), null, null, null, null, null, false, false));
    verify(new RoundTripWorkloadSpec(0, 0, null, null, null, null, null, null, 0, null, null, 0));
    verify(new TopicsSpec());
    verify(new PartitionsSpec(0, (short) 0, null, null));
    Map<Integer, List<Integer>> partitionAssignments = new HashMap<Integer, List<Integer>>();
    partitionAssignments.put(0, Arrays.asList(1, 2, 3));
    partitionAssignments.put(1, Arrays.asList(1, 2, 3));
    verify(new PartitionsSpec(0, (short) 0, partitionAssignments, null));
    verify(new PartitionsSpec(0, (short) 0, null, null));
}
Also used : WorkerDone(org.apache.kafka.trogdor.rest.WorkerDone) WorkerStopping(org.apache.kafka.trogdor.rest.WorkerStopping) TasksResponse(org.apache.kafka.trogdor.rest.TasksResponse) WorkerRunning(org.apache.kafka.trogdor.rest.WorkerRunning) HashMap(java.util.HashMap) NetworkPartitionFaultSpec(org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec) RoundTripWorkloadSpec(org.apache.kafka.trogdor.workload.RoundTripWorkloadSpec) Kibosh(org.apache.kafka.trogdor.fault.Kibosh) AgentStatusResponse(org.apache.kafka.trogdor.rest.AgentStatusResponse) ProcessStopFaultSpec(org.apache.kafka.trogdor.fault.ProcessStopFaultSpec) ProduceBenchSpec(org.apache.kafka.trogdor.workload.ProduceBenchSpec) PartitionsSpec(org.apache.kafka.trogdor.workload.PartitionsSpec) FilesUnreadableFaultSpec(org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec) List(java.util.List) TopicsSpec(org.apache.kafka.trogdor.workload.TopicsSpec) Test(org.junit.jupiter.api.Test)

Aggregations

TasksResponse (org.apache.kafka.trogdor.rest.TasksResponse)7 TasksRequest (org.apache.kafka.trogdor.rest.TasksRequest)4 WorkerRunning (org.apache.kafka.trogdor.rest.WorkerRunning)3 HashMap (java.util.HashMap)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 FilesUnreadableFaultSpec (org.apache.kafka.trogdor.fault.FilesUnreadableFaultSpec)2 Kibosh (org.apache.kafka.trogdor.fault.Kibosh)2 NetworkPartitionFaultSpec (org.apache.kafka.trogdor.fault.NetworkPartitionFaultSpec)2 ProcessStopFaultSpec (org.apache.kafka.trogdor.fault.ProcessStopFaultSpec)2 AgentStatusResponse (org.apache.kafka.trogdor.rest.AgentStatusResponse)2 CreateTaskRequest (org.apache.kafka.trogdor.rest.CreateTaskRequest)2 TaskStateType (org.apache.kafka.trogdor.rest.TaskStateType)2 WorkerDone (org.apache.kafka.trogdor.rest.WorkerDone)2 WorkerStopping (org.apache.kafka.trogdor.rest.WorkerStopping)2 ProduceBenchSpec (org.apache.kafka.trogdor.workload.ProduceBenchSpec)2 RoundTripWorkloadSpec (org.apache.kafka.trogdor.workload.RoundTripWorkloadSpec)2 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 ZoneOffset (java.time.ZoneOffset)1