#include <APIServer.hpp>
Public Member Functions | |
APIServer () | |
virtual | ~APIServer () |
void | terminateServer () |
void | initServer () |
void | listenForConnections () |
void | processMessages (SysServerConnection *connection) |
ServiceReturn | shutdown () |
virtual bool | isStoppable () |
void | cleanupProcessResources (ServiceMessage &message) |
virtual void | stop () |
void | requestLock () |
void | releaseLock () |
APIServerInstance * | getInstance (ServiceMessage &m) |
void | dispatch (ServiceMessage &message) |
void | sessionTerminated (APIServerThread *thread) |
void | cleanupTerminatedSessions () |
Protected Attributes | |
SysMutex | lock |
SysServerStream | server |
bool | serverActive |
APIServerInstance * | instances |
std::list< APIServerThread * > | terminatedThreads |
Definition at line 52 of file APIServer.hpp.
|
inline |
Definition at line 55 of file APIServer.hpp.
|
inlinevirtual |
Definition at line 56 of file APIServer.hpp.
void APIServer::cleanupProcessResources | ( | ServiceMessage & | message | ) |
Cleanup sessions specific resources after a Rexx process terminates.
message | The service message with the session information. |
Definition at line 352 of file APIServer.cpp.
References APIServerInstance::cleanupProcessResources(), and getInstance().
Referenced by dispatch().
void APIServer::cleanupTerminatedSessions | ( | ) |
Cleanup the resources devoted to threads that have terminated.
Definition at line 124 of file APIServer.cpp.
References SysThread::terminate(), and terminatedThreads.
Referenced by listenForConnections().
void APIServer::dispatch | ( | ServiceMessage & | message | ) |
Dispatch an API server control message.
message | The control message parameter. |
Definition at line 315 of file APIServer.cpp.
References cleanupProcessResources(), CONNECTION_ACTIVE, MESSAGE_OK, ServiceMessage::operation, ServiceMessage::parameter1, PROCESS_CLEANUP, ServiceMessage::result, REXXAPI_VERSION, SERVER_FAILURE, ServiceMessage::setExceptionInfo(), shutdown(), and SHUTDOWN_SERVER.
Referenced by processMessages().
APIServerInstance * APIServer::getInstance | ( | ServiceMessage & | m | ) |
Get the server instance associate with a particular userid, creating a new instance if this is the first time we've processed a request for this id.
m | The service message associated with the request. |
Definition at line 415 of file APIServer.cpp.
References instances, APIServerInstance::isUser(), and APIServerInstance::next.
Referenced by cleanupProcessResources(), and processMessages().
void APIServer::initServer | ( | ) |
Initialize the server side of the operation.
Definition at line 53 of file APIServer.cpp.
References SysMutex::create(), lock, SysServerStream::make(), REXX_API_PORT, server, SERVER_FAILURE, and serverActive.
Referenced by Run().
|
virtual |
Test to see if the api server is in a state where it can be stopped. A stoppable state implies there are no session specific resources currently active in the server.
Definition at line 391 of file APIServer.cpp.
References instances, APIServerInstance::isStoppable(), and APIServerInstance::next.
Referenced by shutdown().
void APIServer::listenForConnections | ( | ) |
Process the Rexx API requests as a queue of messages. Each message is handled through to completion, so the message queue is the synchronization point.
Definition at line 82 of file APIServer.cpp.
References cleanupTerminatedSessions(), SysServerStream::connect(), server, serverActive, and APIServerThread::start().
Referenced by Run().
void APIServer::processMessages | ( | SysServerConnection * | connection | ) |
Process the Rexx API requests as a queue of messages. Each message is handled through to completion, so the message queue is the synchronization point.
Definition at line 215 of file APIServer.cpp.
References APIManager, CLOSE_CONNECTION, CONCURRENCY_TRACE, Utilities::currentThreadId(), dbgprintf(), SysServerConnection::disconnect(), dispatch(), APIServerInstance::dispatch(), getInstance(), MacroSpaceManager, MESSAGE_OK, ServiceMessage::messageTarget, ServiceMessage::nameArg, ServiceMessage::operation, QueueManager, ServiceMessage::readMessage(), RegistrationManager, ServiceMessage::result, rxapiCounter, SERVER_ERROR, serverActive, ServerManagerText(), ServerOperationText(), ServiceMessage::session, Utilities::traceConcurrency(), ServiceMessage::userid, and ServiceMessage::writeResult().
Referenced by APIServerThread::dispatch().
void APIServer::releaseLock | ( | ) |
Release the global server API lock.
Definition at line 449 of file APIServer.cpp.
References lock, and SysMutex::release().
Referenced by ServerLock::~ServerLock().
void APIServer::requestLock | ( | ) |
Request the global server API lock.
Definition at line 440 of file APIServer.cpp.
References lock, and SysMutex::request().
Referenced by ServerLock::ServerLock().
void APIServer::sessionTerminated | ( | APIServerThread * | thread | ) |
Handle a session termination event.
thread |
Definition at line 110 of file APIServer.cpp.
References terminatedThreads.
Referenced by APIServerThread::dispatch().
ServiceReturn APIServer::shutdown | ( | ) |
Cause the API server to shutdown.
Definition at line 364 of file APIServer.cpp.
References isStoppable(), SERVER_NOT_STOPPABLE, SERVER_STOPPED, and serverActive.
Referenced by dispatch().
|
virtual |
void APIServer::terminateServer | ( | ) |
Do server shutdown processing and resource cleanup.
Definition at line 69 of file APIServer.cpp.
References SysServerStream::close(), server, and serverActive.
|
protected |
Definition at line 77 of file APIServer.hpp.
Referenced by getInstance(), and isStoppable().
|
protected |
Definition at line 74 of file APIServer.hpp.
Referenced by initServer(), releaseLock(), and requestLock().
|
protected |
Definition at line 75 of file APIServer.hpp.
Referenced by initServer(), listenForConnections(), and terminateServer().
|
protected |
Definition at line 76 of file APIServer.hpp.
Referenced by initServer(), listenForConnections(), processMessages(), shutdown(), stop(), and terminateServer().
|
protected |
Definition at line 78 of file APIServer.hpp.
Referenced by cleanupTerminatedSessions(), and sessionTerminated().