io.nosqlbench.virtdata.core.bindings.VirtDataDocs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package io.nosqlbench.virtdata.core.bindings;
import io.nosqlbench.virtdata.api.processors.DocFuncData;
import io.nosqlbench.virtdata.api.processors.FunctionDocInfoProcessor;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
/**
* This is the top-level API supporting access to the documentation models
* for all known {@link io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper} and
* {@link io.nosqlbench.virtdata.api.annotations.PerThreadMapper} instances in the runtime.
*/
public class VirtDataDocs {
private final static MethodHandles.Lookup lookup = MethodHandles.publicLookup();
public static List getAllNames() {
VirtDataFunctionFinder finder = new VirtDataFunctionFinder();
return finder.getFunctionNames();
}
public static List getAllDocs() {
VirtDataFunctionFinder finder = new VirtDataFunctionFinder();
List functionNames = finder.getFunctionNames();
List docs = new ArrayList<>();
try {
for (String n : functionNames) {
String s = n + FunctionDocInfoProcessor.AUTOSUFFIX;
Class> aClass = Class.forName(s);
MethodHandle constructor = lookup.findConstructor(aClass, MethodType.methodType(Void.TYPE));
Object o = constructor.invoke();
if (DocFuncData.class.isAssignableFrom(o.getClass())) {
docs.add(DocFuncData.class.cast(o));
} else {
throw new RuntimeException("class " + o.getClass() + " could not be assigned to " + DocFuncData.class.getSimpleName());
}
}
} catch (Throwable e) {
throw new RuntimeException("Error while loading doc models:" + e.toString());
}
return docs;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy