public abstract class RuntimeEngine extends Object implements LimitedRuntimeEngine
Modifier and Type | Field and Description |
---|---|
protected Deployment |
deployment |
protected NetworkOperationManager |
networkOperationManager |
protected NetworkPartitionManager |
networkPartitionManager |
protected Map<String,Node> |
nodeMap |
protected Map<String,NodeWorkspace> |
nodeWorkspaceMap |
protected boolean |
stopped |
Constructor and Description |
---|
RuntimeEngine(Deployment deployment,
Map<String,NodeWorkspace> nodeWorkspaceMap) |
Modifier and Type | Method and Description |
---|---|
void |
addNewNode(Node node,
NodeWorkspace nodeWorkspace) |
protected abstract void |
createNodeContainer(Node node)
This method should create a container based on the given node definition.
|
void |
enforceOrder(String eventName,
FailifyCheckedRunnable action)
This method waits indefinitely for the given test case event's dependencies to be marked as satisfied in the event
server, executes the given action, and finally, marks the given event name as satisfied in the event server.
|
void |
enforceOrder(String eventName,
Integer timeout,
FailifyCheckedRunnable action)
This method waits for the given test case event's dependencies to be marked as satisfied in the event server,
executes the given action, and finally, marks the given event name as satisfied in the event server.
|
protected abstract String |
getEventServerIpAddress()
This method should find the best IP address for the nodes to connect to the event server based on the current environment
|
protected Map<String,String> |
getNodeEnvironmentVariablesMap(String nodeName) |
protected Map<String,String> |
getNodeEnvironmentVariablesMap(String nodeName,
Map<String,String> environment) |
protected Set<ExposedPortDefinition> |
getNodeExposedPorts(String nodeName) |
protected String |
getNodeInitCommand(String nodeName) |
protected String |
getNodeStartCommand(String nodeName) |
protected String |
getNodeStopCommand(String nodeName) |
static RuntimeEngine |
getRuntimeEngine(Deployment deployment,
Map<String,NodeWorkspace> nodeWorkspaceMap) |
protected Map<String,String> |
improveEnvironmentVariablesMap(String nodeName,
Map<String,String> environment) |
protected abstract Map<String,String> |
improveEnvironmentVariablesMapForEngine(String nodeName,
Map<String,String> environment)
This method improves a node's env var map
|
boolean |
isStopped() |
void |
networkOperation(String nodeName,
NetOp.BuilderBase... netOpBuilders)
Applies a network operation including network delay and loss addition and removal on a node
|
void |
networkPartition(NetPart netPart)
Imposes a network partition based on the given partition scheme in the deployed environment
|
Set<String> |
nodeNames() |
void |
removeNetworkPartition(NetPart netPart) |
void |
start(FailifyRunner failifyRunner) |
protected void |
startEventServer() |
protected abstract void |
startFileSharingService()
This method should start the file sharing service (if any), create the defined shared directory in the deployment definition
if they do not exist, and make them available through the sharing service.
|
protected abstract void |
startNodes()
This method should start all of the nodes.
|
void |
stop(boolean kill,
Integer secondsUntilForcedStop) |
protected void |
stopEventServer() |
protected abstract void |
stopFileSharingService()
This method should stop the potentially running file sharing server and unmount shared directories in the nodes (if necessary).
|
protected abstract void |
stopNodes(Boolean kill,
Integer secondsUntilForcedStop)
This method should stop all of the nodes and in case of a failure in stopping something it won't throw any exception, but
error logs the exception or a message.
|
void |
waitFor(String eventName)
This method waits indefinitely for the given event's dependencies to be marked as satisfied in the event server.
|
void |
waitFor(String eventName,
Boolean includeEvent)
This method waits indefinitely for the given event's dependencies and the event itself (if desired) to be marked
as satisfied in the event server.
|
void |
waitFor(String eventName,
Boolean includeEvent,
Integer timeout)
This method waits for the given event's dependencies and the event itself (if desired) to be marked as satisfied in
the event server.
|
void |
waitFor(String eventName,
Integer timeout)
This method waits for the given event's dependencies to be marked as satisfied in the event server.
|
void |
waitForRunSequenceCompletion()
This method waits indefinitely for the run sequence to be enforced completely, and then returns.
|
void |
waitForRunSequenceCompletion(Integer timeout)
This method waits for the run sequence to be enforced completely, and then returns.
|
void |
waitForRunSequenceCompletion(Integer timeout,
Integer nextEventReceiptTimeout)
This method waits for the run sequence to be enforced completely, and then returns.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clockDrift, ip, killNode, portMapping, restartNode, runCommandInNode, startNode, stopNode
protected final Deployment deployment
protected Map<String,NodeWorkspace> nodeWorkspaceMap
protected boolean stopped
protected final NetworkPartitionManager networkPartitionManager
protected final NetworkOperationManager networkOperationManager
public RuntimeEngine(Deployment deployment, Map<String,NodeWorkspace> nodeWorkspaceMap)
public static RuntimeEngine getRuntimeEngine(Deployment deployment, Map<String,NodeWorkspace> nodeWorkspaceMap)
public Set<String> nodeNames()
nodeNames
in interface LimitedRuntimeEngine
public boolean isStopped()
public void start(FailifyRunner failifyRunner) throws RuntimeEngineException
RuntimeEngineException
protected void startEventServer() throws RuntimeEngineException
RuntimeEngineException
public void stop(boolean kill, Integer secondsUntilForcedStop)
public void addNewNode(Node node, NodeWorkspace nodeWorkspace) throws RuntimeEngineException
RuntimeEngineException
protected void stopEventServer()
protected Map<String,String> getNodeEnvironmentVariablesMap(String nodeName, Map<String,String> environment)
protected Map<String,String> improveEnvironmentVariablesMap(String nodeName, Map<String,String> environment) throws RuntimeEngineException
RuntimeEngineException
protected final Map<String,String> getNodeEnvironmentVariablesMap(String nodeName) throws RuntimeEngineException
RuntimeEngineException
protected Set<ExposedPortDefinition> getNodeExposedPorts(String nodeName)
public void waitFor(String eventName) throws RuntimeEngineException
LimitedRuntimeEngine
waitFor
in interface LimitedRuntimeEngine
eventName
- the event name to wait forRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequencepublic void waitFor(String eventName, Boolean includeEvent) throws RuntimeEngineException
LimitedRuntimeEngine
waitFor
in interface LimitedRuntimeEngine
eventName
- the event name to wait forincludeEvent
- if the wait should include the event itself or notRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequencepublic void waitFor(String eventName, Integer timeout) throws RuntimeEngineException, TimeoutException
LimitedRuntimeEngine
waitFor
in interface LimitedRuntimeEngine
eventName
- the event name to wait fortimeout
- the timeout amount in secondsRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequenceTimeoutException
- if the wait timeoutspublic void waitFor(String eventName, Boolean includeEvent, Integer timeout) throws RuntimeEngineException, TimeoutException
LimitedRuntimeEngine
waitFor
in interface LimitedRuntimeEngine
eventName
- the event name to wait forincludeEvent
- if the wait should include the event itself or nottimeout
- the timeout amount in secondsRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequenceTimeoutException
- if the wait timeoutspublic void enforceOrder(String eventName, FailifyCheckedRunnable action) throws RuntimeEngineException
LimitedRuntimeEngine
enforceOrder
in interface LimitedRuntimeEngine
eventName
- the event name to wait foraction
- the action to execute after waiting is completedRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequence
or the event is not a test case eventpublic void enforceOrder(String eventName, Integer timeout, FailifyCheckedRunnable action) throws RuntimeEngineException, TimeoutException
LimitedRuntimeEngine
enforceOrder
in interface LimitedRuntimeEngine
eventName
- the event name to wait fortimeout
- the timeout amount in secondsaction
- the action to execute after waiting is completedRuntimeEngineException
- if something goes wrong or the event name is not referred to in the run sequence
or the event is not a test case eventTimeoutException
- if the wait timeoutspublic void waitForRunSequenceCompletion() throws TimeoutException
LimitedRuntimeEngine
waitForRunSequenceCompletion
in interface LimitedRuntimeEngine
TimeoutException
- if either type of timeout happenspublic void waitForRunSequenceCompletion(Integer timeout) throws TimeoutException
LimitedRuntimeEngine
waitForRunSequenceCompletion
in interface LimitedRuntimeEngine
timeout
- the waiting timeout in secondsTimeoutException
- if either type of timeout happenspublic void waitForRunSequenceCompletion(Integer timeout, Integer nextEventReceiptTimeout) throws TimeoutException
LimitedRuntimeEngine
waitForRunSequenceCompletion
in interface LimitedRuntimeEngine
timeout
- the waiting timeout in secondsnextEventReceiptTimeout
- the number of seconds to wait until timeout the receipt of the next event in the
run sequenceTimeoutException
- if either type of timeout happenspublic void networkPartition(NetPart netPart) throws RuntimeEngineException
LimitedRuntimeEngine
networkPartition
in interface LimitedRuntimeEngine
netPart
- the desired scheme for the partition. Take a look at NetPart
class for more informationRuntimeEngineException
- if something goes wrongNodeNotFoundException
- if one of partitions includes a node that doesn't existpublic void removeNetworkPartition(NetPart netPart) throws RuntimeEngineException
removeNetworkPartition
in interface LimitedRuntimeEngine
RuntimeEngineException
public void networkOperation(String nodeName, NetOp.BuilderBase... netOpBuilders) throws RuntimeEngineException
LimitedRuntimeEngine
networkOperation
in interface LimitedRuntimeEngine
nodeName
- the node to apply the network operation onnetOpBuilders
- the specifics of the network operation. Take a look a NetOp
class for more information.
NetOp
static methods should be used to create objects of this type.RuntimeEngineException
- if something goes wrongprotected abstract Map<String,String> improveEnvironmentVariablesMapForEngine(String nodeName, Map<String,String> environment) throws RuntimeEngineException
nodeName
- the corresponding node to be improvedenvironment
- the current environment of the nodeRuntimeEngineException
- if something goes wrongprotected abstract String getEventServerIpAddress() throws RuntimeEngineException
RuntimeEngineException
- if something goes wrongprotected abstract void createNodeContainer(Node node) throws RuntimeEngineException
node
- the node definition to create a container uponRuntimeEngineException
- if something goes wrongprotected abstract void startNodes() throws RuntimeEngineException
RuntimeEngineException
protected abstract void stopNodes(Boolean kill, Integer secondsUntilForcedStop)
protected abstract void startFileSharingService() throws RuntimeEngineException
RuntimeEngineException
- if some error happens when creating the shared directory for the nodesprotected abstract void stopFileSharingService()
Copyright © 2019. All rights reserved.