Cleanup for Deprecated ActivityType (#2079)

* Cleanup for Deprecated ActivityType

* Rename ActivtyType class

* Use StandardActivityType
This commit is contained in:
Dave Fisher 2024-11-18 11:43:23 -08:00 committed by GitHub
parent a8ab07a1f5
commit 68b148575f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 19 deletions

View File

@ -36,7 +36,7 @@ import java.util.function.Function;
import java.util.function.LongFunction; import java.util.function.LongFunction;
/** /**
* <P>The DriverAdapter interface is expected to be the replacement * <P>The DriverAdapter interface is the replacement
* for ActivityTypes. This interface takes a simpler * for ActivityTypes. This interface takes a simpler
* approach. Specifically, all of the core logic which was being pasted into each * approach. Specifically, all of the core logic which was being pasted into each
* driver type is centralized, and only the necessary interfaces * driver type is centralized, and only the necessary interfaces

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022-2023 nosqlbench * Copyright (c) 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.
@ -29,15 +29,16 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
/** /**
* <p>An ActivityType is the central extension point in NB for new * <p>An ActivityType was the central extension point in NB for new
* activity types drivers. It is responsible for naming the activity type, as well as providing * activity types drivers. Please use DriverAdapter instead.
* It is responsible for naming the activity type, as well as providing
* the input, activity, and motor instances that will be assembled into an activity.</p> * the input, activity, and motor instances that will be assembled into an activity.</p>
* <p>At the very minimum, a useful implementation of an activity type should provide * <p>At the very minimum, a useful implementation of an activity type should provide
* an action dispenser. Default implementations of input and motor dispensers are provided, * an action dispenser. Default implementations of input and motor dispensers are provided,
* and by extension, default inputs and motors.</p> * and by extension, default inputs and motors.</p>
*/ */
//@Deprecated(forRemoval = true,since = "5.0") //@Deprecated(forRemoval = true,since = "5.0")
public interface ActivityType<A extends Activity> { public interface LegacyActivityType<A extends Activity> {
/** /**

View File

@ -20,14 +20,14 @@ import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.nb.api.components.core.NBComponent; import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef; import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.activityapi.core.ActionDispenser; import io.nosqlbench.engine.api.activityapi.core.ActionDispenser;
import io.nosqlbench.engine.api.activityapi.core.ActivityType; import io.nosqlbench.engine.api.activityapi.core.LegacyActivityType;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class StandardActivityType<A extends StandardActivity<?,?>> implements ActivityType<A> { public class StandardActivityType<A extends StandardActivity<?,?>> implements LegacyActivityType<A> {
private static final Logger logger = LogManager.getLogger("ACTIVITY"); private static final Logger logger = LogManager.getLogger("ACTIVITY");
private final Map<String, DriverAdapter> adapters = new HashMap<>(); private final Map<String, DriverAdapter> adapters = new HashMap<>();

View File

@ -25,7 +25,6 @@ import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.nb.api.errors.BasicError; import io.nosqlbench.nb.api.errors.BasicError;
import io.nosqlbench.nb.api.spi.SimpleServiceLoader; import io.nosqlbench.nb.api.spi.SimpleServiceLoader;
import io.nosqlbench.nb.api.system.NBEnvironment; import io.nosqlbench.nb.api.system.NBEnvironment;
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
import io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType; import io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType;
import io.nosqlbench.nb.annotations.Maturity; import io.nosqlbench.nb.annotations.Maturity;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -42,13 +41,12 @@ import java.util.stream.Collectors;
public class ActivityTypeLoader { public class ActivityTypeLoader {
private static final Logger logger = LogManager.getLogger(ActivityTypeLoader.class); private static final Logger logger = LogManager.getLogger(ActivityTypeLoader.class);
private final SimpleServiceLoader<ActivityType> ACTIVITYTYPE_SPI_FINDER = new SimpleServiceLoader<ActivityType>(ActivityType.class, Maturity.Any);
private final SimpleServiceLoader<DriverAdapter> DRIVERADAPTER_SPI_FINDER = new SimpleServiceLoader<>(DriverAdapter.class, Maturity.Any); private final SimpleServiceLoader<DriverAdapter> DRIVERADAPTER_SPI_FINDER = new SimpleServiceLoader<>(DriverAdapter.class, Maturity.Any);
private final SimpleServiceLoader<DriverAdapterLoader> DRIVERADAPTERLOADER_SPI_FINDER = new SimpleServiceLoader<>(DriverAdapterLoader.class, Maturity.Any); private final SimpleServiceLoader<DriverAdapterLoader> DRIVERADAPTERLOADER_SPI_FINDER = new SimpleServiceLoader<>(DriverAdapterLoader.class, Maturity.Any);
private final Set<URL> jarUrls = new HashSet<>(); private final Set<URL> jarUrls = new HashSet<>();
public ActivityTypeLoader setMaturity(final Maturity maturity) { public ActivityTypeLoader setMaturity(final Maturity maturity) {
this.ACTIVITYTYPE_SPI_FINDER.setMaturity(maturity); this.DRIVERADAPTER_SPI_FINDER.setMaturity(maturity);
return this; return this;
} }
@ -120,7 +118,7 @@ public class ActivityTypeLoader {
return urlsToAdd; return urlsToAdd;
} }
public Optional<ActivityType> load(final ActivityDef activityDef, final NBComponent parent) { public Optional<StandardActivityType> load(final ActivityDef activityDef, final NBComponent parent) {
String driverName = activityDef.getParams() String driverName = activityDef.getParams()
.getOptionalString("driver", "type") .getOptionalString("driver", "type")
@ -137,18 +135,17 @@ public class ActivityTypeLoader {
}) })
.ifPresent(this::extendClassLoader); .ifPresent(this::extendClassLoader);
return getDriverAdapter(driverName,activityDef,parent) return getDriverAdapter(driverName,activityDef,parent);
.or(() -> this.ACTIVITYTYPE_SPI_FINDER.getOptionally(driverName));
} }
private Optional<ActivityType> getDriverAdapter(final String activityTypeName, final ActivityDef activityDef, final NBComponent parent) { private Optional<StandardActivityType> getDriverAdapter(final String activityTypeName, final ActivityDef activityDef, final NBComponent parent) {
final Optional<DriverAdapter> oda = this.DRIVERADAPTER_SPI_FINDER.getOptionally(activityTypeName); final Optional<DriverAdapter> oda = this.DRIVERADAPTER_SPI_FINDER.getOptionally(activityTypeName);
if (oda.isPresent()) { if (oda.isPresent()) {
final DriverAdapter<?, ?> driverAdapter = oda.get(); final DriverAdapter<?, ?> driverAdapter = oda.get();
final ActivityType activityType = new StandardActivityType<>(driverAdapter, activityDef, parent); final StandardActivityType activityType = new StandardActivityType<>(driverAdapter, activityDef, parent);
return Optional.of(activityType); return Optional.of(activityType);
} }
return Optional.empty(); return Optional.empty();

View File

@ -25,8 +25,6 @@ import io.nosqlbench.nb.api.nbio.Content;
import io.nosqlbench.nb.api.nbio.NBIO; import io.nosqlbench.nb.api.nbio.NBIO;
import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef; import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.nb.api.errors.BasicError; import io.nosqlbench.nb.api.errors.BasicError;
import io.nosqlbench.engine.api.activityapi.core.ActivityType;
import io.nosqlbench.engine.core.lifecycle.activity.ActivityTypeLoader;
import io.nosqlbench.nb.annotations.Service; import io.nosqlbench.nb.annotations.Service;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;

View File

@ -27,8 +27,6 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
// TODO: Consider using "Driver Adapter" or "Workload Adapter" instead of ActivityType
/** /**
* <p> * <p>
* A ParsedTemplate represents any string provided by a user which is meant to be * A ParsedTemplate represents any string provided by a user which is meant to be