Class: ExecutionEngine

ExecutionEngine

ExecutionEngine is a Singleton that manages the clients executing the functions. It makes sure that the environment/stubs are created and ready for the required functions to be executed

Constructor

new ExecutionEngine(socketCommunicator)

Constructor that sets up the Execution engine and initializes it
Parameters:
Name Type Description
socketCommunicator SocketCommunicator The Global Singleton SocketCommunicator for this instance
Source:
Requires:
  • module:Sandbox

Requires

  • module:Sandbox

Methods

(static) executeFunctionLocally()

Function to Execute the function locally if no resources are available
Source:

(static) getExecutionEngine()

Getter for the current singleton ExecutionEngine
Source:

addToResources(socketCommEngine)

Function that adds to available resources if within the resrouce timeout
Parameters:
Name Type Description
socketCommEngine CommunicationEngine The CommunicationEngine of the socket to add to resources
Source:

aggregateResults(socketCommEngine, err, results, finalCallback)

Function that aggregates the results from all the clients
Parameters:
Name Type Description
socketCommEngine CommunicationEngine
err Error Error returned by client
results JSON Results returned by client
finalCallback function Called after results are aggregated
Source:

executeBroadcast(map, reduce, options, array)

Executes the Spawn functionality
Parameters:
Name Type Description
map function Function to map the stuff that needs to be done in each client
reduce function The reduce function to collate the results
options JSON Contains options like the scope of the closure example {scope:{testVariable:1}} default scope is {}
array function The function to be called after completion of execution
Source:

executeMapFunction(finalCallback)

Function to trigger the map function execution
Parameters:
Name Type Description
finalCallback function Callback called after map function executes
Source:

executeMapReduce(array, map, reduce, options)

This does the mapReduce capabilities of the system. Usually, these are the functions within the async callbacks.
Parameters:
Name Type Description
array JSON The array on which the map has to be executed
map function Function to map the stuff that needs to be done in each client
reduce function The reduce function to collate the results
options object Contains options like the scope of the closure example {scope:{testVariable:1}} default scope is {}
Source:

executeParallel(array, map, reduce, options, array)

Executes the Parallel functionality
Parameters:
Name Type Description
array Array The array of functions to be executed in parallel
map function Function to map the stuff that needs to be done in each client
reduce function The reduce function to collate the results
options JSON Contains options like the scope of the closure example {scope:{testVariable:1}} default scope is {}
array function The function to be called after completion of execution
Source:

initializeEnvironment(data, finalCallback)

Function that initializes environment for execution
Parameters:
Name Type Description
data JSON The data used to initialize the Sandbox
finalCallback function Callback called once environment is initialized
Source:

onSocketEnvironmentInitialized(socketCommEngine)

Function that is called when a client initializes its Environment. Used to keep track of resources and start execution once they're done
Parameters:
Name Type Description
socketCommEngine CommunicationEngine The CommunicationEngine of the socket
Source:

resetExecutionEngine()

Function to reset the Engine
Source: