#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. | |
DnxChannel * | dnxDispatcherGetChannel (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. |
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.
Definition in file dnxDispatcher.c.
typedef struct iDnxDispatcher_ iDnxDispatcher |
The implementation data structure for a dispatcher object.
static void* dnxDispatcher | ( | void * | data | ) | [static] |
The dispatcher thread entry point.
[in] | data | - an opaque pointer to the dispatcher object. |
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.
[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. |
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.
[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.
[in] | disp | - the dispatcher from which to retrieve the channel. |
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.
[in] | idisp | - the dispatcher object. |
[in] | pSvcReq | - the service request to be dispatched. |
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.
[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. |
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.