mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
cleanup service loader code
This commit is contained in:
parent
7e776d5fcf
commit
6e4eff1515
@ -1,16 +0,0 @@
|
||||
package io.nosqlbench.docsys.core;
|
||||
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public class WebObjectLoader {
|
||||
public static List<WebServiceObject> loadWebServiceObjects() {
|
||||
List<WebServiceObject> endpoints = new ArrayList<>();
|
||||
ServiceLoader<WebServiceObject> loader = ServiceLoader.load(WebServiceObject.class);
|
||||
loader.forEach(endpoints::add);
|
||||
return endpoints;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import javax.ws.rs.core.Configuration;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "docserver-status")
|
||||
@Singleton
|
||||
@Path("_")
|
||||
public class DocServerStatusEndpoint implements WebServiceObject {
|
||||
|
@ -20,7 +20,7 @@ import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "docsys-markdown")
|
||||
@Singleton
|
||||
@Path("/services/docs/")
|
||||
public class DocsysMarkdownEndpoint implements WebServiceObject {
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
//@Service(WebServiceObject.class)
|
||||
//@Service(value=WebServiceObject.class,selector="test")
|
||||
@Singleton
|
||||
@Path("test1")
|
||||
public class TestServlet1 implements WebServiceObject {
|
||||
|
@ -6,12 +6,8 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "cockroachdb")
|
||||
public class CockroachActivityType implements ActivityType<CockroachActivity> {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cockroachdb";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(CockroachActivity activity) {
|
||||
|
@ -17,13 +17,9 @@ import java.time.Instant;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "cql")
|
||||
public class CqlActivityType implements ActivityType<CqlActivity> {
|
||||
|
||||
public String getName() {
|
||||
return "cql";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CqlActivity getActivity(ActivityDef activityDef) {
|
||||
|
||||
|
@ -11,14 +11,9 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Service(ResultValueFilterType.class)
|
||||
@Service(value = ResultValueFilterType.class, selector = "cql")
|
||||
public class CQLResultFilterType implements ResultValueFilterType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cql";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultFilterDispenser getDispenser(String config) {
|
||||
return new Dispenser(config);
|
||||
|
@ -4,13 +4,15 @@ import io.nosqlbench.generators.cql.lang.CqlWorkloadGen;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "cql-workload-generator")
|
||||
@Path("/services/cql/")
|
||||
@Singleton
|
||||
public class CqlWorkloadGeneratorEndpoint implements WebServiceObject {
|
||||
|
||||
@POST
|
||||
|
@ -5,14 +5,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "cqlverify")
|
||||
public class CqlVerifyActivityType implements ActivityType<CqlVerifyActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cqlverify";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(CqlVerifyActivity activity) {
|
||||
return new CqlVerifyActionDispenser(activity);
|
||||
|
@ -30,16 +30,11 @@ import org.apache.logging.log4j.LogManager;
|
||||
*
|
||||
* Diag serves as a basic template for implementing your own activity type.
|
||||
*/
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "diag")
|
||||
public class DiagActivityType implements ActivityType<DiagActivity> {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(DiagActivityType.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "diag";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(DiagActivity activity) {
|
||||
return new DiagActionDispenser(activity);
|
||||
|
@ -25,7 +25,6 @@ public class DiagActivityTypeTest {
|
||||
@Test
|
||||
public void testDiagActivity() {
|
||||
DiagActivityType da = new DiagActivityType();
|
||||
da.getName();
|
||||
ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;");
|
||||
DiagActivity a = da.getActivity(ad);
|
||||
a.initActivity();
|
||||
|
@ -5,14 +5,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "dsegraph")
|
||||
public class GraphActivityType implements ActivityType<GraphActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "dsegraph";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphActivity getActivity(ActivityDef activityDef) {
|
||||
return new GraphActivity(activityDef);
|
||||
|
@ -7,16 +7,11 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "http")
|
||||
public class HttpActivityType implements ActivityType<HttpActivity> {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(HttpActivityType.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "http";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(HttpActivity activity) {
|
||||
if (activity.getParams().getOptionalString("async").isPresent()) {
|
||||
|
@ -5,14 +5,10 @@ import io.nosqlbench.engine.api.activityapi.core.ActionDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class HttpActivityTypeTest {
|
||||
@Test
|
||||
public void testHttpActivity() {
|
||||
HttpActivityType httpAt = new HttpActivityType();
|
||||
String atname = httpAt.getName();
|
||||
assertThat(atname.equals("http"));
|
||||
|
||||
ActivityDef ad = ActivityDef.parseActivityDef("driver=http; yaml=http-google.yaml; port=80; cycles=1;");
|
||||
HttpActivity httpActivity = httpAt.getActivity(ad);
|
||||
|
@ -5,12 +5,8 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "jmx")
|
||||
public class JMXActivityType implements ActivityType<JMXActivity> {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "jmx";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JMXActivity getActivity(ActivityDef activityDef) {
|
||||
|
@ -6,12 +6,8 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "kafkaproducer")
|
||||
public class KafkaProducerActivityType implements ActivityType<KafkaProducerActivity> {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "kafkaproducer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaProducerActivity getActivity(ActivityDef activityDef) {
|
||||
@ -19,7 +15,7 @@ public class KafkaProducerActivityType implements ActivityType<KafkaProducerActi
|
||||
}
|
||||
|
||||
private static class Dispenser implements ActionDispenser {
|
||||
private KafkaProducerActivity activity;
|
||||
private final KafkaProducerActivity activity;
|
||||
|
||||
private Dispenser(KafkaProducerActivity activity) {
|
||||
this.activity = activity;
|
||||
|
@ -6,14 +6,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "mongodb")
|
||||
public class MongoActivityType implements ActivityType<MongoActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mongodb";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MongoActivity getActivity(ActivityDef activityDef) {
|
||||
return new MongoActivity(activityDef);
|
||||
|
@ -9,11 +9,6 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
@Service(value = ActivityType.class, selector = "pulsar")
|
||||
public class PulsarActivityType implements ActivityType<PulsarActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "pulsar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionDispenser getActionDispenser(PulsarActivity activity) {
|
||||
if (activity.getParams().getOptionalString("async").isPresent()) {
|
||||
|
@ -8,14 +8,9 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "stdout")
|
||||
public class StdoutActivityType implements ActivityType<StdoutActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stdout";
|
||||
}
|
||||
|
||||
@Override
|
||||
public StdoutActivity getActivity(ActivityDef activityDef) {
|
||||
Optional<String> yaml = activityDef.getParams().getOptionalString("yaml", "workload");
|
||||
|
@ -22,8 +22,6 @@ import io.nosqlbench.engine.api.activityapi.core.ActionDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Created by sebastianestevez on 5/5/17.
|
||||
*/
|
||||
@ -32,8 +30,6 @@ public class StdoutActivityTypeTest {
|
||||
@Test
|
||||
public void testDiagActivity() {
|
||||
StdoutActivityType stdoutAt = new StdoutActivityType();
|
||||
String atname = stdoutAt.getName();
|
||||
assertThat(atname.equals("stdout"));
|
||||
ActivityDef ad = ActivityDef.parseActivityDef("driver=stdout; yaml=stdout-test;");
|
||||
StdoutActivity stdoutActivity = stdoutAt.getActivity(ad);
|
||||
ActionDispenser actionDispenser = stdoutAt.getActionDispenser(stdoutActivity);
|
||||
|
@ -25,14 +25,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "tcpclient")
|
||||
public class TCPClientActivityType implements ActivityType<TCPClientActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "tcpclient";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TCPClientActivity getActivity(ActivityDef activityDef) {
|
||||
return new TCPClientActivity(activityDef);
|
||||
@ -44,7 +39,7 @@ public class TCPClientActivityType implements ActivityType<TCPClientActivity> {
|
||||
}
|
||||
|
||||
private static class Dispenser implements ActionDispenser {
|
||||
private StdoutActivity activity;
|
||||
private final StdoutActivity activity;
|
||||
|
||||
private Dispenser(StdoutActivity activity) {
|
||||
this.activity = activity;
|
||||
|
@ -25,14 +25,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "tcpserver")
|
||||
public class TCPServerActivityType implements ActivityType<TCPServerActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "tcpserver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TCPServerActivity getActivity(ActivityDef activityDef) {
|
||||
return new TCPServerActivity(activityDef);
|
||||
@ -44,7 +39,7 @@ public class TCPServerActivityType implements ActivityType<TCPServerActivity> {
|
||||
}
|
||||
|
||||
private static class Dispenser implements ActionDispenser {
|
||||
private StdoutActivity activity;
|
||||
private final StdoutActivity activity;
|
||||
|
||||
private Dispenser(StdoutActivity activity) {
|
||||
this.activity = activity;
|
||||
|
@ -7,14 +7,9 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(ActivityType.class)
|
||||
@Service(value = ActivityType.class, selector = "webdriver")
|
||||
public class WebDriverActivityType implements ActivityType<WebDriverActivity> {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "webdriver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebDriverActivity getActivity(ActivityDef activityDef) {
|
||||
return new WebDriverActivity(activityDef);
|
||||
|
@ -24,8 +24,7 @@ import io.nosqlbench.engine.api.activityimpl.CoreServices;
|
||||
import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
|
||||
import io.nosqlbench.engine.api.activityimpl.action.CoreActionDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser;
|
||||
import io.nosqlbench.engine.api.util.SimpleServiceLoader;
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -38,16 +37,9 @@ import java.util.Optional;
|
||||
* an action dispenser. Default implementations of input and motor dispensers are provided,
|
||||
* and by extension, default inputs and motors.</p>
|
||||
*/
|
||||
public interface ActivityType<A extends Activity> extends Named {
|
||||
public interface ActivityType<A extends Activity> {
|
||||
|
||||
SimpleServiceLoader<ActivityType> FINDER = new SimpleServiceLoader<>(ActivityType.class);
|
||||
/**
|
||||
* Return the short name of this activity type. The fully qualified name of an activity type is
|
||||
* this value, prefixed by the package of the implementing class.
|
||||
*
|
||||
* @return An activity type name, like "diag"
|
||||
*/
|
||||
String getName();
|
||||
SimpleServiceLoader<ActivityType> FINDER = new SimpleServiceLoader<ActivityType>(ActivityType.class);
|
||||
|
||||
/**
|
||||
* Create an instance of an activity from the activity type.
|
||||
|
@ -37,14 +37,9 @@ import java.util.function.Predicate;
|
||||
* clause. In the example above, the default policy would be "exclude",
|
||||
* given that the fist clause is "include".
|
||||
*/
|
||||
@Service(ResultValueFilterType.class)
|
||||
@Service(value = ResultValueFilterType.class, selector = "core")
|
||||
public class CoreResultValueFilter implements ResultValueFilterType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultFilterDispenser getDispenser(String config) {
|
||||
return new Dispenser(config);
|
||||
|
@ -19,15 +19,14 @@ package io.nosqlbench.engine.api.activityapi.cyclelog.filters;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.engine.api.util.SimpleConfig;
|
||||
import io.nosqlbench.engine.api.util.SimpleServiceLoader;
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
public interface ExperimentalResultFilterType extends Named {
|
||||
public interface ExperimentalResultFilterType {
|
||||
|
||||
SimpleServiceLoader<ExperimentalResultFilterType> FINDER =
|
||||
new SimpleServiceLoader<>(ExperimentalResultFilterType.class);
|
||||
new SimpleServiceLoader<>(ExperimentalResultFilterType.class);
|
||||
|
||||
default IntPredicateDispenser getFilterDispenser(Activity activity) {
|
||||
SimpleConfig conf = new SimpleConfig(activity, "resultfilter");
|
||||
|
@ -29,14 +29,9 @@ import java.util.function.IntPredicate;
|
||||
* array is used. When the type widens, this will need to use a native
|
||||
* int trie or something else that is time and space efficient.
|
||||
*/
|
||||
@Service(ExperimentalResultFilterType.class)
|
||||
@Service(value = ExperimentalResultFilterType.class, selector = "include")
|
||||
public class IncludeCodesTypeExperimental implements ExperimentalResultFilterType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "include";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntPredicate getIntPredicate(SimpleConfig conf) {
|
||||
return new IncludeCodes(conf);
|
||||
|
@ -17,10 +17,9 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityapi.cyclelog.filters;
|
||||
|
||||
import io.nosqlbench.engine.api.util.SimpleServiceLoader;
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
|
||||
public interface ResultValueFilterType extends Named {
|
||||
public interface ResultValueFilterType {
|
||||
|
||||
SimpleServiceLoader<ResultValueFilterType> FINDER = new SimpleServiceLoader<>(ResultValueFilterType.class);
|
||||
|
||||
|
@ -23,12 +23,8 @@ import io.nosqlbench.engine.api.activityapi.input.InputDispenser;
|
||||
import io.nosqlbench.engine.api.activityapi.input.InputType;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(InputType.class)
|
||||
@Service(value = InputType.class, selector = "cyclelog")
|
||||
public class CycleLogInputType implements InputType {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cyclelog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputDispenser getInputDispenser(Activity activity) {
|
||||
|
@ -27,14 +27,9 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@Service(OutputType.class)
|
||||
@Service(value = OutputType.class, selector = "cyclelog")
|
||||
public class CycleLogOutputType implements OutputType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cyclelog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputDispenser getOutputDispenser(Activity activity) {
|
||||
return new Dispenser(activity);
|
||||
|
@ -24,7 +24,7 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@Service(OutputDispenser.class)
|
||||
@Service(value = OutputDispenser.class, selector = "logging-marker")
|
||||
public class LoggingMarkerDispenser implements OutputDispenser {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(LoggingMarkerDispenser.class);
|
||||
|
@ -18,13 +18,12 @@
|
||||
package io.nosqlbench.engine.api.activityapi.input;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.engine.api.util.SimpleServiceLoader;
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
|
||||
public interface InputType extends Named {
|
||||
public interface InputType {
|
||||
|
||||
SimpleServiceLoader<InputType> FINDER =
|
||||
new SimpleServiceLoader<>(InputType.class);
|
||||
new SimpleServiceLoader<>(InputType.class);
|
||||
|
||||
InputDispenser getInputDispenser(Activity activity);
|
||||
}
|
||||
|
@ -18,13 +18,12 @@
|
||||
package io.nosqlbench.engine.api.activityapi.output;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.Activity;
|
||||
import io.nosqlbench.engine.api.util.SimpleServiceLoader;
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
|
||||
|
||||
public interface OutputType extends Named {
|
||||
public interface OutputType {
|
||||
|
||||
SimpleServiceLoader<OutputType> FINDER =
|
||||
new SimpleServiceLoader<>(OutputType.class);
|
||||
new SimpleServiceLoader<>(OutputType.class);
|
||||
|
||||
OutputDispenser getOutputDispenser(Activity activity);
|
||||
|
||||
|
@ -23,14 +23,9 @@ import io.nosqlbench.engine.api.activityapi.input.InputDispenser;
|
||||
import io.nosqlbench.engine.api.activityapi.input.InputType;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(InputType.class)
|
||||
@Service(value = InputType.class, selector = "atomicseq")
|
||||
public class TargetRateInputType implements InputType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "atomicseq";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputDispenser getInputDispenser(Activity activity) {
|
||||
return new Dispenser(activity);
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2016 jshook
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.api.util;
|
||||
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimpleServiceLoader<T extends Named> {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(SimpleServiceLoader.class);
|
||||
private final Class<? extends T> serviceType;
|
||||
private static SimpleServiceLoader instance;
|
||||
|
||||
private final Map<String, T> types = new ConcurrentHashMap<>();
|
||||
|
||||
public SimpleServiceLoader(Class<? extends T> serviceType) {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public Optional<T> get(String implName) {
|
||||
return Optional.ofNullable(getTypes().get(implName));
|
||||
}
|
||||
|
||||
public T getOrThrow(String implName) {
|
||||
Optional<T> at = Optional.ofNullable(getTypes().get(implName));
|
||||
return at.orElseThrow(
|
||||
() -> new RuntimeException(serviceType.getSimpleName() + " '" + implName + "' not found. Available types:" +
|
||||
this.getTypes().keySet().stream().collect(Collectors.joining(",")))
|
||||
);
|
||||
}
|
||||
|
||||
private synchronized Map<String, T> getTypes() {
|
||||
if (types.size()==0) {
|
||||
ClassLoader cl = getClass().getClassLoader();
|
||||
logger.debug("loading service types for " + serviceType.getSimpleName());
|
||||
ServiceLoader<? extends T> sl = ServiceLoader.load(serviceType);
|
||||
try {
|
||||
for (T inputType : sl) {
|
||||
if (types.get(inputType.getName()) != null) {
|
||||
throw new RuntimeException("ActivityType '" + inputType.getName()
|
||||
+ "' is already defined.");
|
||||
}
|
||||
types.put(inputType.getName(),inputType);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
logger.debug("Loaded Types:" + types.keySet());
|
||||
return types;
|
||||
}
|
||||
|
||||
public List<T> getAll() {
|
||||
List<T> types = new ArrayList<>(getTypes().values());
|
||||
types.sort(Comparator.comparing(Named::getName));
|
||||
return Collections.unmodifiableList(types);
|
||||
}
|
||||
|
||||
}
|
@ -24,10 +24,10 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
/**
|
||||
* Provide a local MetricRegistryService for tests
|
||||
*/
|
||||
@Service(MetricRegistryService.class)
|
||||
@Service(value = MetricRegistryService.class, selector = "test-registry")
|
||||
public class TestMetricsRegistry implements MetricRegistryService {
|
||||
|
||||
private MetricRegistry metricRegistry = new MetricRegistry();
|
||||
private final MetricRegistry metricRegistry = new MetricRegistry();
|
||||
|
||||
@Override
|
||||
public MetricRegistry getMetricRegistry() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.nosqlbench.engine.cli;
|
||||
|
||||
import io.nosqlbench.docsys.core.DocServerApp;
|
||||
import io.nosqlbench.docsys.core.NBWebServerApp;
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogDumperUtility;
|
||||
import io.nosqlbench.engine.api.activityapi.cyclelog.outputs.cyclelog.CycleLogImporterUtility;
|
||||
@ -163,7 +163,7 @@ public class NBCLI {
|
||||
System.exit(0);
|
||||
}
|
||||
if (args.length > 0 && args[0].toLowerCase().matches("docserver|appserver")) {
|
||||
DocServerApp.main(Arrays.copyOfRange(args, 1, args.length));
|
||||
NBWebServerApp.main(Arrays.copyOfRange(args, 1, args.length));
|
||||
System.exit(0);
|
||||
}
|
||||
if (args.length > 0 && args[0].toLowerCase().equals(MarkdownExporter.APP_NAME)) {
|
||||
@ -194,7 +194,7 @@ public class NBCLI {
|
||||
}
|
||||
|
||||
if (options.wantsActivityTypes()) {
|
||||
ActivityType.FINDER.getAll().stream().map(ActivityType::getName).forEach(System.out::println);
|
||||
ActivityType.FINDER.getAllSelectors().forEach(System.out::println);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -251,12 +251,12 @@ public class NBCLI {
|
||||
}
|
||||
|
||||
if (options.wantsInputTypes()) {
|
||||
InputType.FINDER.getAll().stream().map(InputType::getName).forEach(System.out::println);
|
||||
InputType.FINDER.getAllSelectors().forEach(System.out::println);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (options.wantsMarkerTypes()) {
|
||||
OutputType.FINDER.getAll().stream().map(OutputType::getName).forEach(System.out::println);
|
||||
OutputType.FINDER.getAllSelectors().forEach(System.out::println);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
@ -103,11 +103,6 @@ public class GrafanaMetricsAnnotator implements Annotator, ConfigAware {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "grafana";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfig(Map<String, ?> providedConfig) {
|
||||
ConfigModel configModel = getConfigModel();
|
||||
|
@ -47,6 +47,7 @@ public class Annotators {
|
||||
Object typeObj = cmap.remove("type");
|
||||
String typename = typeObj.toString();
|
||||
ServiceLoader.Provider<Annotator> annotatorProvider = providers.get(typename);
|
||||
|
||||
if (annotatorProvider == null) {
|
||||
throw new RuntimeException("Annotation provider with selector '" + typename + "' was not found.");
|
||||
}
|
||||
@ -98,7 +99,7 @@ public class Annotators {
|
||||
public static synchronized void recordAnnotation(Annotation annotation) {
|
||||
for (Annotator annotator : getAnnotators()) {
|
||||
try {
|
||||
logger.trace("calling annotator " + annotator.getName());
|
||||
logger.trace("calling annotator " + annotator.getClass().getAnnotation(Service.class).selector());
|
||||
annotator.recordAnnotation(annotation);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
|
@ -280,14 +280,15 @@ public class ScenarioController {
|
||||
if (executor == null && createIfMissing) {
|
||||
|
||||
String activityTypeName = activityDef.getParams().getOptionalString("driver", "type").orElse(null);
|
||||
List<String> knownTypes = ActivityType.FINDER.getAll().stream().map(ActivityType::getName).collect(Collectors.toList());
|
||||
|
||||
List<String> knownTypes = ActivityType.FINDER.getAllSelectors();
|
||||
|
||||
// Infer the type from either alias or yaml if possible (exactly one matches)
|
||||
if (activityTypeName == null) {
|
||||
List<String> matching = knownTypes.stream().filter(
|
||||
n ->
|
||||
activityDef.getParams().getOptionalString("alias").orElse("").contains(n)
|
||||
|| activityDef.getParams().getOptionalString("yaml", "workload").orElse("").contains(n)
|
||||
n ->
|
||||
activityDef.getParams().getOptionalString("alias").orElse("").contains(n)
|
||||
|| activityDef.getParams().getOptionalString("yaml", "workload").orElse("").contains(n)
|
||||
).collect(Collectors.toList());
|
||||
if (matching.size() == 1) {
|
||||
activityTypeName = matching.get(0);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.nosqlbench.engine.core.metadata;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
import io.nosqlbench.nb.api.content.NBIO;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -44,7 +45,8 @@ public class MarkdownDocInfo {
|
||||
|
||||
public String forActivityInstance(String s) {
|
||||
ActivityType activityType = ActivityType.FINDER.getOrThrow(s);
|
||||
return forResourceMarkdown(activityType.getName() + ".md", "docs/");
|
||||
return forResourceMarkdown(activityType.getClass().getAnnotation(Service.class)
|
||||
.selector() + ".md", "docs/");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,16 +31,6 @@ public class LoggingAnnotator implements Annotator, ConfigAware {
|
||||
annotatorLog.log(level, inlineForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The annotated selector of this implementation,
|
||||
* ensuring that selector and name stay the same
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
String selector = LoggingAnnotator.class.getAnnotation(Service.class).selector();
|
||||
return selector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfig(Map<String, ?> providedConfig) {
|
||||
ConfigModel configModel = getConfigModel();
|
||||
|
@ -21,17 +21,17 @@ import com.codahale.metrics.MetricRegistry;
|
||||
import io.nosqlbench.engine.api.activityapi.core.MetricRegistryService;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(MetricRegistryService.class)
|
||||
@Service(value = MetricRegistryService.class, selector = "metrics-context")
|
||||
public class MetricsContext implements MetricRegistryService {
|
||||
|
||||
private static MetricsContext instance;
|
||||
|
||||
private MetricReporters metricReporters = MetricReporters.getInstance();
|
||||
private MetricRegistry metrics = new NBMetricsRegistry();
|
||||
private final MetricReporters metricReporters = MetricReporters.getInstance();
|
||||
private final MetricRegistry metrics = new NBMetricsRegistry();
|
||||
|
||||
public static MetricsContext getInstance() {
|
||||
synchronized (MetricsContext.class) {
|
||||
if (instance==null) {
|
||||
if (instance == null) {
|
||||
instance = new MetricsContext();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package io.nosqlbench.engine.docs;
|
||||
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
import io.nosqlbench.nb.api.markdown.providers.DocsRootDirectory;
|
||||
import io.nosqlbench.nb.api.markdown.providers.RawMarkdownSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service(RawMarkdownSource.class)
|
||||
@Service(value = RawMarkdownSource.class, selector = "docs-for-eb")
|
||||
public class NosqlBenchRawMarkdownSource extends DocsRootDirectory {
|
||||
|
||||
@Override
|
||||
|
@ -5,15 +5,15 @@ import io.nosqlbench.docsys.api.DocsBinder;
|
||||
import io.nosqlbench.docsys.api.DocsysDynamicManifest;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(DocsysDynamicManifest.class)
|
||||
@Service(value = DocsysDynamicManifest.class, selector = "docs-for-eb")
|
||||
public class NosqlbenchMarkdownManifest implements DocsysDynamicManifest {
|
||||
@Override
|
||||
public DocsBinder getDocs() {
|
||||
return new Docs().namespace("docs-for-eb")
|
||||
.addFirstFoundPath(
|
||||
"engine-docs/src/main/resources/docs-for-nb/",
|
||||
"docs-for-nb/"
|
||||
).setEnabledByDefault(true)
|
||||
.asDocsBinder();
|
||||
.addFirstFoundPath(
|
||||
"engine-docs/src/main/resources/docs-for-nb/",
|
||||
"docs-for-nb/"
|
||||
).setEnabledByDefault(true)
|
||||
.asDocsBinder();
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,9 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.script.ScriptContext;
|
||||
|
||||
@Service(ScriptingPluginInfo.class)
|
||||
@Service(value = ScriptingPluginInfo.class, selector = "histologger")
|
||||
public class HdrHistoLogPluginData implements ScriptingPluginInfo<HdrHistoLogPlugin> {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "allows script control of HDR histogram interval logging";
|
||||
@ -36,9 +37,4 @@ public class HdrHistoLogPluginData implements ScriptingPluginInfo<HdrHistoLogPlu
|
||||
public HdrHistoLogPlugin getExtensionObject(Logger logger, MetricRegistry metricRegistry, ScriptContext scriptContext) {
|
||||
return new HdrHistoLogPlugin(logger,metricRegistry,scriptContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseVariableName() {
|
||||
return "histologger";
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "openapi")
|
||||
@Singleton
|
||||
@Path("/openapi")
|
||||
public class OpenApiEndpoint implements WebServiceObject {
|
||||
|
@ -25,7 +25,7 @@ import java.io.CharArrayWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "scenario-executor")
|
||||
@Singleton
|
||||
@Path("/services/executor/")
|
||||
public class ScenarioExecutorEndpoint implements WebServiceObject {
|
||||
|
@ -18,7 +18,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "service-status")
|
||||
@Singleton
|
||||
@Path("/services/status")
|
||||
public class ServiceStatusEndpoint implements WebServiceObject {
|
||||
|
@ -21,7 +21,7 @@ import javax.ws.rs.core.Response;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "workload-finder")
|
||||
@Singleton
|
||||
@Path("/services/workloads")
|
||||
public class WorkloadFinderEndpoint implements WebServiceObject {
|
||||
|
@ -18,9 +18,9 @@ import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(value = WebServiceObject.class, selector = "workspaces")
|
||||
@Path("/services/workspaces")
|
||||
@Singleton
|
||||
@Service(WebServiceObject.class)
|
||||
public class WorkspacesEndpoint implements WebServiceObject {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(WorkspacesEndpoint.class);
|
||||
@ -110,7 +110,7 @@ public class WorkspacesEndpoint implements WebServiceObject {
|
||||
try {
|
||||
WorkSpace ws = getSvc().getWorkspace(workspace);
|
||||
WorkspaceView wsview = ws.getWorkspaceView();
|
||||
if (ls != null && !ls.toLowerCase().equals("false")) {
|
||||
if (ls != null && !ls.equalsIgnoreCase("false")) {
|
||||
List<WorkspaceItemView> listing = ws.getWorkspaceListingView("");
|
||||
if (contains != null) {
|
||||
listing = listing.stream().filter(i -> i.contains(contains)).collect(Collectors.toList());
|
||||
@ -132,7 +132,7 @@ public class WorkspacesEndpoint implements WebServiceObject {
|
||||
@QueryParam("ls") String ls) {
|
||||
|
||||
try {
|
||||
if (ls != null && !ls.toLowerCase().equals("false")) {
|
||||
if (ls != null && !ls.equalsIgnoreCase("false")) {
|
||||
WorkSpace ws = getSvc().getWorkspace(workspace);
|
||||
List<WorkspaceItemView> listing = ws.getWorkspaceListingView(filename);
|
||||
return Response.ok(listing).build();
|
||||
|
@ -31,5 +31,6 @@ import java.lang.annotation.Target;
|
||||
public @interface Service {
|
||||
Class<?> value();
|
||||
|
||||
String selector() default "";
|
||||
String selector();
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package io.nosqlbench.nb.api.annotations;
|
||||
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
|
||||
/**
|
||||
* An implementation of this type is responsible for taking annotation details and
|
||||
* logging them in a useful place.
|
||||
*/
|
||||
public interface Annotator extends Named {
|
||||
public interface Annotator {
|
||||
|
||||
/**
|
||||
* Submit an annotation to some type of annotation store, logging or eventing mechanism.
|
||||
|
@ -4,7 +4,7 @@ import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.api.markdown.providers.DocsRootDirectory;
|
||||
import io.nosqlbench.nb.api.markdown.providers.RawMarkdownSource;
|
||||
|
||||
@Service(RawMarkdownSource.class)
|
||||
@Service(value = RawMarkdownSource.class, selector = "docs-for-testing")
|
||||
public class DocsForTestingOnly extends DocsRootDirectory {
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +0,0 @@
|
||||
package io.nosqlbench.nb.api.spi;
|
||||
|
||||
public interface Named {
|
||||
/**
|
||||
* <p>Return the name for this function library implementation.</p>
|
||||
*
|
||||
* @return Simple lower-case canonical library name
|
||||
*/
|
||||
String getName();
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2016 jshook
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package io.nosqlbench.nb.api.spi;
|
||||
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimpleServiceLoader<T> {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(SimpleServiceLoader.class);
|
||||
private final Class<? extends T> serviceType;
|
||||
|
||||
public SimpleServiceLoader(Class<? extends T> serviceType) {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public Optional<T> get(String implName) {
|
||||
LinkedHashMap<String, ServiceLoader.Provider<? extends T>> namedProviders = getNamedProviders();
|
||||
ServiceLoader.Provider<? extends T> providers = namedProviders.get(implName);
|
||||
return Optional.ofNullable(providers == null ? null : providers.get());
|
||||
}
|
||||
|
||||
public T getOrThrow(String implName) {
|
||||
Optional<T> t = get(implName);
|
||||
return t.orElseThrow(
|
||||
() -> new RuntimeException(serviceType.getSimpleName() + " '" + implName + "' not found. Available types:" +
|
||||
this.getNamedProviders().keySet().stream().collect(Collectors.joining(",")))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the service providers which are annotated with {@link Service} and selector names.
|
||||
*
|
||||
* @param includes If provided, a list of patterns which are used to include named services based on the selector name from the
|
||||
* {@link Service} annotation.
|
||||
* @return A map of providers of T
|
||||
*/
|
||||
public synchronized LinkedHashMap<String, ServiceLoader.Provider<? extends T>> getNamedProviders(Pattern... includes) {
|
||||
ServiceLoader<? extends T> loader = ServiceLoader.load(serviceType);
|
||||
List<Pattern> patterns = (includes != null && includes.length > 0) ? Arrays.asList(includes) : List.of(Pattern.compile(".*"));
|
||||
|
||||
LinkedHashMap<String, ServiceLoader.Provider<? extends T>> providers;
|
||||
providers = new LinkedHashMap<>();
|
||||
|
||||
loader.stream().forEach(provider -> {
|
||||
Class<? extends T> type = provider.type();
|
||||
if (!type.isAnnotationPresent(Service.class)) {
|
||||
throw new RuntimeException(
|
||||
"Annotator services must be annotated with distinct selectors\n" +
|
||||
"such as @Service(Annotator.class,selector=\"myimpl42\")"
|
||||
);
|
||||
}
|
||||
Service service = type.getAnnotation(Service.class);
|
||||
for (Pattern pattern : patterns) {
|
||||
if (pattern.matcher(service.selector()).matches()) {
|
||||
providers.put(service.selector(), provider);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return providers;
|
||||
}
|
||||
|
||||
public List<String> getAllSelectors(Pattern... patterns) {
|
||||
return new ArrayList<>(getNamedProviders(patterns).keySet());
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@ import java.util.stream.Collectors;
|
||||
public class FunctionDocInfoWriter implements FuncEnumerator.Listener {
|
||||
|
||||
private final String suffix;
|
||||
private Filer filer;
|
||||
private Messager messenger;
|
||||
private final Filer filer;
|
||||
private final Messager messenger;
|
||||
|
||||
public FunctionDocInfoWriter(Filer filer, Messager messenger, String suffix) {
|
||||
this.filer = filer;
|
||||
@ -100,7 +100,7 @@ public class FunctionDocInfoWriter implements FuncEnumerator.Listener {
|
||||
ctors.add("add(new $T<$T>() {{$>\n", ArrayList.class, String.class);
|
||||
for (String s : example) {
|
||||
Matcher m = Pattern.compile(Matcher.quoteReplacement("$")).matcher(s);
|
||||
s=m.replaceAll(m.quoteReplacement("$$"));
|
||||
s = m.replaceAll(Matcher.quoteReplacement("$$"));
|
||||
ctors.add("add(\"" + s + "\");\n");
|
||||
}
|
||||
ctors.add("$<}});\n");
|
||||
@ -127,7 +127,8 @@ public class FunctionDocInfoWriter implements FuncEnumerator.Listener {
|
||||
|
||||
|
||||
AnnotationSpec serviceAnnotation = AnnotationSpec.builder(Service.class)
|
||||
.addMember("value","$T.class",DocFuncData.class)
|
||||
.addMember("value", "$T.class", DocFuncData.class)
|
||||
.addMember("selector", "$S", doc.getPackageName() + "." + doc.getClassName())
|
||||
.build();
|
||||
|
||||
TypeSpec manifestType = TypeSpec.classBuilder(newClassName)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.nosqlbench.virtdata.core.bindings;
|
||||
|
||||
import io.nosqlbench.nb.api.spi.Named;
|
||||
import io.nosqlbench.virtdata.lang.ast.Expression;
|
||||
import io.nosqlbench.virtdata.lang.ast.FunctionCall;
|
||||
import io.nosqlbench.virtdata.lang.parser.VirtDataDSL;
|
||||
@ -12,7 +11,7 @@ import java.util.stream.Collectors;
|
||||
* A VirtDataFunctionLibrary is simply a way to ask for a set
|
||||
* of named function objects in a generic way.
|
||||
*/
|
||||
public interface VirtDataFunctionLibrary extends Named {
|
||||
public interface VirtDataFunctionLibrary {
|
||||
|
||||
/**
|
||||
* Given a signature for a unary function which takes an input
|
||||
|
@ -9,9 +9,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VirtDataLibraries implements VirtDataFunctionLibrary {
|
||||
private final static Logger logger = LogManager.getLogger(VirtDataLibraries.class);
|
||||
private static VirtDataLibraries instance = new VirtDataLibraries();
|
||||
private final Map<String,DataMapper<?>> threadSafeCache = new HashMap<>();
|
||||
private final static Logger logger = LogManager.getLogger(VirtDataLibraries.class);
|
||||
private static final VirtDataLibraries instance = new VirtDataLibraries();
|
||||
private final Map<String, DataMapper<?>> threadSafeCache = new HashMap<>();
|
||||
|
||||
private final VirtDataFunctionResolver resolver = new VirtDataFunctionResolver();
|
||||
|
||||
@ -21,11 +21,6 @@ public class VirtDataLibraries implements VirtDataFunctionLibrary {
|
||||
|
||||
private VirtDataLibraries() {
|
||||
}
|
||||
@Override
|
||||
|
||||
public String getName() {
|
||||
return "ALL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResolvedFunction> resolveFunctions(
|
||||
|
@ -13,7 +13,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "virtdata")
|
||||
@Singleton
|
||||
@Path("virtdata")
|
||||
public class VirtDataService implements WebServiceObject {
|
||||
|
@ -18,7 +18,7 @@ import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(WebServiceObject.class)
|
||||
@Service(value = WebServiceObject.class, selector = "autodocs")
|
||||
@Singleton
|
||||
@Path("/services/virtdata/functions/")
|
||||
public class AutoDocsWebService implements WebServiceObject {
|
||||
|
@ -5,7 +5,7 @@ import io.nosqlbench.docsys.api.Docs;
|
||||
import io.nosqlbench.docsys.api.DocsBinder;
|
||||
import io.nosqlbench.docsys.api.DocsysDynamicManifest;
|
||||
|
||||
@Service(DocsysDynamicManifest.class)
|
||||
@Service(value = DocsysDynamicManifest.class, selector = "virtdata-docs")
|
||||
public class VirtdataMarkdownManifest implements DocsysDynamicManifest {
|
||||
|
||||
public DocsBinder getDocs() {
|
||||
|
Loading…
Reference in New Issue
Block a user