fwRPC
 All Files Functions Variables
fwRPC_workerManager.ctl File Reference

Functions

void fwRPC_workerManager_initialize (int workerCount=-1, int maxWorkers=-1, string workerDeathCB)
 
int fwRPC_workerManager_notifyHeartbeat (int id) synchronized(g_fwRPC_workerManager_workers)
 
int fwRPC_workerManager_findSuitableWorker (bool exclusiveExec, dyn_mixed &worker) synchronized(g_fwRPC_workerManager_workers)
 
int fwRPC_workerManager_registerWorker (dyn_mixed worker) synchronized(g_fwRPC_workerManager_workers)
 
int fwRPC_workerManager_deleteWorker (int workerId) synchronized(g_fwRPC_workerManager_workers)
 
void fwRPC_workerManager_updateState (dyn_mixed worker) synchronized(g_fwRPC_workerManager_workers)
 
int fwRPC_workerManager_getWorkerCount ()
 
bool fwRPC_workerManager_pendWorkerRestart (bool immediateRestart) synchronized(g_fwRPC_workerManager_workers)
 
bool fwRPC_workerManager_isWorkerPendingRestart (dyn_mixed worker)
 
bool fwRPC_workerManager_isAnyWorkerPendingRestart ()
 
void fwRPC_workerManager_restartWorker (dyn_mixed worker) synchronized(g_fwRPC_workerManager_workers)
 
private void _fwRPC_workerManager_balanceWorkerInstances (int min, int max, int starting)
 
private void _fwRPC_workerManager_workerPostMortem (int workerId)
 
private void _fwRPC_workerManager_heartmonitor (dyn_mixed worker)
 
private int _fwRPC_workerManager_workersIterator_nextKey () synchronized(g_fwRPC_workerManager_workers)
 

Variables

private global mapping g_fwRPC_workerManager_workers
 
private global int g_fwRPC_workerManager_workersIterator
 
private global string g_fwRPC_workerManager_workerDeathCB
 

Detailed Description

This library contains the set of functions that handles worker management.

Part of the server-side RPC library.

Author
Victor Rodrigues (CERN, BE-ICS-SDS)

Function Documentation

int fwRPC_workerManager_deleteWorker ( int  workerId)

Delete a worker from the worker collection and it's DP.

Parameters
workerId(IN, int) worker to delete
Returns
0 on success -1 otherwise
Exceptions
nothing
int fwRPC_workerManager_findSuitableWorker ( bool  exclusiveExec,
dyn_mixed &  worker 
)

Attempt to find a worker which is able to execute a function under the given exclusivity option.

Parameters
exclusiveExec(IN, bool) whether the request requires exclusive execution
worker(OUT, worker) a suitable worker, if found
Returns
0 on success -1 if no suitable worker is available
Exceptions
nothing
int fwRPC_workerManager_getWorkerCount ( )

Return the total number of registered workers in the local system.

Returns
number of workers
Exceptions
nothing
void fwRPC_workerManager_initialize ( int  workerCount = -1,
int  maxWorkers = -1,
string  workerDeathCB 
)

Ensures that the system starts with workerCount workers, and is bound to maxWorkers, unless workerCount is -1, in which case no worker ctrl manager management is performed (and maxWorkers is therefore ignored). Starts any stopped workers.

Parameters
workerCount(IN, int) starting number of workers
maxWorkers(IN, int) max number of workers allowed
workerDeathCB(IN, string) callback to be executed on worker update event
Returns
nothing
Exceptions
onPMON error
bool fwRPC_workerManager_isAnyWorkerPendingRestart ( )

Return whether or not any workers are pending restart.

Returns
true if at least one worker is pending restart false if no workers are pending restart
Exceptions
nothing
bool fwRPC_workerManager_isWorkerPendingRestart ( dyn_mixed  worker)

Return whether or not a given worker is pending restart.

Parameters
worker(IN, dyn_mixed) worker object to check
Returns
true if worker is pending restart false otherwise
Exceptions
nothing
int fwRPC_workerManager_notifyHeartbeat ( int  id)

Notify a heartbeat event for a given worker by it's ID. This function should be called whenever a heartbeat message is received from the worker itself.

Parameters
id(IN, int) worker id
Returns
0 on success -1 if the worker doesn't exist
Exceptions
nothing
bool fwRPC_workerManager_pendWorkerRestart ( bool  immediateRestart)

Set all workers to a pending restart state.

The worker manager will attempt to restart the workers immediately. If this is done, then the function will return false to indicate that the worker manager is not pending restart. If this is not the case then the function will return true, indicating that the worker manager is still pending restart on at least one worker.

Parameters
immediateRestart(IN, bool) whether we can try to restart immediately if a worker is idle
Returns
true if the worker manager is pending restart
Exceptions
nothing
int fwRPC_workerManager_registerWorker ( dyn_mixed  worker)

Add a worker to the worker collection if it's not already present. If the worker already exists in the collection then it will not be replaced, and this function will return -1.

Parameters
worker(IN, dyn_mixed) worker to register
Returns
0 on success -1 otherwise
Exceptions
nothing
void fwRPC_workerManager_restartWorker ( dyn_mixed  worker)

Restart a given worker.

Parameters
worker(IN, dyn_mixed) worker to restart
Returns
nothing
Exceptions
nothing
void fwRPC_workerManager_updateState ( dyn_mixed  worker)

Update a specific worker with a new state.

Only status, job count and locked status will be changed.

If the worker does not currently exist, it will be added to the pool as an active worker.

Parameters
worker(IN, dyn_mixed) New worker state
Returns
nothing
Exceptions
nothing

Variable Documentation

private global string g_fwRPC_workerManager_workerDeathCB

Callback function to call when a worker is declared dead

private global mapping g_fwRPC_workerManager_workers

Mapping of workers. Structure: key = worker id value = worker object (see fwRPC_workerModel.ctl)

private global int g_fwRPC_workerManager_workersIterator

Worker iterator for round-robin load balancing value is 0 if no workers exist.