1 #ifndef CONNECT_SERVICES__GRID_WORKER_HPP
2 #define CONNECT_SERVICES__GRID_WORKER_HPP
204 const string& GetJobKey()
const;
215 const string& GetJobInput()
const;
224 void SetJobOutput(
const string&
output);
228 void SetJobRetCode(
int ret_code);
238 size_t GetInputBlobSize()
const;
242 void PutProgressMessage(
const string& msg,
bool send_immediately =
false,
243 bool overwrite =
true);
265 void CommitJobWithFailure(
const string& err_msg,
bool no_retries =
false);
284 void RescheduleJob(
const string& affinity,
const string& group =
kEmptyStr);
315 const string& GetQueueName()
const;
319 const string& GetClientName()
const;
332 void JobDelayExpiration(
unsigned runtime_inc);
336 bool IsLogRequested()
const;
342 void RequestExclusiveMode();
344 const string& GetJobOutput()
const;
348 unsigned int GetJobNumber()
const;
359 bool IsJobCommitted()
const;
360 ECommitStatus GetCommitStatus()
const;
361 static const char* GetCommitStatusDescription(ECommitStatus commit_status);
363 bool IsJobLost()
const;
377 void RequestShutdown();
378 bool IsShutdownRequested()
const;
441 template <
typename TWorkerNodeJob>
465 template <
typename TWorkerNodeJob,
typename TWorkerNodeIdleTask>
473 m_IdleTask.reset(
new TWorkerNodeIdleTask(context));
474 }
catch (exception& ex) {
476 "Error during Idle task construction: " << ex.what());
486 #define NCBI_DECLARE_WORKERNODE_FACTORY_IMPL(TWorkerNodeJob, Version) \
489 const char* const CSimpleJobFactory<TWorkerNodeJob>::m_JobVersion = \
490 #TWorkerNodeJob " version " NCBI_AS_STRING(Version); \
492 const char* const CSimpleJobFactory<TWorkerNodeJob>::m_AppName = \
496 #define NCBI_DECLARE_WORKERNODE_FACTORY(TWorkerNodeJob, Version) \
497 typedef CSimpleJobFactory<TWorkerNodeJob> TWorkerNodeJob##Factory; \
498 NCBI_DECLARE_WORKERNODE_FACTORY_IMPL(TWorkerNodeJob, Version)
500 #define NCBI_DECLARE_WORKERNODE_FACTORY_EX( \
501 TWorkerNodeJob, TWorkerNodeIdleTask, Version) \
502 typedef CSimpleJobFactoryEx<TWorkerNodeJob, TWorkerNodeIdleTask> \
503 TWorkerNodeJob##FactoryEx; \
504 NCBI_DECLARE_WORKERNODE_FACTORY_IMPL(TWorkerNodeJob, Version)
554 string procinfo_file_name =
string());
556 void RequestShutdown();
558 void ForceSingleThread();
566 unsigned int GetMaxThreads()
const;
570 Uint8 GetTotalMemoryLimit()
const;
574 unsigned GetTotalTimeLimit()
const;
575 time_t GetStartupTime()
const;
576 unsigned GetQueueTimeout()
const;
578 bool IsHostInAdminHostsList(
const string& host)
const;
580 unsigned GetCommitJobInterval()
const;
581 unsigned GetCheckStatusPeriod()
const;
582 size_t GetServerOutputSize();
584 const string& GetQueueName()
const;
586 const string& GetClientName()
const;
588 string GetAppName()
const;
593 const string& GetServiceName()
const;
606 static void DisableDefaultRequestEventLogging(
607 EDisabledRequestEvents disabled_events = eDisableStartStop);
611 void Suspend(
bool pullback,
unsigned timeout);
613 bool IsSuspended()
const;
623 eExclusiveModeIsAlreadySet
628 switch (GetErrCode())
630 case ePortBusy:
return "ePortBusy";
631 case eJobIsLost:
return "eJobIsLost";
632 case eJobFactoryIsNotSet:
return "eJobFactoryIsNotSet";
633 case eExclusiveModeIsAlreadySet:
return "eExclusiveModeIsAlreadySet";
Client API for NetCache server.
Client API for NCBI NetSchedule server.
EShutdownLevel
Shutdown level.
Smart pointer to a part of the NetSchedule API that does job retrieval and processing on the worker n...
Worker Node Idle Task Context.
Listener of events generated by CGridWorkerNodeApp.
Clean-up event source for the worker node.
Worker Node Idle Task Interface.
Worker Node initialize context.
Worker Node Job Factory interface.
Worker Node Job interface.
#define ERR_POST_XX(error_name, err_subcode, message)
Error posting with error code having given name and with given error subcode.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
virtual void HandleEvent(EWorkerNodeCleanupEvent cleanup_event)=0
CWorkerNodeIdleThread & m_Thread
virtual void Init(const IWorkerNodeInitContext &context)
Initialize a worker node factory.
virtual void Init(const IWorkerNodeInitContext &context)
Initialize a worker node factory.
static const char *const m_AppName
virtual int Do(CWorkerNodeJobContext &context)=0
Execute the job.
unique_ptr< TWorkerNodeIdleTask > m_IdleTask
virtual ~IWorkerNodeJob()
virtual void AddListener(IWorkerNodeCleanupEventListener *listener)=0
virtual const CNcbiEnvironment & GetEnvironment() const =0
Get environment variables.
bool NeedRunAgain() const
virtual CNetCacheAPI GetNetCacheAPI() const =0
Get the shared NetCacheAPI object used by the worker node framework.
virtual IWorkerNodeJob * CreateInstance(void)
Create a job.
virtual void Init(const IWorkerNodeInitContext &)
Initialize a worker node factory.
virtual ~IWorkerNodeJobFactory()
static const char *const m_JobVersion
pair< string, SBuildInfo > TVersion
virtual void Run(CWorkerNodeIdleTaskContext &)=0
Do the Idle task here.
virtual void Notify(const CWorkerNodeJobContext &job, EEvent event)=0
EDisabledRequestEvents
Disable the automatic logging of request-start and request-stop events by the framework itself.
virtual string GetJobVersion() const
Get the job version.
virtual IWorkerNodeIdleTask * GetIdleTask()
Get the Idle task.
virtual IWorkerNodeJob * CreateInstance(void)=0
Create a job.
const IWorkerNodeInitContext * m_WorkerNodeInitContext
virtual ~IWorkerNodeInitBaseContext()
virtual CNetScheduleAPI GetNetScheduleAPI() const =0
Get the shared NetScheduleAPI object used by the worker node framework.
virtual string GetJobVersion() const =0
Get the job version.
CWorkerNodeIdleTaskContext(const CWorkerNodeIdleTaskContext &)
virtual void RemoveListener(IWorkerNodeCleanupEventListener *listener)=0
NCBI_EXCEPTION_DEFAULT(CGridWorkerNodeException, CException)
virtual string GetAppVersion() const
virtual ~IWorkerNodeCleanupEventListener()
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
virtual string GetAppName() const
virtual const CArgs & GetArgs() const =0
Get command line arguments.
virtual const IRegistry & GetConfig() const =0
Get a config file registry.
virtual void CallEventHandlers()=0
CWorkerNodeIdleTaskContext & operator=(const CWorkerNodeIdleTaskContext &)
EWorkerNodeCleanupEvent
Event notifying of a safe clean-up point.
virtual IWorkerNodeIdleTask * GetIdleTask()
Get the Idle task.
virtual IWorkerNodeCleanupEventSource * GetCleanupEventSource() const =0
Get interface for registering clean-up event listeners.
virtual string GetAppName() const
virtual ~IWorkerNodeIdleTask()
@ eRegularCleanup
For jobs – run from the same thread after Do() is done; for the whole WN – run from a separate (clean...
@ eOnHardExit
Called on emergency shutdown, always from a different (clean-up) thread, even for the jobs.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
void Run(void)
Enter the main loop.
enum ENcbiSwitch ESwitch
Aux.
#define NCBI_XCONNECT_EXPORT
Miscellaneous common-use basic types and functionality.
Process information in the NCBI Registry, including working with configuration files.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
Multi-threading – classes, functions, and features.
#define NCBI_NET_COMPONENT(component)
NetSchedule client specs.
static SQLCHAR output[256]
Defines CRequestContext class for NCBI C++ diagnostic API.
Pool of generic task-executing threads.
unique_ptr< CObjectIStream > GetIStream(string path, ESerialDataFormat serial_format)