Interface Activity
- All Superinterfaces:
ActivityDefObserver,java.lang.Comparable<Activity>,ProgressCapable,StateCapable
- All Known Implementing Classes:
SimpleActivity,StandardActivity,StandardActivityType
public interface Activity extends java.lang.Comparable<Activity>, ActivityDefObserver, ProgressCapable, StateCapable
Provides the components needed to build and run an activity a runtime.
The easiest way to build a useful Activity is to extend
SimpleActivity.-
Method Summary
Modifier and Type Method Description voidcloseAutoCloseables()Close all autocloseables that have been registered with this Activity.ActionDispensergetActionDispenserDelegate()ActivityControllergetActivityController()io.nosqlbench.engine.api.activityimpl.ActivityDefgetActivityDef()default java.lang.StringgetAlias()java.io.InputStreamgetConsoleIn()java.io.PrintWritergetConsoleOut()RateLimitergetCycleLimiter()Get the current cycle rate limiter for this activity.RateLimitergetCycleRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the cycle rate limiter in a safe way.default java.lang.StringgetCycleSummary()default java.util.function.Function<java.lang.Throwable,java.lang.String>getErrorNameMapper()When a driver needs to identify an error uniquely for the purposes of routing it to the correct error handler, or naming it in logs, or naming metrics, override this method in your activity.ErrorMetricsgetExceptionMetrics()InputDispensergetInputDispenserDelegate()ActivityInstrumentationgetInstrumentation()Get or create the instrumentation needed for this activity.OutputDispensergetMarkerDispenserDelegate()intgetMaxTries()MotorDispensergetMotorDispenserDelegate()default io.nosqlbench.engine.api.activityimpl.ParameterMapgetParams()RateLimitergetPhaseLimiter()Get the current phase rate limiter for this activity.RateLimitergetPhaseRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the phaseRateLimiterin a concurrent-safe way.IntPredicateDispensergetResultFilterDispenserDelegate()com.codahale.metrics.TimergetResultTimer()RunStategetRunState()longgetStartedAtMillis()RateLimitergetStrideLimiter()Get the current stride rate limiter for this activity.RateLimitergetStrideRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the strideRateLimiterin a concurrent-safe way.default voidinitActivity()voidregisterAutoCloseable(java.lang.AutoCloseable closeable)Register an object which should be closed after this activity is shutdown.voidsetActionDispenserDelegate(ActionDispenser actionDispenser)voidsetActivityController(ActivityController activityController)Provide the activity with the controls needed to stop itself.voidsetConsoleOut(java.io.PrintWriter writer)voidsetCycleLimiter(RateLimiter rateLimiter)Set the cycle rate limiter for this activity.voidsetInputDispenserDelegate(InputDispenser inputDispenser)voidsetMotorDispenserDelegate(MotorDispenser motorDispenser)voidsetOutputDispenserDelegate(OutputDispenser outputDispenser)voidsetPhaseLimiter(RateLimiter rateLimiter)Set the phase rate limiter for this activity.voidsetResultFilterDispenserDelegate(IntPredicateDispenser resultFilterDispenser)voidsetRunState(RunState runState)voidsetStrideLimiter(RateLimiter rateLimiter)Set the stride rate limiter for this activity.default voidshutdownActivity()Methods inherited from interface io.nosqlbench.engine.api.activityapi.core.ActivityDefObserver
onActivityDefUpdateMethods inherited from interface io.nosqlbench.engine.api.activityimpl.input.ProgressCapable
getProgressMeter
-
Method Details
-
setActivityController
Provide the activity with the controls needed to stop itself.- Parameters:
activityController- The dedicated control interface for this activity
-
getActivityController
ActivityController getActivityController() -
registerAutoCloseable
void registerAutoCloseable(java.lang.AutoCloseable closeable)Register an object which should be closed after this activity is shutdown.- Parameters:
closeable- An Autocloseable object
-
getActivityDef
io.nosqlbench.engine.api.activityimpl.ActivityDef getActivityDef() -
getAlias
default java.lang.String getAlias() -
getParams
default io.nosqlbench.engine.api.activityimpl.ParameterMap getParams() -
initActivity
default void initActivity() -
closeAutoCloseables
void closeAutoCloseables()Close all autocloseables that have been registered with this Activity. -
getMotorDispenserDelegate
MotorDispenser getMotorDispenserDelegate() -
setMotorDispenserDelegate
-
getInputDispenserDelegate
InputDispenser getInputDispenserDelegate() -
setInputDispenserDelegate
-
getActionDispenserDelegate
ActionDispenser getActionDispenserDelegate() -
setActionDispenserDelegate
-
getResultFilterDispenserDelegate
IntPredicateDispenser getResultFilterDispenserDelegate() -
setResultFilterDispenserDelegate
-
getMarkerDispenserDelegate
OutputDispenser getMarkerDispenserDelegate() -
setOutputDispenserDelegate
-
getRunState
RunState getRunState()- Specified by:
getRunStatein interfaceStateCapable
-
setRunState
-
getStartedAtMillis
long getStartedAtMillis() -
shutdownActivity
default void shutdownActivity() -
getCycleSummary
default java.lang.String getCycleSummary() -
getCycleLimiter
RateLimiter getCycleLimiter()Get the current cycle rate limiter for this activity. The cycle rate limiter is used to throttle the rate at which cycles are dispatched across all threads in the activity- Returns:
- the cycle
RateLimiter
-
setCycleLimiter
Set the cycle rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetCycleRateLimiter(Supplier)should be used.- Parameters:
rateLimiter- The cycleRateLimiterfor this activity
-
getCycleRateLimiter
Get or create the cycle rate limiter in a safe way. Implementations should ensure that this method is synchronized or that each requester gets the same cycle rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created cycle
RateLimiter
-
getStrideLimiter
RateLimiter getStrideLimiter()Get the current stride rate limiter for this activity. The stride rate limiter is used to throttle the rate at which new strides are dispatched across all threads in an activity.- Returns:
- The stride
RateLimiter
-
setStrideLimiter
Set the stride rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetStrideRateLimiter(Supplier)} should be used.- Parameters:
rateLimiter- The strideRateLimiterfor this activity.
-
getStrideRateLimiter
Get or create the strideRateLimiterin a concurrent-safe way. Implementations should ensure that this method is synchronized or that each requester gets the same stride rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created stride
RateLimiter
-
getPhaseLimiter
RateLimiter getPhaseLimiter()Get the current phase rate limiter for this activity. The phase rate limiter is used to throttle the rate at which new phases are dispatched across all threads in an activity.- Returns:
- The stride
RateLimiter
-
getResultTimer
com.codahale.metrics.Timer getResultTimer() -
setPhaseLimiter
Set the phase rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetPhaseRateLimiter(Supplier)} should be used.- Parameters:
rateLimiter- The phaseRateLimiterfor this activity.
-
getPhaseRateLimiter
Get or create the phaseRateLimiterin a concurrent-safe way. Implementations should ensure that this method is synchronized or that each requester gets the same phase rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created phase
RateLimiter
-
getInstrumentation
ActivityInstrumentation getInstrumentation()Get or create the instrumentation needed for this activity. This provides a single place to find and manage, and document instrumentation that is uniform across all activities.- Returns:
- A new or existing instrumentation object for this activity.
-
getConsoleOut
java.io.PrintWriter getConsoleOut() -
getConsoleIn
java.io.InputStream getConsoleIn() -
setConsoleOut
void setConsoleOut(java.io.PrintWriter writer) -
getExceptionMetrics
ErrorMetrics getExceptionMetrics() -
getErrorNameMapper
default java.util.function.Function<java.lang.Throwable,java.lang.String> getErrorNameMapper()When a driver needs to identify an error uniquely for the purposes of routing it to the correct error handler, or naming it in logs, or naming metrics, override this method in your activity.- Returns:
- A function that can reliably and safely map an instance of Throwable to a stable name.
-
getMaxTries
int getMaxTries()
-