-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
further integrate the previous merge
* this commit also moved some packages
- Loading branch information
Showing
55 changed files
with
901 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/cc/tasks/stresstest/metrics/Metric.java → ...va/org/aksw/iguana/cc/metrics/Metric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sks/stresstest/metrics/MetricManager.java → ...aksw/iguana/cc/metrics/MetricManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.aksw.iguana.cc.tasks.stresstest.metrics; | ||
package org.aksw.iguana.cc.metrics; | ||
|
||
import java.util.List; | ||
|
||
|
20 changes: 20 additions & 0 deletions
20
src/main/java/org/aksw/iguana/cc/metrics/ModelWritingMetric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.aksw.iguana.cc.metrics; | ||
|
||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
import org.aksw.iguana.commons.rdf.IRES; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ModelFactory; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface ModelWritingMetric { | ||
default @Nonnull Model createMetricModel(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data, IRES.Factory iresFactory) { | ||
return ModelFactory.createDefaultModel(); | ||
} | ||
|
||
default @Nonnull Model createMetricModel(List<HttpWorker> workers, Map<String, List<HttpWorker.ExecutionStats>> data, IRES.Factory iresFactory) { | ||
return ModelFactory.createDefaultModel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.aksw.iguana.cc.metrics; | ||
|
||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
|
||
import java.util.List; | ||
|
||
public interface QueryMetric { | ||
Number calculateQueryMetric(List<HttpWorker.ExecutionStats> data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.aksw.iguana.cc.metrics; | ||
|
||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
|
||
import java.util.List; | ||
|
||
public interface TaskMetric { | ||
Number calculateTaskMetric(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.aksw.iguana.cc.metrics; | ||
|
||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
|
||
import java.util.List; | ||
|
||
public interface WorkerMetric { | ||
Number calculateWorkerMetric(HttpWorker.Config worker, List<HttpWorker.ExecutionStats>[] data); | ||
} |
92 changes: 92 additions & 0 deletions
92
src/main/java/org/aksw/iguana/cc/metrics/impl/AggregatedExecutionStatistics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.aksw.iguana.cc.metrics.impl; | ||
|
||
import org.aksw.iguana.cc.metrics.Metric; | ||
import org.aksw.iguana.cc.metrics.ModelWritingMetric; | ||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
import org.aksw.iguana.commons.rdf.IONT; | ||
import org.aksw.iguana.commons.rdf.IPROP; | ||
import org.aksw.iguana.commons.rdf.IRES; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ModelFactory; | ||
import org.apache.jena.rdf.model.Resource; | ||
import org.apache.jena.rdf.model.ResourceFactory; | ||
import org.apache.jena.vocabulary.RDF; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.math.BigInteger; | ||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static org.aksw.iguana.commons.time.TimeUtils.toXSDDurationInSeconds; | ||
|
||
public class AggregatedExecutionStatistics extends Metric implements ModelWritingMetric { | ||
|
||
public AggregatedExecutionStatistics() { | ||
super("Aggregated Execution Statistics", "AES", "Sums up the statistics of each query execution for each query a worker and task has. The result size only contains the value of the last execution."); | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public Model createMetricModel(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data, IRES.Factory iresFactory) { | ||
Model m = ModelFactory.createDefaultModel(); | ||
for (var worker : workers) { | ||
for (int i = 0; i < worker.config().queries().getQueryCount(); i++) { | ||
Resource queryRes = iresFactory.getWorkerQueryResource(worker, i); | ||
m.add(createAggregatedModel(data[(int) worker.getWorkerID()][i], queryRes)); | ||
} | ||
} | ||
return m; | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public Model createMetricModel(List<HttpWorker> workers, Map<String, List<HttpWorker.ExecutionStats>> data, IRES.Factory iresFactory) { | ||
Model m = ModelFactory.createDefaultModel(); | ||
for (String queryID : data.keySet()) { | ||
Resource queryRes = iresFactory.getTaskQueryResource(queryID); | ||
m.add(createAggregatedModel(data.get(queryID), queryRes)); | ||
} | ||
return m; | ||
} | ||
|
||
private static Model createAggregatedModel(List<HttpWorker.ExecutionStats> data, Resource queryRes) { | ||
Model m = ModelFactory.createDefaultModel(); | ||
BigInteger succeeded = BigInteger.ZERO; | ||
BigInteger failed = BigInteger.ZERO; | ||
Optional<BigInteger> resultSize = Optional.empty(); | ||
BigInteger wrongCodes = BigInteger.ZERO; | ||
BigInteger timeOuts = BigInteger.ZERO; | ||
BigInteger unknownExceptions = BigInteger.ZERO; | ||
Duration totalTime = Duration.ZERO; | ||
|
||
for (HttpWorker.ExecutionStats exec : data) { | ||
switch (exec.endState()) { | ||
case SUCCESS -> succeeded = succeeded.add(BigInteger.ONE); | ||
case TIMEOUT -> timeOuts = timeOuts.add(BigInteger.ONE); | ||
case HTTP_ERROR -> wrongCodes = wrongCodes.add(BigInteger.ONE); | ||
case MISCELLANEOUS_EXCEPTION -> unknownExceptions = unknownExceptions.add(BigInteger.ONE); | ||
} | ||
|
||
if (!exec.successful()) | ||
failed = failed.add(BigInteger.ONE); | ||
|
||
totalTime = totalTime.plus(exec.duration()); | ||
if (exec.contentLength().isPresent()) | ||
resultSize = Optional.of(BigInteger.valueOf(exec.contentLength().getAsLong())); | ||
} | ||
|
||
m.add(queryRes, IPROP.succeeded, ResourceFactory.createTypedLiteral(succeeded)); | ||
m.add(queryRes, IPROP.failed, ResourceFactory.createTypedLiteral(failed)); | ||
if (resultSize.isPresent()) | ||
m.add(queryRes, IPROP.resultSize, ResourceFactory.createTypedLiteral(resultSize.get())); | ||
m.add(queryRes, IPROP.timeOuts, ResourceFactory.createTypedLiteral(timeOuts)); | ||
m.add(queryRes, IPROP.wrongCodes, ResourceFactory.createTypedLiteral(wrongCodes)); | ||
m.add(queryRes, IPROP.unknownException, ResourceFactory.createTypedLiteral(unknownExceptions)); | ||
m.add(queryRes, IPROP.totalTime, ResourceFactory.createTypedLiteral(toXSDDurationInSeconds(totalTime))); | ||
m.add(queryRes, RDF.type, IONT.executedQuery); | ||
|
||
return m; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/org/aksw/iguana/cc/metrics/impl/EachExecutionStatistic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.aksw.iguana.cc.metrics.impl; | ||
|
||
import org.aksw.iguana.cc.metrics.Metric; | ||
import org.aksw.iguana.cc.metrics.ModelWritingMetric; | ||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
import org.aksw.iguana.commons.rdf.IPROP; | ||
import org.aksw.iguana.commons.rdf.IRES; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ModelFactory; | ||
import org.apache.jena.rdf.model.Resource; | ||
import org.apache.jena.rdf.model.ResourceFactory; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.math.BigInteger; | ||
import java.util.List; | ||
|
||
public class EachExecutionStatistic extends Metric implements ModelWritingMetric { | ||
|
||
public EachExecutionStatistic() { | ||
super("Each Query Execution Statistic", "EachQuery", "This metric saves the statistics of each query execution."); | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public Model createMetricModel(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data, IRES.Factory iresFactory) { | ||
Model m = ModelFactory.createDefaultModel(); | ||
for (var worker : workers) { | ||
for (int i = 0; i < worker.config().queries().getQueryCount(); i++) { | ||
Resource workerQueryResource = iresFactory.getWorkerQueryResource(worker, i); | ||
Resource queryRes = IRES.getResource(worker.config().queries().getQueryId(i)); | ||
BigInteger run = BigInteger.ONE; | ||
for (HttpWorker.ExecutionStats exec : data[(int) worker.getWorkerID()][i]) { | ||
Resource runRes = iresFactory.getWorkerQueryRunResource(worker, i, run); | ||
m.add(workerQueryResource, IPROP.queryExecution, runRes); | ||
m.add(runRes, IPROP.time, ResourceFactory.createTypedLiteral(exec.duration())); | ||
m.add(runRes, IPROP.success, ResourceFactory.createTypedLiteral(exec.successful())); | ||
m.add(runRes, IPROP.run, ResourceFactory.createTypedLiteral(run)); | ||
m.add(runRes, IPROP.code, ResourceFactory.createTypedLiteral(exec.endState().value)); | ||
// TODO: maybe add http status code | ||
if (exec.contentLength().isPresent()) | ||
m.add(runRes, IPROP.resultSize, ResourceFactory.createTypedLiteral(exec.contentLength().getAsLong())); | ||
m.add(runRes, IPROP.queryID, queryRes); | ||
run = run.add(BigInteger.ONE); | ||
} | ||
} | ||
} | ||
return m; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.aksw.iguana.cc.metrics.impl; | ||
|
||
import org.aksw.iguana.cc.metrics.Metric; | ||
import org.aksw.iguana.cc.metrics.TaskMetric; | ||
import org.aksw.iguana.cc.metrics.WorkerMetric; | ||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
|
||
public class NoQ extends Metric implements TaskMetric, WorkerMetric { | ||
|
||
public NoQ() { | ||
super("Number of Queries", "NoQ", "This metric calculates the number of successfully executed queries."); | ||
} | ||
|
||
@Override | ||
public Number calculateTaskMetric(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data) { | ||
BigInteger sum = BigInteger.ZERO; | ||
for (var worker : workers) { | ||
sum = sum.add((BigInteger) this.calculateWorkerMetric(worker.config(), data[(int) worker.getWorkerID()])); | ||
} | ||
return sum; | ||
} | ||
|
||
@Override | ||
public Number calculateWorkerMetric(HttpWorker.Config worker, List<HttpWorker.ExecutionStats>[] data) { | ||
BigInteger sum = BigInteger.ZERO; | ||
for (List<HttpWorker.ExecutionStats> datum : data) { | ||
for (HttpWorker.ExecutionStats exec : datum) { | ||
if (exec.successful()) { | ||
sum = sum.add(BigInteger.ONE); | ||
} | ||
} | ||
} | ||
return sum; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.aksw.iguana.cc.metrics.impl; | ||
|
||
import org.aksw.iguana.cc.metrics.Metric; | ||
import org.aksw.iguana.cc.metrics.TaskMetric; | ||
import org.aksw.iguana.cc.metrics.WorkerMetric; | ||
import org.aksw.iguana.cc.worker.HttpWorker; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.math.RoundingMode; | ||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
public class NoQPH extends Metric implements TaskMetric, WorkerMetric { | ||
|
||
public NoQPH() { | ||
super("Number of Queries per Hour", "NoQPH", "This metric calculates the number of successfully executed queries per hour."); | ||
} | ||
@Override | ||
public Number calculateTaskMetric(List<HttpWorker> workers, List<HttpWorker.ExecutionStats>[][] data) { | ||
BigDecimal sum = BigDecimal.ZERO; | ||
for (var worker : workers) { | ||
sum = sum.add((BigDecimal) this.calculateWorkerMetric(worker.config(), data[(int) worker.getWorkerID()])); | ||
} | ||
return sum; | ||
} | ||
|
||
@Override | ||
public Number calculateWorkerMetric(HttpWorker.Config worker, List<HttpWorker.ExecutionStats>[] data) { | ||
BigDecimal successes = BigDecimal.ZERO; | ||
Duration totalTime = Duration.ZERO; | ||
for (List<HttpWorker.ExecutionStats> datum : data) { | ||
for (HttpWorker.ExecutionStats exec : datum) { | ||
if (exec.successful()) { | ||
successes = successes.add(BigDecimal.ONE); | ||
totalTime = totalTime.plus(exec.duration()); | ||
} | ||
} | ||
} | ||
BigDecimal tt = (new BigDecimal(BigInteger.valueOf(totalTime.toNanos()), 9)).divide(BigDecimal.valueOf(3600), 20, RoundingMode.HALF_UP); | ||
|
||
try { | ||
return successes.divide(tt, 10, RoundingMode.HALF_UP); | ||
} catch (ArithmeticException e) { | ||
return BigDecimal.ZERO; | ||
} | ||
} | ||
} |
Oops, something went wrong.