1 #ifndef CONNECT_SERVICES__GRID_WORKER_APP_HPP
2 #define CONNECT_SERVICES__GRID_WORKER_APP_HPP
108 virtual void Init(
void);
113 virtual int Run(
void);
117 void RequestShutdown();
136 #ifndef GRID_WORKER_APP_NAME
138 #define GRID_WORKER_APP_NAME GRID_APP_NAME
140 #define GRID_WORKER_APP_NAME NcbiEmptyString
144 #ifdef NCBI_BUILD_TAG
145 # define GRID_WORKER_APP_BUILD_TAG NCBI_AS_STRING(NCBI_BUILD_TAG)
147 # define GRID_WORKER_APP_BUILD_TAG kEmptyStr
150 #ifdef NCBI_WORKERNODE_CLASS
152 NCBI_WORKERNODE_CLASS is not supported anymore. \
153 Replace NCBI_WORKERNODE_* with corresponding NCBI_WORKERNODE_*_DERIVED providing app class. \
154 Please be aware that your app class is required to accept SBuildInfo and pass it to CGridWorkerApp.
157 #define NCBI_WORKERNODE_MAIN_IMPL(TFactory, CGridWorkerApp, Version, SetListener) \
158 int main(int argc, const char* argv[]) \
160 GetDiagContext().SetOldPostFormat(false); \
161 CGridWorkerApp app(new TFactory, \
162 CVersionInfo(#Version, NCBI_TEAMCITY_PROJECT_NAME_PROXY), \
163 NCBI_APP_SBUILDINFO_DEFAULT()); \
165 return app.AppMain(argc, argv, NULL, eDS_ToStdlog, \
166 NcbiEmptyCStr, GRID_WORKER_APP_NAME); \
169 #define NCBI_WORKERNODE_MAIN(TWorkerNodeJob, Version) \
170 NCBI_WORKERNODE_MAIN_DERIVED(TWorkerNodeJob, CGridWorkerApp, Version)
172 #define NCBI_WORKERNODE_MAIN_DERIVED(TWorkerNodeJob, CGridWorkerApp, Version) \
173 NCBI_DECLARE_WORKERNODE_FACTORY(TWorkerNodeJob, Version) \
174 NCBI_WORKERNODE_MAIN_IMPL(TWorkerNodeJob##Factory, CGridWorkerApp, Version, )
176 #define NCBI_WORKERNODE_MAIN_WITH_LISTENER(TWorkerNodeJob, Version, ListenerClass) \
177 NCBI_WORKERNODE_MAIN_WITH_LISTENER_DERIVED(TWorkerNodeJob, CGridWorkerApp, Version, ListenerClass)
179 #define NCBI_WORKERNODE_MAIN_WITH_LISTENER_DERIVED(TWorkerNodeJob, CGridWorkerApp, Version, ListenerClass) \
180 NCBI_DECLARE_WORKERNODE_FACTORY(TWorkerNodeJob, Version) \
181 NCBI_WORKERNODE_MAIN_IMPL(TWorkerNodeJob##Factory, CGridWorkerApp, Version, app.SetListener(new ListenerClass))
183 #define NCBI_WORKERNODE_MAIN_EX(TWorkerNodeJob, TWorkerNodeIdleTask, Version) \
184 NCBI_WORKERNODE_MAIN_EX_DERIVED(TWorkerNodeJob, TWorkerNodeIdleTask, CGridWorkerApp, Version)
186 #define NCBI_WORKERNODE_MAIN_EX_DERIVED(TWorkerNodeJob, TWorkerNodeIdleTask, CGridWorkerApp, Version) \
187 NCBI_DECLARE_WORKERNODE_FACTORY_EX(TWorkerNodeJob, TWorkerNodeIdleTask, Version) \
188 NCBI_WORKERNODE_MAIN_IMPL(TWorkerNodeJob##FactoryEx, CGridWorkerApp, Version, )
190 #define NCBI_GRID_PKG_WORKER_NODE_MAIN(TWorkerNodeJob, \
191 TWorkerNodeJobFactoryClass, ListenerClass) \
192 int main(int argc, const char* argv[]) \
194 GRID_APP_CHECK_VERSION_ARGS(); \
195 GetDiagContext().SetOldPostFormat(false); \
196 CGridWorkerApp app(new TWorkerNodeJobFactoryClass); \
197 app.SetListener(new ListenerClass); \
198 return app.AppMain(argc, argv, NULL, eDS_ToStdlog, \
199 NcbiEmptyCStr, GRID_WORKER_APP_NAME); \
Main Worker Node application.
CGridWorkerNode GetWorkerNode() const
CGridWorkerApp(const CGridWorkerApp &)
void SetListener(IGridWorkerNodeApp_Listener *listener)
Register a listener of events of this class.
CGridWorkerApp & operator=(const CGridWorkerApp &)
CGridWorkerNode m_WorkerNode
An adapter class for IGridWorkerNodeApp_Listener.
virtual void OnGridWorkerStart()
Notify that CGridWorkerNode::Run() is about to be executed.
virtual void OnGridWorkerStop()
Notify that CGridWorkerNode::Run() has just finished.
Listener of events generated by CGridWorkerNodeApp.
virtual ~IGridWorkerNodeApp_Listener()
virtual void OnInit(CNcbiApplication *) final
virtual void OnGridWorkerStop()=0
Notify that CGridWorkerNode::Run() has just finished.
virtual void OnInit(IWorkerNodeInitBaseContext *)
Perform the necessary pre-init checks.
virtual void OnGridWorkerStart()=0
Notify that CGridWorkerNode::Run() is about to be executed.
Worker Node initialize context.
Worker Node Job Factory interface.
void SetListener(IGridWorkerNodeApp_Listener *listener)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void Run(void)
Enter the main loop.
#define NCBI_SBUILDINFO_DEFAULT()
#define NCBI_XCONNECT_EXPORT
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
This class allows to add build info (date and tag) to application version.