CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::TestRequestExecutor Class Reference

Test executor that services requests with a configurable artificial processing delay; used by RequestGateway::UnitTest(). More...

#include <RequestExecutor.h>

Inheritance diagram for cmlabs::TestRequestExecutor:
[legend]
Collaboration diagram for cmlabs::TestRequestExecutor:
[legend]

Public Member Functions

 TestRequestExecutor (uint32 id, uint32 processTimeMS)
Public Member Functions inherited from cmlabs::RequestExecutor
 RequestExecutor (uint32 id=0, const char *name=NULL)
virtual ~RequestExecutor ()
bool shutdownNetwork ()
 Disconnect from all gateways and stop the network stack.
bool addLongRequestName (const char *name)
 Register a request name to be treated as a long-running request.
bool addGateway (uint32 id, std::string addr, uint16 port, uint8 encryption=NOENC)
 Register a gateway to connect to (repeatable for redundancy).
bool setLongRequestLimit (uint32 limit)
 Cap the number of long requests processed concurrently.
bool receiveNetworkEvent (NetworkEvent *evt, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: gateway connect/disconnect events (drives reconnection).
bool receiveMessage (DataMessage *msg, NetworkChannel *channel, uint64 conid)
 NetworkReceiver hook: incoming request messages, routed to the short/long queue.
bool receiveHTTPRequest (HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 HTTP is not served by executors; always returns false.
DataMessagewaitForLongRequest (uint32 timeoutMS)
 Pull the next long request (worker thread API).
DataMessagewaitForShortRequest (uint32 timeoutMS)
 Pull the next short request (worker thread API).
bool replyToQuery (DataMessage *msg)
 Send a reply for a previously pulled request back to its gateway.
Public Member Functions inherited from cmlabs::Runnable
 Runnable ()
 Initialise flags: not running, allowed to continue.
virtual ~Runnable ()
 Destructor requests a stop (with the default timeout) before destruction proceeds.
virtual bool stop (uint32 timeout=200)
 Ask the worker loop to finish and wait for it to do so.
Public Member Functions inherited from cmlabs::NetworkReceiver
 NetworkReceiver ()
virtual bool receiveTelnetLine (TelnetLine *line, NetworkChannel *channel, uint64 conid)
 A Telnet line arrived.
virtual bool receiveHTTPReply (HTTPReply *reply, HTTPRequest *req, NetworkChannel *channel, uint64 conid)
 An HTTP reply to an earlier async request arrived.
virtual bool receiveWebsocketData (WebsocketData *wsData, NetworkChannel *channel, uint64 conid)
 A WebSocket message arrived.

Protected Member Functions

bool shortRequestRun ()
bool longRequestRun ()
Protected Member Functions inherited from cmlabs::RequestExecutor
bool run ()
 Worker loop: gateway upkeep, heartbeats, reply dispatch.
uint32 sendStatusNow ()
 Send a status heartbeat (queue sizes) to all gateways.
bool sendMessageToGateway (DataMessage *msg, RequestGatewayConnection &con)
 Send a message on one gateway link.
bool replyToGateway (DataMessage *msg)
 Route a finished reply to the gateway that sent the request.

Protected Attributes

uint32 id
uint32 processTimeMS
Protected Attributes inherited from cmlabs::RequestExecutor
std::list< RequestGatewayConnectionconnections
 Configured gateways and their state.
uint32 executorID
 Numeric id reported to gateways.
std::string executorName
 Display name for logging.
NetworkManagermanager
 Owned network stack.
NetworkChannelchannel
 Channel carrying the gateway links.
utils::WaitQueuePointer< DataMessage * > shortExecQ
 Pending short requests.
utils::WaitQueuePointer< DataMessage * > longExecQ
 Pending long requests.
utils::WaitQueuePointer< DataMessage * > replyQ
 Outgoing replies awaiting dispatch.
std::map< uint64, RequestReply * > requestMap
 In-flight request bookkeeping by ref id.
std::vector< std::string > longReqNames
 Request names classified as long.
utils::Mutex mutex
 Guards request bookkeeping.
utils::Mutex conMutex
 Guards ::connections.
utils::Semaphore shortExecQSemaphore
 Signals short-queue arrivals.
utils::Semaphore longExecQSemaphore
 Signals long-queue arrivals.
uint32 threadID
 Worker thread id.
uint64 lastRefID
 Last issued executor reference id.
uint64 repliedCount
 Total replies sent.
uint64 sentCount
 Total messages sent to gateways.
uint64 shortReceivedCount
 Total short requests received.
uint64 longReceivedCount
 Total long requests received.
int32 heartbeatIntervalMS
 Interval between status heartbeats (ms).
uint64 lastHeartbeat
 Time of last heartbeat (ms epoch).
uint32 longReqLimit
 Max concurrent long requests (see setLongRequestLimit()).
Protected Attributes inherited from cmlabs::Runnable
uint32 threadID
 ThreadManager slot ID of the worker thread (0 until known).
bool shouldContinue
 Loop-continuation flag; cleared by stop().
bool isRunning
 Set by the worker while its loop is active.

Friends

THREAD_RET THREAD_FUNCTION_CALL ShortExecutorRun (THREAD_ARG arg)
THREAD_RET THREAD_FUNCTION_CALL LongExecutorRun (THREAD_ARG arg)

Detailed Description

Test executor that services requests with a configurable artificial processing delay; used by RequestGateway::UnitTest().

Definition at line 167 of file RequestExecutor.h.

Constructor & Destructor Documentation

◆ TestRequestExecutor()

cmlabs::TestRequestExecutor::TestRequestExecutor ( uint32 id,
uint32 processTimeMS )

Member Function Documentation

◆ longRequestRun()

◆ shortRequestRun()

◆ LongExecutorRun

◆ ShortExecutorRun

Member Data Documentation

◆ id

uint32 cmlabs::TestRequestExecutor::id
protected

Definition at line 175 of file RequestExecutor.h.

Referenced by TestRequestExecutor().

◆ processTimeMS

uint32 cmlabs::TestRequestExecutor::processTimeMS
protected

Definition at line 176 of file RequestExecutor.h.

Referenced by longRequestRun(), and TestRequestExecutor().


The documentation for this class was generated from the following files: