1 #ifndef STAR_TxUCMCollector
2 #define STAR_TxUCMCollector
20 #include <log4cxx/logger.h>
22 #include "StDbFieldI.h"
23 #include "TxEventLog.h"
26 typedef std::string Options;
65 boolean loadDatabase();
66 MYSQL *getConnection();
67 MYSQL *getConnection (
const char *dbUrl,
const char *dbUsername
68 ,
const char *dbPassword);
69 MYSQL *getConnection (
const std::string &dbUrl,
const std::string &dbUsername
70 ,
const std::string &dbPassword);
71 unsigned int execute(
const std::string &sql);
72 unsigned int execute(
const char *sql);
80 virtual void closeConnection();
104 void setCurrLogFile ();
110 void processLogFile ();
133 virtual StUcmJobs *getJobList(
int limit);
134 virtual StUcmJobs *getJobList(
int limit,
int offset);
136 virtual int getJobId(
const char * reqName,
const char *taskBrokerId,
int jobBrokerId);
142 virtual StUcmEvents *getEventList(
int limit,
int offset);
145 int fillTaskList(
StUcmTasks &tasks,
int limit=0,
int offset=0);
146 int fillJobList(
StUcmJobs &jobs,
int limit=0,
int offset=0);
150 int fillUcmList(
const char *type,
RecordList &records,
int limit=0,
int offset=0);
151 int queryTableSize(
const char *tableName);
152 int queryTableSize(
const char *tableName,
const char *where);
153 int queryTableSize(
const char *tableName,
const StRecord *where);
154 void queryTable(
const char *tableName,
int limit=0,
int offset=0,
const char *where=0);
155 void queryTaskTable(
int limit=0,
int offset=0);
156 void queryJobTable(
int limit=0,
int offset=0);
157 void queryJobTable(
const char *taskID,
int limit=0,
int offset=0);
158 void queryEventTable(
int limit=0,
int offset=0);
159 void queryEventTable(
const char *jobID,
int limit=0,
int offset=0);
162 StDbFieldI *createField(
unsigned int fieldIndx);
164 void createNewTask ();
165 std::string tableNamePrefix(
const char *)
const;
166 std::string jobTableName()
const;
167 std::string eventTableName()
const;
168 void setBrokerJobID(
const StRecord *job);
169 void setBrokerTaskID(
const StRecord *job);
193 void setJobsField (
const std::string &fieldName);
194 void setJobsField (
const char * fieldName);
205 void createJobsTable ();
209 void createEventsTable ();
218 void insertRecord (
const char * insertStr,
const char * tableName);
219 void insertRecord (
const std::string&insertStr,
const std::string&tableName);
228 void updateRecord (
const char * updateStr,
const char * tableName,
const char * condition);
229 void updateRecord (
const std::string&updateStr,
const std::string&tableName,
const std::string&condition);
236 boolean recordExists (
const char * selectStr,
const char * tableName);
237 boolean recordExists (
const std::string&selectStr,
const std::string&tableName);
244 void createTable (
const char * table,
const char *like=0);
245 void createTable (
const std::string &table,
const std::string &like=std::string());
251 static void usage (Options options);
262 static void main(
const char *args[]);
267 static const char*fgTs;
268 static const char*fgEvent;
269 static const char*fgBJobID;
270 static const char*fgBTaskID;
271 static const char*fgRequester;
272 static const char*fgContext;
273 static const char*fgLevel;
274 static const char*fgStage;
275 static const char*fgKey;
276 static const char*fgValue;
278 static const char*fgNewTask;
279 static const char*fgUpdateTask;
280 static const char*fgAddJob;
281 static const char*fgUpdateJob;
282 static const char*fgSiteLocation;
283 static const char*fgStateID;
284 static const char*fgGridJobID;
285 static const char*fgAppStart;
286 static const char*fgAppEnd;
288 static const char*fgStatusFile;
289 static const char*fgStatusFileName;
290 static const char*fgStatusFileModTime;
291 static const char*fgStatusFilePos;
296 log4cxx::LoggerPtr log;
304 bool fIsConnectionOpen;
308 std::string dbUsername;
309 std::string dbPassword;
318 const char * currLogFile;
324 std::map<std::string,std::string> msgHashMap;
331 static const char * fgTaskCols;
334 static const char *fgJobsTableCols;
337 static const char * fgJobCols;
341 static const char * fgEventsTableCols;
344 static const char * fgEventCols;
348 virtual void writeDown(
const std::string& message);
349 virtual void writeDown(
const char *message);
379 virtual void setBrokerTaskID (
const std::string& brokerTaskID);
388 virtual void setBrokerJobID (
int brokerJobID);
410 virtual void setContext (
const std::string& context);
416 virtual void logStart (
const std::string& key,
const std::string& value);
426 virtual void logJobAttribute (
const std::string& key,
const std::string& value);
435 virtual void setJobSubmitLocation (
const std::string& url);
444 virtual void logTask (
unsigned int size=1);
457 virtual void logTask (
const std::string& taskAttributes);
465 virtual void setJobSubmitState (State state);
475 virtual void setJobSubmitID (
const std::string& ID);
487 virtual void logEvent (
const std::string& logMsg,
488 Level level = LEVEL_INFO,
489 Stage stage = STATUS,
490 const std::string& msgContext = TxUCMConstants::defaultContext);
503 virtual void logEvent (
const std::string& userKey,
504 const std::string& userValue,
505 Level level = LEVEL_INFO,
506 Stage stage = STATUS,
507 const std::string& msgContext = TxUCMConstants::defaultContext);
513 virtual void logEnd (
const std::string& key,
const std::string& value);
virtual void setContext(const std::string &context)
static void main(const char *args[])
void processMessage(const std::string &message)
virtual void logEvent(const std::string &logMsg, Level level=LEVEL_INFO, Stage stage=STATUS, const std::string &msgContext=TxUCMConstants::defaultContext)
virtual void logTask(unsigned int size=1)
virtual void setEnvBrokerJobID(const std::string &envBrokerJobID)
virtual void setEnvBrokerTaskID(const std::string &envBrokerTaskID)
virtual void logEnd(const std::string &key, const std::string &value)
virtual void logJobSubmitState(State state)
virtual void logJobSubmitID(const std::string &ID)
virtual void setRequesterName(const std::string &requester)
virtual void logStart(const std::string &key, const std::string &value)
virtual void setDbJobID(int dbJobID)
virtual void logJobAttribute(const std::string &key, const std::string &value)
virtual void logJobSubmitLocation(const std::string &url)
virtual StUcmTasks * getTaskList()