@Test public void testResourceTree() throws Exception { prepare(new TestHandler()); Queue<String> resources = new ConcurrentLinkedDeque<>(); List<Resource.Info> infos = new ArrayList<>(); LoadGenerator loadGenerator = new LoadGenerator.Builder() .port(connector.getLocalPort()) .httpClientTransportBuilder(clientTransportBuilder) .resource(new Resource("/", new Resource("/1", new Resource("/11").responseLength(1024)) .responseLength(10 * 1024)) .responseLength(16 * 1024)) .resourceListener((Resource.NodeListener)info -> { resources.offer(info.getResource().getPath()); infos.add(info); }) .resourceListener((Resource.TreeListener)info -> resources.offer(info.getResource().getPath())) .build(); loadGenerator.begin().get(5, TimeUnit.SECONDS); Assert.assertEquals("/,/1,/11,/", resources.stream().collect(Collectors.joining(","))); Assert.assertTrue(infos.stream().allMatch(info -> info.getStatus() == 200)); }
public CompletableFuture<Void> begin() { if (logger.isDebugEnabled()) { logger.debug("generating load, {}", config); } return proceed().thenCompose(x -> { CompletableFuture[] futures = new CompletableFuture[config.getThreads()]; for (int i = 0; i < futures.length; ++i) { futures[i] = CompletableFuture.supplyAsync(this::process, executorService).thenCompose(Function.identity()); } return CompletableFuture.allOf(futures); }).thenComposeAsync(x -> halt(), executorService); }
LoadGenerator extends ContainerLifeCycle { public CompletableFuture<Void> begin() { if (logger.isDebugEnabled()) { logger.debug("generating load, {}", config); } return proceed().thenCompose(x -> { CompletableFuture[] futures = new CompletableFuture[config.getThreads()]; for (int i = 0; i < futures.length; ++i) { futures[i] = CompletableFuture.supplyAsync(this::process, executorService).thenCompose(Function.identity()); } return CompletableFuture.allOf(futures); }).thenComposeAsync(x -> halt(), executorService); } }
LoadGenerator extends ContainerLifeCycle { public CompletableFuture<Void> begin() { if (logger.isDebugEnabled()) { logger.debug("generating load, {}", config); } return proceed().thenCompose(x -> { CompletableFuture[] futures = new CompletableFuture[config.getThreads()]; for (int i = 0; i < futures.length; ++i) { futures[i] = CompletableFuture.supplyAsync(this::process, executorService).thenCompose(Function.identity()); } return CompletableFuture.allOf(futures); }).thenComposeAsync(x -> halt(), executorService); } private  LoadGenerator(Config config); }
LoadGenerator extends ContainerLifeCycle { public CompletableFuture<Void> begin() { if (logger.isDebugEnabled()) { logger.debug("generating load, {}", config); } return proceed().thenCompose(x -> { CompletableFuture[] futures = new CompletableFuture[config.getThreads()]; for (int i = 0; i < futures.length; ++i) { futures[i] = CompletableFuture.supplyAsync(this::process, executorService).thenCompose(Function.identity()); } return CompletableFuture.allOf(futures); }).thenComposeAsync(x -> halt(), executorService); } private  LoadGenerator(Config config); Config getConfig(); CompletableFuture<Void> begin(); @ManagedOperation(value = "Interrupts this LoadGenerator", impact = "ACTION") void interrupt(); }
LoadGenerator extends ContainerLifeCycle { public CompletableFuture<Void> begin() { if (logger.isDebugEnabled()) { logger.debug("generating load, {}", config); } return proceed().thenCompose(x -> { CompletableFuture[] futures = new CompletableFuture[config.getThreads()]; for (int i = 0; i < futures.length; ++i) { futures[i] = CompletableFuture.supplyAsync(this::process, executorService).thenCompose(Function.identity()); } return CompletableFuture.allOf(futures); }).thenComposeAsync(x -> halt(), executorService); } private  LoadGenerator(Config config); Config getConfig(); CompletableFuture<Void> begin(); @ManagedOperation(value = "Interrupts this LoadGenerator", impact = "ACTION") void interrupt();  }