Class SimpleActivity
java.lang.Object
io.nosqlbench.engine.api.activityimpl.SimpleActivity
- All Implemented Interfaces:
Activity,ActivityDefObserver,ProgressCapable,StateCapable,java.lang.Comparable<Activity>
- Direct Known Subclasses:
StandardActivity,StandardActivityType
public class SimpleActivity extends java.lang.Object implements Activity, ProgressCapable
A default implementation of an Activity, suitable for building upon.
-
Field Summary
Fields Modifier and Type Field Description protected io.nosqlbench.engine.api.activityimpl.ActivityDefactivityDef -
Constructor Summary
Constructors Constructor Description SimpleActivity(io.nosqlbench.engine.api.activityimpl.ActivityDef activityDef)SimpleActivity(java.lang.String activityDefString) -
Method Summary
Modifier and Type Method Description voidcloseAutoCloseables()Close all autocloseables that have been registered with this Activity.intcompareTo(Activity o)protected <O> OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>>createOpSequence(java.util.function.Function<io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit)Deprecated, for removal: This API element is subject to removal in a future version.protected <O extends io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op>
OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>>createOpSequenceFromCommands(java.util.function.Function<CommandTemplate,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit)Given a function that can create an op of typefrom a CommandTemplate, generate an indexed sequence of ready to call operations. protected <O extends io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op>
OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>>createOpSourceFromCommands(java.util.function.Function<io.nosqlbench.engine.api.templating.ParsedOp,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit, io.nosqlbench.nb.api.config.standard.NBConfiguration cfg, java.util.List<java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>>> parsers)ActionDispensergetActionDispenserDelegate()ActivityControllergetActivityController()io.nosqlbench.engine.api.activityimpl.ActivityDefgetActivityDef()java.io.InputStreamgetConsoleIn()java.io.PrintWritergetConsoleOut()RateLimitergetCycleLimiter()Get the current cycle rate limiter for this activity.RateLimitergetCycleRateLimiter(java.util.function.Supplier<? extends RateLimiter> s)Get or create the cycle rate limiter in a safe way.NBErrorHandlergetErrorHandler()ErrorMetricsgetExceptionMetrics()InputDispensergetInputDispenserDelegate()ActivityInstrumentationgetInstrumentation()Get or create the instrumentation needed for this activity.OutputDispensergetMarkerDispenserDelegate()intgetMaxTries()Activities with retryable operations (when specified with the retry error handler for some types of error), should allow the user to specify how many retries are allowed before giving up on the operation.MotorDispensergetMotorDispenserDelegate()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.ProgressMetergetProgressMeter()IntPredicateDispensergetResultFilterDispenserDelegate()com.codahale.metrics.TimergetResultTimer()RunStategetRunState()longgetStartedAtMillis()RateLimitergetStrideLimiter()Get the current stride rate limiter for this activity.RateLimitergetStrideRateLimiter(java.util.function.Supplier<? extends RateLimiter> s)Get or create the strideRateLimiterin a concurrent-safe way.voidinitActivity()voidonActivityDefUpdate(io.nosqlbench.engine.api.activityimpl.ActivityDef activityDef)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.voidsetDefaultsFromOpSequence(OpSequence<?> seq)Modify the provided ActivityDef with defaults for stride and cycles, if they haven't been provided, based on the length of the sequence as determined by the provided ratios.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.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.nosqlbench.engine.api.activityapi.core.Activity
getAlias, getCycleSummary, getErrorNameMapper, getParams, shutdownActivity
-
Field Details
-
activityDef
protected io.nosqlbench.engine.api.activityimpl.ActivityDef activityDef
-
-
Constructor Details
-
SimpleActivity
public SimpleActivity(io.nosqlbench.engine.api.activityimpl.ActivityDef activityDef) -
SimpleActivity
public SimpleActivity(java.lang.String activityDefString)
-
-
Method Details
-
initActivity
public void initActivity()- Specified by:
initActivityin interfaceActivity
-
getErrorHandler
-
getRunState
- Specified by:
getRunStatein interfaceActivity- Specified by:
getRunStatein interfaceStateCapable
-
setRunState
- Specified by:
setRunStatein interfaceActivity
-
getStartedAtMillis
public long getStartedAtMillis()- Specified by:
getStartedAtMillisin interfaceActivity
-
getMotorDispenserDelegate
- Specified by:
getMotorDispenserDelegatein interfaceActivity
-
setMotorDispenserDelegate
- Specified by:
setMotorDispenserDelegatein interfaceActivity
-
getInputDispenserDelegate
- Specified by:
getInputDispenserDelegatein interfaceActivity
-
setInputDispenserDelegate
- Specified by:
setInputDispenserDelegatein interfaceActivity
-
getActionDispenserDelegate
- Specified by:
getActionDispenserDelegatein interfaceActivity
-
setActionDispenserDelegate
- Specified by:
setActionDispenserDelegatein interfaceActivity
-
getResultFilterDispenserDelegate
- Specified by:
getResultFilterDispenserDelegatein interfaceActivity
-
setResultFilterDispenserDelegate
- Specified by:
setResultFilterDispenserDelegatein interfaceActivity
-
getMarkerDispenserDelegate
- Specified by:
getMarkerDispenserDelegatein interfaceActivity
-
setOutputDispenserDelegate
- Specified by:
setOutputDispenserDelegatein interfaceActivity
-
getActivityDef
public io.nosqlbench.engine.api.activityimpl.ActivityDef getActivityDef()- Specified by:
getActivityDefin interfaceActivity
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<Activity>
-
getActivityController
- Specified by:
getActivityControllerin interfaceActivity
-
setActivityController
Description copied from interface:ActivityProvide the activity with the controls needed to stop itself.- Specified by:
setActivityControllerin interfaceActivity- Parameters:
activityController- The dedicated control interface for this activity
-
registerAutoCloseable
public void registerAutoCloseable(java.lang.AutoCloseable closeable)Description copied from interface:ActivityRegister an object which should be closed after this activity is shutdown.- Specified by:
registerAutoCloseablein interfaceActivity- Parameters:
closeable- An Autocloseable object
-
closeAutoCloseables
public void closeAutoCloseables()Description copied from interface:ActivityClose all autocloseables that have been registered with this Activity.- Specified by:
closeAutoCloseablesin interfaceActivity
-
getCycleLimiter
Description copied from interface:ActivityGet 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- Specified by:
getCycleLimiterin interfaceActivity- Returns:
- the cycle
RateLimiter
-
setCycleLimiter
Description copied from interface:ActivitySet the cycle rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versionActivity.getCycleRateLimiter(Supplier)should be used.- Specified by:
setCycleLimiterin interfaceActivity- Parameters:
rateLimiter- The cycleRateLimiterfor this activity
-
getCycleRateLimiter
Description copied from interface:ActivityGet 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.- Specified by:
getCycleRateLimiterin interfaceActivity- Parameters:
s- ARateLimiterSupplier- Returns:
- An extant or newly created cycle
RateLimiter
-
getStrideLimiter
Description copied from interface:ActivityGet 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.- Specified by:
getStrideLimiterin interfaceActivity- Returns:
- The stride
RateLimiter
-
setStrideLimiter
Description copied from interface:ActivitySet the stride rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versionActivity.getStrideRateLimiter(Supplier)} should be used.- Specified by:
setStrideLimiterin interfaceActivity- Parameters:
rateLimiter- The strideRateLimiterfor this activity.
-
getStrideRateLimiter
Description copied from interface:ActivityGet 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.- Specified by:
getStrideRateLimiterin interfaceActivity- Parameters:
s- ARateLimiterSupplier- Returns:
- An extant or newly created stride
RateLimiter
-
getPhaseLimiter
Description copied from interface:ActivityGet 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.- Specified by:
getPhaseLimiterin interfaceActivity- Returns:
- The stride
RateLimiter
-
getResultTimer
public com.codahale.metrics.Timer getResultTimer()- Specified by:
getResultTimerin interfaceActivity
-
setPhaseLimiter
Description copied from interface:ActivitySet the phase rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versionActivity.getPhaseRateLimiter(Supplier)} should be used.- Specified by:
setPhaseLimiterin interfaceActivity- Parameters:
rateLimiter- The phaseRateLimiterfor this activity.
-
getPhaseRateLimiter
public RateLimiter getPhaseRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Description copied from interface:ActivityGet 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.- Specified by:
getPhaseRateLimiterin interfaceActivity- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created phase
RateLimiter
-
getInstrumentation
Description copied from interface:ActivityGet 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.- Specified by:
getInstrumentationin interfaceActivity- Returns:
- A new or existing instrumentation object for this activity.
-
getConsoleOut
public java.io.PrintWriter getConsoleOut()- Specified by:
getConsoleOutin interfaceActivity
-
getConsoleIn
public java.io.InputStream getConsoleIn()- Specified by:
getConsoleInin interfaceActivity
-
setConsoleOut
public void setConsoleOut(java.io.PrintWriter writer)- Specified by:
setConsoleOutin interfaceActivity
-
getExceptionMetrics
- Specified by:
getExceptionMetricsin interfaceActivity
-
onActivityDefUpdate
public void onActivityDefUpdate(io.nosqlbench.engine.api.activityimpl.ActivityDef activityDef)- Specified by:
onActivityDefUpdatein interfaceActivityDefObserver
-
setDefaultsFromOpSequence
Modify the provided ActivityDef with defaults for stride and cycles, if they haven't been provided, based on the length of the sequence as determined by the provided ratios. Also, modify the ActivityDef with reasonable defaults when requested.- Parameters:
seq- - TheOpSequenceto derive the defaults from
-
createOpSequenceFromCommands
protected <O extends io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op> OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> createOpSequenceFromCommands(java.util.function.Function<CommandTemplate,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit)Given a function that can create an op of typefrom a CommandTemplate, generate an indexed sequence of ready to call operations. This method works almost exactly like the createOpSequenceFromCommands(Function), except that it uses theCommandTemplatesemantics, which are more general and allow for map-based specification of operations with bindings in each field. It is recommended to use the CommandTemplate form than the- Type Parameters:
O-- Parameters:
opinit-- Returns:
-
createOpSourceFromCommands
protected <O extends io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op> OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> createOpSourceFromCommands(java.util.function.Function<io.nosqlbench.engine.api.templating.ParsedOp,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit, io.nosqlbench.nb.api.config.standard.NBConfiguration cfg, java.util.List<java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>>> parsers) -
createOpSequence
@Deprecated(forRemoval=true) protected <O> OpSequence<io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> createOpSequence(java.util.function.Function<io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate,io.nosqlbench.engine.api.activityimpl.OpDispenser<O>> opinit)Deprecated, for removal: This API element is subject to removal in a future version.Given a function that can create an op of typefrom an OpTemplate, generate an indexed sequence of ready to call operations. This method uses the following conventions to derive the sequence: - If an 'op', 'stmt', or 'statement' parameter is provided, then it's value is taken as the only provided statement.
- If a 'yaml, or 'workload' parameter is provided, then the statements in that file are taken with their ratios
- Any provided tags filter is used to select only the statements which have matching tags. If no tags are provided, then all the found statements are included.
- The ratios and the 'seq' parameter are used to build a sequence of the ready operations, where the sequence length is the sum of the ratios.
- Type Parameters:
O- A holder for an executable operation for the native driver used by this activity.- Parameters:
opinit- A function to map an OpTemplate to the executable operation form required by the native driver for this activity.- Returns:
- The sequence of operations as determined by filtering and ratios
-
getProgressMeter
- Specified by:
getProgressMeterin interfaceProgressCapable
-
getMaxTries
public int getMaxTries()Activities with retryable operations (when specified with the retry error handler for some types of error), should allow the user to specify how many retries are allowed before giving up on the operation.- Specified by:
getMaxTriesin interfaceActivity- Returns:
- The number of allowable retries
-