mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
update syntax to work with JLS 11
This commit is contained in:
parent
d7ab72e7b7
commit
80321e3853
engine-api/src/main/java/io/nosqlbench/engine/api/scoping
engine-clients/src/test/java/io/nosqlbench/engine/clients/prometheus
mvn-defaults
@ -27,17 +27,18 @@ public enum ScopedSupplier {
|
||||
|
||||
public <T> Supplier<T> supplier(Supplier<T> supplier) {
|
||||
|
||||
return switch (this) {
|
||||
case singleton -> {
|
||||
switch (this) {
|
||||
case singleton:
|
||||
T got = supplier.get();
|
||||
yield () -> got;
|
||||
}
|
||||
case thread -> {
|
||||
return () -> got;
|
||||
case thread:
|
||||
ThreadLocal<T> tlsupplier = ThreadLocal.withInitial(supplier);
|
||||
yield () -> tlsupplier.get();
|
||||
}
|
||||
case caller -> supplier;
|
||||
};
|
||||
return tlsupplier::get;
|
||||
case caller:
|
||||
return supplier;
|
||||
default:
|
||||
throw new RuntimeException("Unknown scope type:" + this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package io.nosqlbench.engine.clients.prometheus;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.nosqlbench.nb.api.content.NBIO;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -14,43 +15,11 @@ public class PMatrixElemTest {
|
||||
@Test
|
||||
public void testMatrixElem() {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
String json = """
|
||||
{
|
||||
"status" : "success",
|
||||
"data" : {
|
||||
"resultType" : "matrix",
|
||||
"result" : [
|
||||
{
|
||||
"metric" : {
|
||||
"__name__" : "up",
|
||||
"job" : "prometheus",
|
||||
"instance" : "localhost:9090"
|
||||
},
|
||||
"values" : [
|
||||
[ 1435781430.781, "1" ],
|
||||
[ 1435781445.781, "1" ],
|
||||
[ 1435781460.781, "1" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"metric" : {
|
||||
"__name__" : "up",
|
||||
"job" : "node",
|
||||
"instance" : "localhost:9091"
|
||||
},
|
||||
"values" : [
|
||||
[ 1435781430.781, "0" ],
|
||||
[ 1435781445.781, "0" ],
|
||||
[ 1435781460.781, "1" ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}""";
|
||||
String json = NBIO.classpath().name("test.json").one().asString();
|
||||
Type type = new TypeToken<PromQueryResult<PMatrixData>>() {
|
||||
}.getType();
|
||||
Object result = gson.fromJson(json, type);
|
||||
assertThat(result).isOfAnyClassIn(PromQueryResult.class);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
{
|
||||
"status": "success",
|
||||
"data": {
|
||||
"resultType": "matrix",
|
||||
"result": [
|
||||
{
|
||||
"metric": {
|
||||
"__name__": "up",
|
||||
"job": "prometheus",
|
||||
"instance": "localhost:9090"
|
||||
},
|
||||
"values": [
|
||||
[
|
||||
1435781430.781,
|
||||
"1"
|
||||
],
|
||||
[
|
||||
1435781445.781,
|
||||
"1"
|
||||
],
|
||||
[
|
||||
1435781460.781,
|
||||
"1"
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"metric": {
|
||||
"__name__": "up",
|
||||
"job": "node",
|
||||
"instance": "localhost:9091"
|
||||
},
|
||||
"values": [
|
||||
[
|
||||
1435781430.781,
|
||||
"0"
|
||||
],
|
||||
[
|
||||
1435781445.781,
|
||||
"0"
|
||||
],
|
||||
[
|
||||
1435781460.781,
|
||||
"1"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -499,15 +499,15 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<debug>true</debug>
|
||||
<!-- <release>${java.target.version}</release>-->
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
<!-- <compilerArgs>-->
|
||||
<!-- --enable-preview-->
|
||||
<!-- </compilerArgs>-->
|
||||
<!--<compilerArgument>-Xdoclint:all</compilerArgument>-->
|
||||
<!-- <compilerArgument>-Xlint:all</compilerArgument>-->
|
||||
<debug>true</debug>
|
||||
<!-- <release>${java.target.version}</release>-->
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<!-- <compilerArgs>-->
|
||||
<!-- --enable-preview-->
|
||||
<!-- </compilerArgs>-->
|
||||
<!--<compilerArgument>-Xdoclint:all</compilerArgument>-->
|
||||
<!-- <compilerArgument>-Xlint:all</compilerArgument>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user