ServerDaemon
Usage
use ServerDaemon;
or
import ServerDaemon;
- enum ServerDaemonType { DEFAULT, INTEGRATION, METRICS, STATUS }
- enum constant DEFAULT
- enum constant INTEGRATION
- enum constant METRICS
- enum constant STATUS
- const sdLogger = new Logger(logLevel, logChannel)
- var serverDaemonTypes = try! getDaemonTypes()
- proc getDaemonTypes() throws
Retrieves a list of 1..n ServerDaemonType objects generated
from the comma-delimited list of ServerDaemonType strings
provided in the daemonTypes command-line parameter
- proc metricsEnabled()
Returns a boolean indicating if Arkouda is configured to generate and
make available metrics via a dedicated metrics socket
- proc integrationEnabled()
Returns a boolean indicating whether Arkouda is configured to
register/deregister with an external system such as Kubernetes.
- proc multipleServerDaemons()
Returns a boolean indicating if there are multiple ServerDaemons
- proc register(endpoint: ServiceEndpoint) throws
Generates the Kubernetes app name for Arkouda, which varies based
upon which pod corresponds to Locale 0.
- class ArkoudaServerDaemon
The ArkoudaServerDaemon class defines the run and shutdown
functions all derived classes must override
- var st = new owned SymTab()
- var shutdownDaemon = false
- var port : int
- proc run() throws
- proc requestShutdown(user: string) throws
Prompts the ArkoudaServerDaemon to initiate a shutdown, triggering
a change in state which will cause the derived ArkoudaServerDaemon
to (1) exit the daemon loop within the run function and (2) execute
the shutdown function.
- proc extractRequest(request: string) : RequestMsg throws
Converts the incoming request JSON string into RequestMsg object.
- proc shutdown() throws
Encapsulates logic that is to be invoked once a ArkoudaSeverDaemon
has exited the daemon loop.
- class DefaultServerDaemon : ArkoudaServerDaemon
The DefaultServerDaemon class serves as the default Arkouda server
daemon which is run within the arkouda_server driver
- var serverToken : string
- var arkDirectory : string
- var connectUrl : string
- var reqCount : int = 0
- var repCount : int = 0
- var context : ZMQ.Context
- var socket : ZMQ.Socket
- proc init()
- proc getConnectUrl(token: string) throws
- proc printServerSplashMessage(token: string, arkDirectory: string) throws
- proc createServerConnectionInfo() throws
Creates the serverConnectionInfo file on arkouda_server startup
- proc deleteServerConnectionInfo() throws
Deletes the serverConnetionFile on arkouda_server shutdown
- proc sendRepMsg(in response: MsgTuple, user: string) : (string, bool) throws
Following processing of incoming message, sends a message back to the client.
- proc authenticateUser(token: string) throws
Compares the token submitted by the user with the arkouda_server token. If the tokens do not match, or the user did not submit a token, an ErrorWithMsg is thrown.
- Arguments:
token – the submitted token string
- override proc requestShutdown(user: string) throws
Sets the shutdownDaemon boolean to true and sends the shutdown command to socket, which stops the arkouda_server listener thread and closes socket.
- proc registerServerCommands()
Register our server commands in the CommandMap
There are 3 general types
Standard, required commands which adhere to the standard Message signature
Specialized, required commands which do not adhere to the standard Message signature
“Optional” modules which are included at compilation time via ServerModules.cfg
- proc initArkoudaDirectory() throws
- override proc shutdown() throws
The overridden shutdown function calls exit(0) if there are multiple
ServerDaemons configured for this Arkouda instance.
- proc processMetrics(user: string, cmd: string, args: MessageArgs, elapsedTime: real, memUsed: uint) throws
- proc processErrorMessageMetrics(user, cmd, errorMsg) throws
- proc getErrorName(err)
- override proc run() throws
- var activityMutex : sync string
- var idlePeriodStart : atomic real
- var seenNotableActivity : atomic bool
- proc startAsyncCheckpointTask()
Starts a task for asynchronous checkpointing.
- proc serverIdleStart()
Indicates that the server is “idle”. Records “now” as the time when idle-ness started, unless the server is already “idle”, in which case the previous idle-start time is preserved.
- proc serverIdleStop()
Indicates that the server is no longer “idle”.
- proc serverActivityMark()
- proc waitForActivityMutex()
Waits until ‘activityMutex’ is empty; leaves it empty.
- class MetricsServerDaemon : ArkoudaServerDaemon
The MetricsServerDaemon provides a separate endpoint for gathering user, request,
locale, and server-scoped metrics. The separate port lessens the possibility of
metrics requests being blocked by command requests.
- var context : ZMQ.Context
- var socket : ZMQ.Socket
- proc init()
- override proc run() throws
- class ExternalIntegrationServerDaemon : DefaultServerDaemon
The ExternalIntegrationServerDaemon class registers Arkouda with the
configured external system and then invokes ArkoudaServerDeamon.run()
- override proc run() throws
Overridden run function registers the ServerDaemon with an
external system and then invokes the parent run function.
- override proc shutdown() throws
Overridden shutdown function deregisters Arkouda from an external
system and then invokes the parent shutdown() function.
- class ServerStatusDaemon : ArkoudaServerDaemon
The ServerStatusDaemon provides a non-blocking endpoint for retrieving
server status via a separate, dedicated port to lessen the chances of
blocking incoming status requests with command requests.
- var context : ZMQ.Context
- var socket : ZMQ.Socket
- proc init()
- override proc run() throws
- proc getServerDaemon(daemonType: ServerDaemonType) : shared ArkoudaServerDaemon throws
- proc getServerDaemons() throws