mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Merge pull request #1102 from nosqlbench/nosqlbench-994-unused-driver-warning
Nosqlbench 994 unused driver warning
This commit is contained in:
commit
89bcda6f82
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -86,10 +86,10 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser<Cqld4CqlOp, C
|
|||||||
protected LongFunction<Statement> getEnhancedStmtFunc(LongFunction<Statement> basefunc, ParsedOp op) {
|
protected LongFunction<Statement> getEnhancedStmtFunc(LongFunction<Statement> basefunc, ParsedOp op) {
|
||||||
|
|
||||||
LongFunction<Statement> partial = basefunc;
|
LongFunction<Statement> partial = basefunc;
|
||||||
partial = op.enhanceEnum(partial, "cl", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
partial = op.enhanceEnumOptionally(partial, "cl", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
||||||
partial = op.enhanceEnum(partial, "consistency_level", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
partial = op.enhanceEnumOptionally(partial, "consistency_level", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
||||||
partial = op.enhanceEnum(partial, "scl", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
partial = op.enhanceEnumOptionally(partial, "scl", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
||||||
partial = op.enhanceEnum(partial, "serial_consistency_level", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
partial = op.enhanceEnumOptionally(partial, "serial_consistency_level", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
||||||
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class, Statement::setIdempotent);
|
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class, Statement::setIdempotent);
|
||||||
partial = op.enhanceFuncOptionally(partial, "timeout", double.class, (statement, l) -> statement.setTimeout(Duration.ofMillis((long) (l * 1000L))));
|
partial = op.enhanceFuncOptionally(partial, "timeout", double.class, (statement, l) -> statement.setTimeout(Duration.ofMillis((long) (l * 1000L))));
|
||||||
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class, Statement::setCustomPayload);
|
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class, Statement::setCustomPayload);
|
||||||
|
@ -160,6 +160,7 @@ public abstract class BaseDriverAdapter<R extends Op, S> implements DriverAdapte
|
|||||||
.add(Param.optional("stride").setRegex("\\d+"))
|
.add(Param.optional("stride").setRegex("\\d+"))
|
||||||
.add(Param.optional("striderate", String.class, "rate limit for strides per second"))
|
.add(Param.optional("striderate", String.class, "rate limit for strides per second"))
|
||||||
.add(Param.optional("cycles").setRegex("\\d+[KMBGTPE]?|\\d+[KMBGTPE]?\\.\\.\\d+[KMBGTPE]?").setDescription("cycle interval to use"))
|
.add(Param.optional("cycles").setRegex("\\d+[KMBGTPE]?|\\d+[KMBGTPE]?\\.\\.\\d+[KMBGTPE]?").setDescription("cycle interval to use"))
|
||||||
|
.add(Param.optional("recycles").setDescription("allow cycles to be re-used this many times"))
|
||||||
.add(Param.optional(List.of("cyclerate", "targetrate", "rate"), String.class, "rate limit for cycles per second"))
|
.add(Param.optional(List.of("cyclerate", "targetrate", "rate"), String.class, "rate limit for cycles per second"))
|
||||||
.add(Param.optional("phaserate", String.class, "rate limit for phases per second"))
|
.add(Param.optional("phaserate", String.class, "rate limit for phases per second"))
|
||||||
.add(Param.optional("seq", String.class, "sequencing algorithm"))
|
.add(Param.optional("seq", String.class, "sequencing algorithm"))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -893,7 +893,7 @@ public class ParsedOp implements LongFunction<Map<String, ?>>, StaticFieldReader
|
|||||||
* @param <FE> The enhancer function result type
|
* @param <FE> The enhancer function result type
|
||||||
* @return an (optionally) enhanced base function
|
* @return an (optionally) enhanced base function
|
||||||
*/
|
*/
|
||||||
public <FA,FE extends Enum<FE>> LongFunction<FA> enhanceEnum(
|
public <FA,FE extends Enum<FE>> LongFunction<FA> enhanceEnumOptionally(
|
||||||
LongFunction<FA> func,
|
LongFunction<FA> func,
|
||||||
String field,
|
String field,
|
||||||
Class<FE> type,
|
Class<FE> type,
|
||||||
|
@ -135,6 +135,14 @@
|
|||||||
<directory>src/test/resources</directory>
|
<directory>src/test/resources</directory>
|
||||||
<filtering>false</filtering> <!-- exclusion from defaults -->
|
<filtering>false</filtering> <!-- exclusion from defaults -->
|
||||||
</testResource>
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>log4j2-test.xml</include>
|
||||||
|
</includes>
|
||||||
|
</testResource>
|
||||||
|
|
||||||
</testResources>
|
</testResources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package io.nosqlbench.engine.api.activityimpl.uniform;
|
|||||||
|
|
||||||
import io.nosqlbench.api.config.standard.*;
|
import io.nosqlbench.api.config.standard.*;
|
||||||
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
|
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
|
||||||
|
import io.nosqlbench.api.errors.BasicError;
|
||||||
import io.nosqlbench.api.errors.OpConfigError;
|
import io.nosqlbench.api.errors.OpConfigError;
|
||||||
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
|
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
|
||||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||||
@ -66,9 +67,14 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServiceLoader<DriverAdapter> adapterLoader = ServiceLoader.load(DriverAdapter.class);
|
ServiceLoader<DriverAdapter> adapterLoader = ServiceLoader.load(DriverAdapter.class);
|
||||||
Optional<DriverAdapter> defaultAdapter = activityDef.getParams().getOptionalString("driver")
|
Optional<String> defaultDriverName = activityDef.getParams().getOptionalString("driver");
|
||||||
|
Optional<DriverAdapter> defaultAdapter = defaultDriverName
|
||||||
.flatMap(s -> ServiceSelector.of(s, adapterLoader).get());
|
.flatMap(s -> ServiceSelector.of(s, adapterLoader).get());
|
||||||
|
|
||||||
|
if (defaultDriverName.isPresent() && defaultAdapter.isEmpty()) {
|
||||||
|
throw new BasicError("Unable to load default driver adapter '" + defaultDriverName.get() + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// HERE, op templates are loaded before drivers are loaded
|
// HERE, op templates are loaded before drivers are loaded
|
||||||
List<OpTemplate> opTemplates = loadOpTemplates(defaultAdapter);
|
List<OpTemplate> opTemplates = loadOpTemplates(defaultAdapter);
|
||||||
|
|
||||||
@ -77,11 +83,12 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
|||||||
List<DriverAdapter> adapterlist = new ArrayList<>();
|
List<DriverAdapter> adapterlist = new ArrayList<>();
|
||||||
NBConfigModel supersetConfig = ConfigModel.of(StandardActivity.class).add(yamlmodel);
|
NBConfigModel supersetConfig = ConfigModel.of(StandardActivity.class).add(yamlmodel);
|
||||||
|
|
||||||
|
Optional<String> defaultDriverOption = activityDef.getParams().getOptionalString("driver");
|
||||||
for (OpTemplate ot : opTemplates) {
|
for (OpTemplate ot : opTemplates) {
|
||||||
ParsedOp incompleteOpDef = new ParsedOp(ot, NBConfiguration.empty(), List.of());
|
ParsedOp incompleteOpDef = new ParsedOp(ot, NBConfiguration.empty(), List.of());
|
||||||
String driverName = incompleteOpDef.takeOptionalStaticValue("driver", String.class)
|
String driverName = incompleteOpDef.takeOptionalStaticValue("driver", String.class)
|
||||||
.or(() -> incompleteOpDef.takeOptionalStaticValue("type",String.class))
|
.or(() -> incompleteOpDef.takeOptionalStaticValue("type",String.class))
|
||||||
.or(() -> activityDef.getParams().getOptionalString("driver"))
|
.or(() -> defaultDriverOption)
|
||||||
.orElseThrow(() -> new OpConfigError("Unable to identify driver name for op template:\n" + ot));
|
.orElseThrow(() -> new OpConfigError("Unable to identify driver name for op template:\n" + ot));
|
||||||
|
|
||||||
// String driverName = ot.getOptionalStringParam("driver")
|
// String driverName = ot.getOptionalStringParam("driver")
|
||||||
@ -109,7 +116,6 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
|||||||
}
|
}
|
||||||
supersetConfig.assertValidConfig(activityDef.getParams().getStringStringMap());
|
supersetConfig.assertValidConfig(activityDef.getParams().getStringStringMap());
|
||||||
|
|
||||||
|
|
||||||
DriverAdapter adapter = adapters.get(driverName);
|
DriverAdapter adapter = adapters.get(driverName);
|
||||||
adapterlist.add(adapter);
|
adapterlist.add(adapter);
|
||||||
ParsedOp pop = new ParsedOp(ot, adapter.getConfiguration(), List.of(adapter.getPreprocessor()));
|
ParsedOp pop = new ParsedOp(ot, adapter.getConfiguration(), List.of(adapter.getPreprocessor()));
|
||||||
@ -117,6 +123,13 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
|||||||
pops.add(pop);
|
pops.add(pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaultDriverOption.isPresent()) {
|
||||||
|
long matchingDefault = mappers.keySet().stream().filter(n -> n.equals(defaultDriverOption.get())).count();
|
||||||
|
if (matchingDefault==0) {
|
||||||
|
logger.warn("All op templates used a different driver than the default '" + defaultDriverOption.get()+"'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean strict = activityDef.getParams().getOptionalBoolean("strict").orElse(false);
|
boolean strict = activityDef.getParams().getOptionalBoolean("strict").orElse(false);
|
||||||
sequence = createOpSourceFromParsedOps(adapters, mappers, adapterlist, pops);
|
sequence = createOpSourceFromParsedOps(adapters, mappers, adapterlist, pops);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
package io.nosqlbench.nb.api.config;
|
package io.nosqlbench.nb.api.config;
|
||||||
|
|
||||||
import io.nosqlbench.api.config.standard.ConfigModel;
|
import io.nosqlbench.api.config.standard.*;
|
||||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
|
||||||
import io.nosqlbench.api.config.standard.Param;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -36,6 +34,25 @@ public class ConfigModelTest {
|
|||||||
NBConfiguration cfg = cm.apply(Map.of("c", 232));
|
NBConfiguration cfg = cm.apply(Map.of("c", 232));
|
||||||
assertThat(cfg.getOptional("a")).isEmpty();
|
assertThat(cfg.getOptional("a")).isEmpty();
|
||||||
assertThat(cfg.get("c",int.class)).isEqualTo(232);
|
assertThat(cfg.get("c",int.class)).isEqualTo(232);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoxingSupport() {
|
||||||
|
NBConfigModel model = ConfigModel.of(ConfigModelTest.class)
|
||||||
|
.add(Param.defaultTo("val",5))
|
||||||
|
.asReadOnly();
|
||||||
|
NBConfiguration config = model.apply(Map.of("val", 7));
|
||||||
|
Integer val1 = config.getOrDefault("val", 8);
|
||||||
|
assertThat(val1).isEqualTo(7);
|
||||||
|
|
||||||
|
int val2 = config.getOrDefault("val", 9);
|
||||||
|
assertThat(val2).isEqualTo(7);
|
||||||
|
|
||||||
|
Integer val3 = config.get("val");
|
||||||
|
assertThat(val3).isEqualTo(7);
|
||||||
|
|
||||||
|
int val4 = config.get("val");
|
||||||
|
assertThat(val4).isEqualTo(7);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 nosqlbench
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -21,6 +21,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This provides common thread local instancing for sharing a thread local map across classes.
|
* This provides common thread local instancing for sharing a thread local map across classes.
|
||||||
|
* This is being described as a <em>Thread Local State Cache</em>.
|
||||||
*/
|
*/
|
||||||
public class SharedState {
|
public class SharedState {
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2023 nosqlbench
|
||||||
|
*
|
||||||
|
* 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.virtdata.library.basics.shared.from_long.to_object;
|
||||||
|
|
||||||
|
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||||
|
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||||
|
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||||
|
|
||||||
|
import java.util.function.LongFunction;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function takes a long input and ignores it. It returns a generic object which is meant to be used as input to
|
||||||
|
* other function which don't need a specific input.
|
||||||
|
*/
|
||||||
|
@ThreadSafeMapper
|
||||||
|
@Categories({Category.general})
|
||||||
|
public class Discard implements LongFunction<Object> {
|
||||||
|
Object object = "discard";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object apply(long value) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user