HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_Service Class Reference

#include <PDG_Service.h>

+ Inheritance diagram for PDG_Service:

Public Member Functions

 PDG_Service (const PDG_BaseType *type, const PDGT_ValueArgs &extra_args, bool internal_service)
 
 ~PDG_Service () override
 
void setName (const UT_StringHolder &name)
 
const UT_StringHoldername () const
 
bool isInternal () const
 
void setPersistent (bool persistent)
 
bool isPersistent () const
 
void setAutoStart (bool auto_start)
 
bool isAutoStart () const
 
void setData (const UT_OptionsHolder &new_data)
 Sets/gets the custom data dictionary on the service. More...
 
const UT_OptionsHolderdata ()
 
void setMqUrl (const UT_StringHolder &url)
 
const UT_StringHoldermqUrl () 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_StringHolderclientLogDir () const
 
void setMqLogDir (const UT_StringHolder &log_dir)
 Sets/gets the directory that the MQ relay writes its logs to. More...
 
const UT_StringHoldermqLogDir () 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_StringArrayenvVarNames () const
 
void setEnvVarValues (const UT_StringArray &env_var_values)
 
const UT_StringArrayenvVarValues () const
 
void setExtraArguments (const UT_StringArray &args)
 Sets/gets the extra args array for the service. More...
 
const UT_StringArrayextraArguments () const
 
const UT_StringHoldercommand () const
 Returns the command line string for the service. More...
 
const UT_StringHolderscript () const
 Returns the script file path for the service. More...
 
void setServiceSchedulerType (PDG_ServiceSchedulerType type)
 Sets the service scheduler type. More...
 
void setSchedulerTypeName (const UT_StringHolder &type_name)
 Sets the scheduler type name. More...
 
void setScheduler (const UT_StringHolder &name, const UT_StringHolder &context_name)
 
void clearScheduler ()
 
PDG_ServiceSchedulerType serviceSchedulerType () const
 Returns the type of scheduler service in use. More...
 
const UT_StringHolderschedulerTypeName () const
 
const UT_StringHolderschedulerName () const
 
const UT_StringHolderschedulerContextName () 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 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...
 
bool isRunningOnScheduler (const PDG_Scheduler *scheduler)
 Returns true if the service is using the specified scheduler. More...
 
PDG_SchedulerrunningScheduler () const
 Returns the scheduler that the service is running on, if any. More...
 
UT_StringArray clientNames () const
 Queries the list of all active service client names. More...
 
UT_StringHolder clientName (int client_num) const
 
PDG_ServiceClientclient (const UT_StringHolder &name)
 Returns the service client info for a particular client. More...
 
PDG_ServiceClientaddPendingClient (const UT_StringHolder &server_address, int server_port, int client_num)
 
PDG_ServiceStartResult startService (UT_WorkBuffer &errors, const PDG_GraphContext *context, 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 resumeService (UT_WorkBuffer &errors, const PDG_GraphContext *context)
 
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, bool as_native, bool apply_wedges)
 
PDGN::PDGN_Message * executeWorkItem (UT_WorkBuffer &errors, const UT_StringHolder &client_name, const PDG_WorkItem *work_item, const UT_WorkBuffer &script_buffer, bool as_native, bool apply_wedges)
 
void startPollingClient (const PDG_GraphContext *context)
 
void stopPollingClient (bool wait)
 
const UT_StringHolderpollingClientName () 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
 
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
 
bool ping (UT_WorkBuffer &errors) const
 
- 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 BaseTypetype () const
 
const UT_StringHoldertypeName () const
 
const PDGT_ValueArgsextraArgs () const
 
bool compareType (const BaseType *other_type, bool deep=true) const
 
void setReloading (bool is_reloading)
 
bool isReloading () const
 

Friends

class PDG_ServiceScheduler
 
class PDG_ServiceManager
 

Additional Inherited Members

- Public Types inherited from PDGT_TypeInstance< EnumType >
using BaseType = PDGT_BaseType< EnumType >
 
- Protected Attributes inherited from PDGT_TypeInstance< EnumType >
const BaseTypemyBaseType
 
PDGT_ValueArgs myExtraArgs
 
bool myReloading
 

Detailed Description

Definition at line 43 of file PDG_Service.h.

Constructor & Destructor Documentation

PDG_Service::PDG_Service ( const PDG_BaseType type,
const PDGT_ValueArgs extra_args,
bool  internal_service 
)

