use of com.linkedin.parseq.CountingEngine in project rest.li by linkedin.
the class TestMultiplexerRunMode method engine.
private CountingEngine engine() {
ExecutorService taskScheduler = Executors.newFixedThreadPool(1);
ScheduledExecutorService timerScheduler = Executors.newSingleThreadScheduledExecutor();
CountingEngine countingEngine = new CountingEngine(taskScheduler, new DelayedExecutorAdapter(timerScheduler), LoggerFactory.getILoggerFactory(), Maps.newHashMap());
return countingEngine;
}
use of com.linkedin.parseq.CountingEngine in project rest.li by linkedin.
the class TestMultiplexerRunMode method testMultiplexedAsyncGetRequest.
@Test(dataProvider = "multiplexerConfigurations")
public void testMultiplexedAsyncGetRequest(MultiplexerRunMode multiplexerRunMode) throws URISyntaxException, IOException, InterruptedException {
RestLiConfig config = new RestLiConfig();
config.addResourcePackageNames("com.linkedin.restli.server.multiplexer.resources");
config.setMultiplexerRunMode(multiplexerRunMode);
CountingEngine engine = engine();
RestLiServer server = new RestLiServer(config, resourceFactory(), engine);
IndividualRequest r0 = individualRequest("/users/0", null, Collections.<String, IndividualRequest>emptyMap());
IndividualRequest r1 = individualRequest("/users/1", null, Collections.<String, IndividualRequest>emptyMap());
IndividualRequest r2 = individualRequest("/users/2", null, ImmutableMap.of("0", r0, "1", r1));
// request is seq(par(r0, r1), r2)
RestRequest request = muxRestRequest(ImmutableMap.of("2", r2));
CountDownLatch latch = new CountDownLatch(1);
server.handleRequest(request, new RequestContext(), callback(latch));
assertTrue(latch.await(5, TimeUnit.SECONDS));
if (multiplexerRunMode == MultiplexerRunMode.SINGLE_PLAN) {
assertEquals(engine.plansStarted(), 1);
} else {
// in MULTIPLE_PLANS mode: 1 task for multiplexed request itself + 3 individual tasks r0, r1, r2
assertEquals(engine.plansStarted(), 1 + 3);
}
}
Aggregations