dnxProtocol.h File Reference

Types and definitions for DNX messaging protocol. More...

#include <time.h>
#include "dnxTransport.h"

Go to the source code of this file.

Data Structures

struct  DnxXID
 DNX wire transaction ID structure. More...
struct  DnxNodeRequest
 Request job wire structure. More...
struct  DnxJob
 Send job wire structure. More...
struct  DnxResult
 Send job results wire structure. More...
struct  DnxMgmtRequest
 DNX management request wire structure. More...
struct  DnxMgmtReply
 DNX management response wire structure. More...

Enumerations

enum  DnxObjType {
  DNX_OBJ_SCHEDULER = 0, DNX_OBJ_DISPATCHER, DNX_OBJ_WORKER, DNX_OBJ_COLLECTOR,
  DNX_OBJ_REAPER, DNX_OBJ_JOB, DNX_OBJ_MANAGER, DNX_OBJ_MAX
}
 Defines the type of a DNX object in a network message. More...
enum  DnxReqType { DNX_REQ_REGISTER = 0, DNX_REQ_DEREGISTER, DNX_REQ_ACK, DNX_REQ_NAK }
 Defines the type of a DNX worker node network request. More...
enum  DnxJobState {
  DNX_JOB_NULL = 0, DNX_JOB_PENDING, DNX_JOB_INPROGRESS, DNX_JOB_COMPLETE,
  DNX_JOB_EXPIRED
}
 Defines the state of a DNX job. More...

Functions

int dnxSendMgmtRequest (DnxChannel *channel, DnxMgmtRequest *pRequest)
 Issue a management request.
int dnxSendMgmtReply (DnxChannel *channel, DnxMgmtReply *pReply, char *address)
 Issue a management reply.
int dnxWaitForMgmtReply (DnxChannel *channel, DnxMgmtReply *pReply, int timeout)
 Wait for a management reply to come in (server).
int dnxWaitForMgmtRequest (DnxChannel *channel, DnxMgmtRequest *pRequest, char *address, int timeout)
 Wait for a management request to come in (client).
int dnxMakeXID (DnxXID *pxid, DnxObjType xType, unsigned long xSerial, unsigned long xSlot)
 Create a transaction id (XID) from a type, serial number and slot value.
int dnxEqualXIDs (DnxXID *pxa, DnxXID *pxb)
 Compare two XID's for equality; return a boolean value.


Detailed Description

Types and definitions for DNX messaging protocol.

DNX messages are transport independent and have the following properties:

1. Request - enumerated constant identifying the message payload 2. XML (REST-style) body

Currently supported DNX messages are:

1. DNX_MSG_NODE_REQUEST 2. DNX_MSG_JOB 3. DNX_MSG_RESULT 4. DNX_MSG_MGMT_REQUEST 5. DNX_MSG_MGMT_REPLY


   ----------------------------------------------
   Structure: DNX_MSG_NODE_REQUEST
   Issued By: Worker       (dnxSendNodeRequest)
   Issued To: Registrar    (dnxWaitForNodeRequest)

     <dnxMessage>
       <Request>NodeRequest</Request>
       <XID>Xid:ObjType-ObjSerial-ObjSlot</XID>
       <ReqType>IntegerRequestType</ReqType>
       <JobCap>IntegerCapabilityCount</JobCap>
       <TTL>IntegerSeconds<TTL>
     </dnxMessage>

   ----------------------------------------------
   Structure: DNX_MSG_JOB
   Issued By: Dispatcher   (dnxSendJob)
   Issued To: Worker       (dnxWaitForJob)

     <dnxMessage>
       <Request>Job</Request>
       <XID>Xid:ObjType-ObjSerial-ObjSlot</XID>
       <State>IntegerPending</State>
       <Priority>IntegerPriority</Priority>
       <Timeout>IntegerTimeout</Timeout>
       <Command>StringCommand param1 ... </Command>
     </dnxMessage>

   ----------------------------------------------
   Structure: DNX_MSG_RESULT
   Issued By: Worker       (dnxSendResult)
   Issued To: Collector    (dnxWaitForResult)

     <dnxMessage>
       <Request>Result</Request>
       <XID>Xid:ObjType-ObjSerial-ObjSlot</XID>
       <State>IntegerState</State>
       <Delta>IntegerSeconds</Delta>
       <ResultCode>IntegerResultCode</ResultCode>
       <ResultData>StringResult</ResultData>
     </dnxMessage>

   ----------------------------------------------
   Structure: DNX_MSG_MGMT_REQUEST
   Issued By: Server       (dnxSendMgmtRequest)
   Issued To: Client       (dnxWaitForMgmtRequest)

     <dnxMessage>
       <Request>MgmtRequest</Request>
       <XID>Xid:ObjType-ObjSerial-ObjSlot</XID>
       <Action>StringAction</Action>
     </dnxMessage>

   ----------------------------------------------
   Structure: DNX_MSG_MGMT_REPLY
   Issued By: Client       (dnxSendMgmtReply)
   Issued To: Server       (dnxWaitForMgmtReply)

     <dnxMessage>
       <Request>MgmtReply</Request>
       <XID>Xid:ObjType-ObjSerial-ObjSlot</XID>
       <Result>StringResponse</Result>
     </dnxMessage>

