|
HDK
|
#include <PDG_Service.h>
Inheritance diagram for PDG_Service:Classes | |
| struct | ClientInfo |
| Service client array entry. More... | |
Public Types | |
| enum | ServiceAcquireResult { eServiceAcquireSuccess, eServiceAcquireSuccessLocked, eServiceAcquireBusy, eServiceAcquireLocked, eServiceAcquireInvalidLock } |
| Enumeration of return codes from acquireClient. More... | |
Public Types inherited from PDGT_TypeInstance< EnumType > | |
| using | BaseType = PDGT_BaseType< EnumType > |
Public Member Functions | |
| PDG_Service (const PDG_BaseType *type, const PDGT_ValueArgs &extra_args, const UT_StringHolder &service_command, bool internal_service) | |
| ~PDG_Service () override | |
| void | setName (const UT_StringHolder &name) |
| const UT_StringHolder & | name () const |
| bool | isInternal () const |
| void | setPersistent (bool persistent) |
| bool | isPersistent () const |
| bool | hasErrors () const |
| Returns true if the service has errors when starting. More... | |
| void | setAutoStart (bool auto_start) |
| bool | isAutoStart () const |
| void | setData (PY_PyObject *new_data) |
| PY_PyObject * | data () |
| void | setMqUrl (const UT_StringHolder &url) |
| const UT_StringHolder & | mqUrl () const |
| void | setMqLogLevel (int log_level) |
| int | mqLogLevel () const |
| void | setMqPort (int mq_port) |
| Sets/gets the port used by the MQ relay. More... | |
| int | mqPort () const |
| void | setClientLogDir (const UT_StringHolder &log_dir) |
| const UT_StringHolder & | clientLogDir () const |
| void | setMqLogDir (const UT_StringHolder &log_dir) |
| Sets/gets the directory that the MQ relay writes its logs to. More... | |
| const UT_StringHolder & | mqLogDir () const |
| void | setClientLogType (PDG_ServiceLogType log_type) |
| Sets how the service itself should log output. More... | |
| PDG_ServiceLogType | clientLogType () const |
| void | setEnvVarNames (const UT_StringArray &env_var_names) |
| const UT_StringArray & | envVarNames () const |
| void | setEnvVarValues (const UT_StringArray &env_var_values) |
| const UT_StringArray & | envVarValues () const |
| void | setExtraArguments (const UT_StringArray &args) |
| Sets/gets the extra args array for the service. More... | |
| const UT_StringArray & | extraArguments () const |
| void | setScheduler (const UT_StringHolder &name, const UT_StringHolder &context_name) |
| void | clearScheduler () |
| const UT_StringHolder & | schedulerName () const |
| const UT_StringHolder & | schedulerContextName () const |
| void | setOwner (PDG_ServiceOwner owner) |
| PDG_ServiceOwner | owner () const |
| void | setState (PDG_ServiceState state) |
| Sets/gets the current state of the service. More... | |
| PDG_ServiceState | state () const |
| void | setCommand (const UT_StringHolder &command) |
| const UT_StringHolder & | command () const |
| void | setPoolSize (int pool_size) |
| int | poolSize () const |
| void | setPort (int port) |
| Sets/gets the connection port for the service itself. More... | |
| int | port () const |
| void | setConnectionTimeout (int ms) |
| Sets the service connection timeout in milliseconds. More... | |
| int | connectionTimeout () const |
| void | setMemoryResetType (PDG_ServiceResetType memory_reset_type) |
| Sets the memory limit and reset type for the service. More... | |
| void | setMemoryLimit (exint memory_limit) |
| PDG_ServiceResetType | memoryResetType () const |
| exint | memoryLimit () const |
| bool | isStartingOrRunning () const |
| Returns true if the service is start or is already running. More... | |
| bool | isStoppingOrStopped () const |
| Returns true if the service is stopping, or has already stopped. More... | |
| PDG_Scheduler * | serviceScheduler (UT_WorkBuffer &errors) const |
| UT_StringArray | clientNames () const |
| Queries the list of all active service client names. More... | |
| UT_StringHolder | clientName (int client_num) const |
| ClientInfo * | client (const UT_StringHolder &name) |
| Returns the service client info for a particular client. More... | |
| ClientInfo * | addPendingClient (const UT_StringHolder &server_address, int server_port, int client_num) |
| PDG_ServiceStartResult | startService (UT_WorkBuffer &errors, bool background) |
| bool | resetClient (UT_WorkBuffer &errors, const UT_StringHolder &client_name=UT_StringHolder::theEmptyString) |
| bool | restartClient (UT_WorkBuffer &errors, const UT_StringHolder &client_name) |
| bool | stopClient (UT_WorkBuffer &errors, const UT_StringHolder &client_name) |
| bool | killClient (UT_WorkBuffer &errors, const UT_StringHolder &client_name) |
| bool | stopService (UT_WorkBuffer &errors, bool ignore_stopped) |
| bool | killService (UT_WorkBuffer &errors, bool ignore_stopped) |
| bool | cleanupService (UT_WorkBuffer &errors, bool stop_mq_server, bool wait_for_clients) |
| PDGN::PDGN_Message * | executeWorkItem (UT_WorkBuffer &errors, const UT_StringHolder &client_name, const PDG_WorkItem *work_item) |
| PDGN::PDGN_Message * | executeWorkItem (UT_WorkBuffer &errors, const UT_StringHolder &client_name, const PDG_WorkItem *work_item, const UT_WorkBuffer &script_buffer) |
| void | startPollingClient () |
| void | stopPollingClient () |
| const UT_StringHolder & | pollingClientName () const |
| Returns the name of the polling client, if one exists. More... | |
| bool | hasPollingClient () const |
| Returns true if the service has an active polling client. More... | |
| PDGN::PDGN_PollingClientNNG * | getPollingClient () const |
| void | waitForClients () |
| void | incrementStartingClientsCount () |
| Increments the number of actively starting client. More... | |
| UT_StringHolder | getCommand (const char *server_address, int server_port, int client_num) const |
| void | getCommand (UT_StringArray &command_tokens, const char *server_address, int server_port, int client_num) const |
| bool | ping (int client_num, UT_WorkBuffer &errors) const |
| ServiceAcquireResult | acquireClient (UT_StringHolder &client_name, PDG_WorkItemID item_lock) |
| Acquires a client, which reserves it for the caller. More... | |
| bool | releaseClient (UT_WorkBuffer &errors, const UT_StringHolder &client_name, PDG_ServiceResetWhen reset_when, PDG_ServiceResetType reset_type, int64 memory_usage) |
| Releases a client that was previously acquired, but does not unlock it. More... | |
| bool | unlockClient (PDG_WorkItemID item_lock, PDG_ServiceResetType reset_type, UT_WorkBuffer &errors) |
| Unlocks a service client. More... | |
Public Member Functions inherited from PDGT_TypeInstance< EnumType > | |
| PDGT_TypeInstance () | |
| PDGT_TypeInstance (const PDGT_BaseType< EnumType > *base_type, const PDGT_ValueArgs &extra_args) | |
| virtual | ~PDGT_TypeInstance () |
| virtual int64 | getMemoryUsage (bool inclusive) const |
| virtual bool | reloadInstance (UT_WorkBuffer &errors) |
| const BaseType * | type () const |
| const UT_StringHolder & | typeName () const |
| const PDGT_ValueArgs & | extraArgs () const |
| bool | compareType (const BaseType *other_type, bool deep=true) const |
| void | setReloading (bool is_reloading) |
| bool | isReloading () const |
Static Public Attributes | |
| static const UT_StringHolder | theDataVersion |
| Service data format version. More... | |
Additional Inherited Members | |
Protected Attributes inherited from PDGT_TypeInstance< EnumType > | |
| const BaseType * | myBaseType |
| PDGT_ValueArgs | myExtraArgs |
| bool | myReloading |
Definition at line 42 of file PDG_Service.h.
Enumeration of return codes from acquireClient.
Definition at line 49 of file PDG_Service.h.
| PDG_Service::PDG_Service | ( | const PDG_BaseType * | type, |
| const PDGT_ValueArgs & | extra_args, | ||
| const UT_StringHolder & | service_command, | ||
| bool | internal_service | ||
| ) |
Constructs a new service instance with a default pool size of 1, and no connection information.
|
override |
| ServiceAcquireResult PDG_Service::acquireClient | ( | UT_StringHolder & | client_name, |
| PDG_WorkItemID | item_lock | ||
| ) |
Acquires a client, which reserves it for the caller.
| ClientInfo* PDG_Service::addPendingClient | ( | const UT_StringHolder & | server_address, |
| int | server_port, | ||
| int | client_num | ||
| ) |
Adds a pending service client, which can be waiting on using waitForClients
| bool PDG_Service::cleanupService | ( | UT_WorkBuffer & | errors, |
| bool | stop_mq_server, | ||
| bool | wait_for_clients | ||
| ) |
Cleans up the clients in the service. This method is public so that schedulers can call it on services they manage.
| void PDG_Service::clearScheduler | ( | ) |
Clears the scheduler information associated with a scheduler service
| ClientInfo* PDG_Service::client | ( | const UT_StringHolder & | name | ) |
Returns the service client info for a particular client.
|
inline |
Definition at line 206 of file PDG_Service.h.
|
inline |
Definition at line 218 of file PDG_Service.h.
| UT_StringHolder PDG_Service::clientName | ( | int | client_num | ) | const |
Queries the name of a particular service client, using its client number
| UT_StringArray PDG_Service::clientNames | ( | ) | const |
Queries the list of all active service client names.
|
inline |
Definition at line 280 of file PDG_Service.h.
|
inline |
Definition at line 299 of file PDG_Service.h.
|
inline |
Definition at line 179 of file PDG_Service.h.
|
inline |
Definition at line 226 of file PDG_Service.h.
|
inline |
Definition at line 234 of file PDG_Service.h.
| PDGN::PDGN_Message* PDG_Service::executeWorkItem | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name, | ||
| const PDG_WorkItem * | work_item | ||
| ) |
Submits a work item to a service client asynchronously, and returns the pending message handle for the job.
| PDGN::PDGN_Message* PDG_Service::executeWorkItem | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name, | ||
| const PDG_WorkItem * | work_item, | ||
| const UT_WorkBuffer & | script_buffer | ||
| ) |
Submits a work item to a service client asychronously, and returns the pending messae handle for the job. This variant of the method allows the caller to supply a custom script that will run instead of the standard job script or script data associated with the work item.
|
inline |
Definition at line 240 of file PDG_Service.h.
| UT_StringHolder PDG_Service::getCommand | ( | const char * | server_address, |
| int | server_port, | ||
| int | client_num | ||
| ) | const |
Returns the command for the service client with the specified client number, as a string.
| void PDG_Service::getCommand | ( | UT_StringArray & | command_tokens, |
| const char * | server_address, | ||
| int | server_port, | ||
| int | client_num | ||
| ) | const |
Returns the command for the service client with the specified client number, as an array of arguments
|
inline |
Definition at line 436 of file PDG_Service.h.
|
inline |
Returns true if the service has errors when starting.
Definition at line 166 of file PDG_Service.h.
|
inline |
Returns true if the service has an active polling client.
Definition at line 431 of file PDG_Service.h.
| void PDG_Service::incrementStartingClientsCount | ( | ) |
Increments the number of actively starting client.
|
inline |
Definition at line 173 of file PDG_Service.h.
|
inline |
Returns true if the service is internal to PDG. Internal services cannot be directly managed by users.
Definition at line 153 of file PDG_Service.h.
|
inline |
Definition at line 162 of file PDG_Service.h.
| bool PDG_Service::isStartingOrRunning | ( | ) | const |
Returns true if the service is start or is already running.
| bool PDG_Service::isStoppingOrStopped | ( | ) | const |
Returns true if the service is stopping, or has already stopped.
| bool PDG_Service::killClient | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name | ||
| ) |
Immediately kills the process associated with a service client. The client can be started again at a later point using restartClient. If client_name is empty string all clients are stoppped.
| bool PDG_Service::killService | ( | UT_WorkBuffer & | errors, |
| bool | ignore_stopped | ||
| ) |
Kills the service if it's running, and returns a boolean to indiate the status.
|
inline |
Definition at line 315 of file PDG_Service.h.
|
inline |
Definition at line 313 of file PDG_Service.h.
|
inline |
Definition at line 212 of file PDG_Service.h.
|
inline |
Definition at line 193 of file PDG_Service.h.
|
inline |
Definition at line 199 of file PDG_Service.h.
|
inline |
Definition at line 186 of file PDG_Service.h.
|
inline |
Definition at line 148 of file PDG_Service.h.
|
inline |
Definition at line 267 of file PDG_Service.h.
| bool PDG_Service::ping | ( | int | client_num, |
| UT_WorkBuffer & | errors | ||
| ) | const |
Pings the specified client, and returns true if the client was reachable
| const UT_StringHolder& PDG_Service::pollingClientName | ( | ) | const |
Returns the name of the polling client, if one exists.
|
inline |
Definition at line 287 of file PDG_Service.h.
|
inline |
Definition at line 293 of file PDG_Service.h.
| bool PDG_Service::releaseClient | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name, | ||
| PDG_ServiceResetWhen | reset_when, | ||
| PDG_ServiceResetType | reset_type, | ||
| int64 | memory_usage | ||
| ) |
Releases a client that was previously acquired, but does not unlock it.
| bool PDG_Service::resetClient | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name = UT_StringHolder::theEmptyString |
||
| ) |
Resets a specific service client, or all clients if empty string is passed in as the client_name
| bool PDG_Service::restartClient | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name | ||
| ) |
Restarts a service client. If client_name is empty string all clients are restarted.
|
inline |
Returns the name of the graph that owns the scheduler that created the service, if it's a scheduler service
Definition at line 260 of file PDG_Service.h.
|
inline |
Returns the name of the scheduler associated with the service, if it's a scheduler service
Definition at line 255 of file PDG_Service.h.
| PDG_Scheduler* PDG_Service::serviceScheduler | ( | UT_WorkBuffer & | errors | ) | const |
Queries and returns the scheduler associated with the service, if the service is a scheduler service
|
inline |
Sets/gets the autostart flag, which indicates that the service will start automatically when work items need to use it.
Definition at line 171 of file PDG_Service.h.
|
inline |
Sets/gets the directory that service clients should write their log files to.
Definition at line 204 of file PDG_Service.h.
|
inline |
Sets how the service itself should log output.
Definition at line 216 of file PDG_Service.h.
|
inline |
Sets/gets the command line string that should be used to start clients running in the service pool
Definition at line 278 of file PDG_Service.h.
Sets the service connection timeout in milliseconds.
Definition at line 297 of file PDG_Service.h.
| void PDG_Service::setData | ( | PY_PyObject * | new_data | ) |
Sets/gets an opaque Python data object that can be stored on the service.
|
inline |
Sets/gets the names for the environment variables to be set in this job's environment. This only applies if the service does not have a scheduler.
Definition at line 224 of file PDG_Service.h.
|
inline |
Sets/gets the values for the environment variables to be set in this job's environment. This only applies if the service does not have a scheduler.
Definition at line 232 of file PDG_Service.h.
|
inline |
Sets/gets the extra args array for the service.
Definition at line 238 of file PDG_Service.h.
Definition at line 308 of file PDG_Service.h.
|
inline |
Sets the memory limit and reset type for the service.
Definition at line 303 of file PDG_Service.h.
|
inline |
Sets/gets the directory that the MQ relay writes its logs to.
Definition at line 210 of file PDG_Service.h.
Sets/gets the log level for the MQ process that relays messages between clients and the PDG graph
Definition at line 191 of file PDG_Service.h.
Sets/gets the port used by the MQ relay.
Definition at line 197 of file PDG_Service.h.
|
inline |
Sets/gets the MQ url that the service should use to relay messages between service clients and the PDG graph
Definition at line 184 of file PDG_Service.h.
|
inline |
Sets/gets the unique name for the service. The name of the service is unique to the PDG_ServiceManager that created it.
Definition at line 146 of file PDG_Service.h.
|
inline |
Sets/gets the service owner type – either a session service or a scheduler service
Definition at line 265 of file PDG_Service.h.
|
inline |
Sets/gets the persistent flag, which determines whether a service should be persisted to the pdgservice JSON configuration file. A service that isn't persistent will be lost when the Houdini session is closed.
Definition at line 160 of file PDG_Service.h.
Sets/gets the pool size for the service, which determines the number of concurrent client processes that service executes
Definition at line 285 of file PDG_Service.h.
Sets/gets the connection port for the service itself.
Definition at line 291 of file PDG_Service.h.
| void PDG_Service::setScheduler | ( | const UT_StringHolder & | name, |
| const UT_StringHolder & | context_name | ||
| ) |
For scheduler services, sets the name of the scheduler and graph that created the service.
|
inline |
Sets/gets the current state of the service.
Definition at line 271 of file PDG_Service.h.
| void PDG_Service::startPollingClient | ( | ) |
Starts a background thread that polls the ready listener until all service clients have connected
| PDG_ServiceStartResult PDG_Service::startService | ( | UT_WorkBuffer & | errors, |
| bool | background | ||
| ) |
Stats a service pool. If background is true the service processes are start asynchronously, and control immediately returns after calling this function. It's up to the caller to ensure that the service has started before using it. Returns either success, failure, or already- running.
|
inline |
Definition at line 273 of file PDG_Service.h.
| bool PDG_Service::stopClient | ( | UT_WorkBuffer & | errors, |
| const UT_StringHolder & | client_name | ||
| ) |
Stops a service client and kills the process associated with it. The client can be started again at a later point using restartClient. If client_name is empty string all clients are stoppped.
| void PDG_Service::stopPollingClient | ( | ) |
This will force stop the ready listener. If you want to wait for it to complete, you should call waitForClients() instead.
| bool PDG_Service::stopService | ( | UT_WorkBuffer & | errors, |
| bool | ignore_stopped | ||
| ) |
Stops the service if it's running, and returns a boolean to indiate the status.
| bool PDG_Service::unlockClient | ( | PDG_WorkItemID | item_lock, |
| PDG_ServiceResetType | reset_type, | ||
| UT_WorkBuffer & | errors | ||
| ) |
Unlocks a service client.
| void PDG_Service::waitForClients | ( | ) |
Waits for all pending service clients to connect, and then terminates the ready listener
|
static |
Service data format version.
Definition at line 46 of file PDG_Service.h.