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
@ -27,17 +27,18 @@ public enum ScopedSupplier {
|
|||||||
|
|
||||||
public <T> Supplier<T> supplier(Supplier<T> supplier) {
|
public <T> Supplier<T> supplier(Supplier<T> supplier) {
|
||||||
|
|
||||||
return switch (this) {
|
switch (this) {
|
||||||
case singleton -> {
|
case singleton:
|
||||||
T got = supplier.get();
|
T got = supplier.get();
|
||||||
yield () -> got;
|
return () -> got;
|
||||||
}
|
case thread:
|
||||||
case thread -> {
|
|
||||||
ThreadLocal<T> tlsupplier = ThreadLocal.withInitial(supplier);
|
ThreadLocal<T> tlsupplier = ThreadLocal.withInitial(supplier);
|
||||||
yield () -> tlsupplier.get();
|
return tlsupplier::get;
|
||||||
}
|
case caller:
|
||||||
case caller -> supplier;
|
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.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import io.nosqlbench.nb.api.content.NBIO;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -14,43 +15,11 @@ public class PMatrixElemTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testMatrixElem() {
|
public void testMatrixElem() {
|
||||||
Gson gson = new GsonBuilder().create();
|
Gson gson = new GsonBuilder().create();
|
||||||
String json = """
|
String json = NBIO.classpath().name("test.json").one().asString();
|
||||||
{
|
|
||||||
"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" ]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}""";
|
|
||||||
Type type = new TypeToken<PromQueryResult<PMatrixData>>() {
|
Type type = new TypeToken<PromQueryResult<PMatrixData>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
Object result = gson.fromJson(json, type);
|
Object result = gson.fromJson(json, type);
|
||||||
assertThat(result).isOfAnyClassIn(PromQueryResult.class);
|
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>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<debug>true</debug>
|
<debug>true</debug>
|
||||||
<!-- <release>${java.target.version}</release>-->
|
<!-- <release>${java.target.version}</release>-->
|
||||||
<source>15</source>
|
<source>11</source>
|
||||||
<target>15</target>
|
<target>11</target>
|
||||||
<!-- <compilerArgs>-->
|
<!-- <compilerArgs>-->
|
||||||
<!-- --enable-preview-->
|
<!-- --enable-preview-->
|
||||||
<!-- </compilerArgs>-->
|
<!-- </compilerArgs>-->
|
||||||
<!--<compilerArgument>-Xdoclint:all</compilerArgument>-->
|
<!--<compilerArgument>-Xdoclint:all</compilerArgument>-->
|
||||||
<!-- <compilerArgument>-Xlint:all</compilerArgument>-->
|
<!-- <compilerArgument>-Xlint:all</compilerArgument>-->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user