Package io.engineblock.activityimpl
Class ActivityDef
- java.lang.Object
-
- io.engineblock.activityimpl.ActivityDef
-
public class ActivityDef extends java.lang.ObjectA runtime definition for an activity.
Instances of ActivityDef hold control values for the execution of a single activity. Each thread of the related activity is initialized with the associated ActivityDef. When the ActivityDef is modified, interested activity threads are notified so that they can dynamically adjust.
The canonical values for all parameters are kept internally in the parameter map. Essentially, ActivityDef is just a type-aware wrapper around a thread-safe parameter map, with an atomic change counter which can be used to signal changes to observers.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_ALIASstatic java.lang.StringDEFAULT_ATYPEstatic java.lang.StringDEFAULT_CYCLESstatic intDEFAULT_THREADS
-
Constructor Summary
Constructors Constructor Description ActivityDef(ParameterMap parameterMap)
-
Method Summary
Modifier and Type Method Description java.lang.StringgetActivityType()java.lang.StringgetAlias()The alias that the associated activity instance is known by.java.util.concurrent.atomic.AtomicLonggetChangeCounter()longgetCycleCount()java.lang.StringgetCycleSummary()longgetEndCycle()The last cycle that will be used for execution of this activity, inclusive.ParameterMapgetParams()Get the parameter map, which is the backing-store for all data within an ActivityDef.longgetStartCycle()The first cycle that will be used for execution of this activity, inclusive.intgetThreads()The number of threads (AKA slots) that the associated activity should currently be using.static ActivityDefparseActivityDef(java.lang.String namedActivitySpec)static java.util.Optional<ActivityDef>parseActivityDefOptionally(java.lang.String namedActivitySpec)voidsetCycles(java.lang.String cycles)voidsetEndCycle(long endCycle)voidsetEndCycle(java.lang.String endCycle)voidsetStartCycle(long startCycle)voidsetStartCycle(java.lang.String startCycle)voidsetThreads(int threads)java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_ALIAS
public static final java.lang.String DEFAULT_ALIAS
- See Also:
- Constant Field Values
-
DEFAULT_ATYPE
public static final java.lang.String DEFAULT_ATYPE
- See Also:
- Constant Field Values
-
DEFAULT_CYCLES
public static final java.lang.String DEFAULT_CYCLES
- See Also:
- Constant Field Values
-
DEFAULT_THREADS
public static final int DEFAULT_THREADS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActivityDef
public ActivityDef(ParameterMap parameterMap)
-
-
Method Detail
-
parseActivityDefOptionally
public static java.util.Optional<ActivityDef> parseActivityDefOptionally(java.lang.String namedActivitySpec)
-
parseActivityDef
public static ActivityDef parseActivityDef(java.lang.String namedActivitySpec)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getAlias
public java.lang.String getAlias()
The alias that the associated activity instance is known by.- Returns:
- the alias
-
getActivityType
public java.lang.String getActivityType()
-
getStartCycle
public long getStartCycle()
The first cycle that will be used for execution of this activity, inclusive. If the value is provided as a range as in 0..10, then the first number is the start cycle and the second number is the end cycle +1. Effectively, cycle ranges are [closed,open) intervals, as in [min..max)- Returns:
- the long start cycle
-
setStartCycle
public void setStartCycle(long startCycle)
-
setStartCycle
public void setStartCycle(java.lang.String startCycle)
-
setEndCycle
public void setEndCycle(java.lang.String endCycle)
-
getEndCycle
public long getEndCycle()
The last cycle that will be used for execution of this activity, inclusive.- Returns:
- the long end cycle
-
setEndCycle
public void setEndCycle(long endCycle)
-
getThreads
public int getThreads()
The number of threads (AKA slots) that the associated activity should currently be using.- Returns:
- target thread count
-
setThreads
public void setThreads(int threads)
-
getParams
public ParameterMap getParams()
Get the parameter map, which is the backing-store for all data within an ActivityDef.- Returns:
- the parameter map
-
getChangeCounter
public java.util.concurrent.atomic.AtomicLong getChangeCounter()
-
setCycles
public void setCycles(java.lang.String cycles)
-
getCycleSummary
public java.lang.String getCycleSummary()
-
getCycleCount
public long getCycleCount()
-
-