00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TX_EVENT_LOG_H
00012 #define TX_EVENT_LOG_H
00013
00014 #include <string>
00015
00016 #include "TxUCMConstants.h"
00017
00018 namespace TxLogging {
00019 class StUcmTasks;
00020 class StUcmJobs;
00021 class StUcmEvents;
00022 class StRecord;
00023
00028 class TxEventLog {
00029
00030 public:
00031 enum Stage {
00032 START = 1,
00033 STATUS = 2,
00034 END = 3
00035 };
00036
00037 enum Level {
00038 LEVEL_UNKNOWN = 0,
00039 LEVEL_TRACE = 1,
00040 LEVEL_DEBUG = 2,
00041 LEVEL_INFO = 3,
00042 LEVEL_NOTICE = 4,
00043 LEVEL_WARNING = 5,
00044 LEVEL_ERROR = 6,
00045 LEVEL_CRITICAL = 7,
00046 LEVEL_ALERT = 8,
00047 LEVEL_FATAL = 9,
00048 TOTAL_LEVELS
00049 };
00050
00051 enum State {
00052 UNKNOWN = 0,
00053 UNSUBMITTED = 1,
00054 STAGEIN = 2,
00055 PENDING = 3,
00056 ACTIVE = 4,
00057 SUSPENDED = 5,
00058 STAGEOUT = 6,
00059 CLEANUP = 7,
00060 DONE = 8,
00061 FAILED = 9,
00062 TOTAL_STATES
00063 };
00064
00065 protected:
00071 TxEventLog ();
00072 virtual void writeDown(const std::string& message)=0;
00073 public:
00074
00080 virtual ~TxEventLog ();
00081
00082 virtual void writeDown(const char *message);
00091 virtual void setEnvBrokerTaskID (const std::string& envBrokerTaskID)=0;
00092 void setEnvBrokerTaskID (const char *envBrokerTaskID);
00093
00102 virtual void setEnvBrokerJobID (const std::string& envBrokerJobID)=0;
00103 void setEnvBrokerJobID (const char *envBrokerJobID);
00104
00112 virtual void setBrokerTaskID (const std::string& brokerTaskID)=0;
00113 void setBrokerTaskID (const char *brokerTaskID);
00114
00122 virtual void setBrokerJobID (int brokerJobID)=0;
00123
00130 virtual void setRequesterName (const std::string& requester)=0;
00131 void setRequesterName (const char *requester);
00132
00138 virtual void setContext (const std::string& context)=0;
00139 void setContext (const char *context);
00140
00145 virtual void logStart (const std::string& key, const std::string& value)=0;
00146 void logStart (const char *key = TxUCMConstants::appStart,
00147 const char *value = "application started");
00148
00156 virtual void logJobSubmitLocation (const std::string& url)=0;
00157 void logJobSubmitLocation (const char *url);
00158 virtual void setJobSubmitLocation (const std::string& url)=0;
00159 void setJobSubmitLocation (const char *url);
00160
00169 virtual void logJobAttribute (const std::string& key, const std::string& value)=0;
00170 void logJobAttribute (const char *key, const char *value);
00178 virtual void logTask (unsigned int size=1)=0;
00179
00191 virtual void logTask (const std::string& taskAttributes)=0;
00192 void logTask (const char *taskAttributes);
00199 virtual void logJobSubmitState (State state)=0;
00200 virtual void setJobSubmitState (State state)=0;
00201
00209 virtual void logJobSubmitID (const std::string& ID)=0;
00210 void logJobSubmitID (const char *ID);
00211 virtual void setJobSubmitID (const std::string& ID)=0;
00212 void setJobSubmitID (const char *ID);
00213
00224 virtual void logEvent (const std::string& logMsg,
00225 Level level = LEVEL_INFO,
00226 Stage stage = STATUS,
00227 const std::string& msgContext = TxUCMConstants::defaultContext)=0;
00228
00229 void logEvent (const char *logMsg,
00230 Level level = LEVEL_INFO,
00231 Stage stage = STATUS,
00232 const char *msgContext = TxUCMConstants::defaultContext);
00233
00245 virtual void logEvent (const std::string& userKey,
00246 const std::string& userValue,
00247 Level level = LEVEL_INFO,
00248 Stage stage = STATUS,
00249 const std::string& msgContext = TxUCMConstants::defaultContext)=0;
00250 void logEvent (const char *userKey,
00251 const char *userValue,
00252 Level level = LEVEL_INFO,
00253 Stage stage = STATUS,
00254 const char *msgContext = TxUCMConstants::defaultContext);
00255
00260 virtual void logEnd (const std::string& key, const std::string& value)=0;
00261 void logEnd (const char *key = TxUCMConstants::appEnd,
00262 const char *value = "application ended");
00263
00264
00265 virtual StUcmTasks *getTaskList ();
00266 virtual StUcmTasks *getTaskList (int limit);
00267 virtual StUcmTasks *getTaskList (int limit, int offset) = 0;
00268
00269 virtual StUcmJobs *getJobList();
00270 virtual StUcmJobs *getJobList(StRecord *task);
00271 virtual StUcmJobs *getJobList(StRecord *task, int limit);
00272 virtual StUcmJobs *getJobList(int limit);
00273 virtual StUcmJobs *getJobList(int limit, int offset);
00274 virtual StUcmJobs *getJobList(StRecord *task, int limit, int offset)=0;
00275 virtual int getJobId(const char *requester, const char *taskBrokerId, int jobBrokerId) = 0;
00276
00277 virtual StUcmEvents *getEventList();
00278 virtual StUcmEvents *getEventList(StRecord *job);
00279 virtual StUcmEvents *getEventList(StRecord *job,int limit);
00280 virtual StUcmEvents *getEventList(int limit);
00281 virtual StUcmEvents *getEventList(int limit, int offset);
00282 virtual StUcmEvents *getEventList(StRecord *job,int limit, int offset)=0;
00283
00284 virtual int queryTableSize(const char *tableName);
00285 virtual int queryTableSize(const char *tableName, const char *where)=0;
00286 virtual int queryTableSize(const char *tableName, const StRecord *where)=0;
00287
00288
00289
00290
00291
00292
00293 virtual void setDbJobID (int dbJobID)=0;
00294 };
00295 }
00296 #ifndef TXEVENT_DEFAULT_IMPLEMENTAION
00297 #define TXEVENT_DEFAULT_IMPLEMENTAION(classname) \
00298 StUcmTasks *classname::getTaskList () \
00299 { return TxEventLog::getTaskList() ; } \
00300 StUcmTasks *classname::getTaskList (int limit) \
00301 { return TxEventLog::getTaskList(limit); } \
00302 StUcmJobs *classname::getJobList () \
00303 { return TxEventLog::getJobList() ; } \
00304 StUcmJobs *classname::getJobList (StRecord *task) \
00305 { return TxEventLog::getJobList(task) ; } \
00306 StUcmJobs *classname::getJobList (int limit) \
00307 { return TxEventLog::getJobList(limit); } \
00308 StUcmJobs *classname::getJobList (StRecord *task,int limit) \
00309 { return TxEventLog::getJobList(task,limit); } \
00310 StUcmJobs *classname::getJobList (int limit,int offset) \
00311 { return TxEventLog::getJobList(limit,offset); } \
00312 StUcmEvents *classname::getEventList () \
00313 { return TxEventLog::getEventList() ; } \
00314 StUcmEvents *classname::getEventList (StRecord *job) \
00315 { return TxEventLog::getEventList(job) ; } \
00316 StUcmEvents *classname::getEventList (int limit) \
00317 { return TxEventLog::getEventList(limit); } \
00318 StUcmEvents *classname::getEventList (StRecord *job,int limit) \
00319 { return TxEventLog::getEventList(job,limit); } \
00320 StUcmEvents *classname::getEventList (int limit,int offset) \
00321 { return TxEventLog::getEventList(limit,offset); } \
00322 int classname::queryTableSize (const char *table_name)\
00323 { return TxEventLog::queryTableSize(table_name); } \
00324 void classname::writeDown(const char *message) \
00325 { return TxEventLog::writeDown(message); }
00326
00327 #define TXEVENT_DEFAULT_IMPLEMENTAION_2(classname) \
00328 int classname::getJobId (const char *requester, const char *taskBrokerId, int jobBrokerId)\
00329 { assert(0 && "getJobId has not been implemented yet"); \
00330 return 0; } \
00331 StUcmTasks *classname::getTaskList (int limit, int offset) \
00332 { assert(0 && "getTaskList has not been implemented yet"); \
00333 return 0; } \
00334 StUcmJobs *classname::getJobList (StRecord *task,int limit, int offset) \
00335 { assert(0 && task && limit && offset && "getJobList has not been implemented yet"); \
00336 return 0; } \
00337 StUcmEvents *classname::getEventList (StRecord *job,int limit, int offset) \
00338 { assert(0 && job && limit && offset&& "getEventList has not been implemented yet"); \
00339 return 0; } \
00340 int classname::queryTableSize (const char *table_name, const char *where) \
00341 { assert(0 && table_name && where && "queryTableSize has not been implemented yet"); \
00342 return 0; } \
00343 int classname::queryTableSize (const char *table_name, const StRecord *where) \
00344 { assert(0 && table_name && where && "queryTableSize has not been implemented yet"); \
00345 return 0; } \
00346 void classname::setDbJobID (int bJobID) \
00347 { assert(0 && bJobID && "setDbJobID has not been implemented yet"); }
00348 #endif
00349 #endif