Skip to content

Commit

Permalink
fix usage of wrong list in Stressttest
Browse files Browse the repository at this point in the history
  • Loading branch information
nck-mlcnv committed Aug 9, 2023
1 parent ceabc29 commit f4ca10b
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/main/java/org/aksw/iguana/cc/tasks/impl/Stresstest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.aksw.iguana.cc.tasks.impl;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import org.aksw.iguana.cc.tasks.Task;
import org.aksw.iguana.cc.worker.HttpWorker;
import org.aksw.iguana.cc.worker.ResponseBodyProcessorInstances;
Expand All @@ -23,25 +21,23 @@ public class Stresstest implements Task {
public record Config(
List<HttpWorker.Config> warmupWorkers,
@JsonProperty(required = true) List<HttpWorker.Config> workers
) implements Task.Config {
}


private final long stresstestId;
private final Config config;
) implements Task.Config {}

public record PhaseExecutionConfig(
String name,
List<HttpWorker.Config> workers
) {
}
) {}

public record Result(
long stresstestId,
List<HttpWorker.Result> warmup,
List<HttpWorker.Result> main
) implements Task.Config {
}
) implements Task.Config {}


private final long stresstestId;
private final Config config;


private static final Logger LOGGER = LoggerFactory.getLogger(Stresstest.class);

Expand All @@ -53,13 +49,14 @@ public Stresstest(long stresstestId, Config config, ResponseBodyProcessorInstanc
this.stresstestId = stresstestId;
this.config = config;
long workerId = 0;
if (config.warmupWorkers() != null)
if (config.warmupWorkers() != null) {
for (HttpWorker.Config workerConfig : config.warmupWorkers()) {
for (int i = 0; i < workerConfig.number(); i++) {
var responseBodyProcessor = (workerConfig.parseResults()) ? responseBodyProcessorInstances.getProcessor(workerConfig.acceptHeader()) : null;
warmupWorkers.add(new SPARQLProtocolWorker(workerId++, responseBodyProcessor, (SPARQLProtocolWorker.Config) workerConfig));
}
}
}

for (HttpWorker.Config workerConfig : config.workers()) {
for (int i = 0; i < workerConfig.number(); i++) {
Expand All @@ -71,7 +68,6 @@ public Stresstest(long stresstestId, Config config, ResponseBodyProcessorInstanc

public Result run() {
try {

var warmupResults = executeWorkers(warmupWorkers);
var results = executeWorkers(workers);

Expand All @@ -86,7 +82,7 @@ public Result run() {

private List<HttpWorker.Result> executeWorkers(List<HttpWorker> workers) throws InterruptedException, ExecutionException {
List<HttpWorker.Result> results = new ArrayList<>(workers.size());
var futures = warmupWorkers.stream().map(HttpWorker::start).toList();
var futures = workers.stream().map(HttpWorker::start).toList();
CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).join();
for (CompletableFuture<HttpWorker.Result> future : futures)
results.add(future.get());
Expand Down

0 comments on commit f4ca10b

Please sign in to comment.