The DNX Objects are:

1. DNX_JOB 2. DNX_RESULT 3. DNX_AGENT

Each DNX Job Object has:

1. XID - Assigned at Job creation by the Scheduler 2. State: Pending, Executing, Completed, Cancelled 3. Execution Command 4. Execution Parameters 5. Execution Start Time 5. Execution End Time 6. Result Code 7. Result Data

When and object is serialized and transmitted, only those relevant portions of the object are transmitted - order to optimize bandwith usage and processing time.

For example, a DNX Job object as transmitted to a Dispatcher, via a DNX_MSG_PUT_JOB, will only include the following DNX Job attributes:

XID, State, Execution Command, Execution Parameters and Execution Start Time.

Conversely, a DNX Job object as transmitted to a Collector, via a DNS_PUT_RESULT, will only include the following DNX Job attributes:

XID, State, Execution Start Time, Execution End Time, Result Code, and Result Data

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

Definition in file dnxProtocol.h.


Enumeration Type Documentation

Defines the state of a DNX job.

Enumerator:
DNX_JOB_NULL 
DNX_JOB_PENDING 
DNX_JOB_INPROGRESS 
DNX_JOB_COMPLETE 
DNX_JOB_EXPIRED 

Definition at line 170 of file dnxProtocol.h.

enum DnxObjType

Defines the type of a DNX object in a network message.

Enumerator:
DNX_OBJ_SCHEDULER 
DNX_OBJ_DISPATCHER 
DNX_OBJ_WORKER 
DNX_OBJ_COLLECTOR 
DNX_OBJ_REAPER 
DNX_OBJ_JOB 
DNX_OBJ_MANAGER 
DNX_OBJ_MAX 

Definition at line 148 of file dnxProtocol.h.

enum DnxReqType

Defines the type of a DNX worker node network request.

Enumerator:
DNX_REQ_REGISTER 
DNX_REQ_DEREGISTER 
DNX_REQ_ACK 
DNX_REQ_NAK 

Definition at line 161 of file dnxProtocol.h.


Function Documentation

int dnxEqualXIDs ( DnxXID pxa,
DnxXID pxb 
)

Compare two XID's for equality; return a boolean value.

Parameters:
[in] pxa - a reference to the first XID to be compared.
[in] pxb - a reference to the second XID to be compared.
Returns:
A boolean value; false (0) if pxa is NOT equal to pxa; true (!false) if pxa IS equal to pxb.

Definition at line 76 of file dnxProtocol.c.

References DnxXID::objSerial, DnxXID::objSlot, and DnxXID::objType.

Referenced by dnxJobListCollect().

int dnxMakeXID ( DnxXID pxid,
DnxObjType  xType,
unsigned long  xSerial,
unsigned long  xSlot 
)

Create a transaction id (XID) from a type, serial number and slot value.

