public abstract class RuntimeEngine extends Object implements LimitedRuntimeEngine
Modifier and Type | Field and Description |
---|---|
protected Deployment |
deployment |
protected NetworkManager |
networkManager |
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 |
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 |
networkPartition(NetPart netPart)
Imposes a network partition based on the given partition scheme in the deployed environment
|
Set<String> |
nodeNames() |
void |
removeNetworkPartition(NetPart netPart)
Removes a network partition based on the given partition scheme in the deployed environment
|
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.
|
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 NetworkManager networkManager
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)
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 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
LimitedRuntimeEngine
removeNetworkPartition
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 existprotected 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 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.