9 #ifndef __PDG_SERVICE_H__
10 #define __PDG_SERVICE_H__
32 class PDGN_PollingClientNNG;
135 bool internal_service);
149 {
return myIsInternal; }
156 { myIsPersistent = persistent; }
158 {
return myIsPersistent; }
162 {
return myHasErrors; }
167 { myIsAutoStart = auto_start; }
169 {
return myIsAutoStart; }
187 { myMqLogLevel = log_level; }
189 {
return myMqLogLevel; }
193 { myMqPort = mq_port; }
200 { myClientLogDir = log_dir; }
202 {
return myClientLogDir; }
206 { myMqLogDir = log_dir; }
208 {
return myMqLogDir; }
212 { myClientLogType = log_type; }
214 {
return myClientLogType; }
220 { myEnvVarNames = env_var_names; }
222 {
return myEnvVarNames; }
228 { myEnvVarValues = env_var_values; }
230 {
return myEnvVarValues; }
240 void clearScheduler();
245 {
return mySchedulerName; }
250 {
return mySchedulerContextName; }
255 { myServiceOwner = owner; }
257 {
return myServiceOwner; }
268 { myCommand = command; }
270 {
return myCommand; }
275 { myPoolSize = pool_size; }
277 {
return myPoolSize; }
287 { myConnectionTimeout = ms; }
289 {
return myConnectionTimeout; }
295 myMemoryResetType = memory_reset_type;
300 myMemoryLimit = memory_limit;
303 {
return myMemoryResetType; }
305 {
return myMemoryLimit; }
308 bool isStartingOrRunning()
const;
311 bool isStoppingOrStopped()
const;
330 ClientInfo* addPendingClient(
369 bool ignore_stopped);
376 bool wait_for_clients);
380 PDGN::PDGN_Message* executeWorkItem(
389 PDGN::PDGN_Message* executeWorkItem(
397 void startPollingClient();
401 void stopPollingClient();
408 {
return (myPollingClient !=
nullptr); }
411 PDGN::PDGN_PollingClientNNG*
413 {
return myPollingClient.get(); }
417 void waitForClients();
420 void incrementStartingClientsCount();
425 const char* server_address,
427 int client_num)
const;
433 const char* server_address,
435 int client_num)
const;
442 ServiceAcquireResult acquireClient(
461 static void* runSpawnSessionService(
void*
param);
462 static void* runPollingThread(
void*
param);
464 bool getClientNameFromMessage(
465 PDGN::PDGN_Message* msg,
468 bool startSessionService(
471 bool spawnSessionServiceClients();
485 bool wait_for_clients);
488 static constexpr
int theMaxConcurrentStartup = 24;
489 static constexpr
int theSleepTime = 10;
495 ClientInfoArray myPendingClients;
496 ClientInfoArray myActiveClients;
513 PollingClient myPollingClient;
525 int myConnectionTimeout;
PDG_ServiceStartResult
Enumeration of possible result values from starting a service.
void setState(PDG_ServiceState state)
Sets/gets the current state of the service.
static const UT_StringHolder theDataVersion
Service data format version.
A service client was successfully acquired.
Service client array entry.
const UT_StringArray & envVarValues() const
UT_StringHolder myName
The name of the service client.
void setOwner(PDG_ServiceOwner owner)
void setName(const UT_StringHolder &name)
exint myId
The process or job id for the client.
void setMqUrl(const UT_StringHolder &url)
void setMemoryLimit(exint memory_limit)
void setMqLogLevel(int log_level)
The service lock is invalid – should never occur in practice.
void setEnvVarNames(const UT_StringArray &env_var_names)
bool hasErrors() const
Returns true if the service has errors when starting.
bool isPersistent() const
void setAutoStart(bool auto_start)
const UT_StringHolder & schedulerName() const
PDG_ServiceState
Enumeration of the different states that a service can be in.
const UT_StringHolder & mqLogDir() const
void setClientLogType(PDG_ServiceLogType log_type)
Sets how the service itself should log output.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
void setConnectionTimeout(int ms)
Sets the service connection timeout in milliseconds.
exint myTotalCooks
The total number of tasks the service has cooked.
UT_StringHolder myAddress
The connection address.
void setClientLogDir(const UT_StringHolder &log_dir)
const UT_StringArray & envVarNames() const
exint myPort
The connection port.
void setEnvVarValues(const UT_StringArray &env_var_values)
static const UT_StringHolder theEmptyString
A service client was successfully acquired and locked.
PDG_ServiceOwner
Enumeration of the different types of service owner.
UT_StringHolder myLogPath
The log path for client output.
void setMqPort(int mq_port)
Sets/gets the port used by the MQ relay.
ServiceAcquireResult
Enumeration of return codes from acquireClient.
PDG_ServiceResetType memoryResetType() const
GLuint const GLchar * name
UT_StringArray myCommandArgs
The array of command line args for the client.
void setMemoryResetType(PDG_ServiceResetType memory_reset_type)
Sets the memory limit and reset type for the service.
const UT_StringHolder & command() const
PDGN::PDGN_PollingClientNNG * getPollingClient() const
All service workers are already busy.
void setPersistent(bool persistent)
PDG_ServiceOwner owner() const
void setCommand(const UT_StringHolder &command)
const UT_StringHolder & mqUrl() const
const UT_StringHolder & name() const
const UT_StringHolder & schedulerContextName() const
const UT_StringHolder & clientLogDir() const
PDG_ServiceResetWhen
When service clients should be reset.
exint memoryLimit() const
bool myIsActive
Set to true if the client is active for a job.
int connectionTimeout() const
bool myIsConnected
Set to true once the client has connected.
exint PDG_WorkItemID
Type defs for unique work item IDs.
bool hasPollingClient() const
Returns true if the service has an active polling client.
void setMqLogDir(const UT_StringHolder &log_dir)
Sets/gets the directory that the MQ relay writes its logs to.
PDG_ServiceLogType
Enumeration of service log types.
void setPoolSize(int pool_size)
PDG_ServiceState state() const
PDG_ServiceLogType clientLogType() const
void setPort(int port)
Sets/gets the connection port for the service itself.