Parameters:
[out] pxid - the address of storage for the XID to be returned.
[in] xType - the request type to be stored in the XID.
[in] xSerial - the serial number to be stored in the XID.
[in] xSlot - the slot number to be stored in the XID.
Returns:
Always returns zero.

Definition at line 54 of file dnxProtocol.c.

References DNX_OBJ_MAX, DNX_OK, DnxXID::objSerial, DnxXID::objSlot, and DnxXID::objType.

Referenced by dnxPostNewJob(), dnxWorker(), and main().

int dnxSendMgmtReply ( DnxChannel channel,
DnxMgmtReply pReply,
char *  address 
)

Issue a management reply.

Parameters:
[in] channel - the channel on which to send the management request.
[out] pReply - the management request to be sent.
[out] address - the address to which the reply should be sent.
Returns:
Zero on success, or a non-zero error value.

Definition at line 126 of file dnxProtocol.c.

References DnxXmlBuf::buf, DNX_MAX_ADDRSTR, DNX_XML_INT, DNX_XML_STR, DNX_XML_XID, dnxDebug(), dnxNtop(), dnxPut(), dnxXmlAdd(), dnxXmlClose(), dnxXmlOpen(), DnxMgmtReply::reply, DnxXmlBuf::size, DnxMgmtReply::status, and DnxMgmtReply::xid.

Referenced by dnxAgentServer(), and processCommands().

int dnxSendMgmtRequest ( DnxChannel channel,
DnxMgmtRequest pRequest 
)

Issue a management request.

The address may not be specified, as this method is only to be used on active, connected, client-side code. The address used is the one specified when the connection was established.

Parameters:
[in] channel - the channel on which to send the management request.
[out] pRequest - the management request to be sent.
Returns:
Zero on success, or a non-zero error value.

Definition at line 96 of file dnxProtocol.c.

References DnxMgmtRequest::action, DnxXmlBuf::buf, DNX_XML_STR, DNX_XML_XID, dnxDebug(), dnxPut(), dnxXmlAdd(), dnxXmlClose(), dnxXmlOpen(), DnxXmlBuf::size, and DnxMgmtRequest::xid.

Referenced by main().

int dnxWaitForMgmtReply ( DnxChannel channel,
DnxMgmtReply pReply,
int  timeout 
)

Wait for a management reply to come in (server).

The address may not be retrieved as this command is only intended to be used by client code with an active, connected channel and we can only received data from one address.

Parameters:
[in] channel - the channel from which to read a management request.
[out] pReply - the address of storage in which to return the management reply.
[in] timeout - the maximum number of seconds the caller is willing to wait before accepting a timeout error.
Returns:
Zero on success, or a non-zero error value.

Definition at line 164 of file dnxProtocol.c.

References DnxXmlBuf::buf, DNX_OK, DNX_XML_INT, DNX_XML_STR, DNX_XML_XID, dnxDebug(), dnxGet(), dnxXmlCmpStr(), dnxXmlGet(), DnxMgmtReply::reply, DnxXmlBuf::size, DnxMgmtReply::status, and DnxMgmtReply::xid.

Referenced by main().

int dnxWaitForMgmtRequest ( DnxChannel channel,
DnxMgmtRequest pRequest,
char *  address,
int  timeout 
)

Wait for a management request to come in (client).

Parameters:
[in] channel - the channel from which to read a management request.
[out] pRequest - the address of storage in which to return the management request.
[out] address - the address of storage in which to return the address of the sender. This parameter is optional and may be passed as NULL. If non-NULL, it should be large enough to store sockaddr_* data.
[in] timeout - the maximum number of seconds the caller is willing to wait before accepting a timeout error.
Returns:
Zero on success, or a non-zero error value.

Definition at line 213 of file dnxProtocol.c.

References DnxMgmtRequest::action, DnxXmlBuf::buf, DNX_MAX_ADDRSTR, DNX_OK, DNX_XML_STR, DNX_XML_XID, dnxDebug(), dnxGet(), dnxNtop(), dnxXmlCmpStr(), dnxXmlGet(), DnxXmlBuf::size, and DnxMgmtRequest::xid.

Referenced by dnxAgentServer(), and processCommands().


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