9 #ifndef __PDG_SERVICE_H__
10 #define __PDG_SERVICE_H__
34 class PDGN_PollingClientNNG;
137 bool internal_service);
151 {
return myIsInternal; }
158 { myIsPersistent = persistent; }
160 {
return myIsPersistent; }
164 {
return myHasErrors; }
169 { myIsAutoStart = auto_start; }
171 {
return myIsAutoStart; }
189 { myMqLogLevel = log_level; }
191 {
return myMqLogLevel; }
195 { myMqPort = mq_port; }
202 { myClientLogDir = log_dir; }
204 {
return myClientLogDir; }
208 { myMqLogDir = log_dir; }
210 {
return myMqLogDir; }
214 { myClientLogType = log_type; }
216 {
return myClientLogType; }
222 { myEnvVarNames = env_var_names; }
224 {
return myEnvVarNames; }
230 { myEnvVarValues = env_var_values; }
232 {
return myEnvVarValues; }
236 { myExtraArguments =
args; }
238 {
return myExtraArguments; }
248 void clearScheduler();
253 {
return mySchedulerName; }
258 {
return mySchedulerContextName; }
263 { myServiceOwner = owner; }
265 {
return myServiceOwner; }
276 { myCommand = command; }
278 {
return myCommand; }
283 { myPoolSize = pool_size; }
285 {
return myPoolSize; }
295 { myConnectionTimeout = ms; }
297 {
return myConnectionTimeout; }
303 myMemoryResetType = memory_reset_type;
308 myMemoryLimit = memory_limit;
311 {
return myMemoryResetType; }
313 {
return myMemoryLimit; }
316 bool isStartingOrRunning()
const;
319 bool isStoppingOrStopped()
const;
338 ClientInfo* addPendingClient(
377 bool ignore_stopped);
384 bool wait_for_clients);
388 PDGN::PDGN_Message* executeWorkItem(
397 PDGN::PDGN_Message* executeWorkItem(
405 void startPollingClient();
409 void stopPollingClient();
416 {
return (myPollingClient !=
nullptr); }
419 PDGN::PDGN_PollingClientNNG*
421 {
return myPollingClient.get(); }
425 void waitForClients();
428 void incrementStartingClientsCount();
433 const char* server_address,
435 int client_num)
const;
441 const char* server_address,
443 int client_num)
const;
450 ServiceAcquireResult acquireClient(
469 static void* runSpawnSessionService(
void*
param);
470 static void* runPollingThread(
void*
param);
472 bool getClientNameFromMessage(
473 PDGN::PDGN_Message* msg,
476 bool startSessionService(
479 bool spawnSessionServiceClients();
493 bool wait_for_clients);
496 static constexpr
int theMaxConcurrentStartup = 24;
497 static constexpr
int theSleepTime = 10;
503 ClientInfoArray myPendingClients;
504 ClientInfoArray myActiveClients;
522 PollingClient myPollingClient;
534 int myConnectionTimeout;
exint PDG_WorkItemID
Type defs for unique work item IDs.
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 setExtraArguments(const UT_StringArray &args)
Sets/gets the extra args array for the service.
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
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_ServiceResetWhen
When service clients should be reset.
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
PDG_ServiceLogType
Enumeration of service log types.
All service workers are already busy.
void setPersistent(bool persistent)
PDG_ServiceOwner owner() const
void setCommand(const UT_StringHolder &command)
const UT_StringArray & extraArguments() const
const UT_StringHolder & mqUrl() const
const UT_StringHolder & name() const
const UT_StringHolder & schedulerContextName() const
const UT_StringHolder & clientLogDir() const
PDG_ServiceOwner
Enumeration of the different types of service owner.
PDG_ServiceStartResult
Enumeration of possible result values from starting a service.
PDG_ServiceState
Enumeration of the different states that a service can be in.
exint memoryLimit() const
**If you just want to fire and args
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.
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.
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.