Constructs a new service instance with a default pool size of 1, and no connection information.

PDG_Service::~PDG_Service ( )
override

Member Function Documentation

PDG_ServiceClient* 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

PDG_ServiceClient* PDG_Service::client ( const UT_StringHolder name)

Returns the service client info for a particular client.

const UT_StringHolder& PDG_Service::clientLogDir ( ) const
inline

Definition at line 113 of file PDG_Service.h.

PDG_ServiceLogType PDG_Service::clientLogType ( ) const
inline

Definition at line 125 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.

const UT_StringHolder& PDG_Service::command ( ) const

Returns the command line string for the service.

int PDG_Service::connectionTimeout ( ) const
inline

Definition at line 223 of file PDG_Service.h.

const UT_OptionsHolder& PDG_Service::data ( )
inline

Definition at line 86 of file PDG_Service.h.

const UT_StringArray& PDG_Service::envVarNames ( ) const
inline

Definition at line 133 of file PDG_Service.h.

const UT_StringArray& PDG_Service::envVarValues ( ) const
inline

Definition at line 141 of file PDG_Service.h.

PDGN::PDGN_Message* PDG_Service::executeWorkItem ( UT_WorkBuffer errors,
const UT_StringHolder client_name,
const PDG_WorkItem work_item,
bool  as_native,
bool  apply_wedges 
)

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,
bool  as_native,
bool  apply_wedges 
)

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.

const UT_StringArray& PDG_Service::extraArguments ( ) const
inline

Definition at line 147 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

PDGN::PDGN_PollingClientNNG* PDG_Service::getPollingClient ( ) const
inline

Definition at line 379 of file PDG_Service.h.

bool PDG_Service::hasPollingClient ( ) const
inline

Returns true if the service has an active polling client.

Definition at line 374 of file PDG_Service.h.

bool PDG_Service::isAutoStart ( ) const
inline

Definition at line 80 of file PDG_Service.h.

bool PDG_Service::isInternal ( ) const
inline

Returns true if the service is internal to PDG. Internal services cannot be directly managed by users.

Definition at line 64 of file PDG_Service.h.

bool PDG_Service::isPersistent ( ) const
inline

Definition at line 73 of file PDG_Service.h.

bool PDG_Service::isRunningOnScheduler ( const PDG_Scheduler scheduler)

Returns true if the service is using the specified scheduler.

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.

exint PDG_Service::memoryLimit ( ) const
inline

Definition at line 239 of file PDG_Service.h.

PDG_ServiceResetType PDG_Service::memoryResetType ( ) const
inline

Definition at line 237 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::mqLogDir ( ) const
inline

Definition at line 119 of file PDG_Service.h.

int PDG_Service::mqLogLevel ( ) const
inline

Definition at line 100 of file PDG_Service.h.

int PDG_Service::mqPort ( ) const
inline

Definition at line 106 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::mqUrl ( ) const
inline

Definition at line 93 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::name ( void  ) const
inline

Definition at line 59 of file PDG_Service.h.

PDG_ServiceOwner PDG_Service::owner ( ) const
inline

Definition at line 198 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

bool PDG_Service::ping ( UT_WorkBuffer errors) const

Pings the first connected 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.

int PDG_Service::poolSize ( ) const
inline

Definition at line 211 of file PDG_Service.h.

int PDG_Service::port ( ) const
inline

Definition at line 217 of file PDG_Service.h.

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.

bool PDG_Service::resumeService ( UT_WorkBuffer errors,
const PDG_GraphContext context 
)

Resumes any service clients that were stopped previously and returns a boolean to indicate the status. Has no effect on clients that are already running.

PDG_Scheduler* PDG_Service::runningScheduler ( ) const

Returns the scheduler that the service is running on, if any.

const UT_StringHolder& PDG_Service::schedulerContextName ( ) const
inline

Returns the name of the graph that owns the scheduler that created the service, if it's a scheduler service

Definition at line 191 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::schedulerName ( ) const
inline

Returns the name of the scheduler associated with the service, if it's a scheduler service

Definition at line 186 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::schedulerTypeName ( ) const
inline

Returns the type name of the scheduler associated with the service, if it's a scheduler service

Definition at line 181 of file PDG_Service.h.

const UT_StringHolder& PDG_Service::script ( ) const

Returns the script file path for the service.

PDG_ServiceSchedulerType PDG_Service::serviceSchedulerType ( ) const
inline

