Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 979886e

Browse files
author
Florian Lautenschlager
committed
Fix #153: Due to synchronisation issues sometimes aggregations got overridden.
1 parent 9970054 commit 979886e

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

chronix-server-plugin-management/src/main/java/de/qaware/chronix/server/functions/FunctionCtx.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void add(ChronixTransformation transformation, String joinKey) {
7979
functionCtxEntries.get(joinKey).add(transformation);
8080
}
8181

82-
private void addEntryIfNotExist(String joinKey) {
82+
private synchronized void addEntryIfNotExist(String joinKey) {
8383
if (!functionCtxEntries.containsKey(joinKey)) {
8484
functionCtxEntries.put(joinKey, new FunctionCtxEntry(maxAmountOfTransformations, maxAmountOfAggregations, maxAmountOfAnalyses));
8585
}

chronix-server-plugin-management/src/main/java/de/qaware/chronix/server/functions/FunctionCtxEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public int size() {
7272
return analysisSize + transformationSize + aggregationSize;
7373
}
7474

75-
public void add(ChronixAggregation aggregation, double value) {
75+
public synchronized void add(ChronixAggregation aggregation, double value) {
7676

7777
if (aggregationSize < aggregations.length) {
7878
aggregations[aggregationSize] = aggregation;

chronix-server-test-integration/src/intTest/groovy/de/qaware/chronix/solr/ChronixClientTestIT.groovy

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class ChronixClientTestIT extends Specification {
364364
365365
}
366366
367-
@Unroll
367+
368368
def "Raw query with compression activated"() {
369369
when:
370370
def connection = (solrBaseUrl + "select?indent=on&q=*:*&wt=json").toURL().openConnection()
@@ -375,6 +375,43 @@ class ChronixClientTestIT extends Specification {
375375
result.length != 0
376376
}
377377
378+
def "Test all aggregations are executed 50 times (ticket #153)"() {
379+
given:
380+
def query = new SolrQuery("*:*")
381+
query.setParam(ChronixQueryParams.CHRONIX_FUNCTION, "metric{avg;max}")
382+
query.addField("-data")
383+
384+
def test = true
385+
def success = true
386+
def iteration = 50
387+
when:
388+
while (test && iteration > 0) {
389+
List<MetricTimeSeries> timeSeriesList = chronix.stream(solr, query).collect(Collectors.toList())
390+
iteration = iteration - 1;
391+
392+
for (MetricTimeSeries timeSeries in timeSeriesList) {
393+
def avg = timeSeries.attribute("0_function_avg")
394+
if (avg == null) {
395+
avg = timeSeries.attribute("1_function_avg")
396+
}
397+
def max = timeSeries.attribute("1_function_max")
398+
if (max == null) {
399+
max = timeSeries.attribute("0_function_max")
400+
}
401+
402+
if (max == null || avg == null) {
403+
test = false
404+
success = false
405+
}
406+
}
407+
}
408+
409+
410+
then:
411+
success
412+
413+
}
414+
378415
def testAttributes(MetricTimeSeries series) {
379416
series.attribute("myIntField") as Set<Integer> == [5] as Set<Integer>
380417
series.attribute("myLongField") as Set<Long> == [8L] as Set<Long>

0 commit comments

Comments
 (0)