@Beta
public abstract class MachineLifecycleEffectorTasks
extends java.lang.Object
Knows how to provision machines, making use of ProvidesProvisioningFlags.obtainProvisioningFlags(MachineProvisioningLocation)
,
and provides hooks for injecting behaviour at common places.
Methods are designed for overriding, with the convention that *Async methods should queue (and not block). The following methods are commonly overridden (and you can safely queue tasks, block, or return immediately in them):
startProcessesAtMachine(Supplier)
(required)
stopProcessesAtMachine()
(required, but can be left blank if you assume the VM will be destroyed)
preStartCustom(MachineLocation)
postStartCustom()
preStopCustom()
Attributes.SERVICE_STATE
sensor.Modifier and Type | Class and Description |
---|---|
static class |
MachineLifecycleEffectorTasks.StopMachineDetails<T> |
Modifier and Type | Field and Description |
---|---|
static ConfigKey<java.util.Collection<? extends Location>> |
LOCATIONS |
static ConfigKey<java.lang.Boolean> |
ON_BOX_BASE_DIR_RESOLVED |
static ConfigKey<Duration> |
STOP_PROCESS_TIMEOUT |
Constructor and Description |
---|
MachineLifecycleEffectorTasks() |
Modifier and Type | Method and Description |
---|---|
void |
attachLifecycleEffectors(Entity entity)
Attaches lifecycle effectors (start, restart, stop) to the given entity post-creation.
|
Effector<java.lang.Void> |
newRestartEffector() |
EffectorBody<java.lang.Void> |
newRestartEffectorTask()
Calls
restart(ConfigBag) . |
Effector<java.lang.Void> |
newStartEffector()
Return an effector suitable for setting in a
public static final or attaching dynamically. |
EffectorBody<java.lang.Void> |
newStartEffectorTask()
Returns the
TaskFactory which supplies the implementation for the start effector. |
Effector<java.lang.Void> |
newStopEffector() |
EffectorBody<java.lang.Void> |
newStopEffectorTask()
Calls
stop() . |
static java.lang.String |
resolveOnBoxDir(EntityInternal entity,
MachineLocation machine)
Resolves the on-box dir.
|
void |
restart()
Deprecated.
since 0.7.0 use
restart(ConfigBag) |
void |
restart(ConfigBag parameters)
Default restart implementation for an entity.
|
void |
start(java.util.Collection<? extends Location> locations)
runs the tasks needed to start, wrapped by setting
Attributes.SERVICE_STATE_EXPECTED appropriately |
void |
stop()
Default stop implementation for an entity.
|
public static final ConfigKey<java.lang.Boolean> ON_BOX_BASE_DIR_RESOLVED
public void attachLifecycleEffectors(Entity entity)
public Effector<java.lang.Void> newStartEffector()
public static final
or attaching dynamically.
The effector overrides the corresponding effector from Startable
with
the behaviour in this lifecycle class instance.
public Effector<java.lang.Void> newRestartEffector()
#newStartEffector()}
public Effector<java.lang.Void> newStopEffector()
#newStartEffector()}
public EffectorBody<java.lang.Void> newStartEffectorTask()
TaskFactory
which supplies the implementation for the start effector.
Calls start(Collection)
in this class.
public EffectorBody<java.lang.Void> newRestartEffectorTask()
restart(ConfigBag)
.#newStartEffectorTask()}
public EffectorBody<java.lang.Void> newStopEffectorTask()
stop()
.#newStartEffectorTask()}
public void start(java.util.Collection<? extends Location> locations)
Attributes.SERVICE_STATE_EXPECTED
appropriatelypublic static java.lang.String resolveOnBoxDir(EntityInternal entity, MachineLocation machine)
Initialize and pre-create the right onbox working dir, if an ssh machine location. Logs a warning if not.
@Deprecated public void restart()
restart(ConfigBag)
public void restart(ConfigBag parameters)
Stops processes if possible, then starts the entity again.
public void stop()
Aborts if already stopped, otherwise sets state Lifecycle.STOPPING
then
invokes preStopCustom()
, stopProcessesAtMachine()
, then finally
stopAnyProvisionedMachines()
and sets state Lifecycle.STOPPED