📄 mcoha.hpp
字号:
/******************************************************************* * * * This file is a part of the eXtremeDB-HA Application Framework * * Copyright (c) 2001-2006 McObject LLC * * All Rights Reserved * * * *******************************************************************//* * ++ * * PROJECT: eXtremeDB(tm) (c) 2003 McObject LLC * * SUBSYSTEM: HA framework * * MODULE: mcoha.cpp * * ABSTRACT: HA definitions * * VERSION: 1.0 * * HISTORY: * 1.0- 1 SS 18-Feb-2004 Created it was * * -- */#include "app.h"#include "watchdog.h"#include "monitorDB.hpp"#include "sensor.hpp"#include "framework.hpp"/******************************************************************** class Database - application class - Database context. Is implemented in order to combine HA interface layer and database objects into the database context. Inherits HA interface layer. Agregates class Sensor_1. ********************************************************************/class Database: public HA{ public: Database::Database(int instance); Database::~Database(); Sensor_1 s1; /* class Sensor_1 */// Sensor_2 s2; /* class Sensor_2 */// Sensor_3 s3; /* class Sensor_3 */// Sensor_4 s4; /* class Sensor_4 *///};/********************************************************************Class App is the application class that implements the one and only application object. ********************************************************************/class App: public MCOwrapper{ public: App(); ~App();/* * public methods */ void init(int argc, char **argv); void WatchDog();/* * private methods */ private: void SH(); void StopWait(); void ExitHandler(int code); void KillWatchdog(); void CloseDatabases(int flag); int MasterMode(); int ReplicaMode(); void Master(int flag); MCO_E_HA_REPLICA_STOP_REASON Replica(); int parse_cmd_line(int argc, char **argv); int CreateWatchdog(long msec, MCO_PWATCHDOG proc); Database* CreateDatabase(int instance); Database* ConnectToDatabase( int instance); void InitDBinstance(Database* Db, int instance);// MEMBER_THREAD(App, Run); // attach HA::Run() to C object function/* * private variables */ Database * DbInstances[MAX_HA_INSTANCES]; // the list of created databases int NumberOfDb; // current number of db instances int CurrentDbInstance; // number of current db instance for replica long stop_flag; // indicates that the application is stopped int wdt_flag; // the flag for shared commit watchdog int main_master; // indicates master mode // = 1 - main master // = 0 - slave master // = -1 - not master int replica_mode; // replication mode // = 1 - special mode // = 0 - switch-to-master mode // = -1 - common mode int isReplica; // indicates that the application is now in replica mode timer_unit t_begin, t_start, t_stop, t_end; // time measuring variables timer_unit init_time; // shows the time of the initialization phase of the replication THREAD_ID thRun; // main thread ID mco_HA_params_t mode; // HA mode descriptor;};/******************************************************************** App wrapper methods ********************************************************************//* * Create asynchron timer for the shared commit watchdog procedure. */inline int App::CreateWatchdog(long msec, MCO_PWATCHDOG proc){ return mco_create_watchdog(msec, proc);}inline void App::KillWatchdog() // kill watchdog{ mco_kill_watchdog();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -