dnxDispatcher.c File Reference

Implements the DNX Dispatcher thread. More...

#include "dnxDispatcher.h"
#include "dnxError.h"
#include "dnxDebug.h"
#include "dnxSrvProt.h"
#include "dnxXml.h"
#include "dnxNebMain.h"
#include "dnxRegistrar.h"
#include "dnxJobList.h"
#include "dnxLogging.h"
#include "dnxStats.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  iDnxDispatcher_
 The implementation data structure for a dispatcher object. More...

Typedefs

typedef struct iDnxDispatcher_ iDnxDispatcher
 The implementation data structure for a dispatcher object.

Functions

static int dnxSendJobMsg (iDnxDispatcher *idisp, DnxNewJob *pSvcReq, DnxNodeRequest *pNode)
 Send a job to a designated client node.
static int dnxDispatchJob (iDnxDispatcher *idisp, DnxNewJob *pSvcReq)
 Send a service request to the appropriate worker node.
static void * dnxDispatcher (void *data)
 The dispatcher thread entry point.
DnxChanneldnxDispatcherGetChannel (DnxDispatcher *disp)
 Return the internal comm channel used by the dispatcher.
int dnxDispatcherCreate (char *chname, char *url, DnxJobList *joblist, DnxDispatcher **pdisp)
 Create a new dispatcher object.
void dnxDispatcherDestroy (DnxDispatcher *disp)
 Destroy an existing dispatcher object.


Detailed Description

Implements the DNX Dispatcher thread.

The purpose of this thread is to dispatch service check jobs to the registered worker nodes for execution. It accomplishes this by accepting work node registrations and then dispatching service check jobs to registered worker nodes using a weighted-round-robin algorithm. The algorithm's weighting is based upon the number of jobs-per-second throughput rating of each worker node.

Author:
Robert W. Ingraham (dnx-devel@lists.sourceforge.net)
Attention:
Please submit patches to http://dnx.sourceforge.net

Definition in file dnxDispatcher.c.


Typedef Documentation

The implementation data structure for a dispatcher object.


Function Documentation

static void* dnxDispatcher ( void *  data  )  [static]

The dispatcher thread entry point.

Parameters:
[in] data - an opaque pointer to the dispatcher object.
Returns:
Always returns NULL.

Definition at line 132 of file dnxDispatcher.c.

References DnxNodeRequest::address, DISPATCHES_FAILED, DISPATCHES_OK, DNX_OK, dnxAuditJob(), dnxDispatchJob(), dnxJobListDispatch(), dnxLog(), dnxStatsInc(), iDnxDispatcher_::joblist, and DnxNewJob::pNode.

int dnxDispatcherCreate ( char *  chname,
char *  url,
DnxJobList joblist,
DnxDispatcher **  pdisp 
)

Create a new dispatcher object.

Parameters:
[in] chname - the name of the dispatch channel.
[in] url - the dispatcher channel url.
[in] joblist - a pointer to the global job list object.
[out] pdisp - the address of storage for the return of the new dispatcher object.
Returns:
Zero on success, or a non-zero error value.

Definition at line 178 of file dnxDispatcher.c.

References iDnxDispatcher_::channel, iDnxDispatcher_::chname, DNX_ERR_MEMORY, DNX_ERR_THREAD, DNX_MODE_PASSIVE, DNX_OK, dnxChanMapAdd(), dnxChanMapDelete(), dnxConnect(), dnxDisconnect(), dnxDispatcher(), dnxErrorString(), dnxLog(), iDnxDispatcher_::joblist, iDnxDispatcher_::tid, iDnxDispatcher_::url, xfree, xmalloc, and xstrdup.

void dnxDispatcherDestroy ( DnxDispatcher disp  ) 

Destroy an existing dispatcher object.

Parameters:
[in] disp - a pointer to the dispatcher object to be destroyed.

Definition at line 236 of file dnxDispatcher.c.

References iDnxDispatcher_::channel, iDnxDispatcher_::chname, dnxChanMapDelete(), dnxDisconnect(), iDnxDispatcher_::tid, iDnxDispatcher_::url, and xfree.

DnxChannel* dnxDispatcherGetChannel ( DnxDispatcher disp  ) 

Return the internal comm channel used by the dispatcher.

Return a reference to the dispatcher channel object.

This method exists so the registrar can send a job on the same socket from which it received a job request.

Parameters:
[in] disp - the dispatcher from which to retrieve the channel.
Returns:
the DnxChannel object belonging to disp.

Definition at line 173 of file dnxDispatcher.c.

static int dnxDispatchJob ( iDnxDispatcher idisp,
DnxNewJob pSvcReq 
) [static]

Send a service request to the appropriate worker node.

Parameters:
[in] idisp - the dispatcher object.
[in] pSvcReq - the service request to be dispatched.
Returns:
Zero on success, or a non-zero error value.

Todo:
Implement the fork-error re-scheduling logic as found in run_service_check() in checks.c.

Definition at line 110 of file dnxDispatcher.c.

References dnxSendJobMsg(), and DnxNewJob::pNode.

static int dnxSendJobMsg ( iDnxDispatcher idisp,
DnxNewJob pSvcReq,
DnxNodeRequest pNode 
) [static]

Send a job to a designated client node.

Parameters:
[in] idisp - the dispatcher object.
[in] pSvcReq - the service request block belonging to the client node we're targeting.
[in] pNode - the dnx request node to be sent.
Returns:
Zero on success, or a non-zero error value.

Definition at line 74 of file dnxDispatcher.c.

References DnxNodeRequest::address, iDnxDispatcher_::channel, DnxJob::cmd, DnxNewJob::cmd, DNX_JOB_PENDING, DNX_OK, dnxDebug(), dnxErrorString(), dnxLog(), dnxSendJob(), DnxXID::objSerial, DnxXID::objSlot, DnxJob::priority, DnxJob::state, DnxNewJob::timeout, DnxJob::timeout, DnxJob::xid, and DnxNewJob::xid.


Generated on Tue Apr 13 15:48:08 2010 for DNX by  doxygen 1.5.6