@Bean public RequestTypes microEventRequestTypes() { RequestsBeingExecuted def = this.microEventRequestsBeingExecuted(); RequestTypes types = new RequestTypes( bus, requestCapture); types.getMap() .put(def.getType(), def); return types; }
@GET @Produces("application/json") @Path("/requests") public void activeRequests(@Suspended AsyncResponse asyncResponse, @QueryParam("type") final String type) { ReactiveSeq.of((type == null ? "default" : type)) .map(typeToUse -> activeQueries.getMap() .get(typeToUse) .toString()) .foldFuture(WorkerThreads.ioExecutor.get(), s->s.forEach(Long.MAX_VALUE,result -> asyncResponse.resume(result))); }
@Test public void twoEventsDifferentTypesOneFinishedDefaultTypeIsIgnored() { requests = new RequestsBeingExecuted( bus, "typeA"); types.getMap() .put("typeA", requests); bus.post(RequestEvents.start("data", 130l)); bus.post(RequestEvents.start("data", 120l, "typeA", "data2")); bus.post(RequestEvents.finish("data", 120l, "typeA")); assertThat(requests.events(), is(1)); assertThat(requests.size(), is(0)); }
@Before public void setup() { bus = new EventBus(); requests = new RequestsBeingExecuted( bus); types = new RequestTypes( bus, true); types.getMap() .put("default", requests); }
@Before public void setUp() throws Exception { bus = new EventBus(); queries1 = new RequestsBeingExecuted( bus); queries2 = new RequestsBeingExecuted( bus, "partition"); jobs = new JobsBeingExecuted( new EventBus(), 10, JobName.Types.SIMPLE); RequestTypes types = new RequestTypes( bus, true); types.getMap() .put(queries1.getType(), queries1); types.getMap() .put(queries2.getType(), queries2); active = new ActiveResource( types, jobs); }
@Bean public RequestTypes microEventRequestTypes() { RequestsBeingExecuted def = this.microEventRequestsBeingExecuted(); RequestTypes types = new RequestTypes( bus, requestCapture); types.getMap() .put(def.getType(), def); return types; }
@GET @Produces("application/json") @Path("/requests") public void activeRequests(@Suspended AsyncResponse asyncResponse, @QueryParam("type") final String type) { ReactiveSeq.of((type == null ? "default" : type)) .map(typeToUse -> activeQueries.getMap() .get(typeToUse) .toString()) .foldFuture(WorkerThreads.ioExecutor.get(), s->s.forEach(Long.MAX_VALUE,result -> asyncResponse.resume(result))); }