Returns the type of scheduler service in use.

Definition at line 176 of file PDG_Service.h.

void PDG_Service::setAutoStart ( bool  auto_start)
inline

Sets/gets the autostart flag, which indicates that the service will start automatically when work items need to use it.

Definition at line 78 of file PDG_Service.h.

void PDG_Service::setClientLogDir ( const UT_StringHolder log_dir)
inline

Sets/gets the directory that service clients should write their log files to.

Definition at line 111 of file PDG_Service.h.

void PDG_Service::setClientLogType ( PDG_ServiceLogType  log_type)
inline

Sets how the service itself should log output.

Definition at line 123 of file PDG_Service.h.

void PDG_Service::setConnectionTimeout ( int  ms)
inline

Sets the service connection timeout in milliseconds.

Definition at line 221 of file PDG_Service.h.

void PDG_Service::setData ( const UT_OptionsHolder new_data)
inline

Sets/gets the custom data dictionary on the service.

Definition at line 84 of file PDG_Service.h.

void PDG_Service::setEnvVarNames ( const UT_StringArray env_var_names)
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 131 of file PDG_Service.h.

void PDG_Service::setEnvVarValues ( const UT_StringArray env_var_values)
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 139 of file PDG_Service.h.

void PDG_Service::setExtraArguments ( const UT_StringArray args)
inline

Sets/gets the extra args array for the service.

Definition at line 145 of file PDG_Service.h.

void PDG_Service::setMemoryLimit ( exint  memory_limit)
inline

Definition at line 232 of file PDG_Service.h.

void PDG_Service::setMemoryResetType ( PDG_ServiceResetType  memory_reset_type)
inline

Sets the memory limit and reset type for the service.

Definition at line 227 of file PDG_Service.h.

void PDG_Service::setMqLogDir ( const UT_StringHolder log_dir)
inline

Sets/gets the directory that the MQ relay writes its logs to.

Definition at line 117 of file PDG_Service.h.

void PDG_Service::setMqLogLevel ( int  log_level)
inline

Sets/gets the log level for the MQ process that relays messages between clients and the PDG graph

Definition at line 98 of file PDG_Service.h.

void PDG_Service::setMqPort ( int  mq_port)
inline

Sets/gets the port used by the MQ relay.

Definition at line 104 of file PDG_Service.h.

void PDG_Service::setMqUrl ( const UT_StringHolder url)
inline

Sets/gets the MQ url that the service should use to relay messages between service clients and the PDG graph

Definition at line 91 of file PDG_Service.h.

void PDG_Service::setName ( const UT_StringHolder name)
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 57 of file PDG_Service.h.

void PDG_Service::setOwner ( PDG_ServiceOwner  owner)
inline

Sets/gets the service owner type – either a session service or a scheduler service

Definition at line 196 of file PDG_Service.h.

void PDG_Service::setPersistent ( bool  persistent)
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 71 of file PDG_Service.h.

void PDG_Service::setPoolSize ( int  pool_size)
inline

Sets/gets the pool size for the service, which determines the number of concurrent client processes that service executes

Definition at line 209 of file PDG_Service.h.

void PDG_Service::setPort ( int  port)
inline

Sets/gets the connection port for the service itself.

Definition at line 215 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.

void PDG_Service::setSchedulerTypeName ( const UT_StringHolder type_name)

Sets the scheduler type name.

void PDG_Service::setServiceSchedulerType ( PDG_ServiceSchedulerType  type)

Sets the service scheduler type.

void PDG_Service::setState ( PDG_ServiceState  state)
inline

Sets/gets the current state of the service.

Definition at line 202 of file PDG_Service.h.

void PDG_Service::startPollingClient ( const PDG_GraphContext context)

Starts a background thread that polls the ready listener until all service clients have connected. If a graph context is passed in, the polling client will cancel automatically if the cook associated with the context is canceled

PDG_ServiceStartResult PDG_Service::startService ( UT_WorkBuffer errors,
const PDG_GraphContext context,
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.

PDG_ServiceState PDG_Service::state ( ) const
inline

Definition at line 204 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 ( bool  wait)

Stops the ready listener. If wait is true then the method will block until pending clients have started, otherwise it will forcible stop the polling client

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.

Friends And Related Function Documentation

friend class PDG_ServiceManager
friend

Definition at line 407 of file PDG_Service.h.

friend class PDG_ServiceScheduler
friend

Definition at line 406 of file PDG_Service.h.


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