|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Test executor that services requests with a configurable artificial processing delay; used by RequestGateway::UnitTest(). More...
#include <RequestExecutor.h>
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. | |
| DataMessage * | waitForLongRequest (uint32 timeoutMS) |
| Pull the next long request (worker thread API). | |
| DataMessage * | waitForShortRequest (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< RequestGatewayConnection > | connections |
| Configured gateways and their state. | |
| uint32 | executorID |
| Numeric id reported to gateways. | |
| std::string | executorName |
| Display name for logging. | |
| NetworkManager * | manager |
| Owned network stack. | |
| NetworkChannel * | channel |
| 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) |
Test executor that services requests with a configurable artificial processing delay; used by RequestGateway::UnitTest().
Definition at line 167 of file RequestExecutor.h.
| cmlabs::TestRequestExecutor::TestRequestExecutor | ( | uint32 | id, |
| uint32 | processTimeMS ) |
Definition at line 520 of file RequestExecutor.cpp.
References cmlabs::ThreadManager::CreateThread(), id, LongExecutorRun, processTimeMS, cmlabs::RequestExecutor::RequestExecutor(), ShortExecutorRun, and cmlabs::Runnable::shouldContinue.
Referenced by LongExecutorRun, and ShortExecutorRun.
|
protected |
Definition at line 543 of file RequestExecutor.cpp.
References cmlabs::DataMessage::getRecvTime(), cmlabs::DataMessage::getReference(), cmlabs::GetTimeAgeMS(), cmlabs::GetTimeNow(), processTimeMS, cmlabs::RequestExecutor::replyToQuery(), cmlabs::DataMessage::setRecvTime(), cmlabs::DataMessage::setReference(), cmlabs::Runnable::shouldContinue, and cmlabs::RequestExecutor::waitForLongRequest().
Referenced by LongExecutorRun.
|
protected |
Definition at line 530 of file RequestExecutor.cpp.
References cmlabs::DataMessage::getReference(), cmlabs::RequestExecutor::replyToQuery(), cmlabs::DataMessage::setReference(), cmlabs::Runnable::shouldContinue, and cmlabs::RequestExecutor::waitForShortRequest().
Referenced by ShortExecutorRun.
|
friend |
Definition at line 584 of file RequestExecutor.cpp.
References longRequestRun(), TestRequestExecutor(), THREAD_ARG, THREAD_FUNCTION_CALL, THREAD_RET, and thread_ret_val.
Referenced by TestRequestExecutor().
|
friend |
Definition at line 579 of file RequestExecutor.cpp.
References shortRequestRun(), TestRequestExecutor(), THREAD_ARG, THREAD_FUNCTION_CALL, THREAD_RET, and thread_ret_val.
Referenced by TestRequestExecutor().
|
protected |
Definition at line 175 of file RequestExecutor.h.
Referenced by TestRequestExecutor().
|
protected |
Definition at line 176 of file RequestExecutor.h.
Referenced by longRequestRun(), and TestRequestExecutor().