Initial commit
This commit is contained in:
Executable
+105
@@ -0,0 +1,105 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/common/eventsystem/EventListener.h>
|
||||
#include <wfr/common/types/WfrTypes.h>
|
||||
#include <wfr/common/types/WfsTypes.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/transaction.hxx>
|
||||
#include <odb/session.hxx>
|
||||
|
||||
#include <odb/sqlite/database.hxx>
|
||||
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wfs {
|
||||
class Workflow;
|
||||
class Activity;
|
||||
class ActivityInstance;
|
||||
}
|
||||
}
|
||||
|
||||
namespace wfr {
|
||||
namespace eventsystem {
|
||||
|
||||
namespace odbmodel {
|
||||
|
||||
class Workflow;
|
||||
class Activity;
|
||||
class ActivityInstance;
|
||||
|
||||
}
|
||||
|
||||
class Event;
|
||||
class WorkflowStatusEvent;
|
||||
class ActivityStatusEvent;
|
||||
class ActivityInstanceStatusEvent;
|
||||
class ComputingResourceStatusEvent;
|
||||
class ComponentStatusEvent;
|
||||
|
||||
class SQLiteLogger : public EventListener {
|
||||
protected:
|
||||
static void dbwriterfunc(SQLiteLogger* logger);
|
||||
|
||||
std::unique_ptr<std::thread> loggerThread;
|
||||
bool threadRunning = false;
|
||||
bool threadBreakFlag = false;
|
||||
std::mutex threadMutex;
|
||||
std::condition_variable threadCondition;
|
||||
std::queue<std::shared_ptr<Event>> eventQueue;
|
||||
|
||||
std::string filename;
|
||||
std::unique_ptr<odb::sqlite::database> dbHandle;
|
||||
bool readyFlag = false;
|
||||
|
||||
int statProcessedEvents;
|
||||
int statWrittenEvents;
|
||||
|
||||
/*typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::Workflow>> workflowMap_t;
|
||||
typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::Activity>> activityMap_t;
|
||||
typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::ActivityInstance>> activityInstanceMap_t;
|
||||
|
||||
workflowMap_t workflowMap;
|
||||
activityMap_t activityMap;
|
||||
activityInstanceMap_t activityInstanceMap;*/
|
||||
|
||||
/*void handleWorkflowStatusEvent(WorkflowStatusEvent &event);
|
||||
void handleActicityStatusEvent(ActivityStatusEvent &event);
|
||||
void handleActicityInstanceStatusEvent(ActivityInstanceStatusEvent &event);
|
||||
void handleComputingResourceStatusEvent(ComputingResourceStatusEvent &event);
|
||||
void handleComponentStatusEvent(ComponentStatusEvent &event);
|
||||
|
||||
std::shared_ptr<odbmodel::Workflow> getWorkflowFromWfsMap(wfs::Workflow& wf);
|
||||
void persistWorkflow(std::shared_ptr<odbmodel::Workflow>& wfp, wfs::Workflow& wf);
|
||||
std::shared_ptr<odbmodel::Activity> getActivityFromWfsMap(wfs::Activity& act);
|
||||
void persistActivity(std::shared_ptr<odbmodel::Activity>& ap, wfs::Activity& a);
|
||||
std::shared_ptr<odbmodel::ActivityInstance> getActivityInstanceFromWfsMap(wfs::ActivityInstance& act);
|
||||
void persistActivityInstance(std::shared_ptr<odbmodel::ActivityInstance>& ap, wfs::ActivityInstance& a);
|
||||
|
||||
void writeWorkflowStatus(std::shared_ptr<odbmodel::Workflow>& pWf, WorkflowStatusEvent &event);
|
||||
void writeActivityStatus(std::shared_ptr<odbmodel::Activity>& pA, ActivityStatusEvent &event);
|
||||
void writeActivityInstanceStatus(std::shared_ptr<odbmodel::ActivityInstance>& pA, ActivityInstanceStatusEvent &event);
|
||||
void writeComputingResourceStatus(std::shared_ptr<odbmodel::Workflow>& pwf, std::shared_ptr<odbmodel::ActivityInstance>& pai, ComputingResourceStatusEvent &event);
|
||||
void writeComponentStatus(std::shared_ptr<odbmodel::Workflow>& pwf, ComponentStatusEvent &event);*/
|
||||
|
||||
public:
|
||||
SQLiteLogger(std::string filename);
|
||||
virtual ~SQLiteLogger();
|
||||
|
||||
bool isReady() { return readyFlag; }
|
||||
|
||||
virtual void notifyEvent(const std::shared_ptr<Event>& event) noexcept;
|
||||
};
|
||||
|
||||
} /* namespace eventsystem */
|
||||
} /* namespace wfr */
|
||||
|
||||
Reference in New Issue
Block a user