📄 mcoha.h
字号:
/******************************************************************* * * * mcoHA.h * * * * This file is a part of the eXtremeDB source code * * Copyright (c) 2001-2006 McObject LLC * * All Rights Reserved * * * *******************************************************************/#ifndef MCO_HA_H__#define MCO_HA_H__/* * ++ * * PROJECT: eXtremeDB(tm) (c) McObject LLC * * SUBSYSTEM: High availabitity support * * MODULE: mcoHA.H * * ABSTRACT: HA user interface * * * * VERSION: 1.0 * * HISTORY: * 1.0- 1 AD 04-Jan-2003 Created it was * 1.0- 2 SS 15-Jul-2003 some functions were added: * mco_HA_get_number_of_replicas() * mco_HA_get_io_channel() * 1.0- 3 SS 22-Jul-2003 error handler pointer was added to * mco_HA_attach_replica() * 1.0- 2 SS 24-Jul-2003 pointer to the object mco_channel_t is passed to * mco_xstream_write() & mco_xstream_read() instead of * handles to a communication channel * 3 SS 15-Jul-2003 the function was added to the module mcoinst.c: * mco_get_current_auto_oid() * 4 SS 11-Oct-2003 definition of shared commmit flag * MCO_MULTIPROCESS_COMMIT was added * function mco_trans_commit_synch(...) was added * 5 SS 28-Oct-2003 special mode flag was added to mco_HA_attach_master() * 6 SS 3-Oct-2003 mco_HA_keep_alive() was added * 7 SS 7-jan-2004 in mco_HA_keep_alive() type of argument timeout was changed * to timer_unit * 8 SS 22-apr-2004 flags MCO_HAFLAG_FORCE_MASTER MCO_HAFLAG_FORCE_NOTHING were added * 9 SS 08-feb-2005 asynchronous replication mode was added */#ifdef __cplusplusextern "C" { #endif#include "mco.h" /******************************************************* Special commit interface. MUST BE DEFINED if MCO_CFG_2PHASE_COMMIT is defined *******************************************************///#define MCO_CFG_HA_2PHASE_COMMIT/** previous definition of mco_trans_sequencer_h */typedef struct mco_trans_sequencer_t_ *mco_trans_sequencer_h;/** Mode flags for mco_HA_set_mode(). In each call of mco_HA_set_mode() all the necessary flags MUST be set together.*//** flag's offsets used for flag control */#define MCO_MASTER_MODE_O 0 /**< master mode flag offset */#define MCO_MULTIPROCESS_COMMIT_O 1 /**< commit sharing flag offset */#define MCO_HAMODE_ASYNCH_O 2 /**< asynchron replication mode flag offset */#define MCO_HAMODE_MCAST_O 3 /**< multicast replication mode flag offset */#define MCO_HAMODE_MCAST_NOCONFIRM_O 4 /**< "multicast no confirmation" mode flag offset */#define MCO_HAMODE_HOTSYNCH_O 5 /**< "hot synchroniation" mode flag offset *//** master mode without commit sharing */#define MCO_MASTER_MODE (1<<MCO_MASTER_MODE_O)/** commit sharing flag */#define MCO_MULTIPROCESS_COMMIT (1<<MCO_MULTIPROCESS_COMMIT_O)/** asynchron replication mode, if it is used, notification flag and notification callback routine addredd MUST also be set */#define MCO_HAMODE_ASYNCH (1<<MCO_HAMODE_ASYNCH_O) /** multicast replication mode */#define MCO_HAMODE_MCAST (1<<MCO_HAMODE_MCAST_O)/** "multicast no confirmation" mode */#define MCO_HAMODE_MCAST_NOCONFIRM (1<<MCO_HAMODE_MCAST_NOCONFIRM_O)/**"hot synchroniation" mode flag */#define MCO_HAMODE_HOTSYNCH (1<<MCO_HAMODE_HOTSYNCH_O)#define MCO_HA_MASTER_FLAGS (MCO_MASTER_MODE|MCO_MULTIPROCESS_COMMIT)#define MCO_HA_IS_MASTER( ha ) (ha.flags & MCO_HA_MASTER_FLAGS)/** Definitions of control flag's values, passed to mco_HA_attach_master(...) */#define MCO_HAFLAG_FORCE_NOTHING 0 /**< "none" flag */#define MCO_HAFLAG_FORCE_MASTER 1 /**< "forced master mode" */#define MCO_HAFLAG_REPLICA_NOTIFICATION 2 /**< turns on replica notification. MUST be used INSTEAD of mco_HA_set_mode() call with MCO_HAMODE_NOTIFICATION flag set, because replica MUST be able to send notifications before the replica database is created. The notificatin callback routine address MUST be set in mco_connection_param_t together with this flag. *//** * returns current auto_oid by database handle */MCO_RET mco_get_current_auto_oid(mco_db_h db, /* OUT */ mco_uquad* retvalue);#define mco_channel_h void* /** definition of notification codes for notification callback */typedef enum mco_ha_notification_t { /** replica notifications */ MCO_REPL_NOTIFY_CONNECTED = 0, /**< "connected" notification */ MCO_REPL_NOTIFY_CONNECT_FAILED, /**< "connect failed" notification */ MCO_REPL_NOTIFY_DB_EQUAL, /**< "no need to load DB" notification */ MCO_REPL_NOTIFY_DB_LOAD_BEGIN, /**< "begin loading DB" notification */ MCO_REPL_NOTIFY_DB_LOAD_FAILED, /**< "loading failed" notification, "param1" of notification callback contains MCO_RET code */ MCO_REPL_NOTIFY_DB_LOAD_OK, /**< "succesful loading" notification, "param1" of notification callback contains MCO_E_HA_REPLICA_STOP_REASON code */ MCO_REPL_NOTIFY_COMMIT_FAILED, /**< "commit failed" notification, "param1" of notification callback contains MCO_RET code */ MCO_REPL_NOTIFY_REPLICA_STOPPED, /**< "stopped" notification, */ MCO_REPL_NOTIFY_DB_CREATION_FAILED, /**< "database creation failed" notification, "param1" of notification callback contains MCO_RET code */ MCO_REPL_NOTIFY_HOTSYNC, /**< "begining of hot synchronization" notification */ MCO_REPL_NOTIFY_EOHOTSYNC /**< "end of hot synchronization" notification *///}MCO_HA_NOTIFICATION;/** the prototype for replica notifying procedure */typedef void (*mco_ha_notifying)( uint2 notification_code, /**< notification code*/ uint4 param1, /**< reserved for special cases */ void * param2, /**< reserved for special cases */ void * pcontext /**< user-defined notification context */ ); /** the prototype for stream write procedure */typedef int (*mco_xstream_write)( mco_channel_h ch, ///< pointer to a communicatin channel object const void * from, unsigned nbytes, timer_unit timeout);/** the prototype for stream read procedure */typedef int (*mco_xstream_read)( mco_channel_h ch, void * to, unsigned max_nbytes, timer_unit timeout);/** Then to use a stream, runtime needs a stream handle. Stream handle is an internal detail of communication protocol Pointer to the channel object is passed to these functions as a handle */ #undef mco_channel_htypedef struct { mco_xstream_write fsend; /**< virtual send method */ mco_xstream_read frecv; /**< virtual receive method */ timer_unit current_timeout; /**< for use in load/save operations */ uint4 flags; /**< channel mode/status flags */}mco_channel_t, *mco_channel_h;#ifdef MCO_CFG_HA_2PHASE_COMMIT /**< special commit interface *//**\fn (*mco_HA_ReplicaFailCallback)(MCO_RET ErrorCode, mco_bool commit_flag); Replica Fail Callback Routine prototype \param MCO_RET ErrorCode - Replica failure code\param mco_bool commit_flag - flag indicates open transactions. (flag = true) means that the previous transaction is commited and there is no open transaction on replica side\return Returns boolean flag, = true - requires replica commit = false - requires replica rollback */typedef mco_bool (*mco_HA_ReplicaFailCallback)(MCO_RET ErrorCode, mco_bool commit_flag);#endif //MCO_CFG_HA_2PHASE_COMMITtypedef struct{///... all timeouts, including used in 2-phase commit ... (in timer_unit) timer_unit commit_timeout; ///< timeout for commit timer_unit initial_timeout; ///< initial sync timeout timer_unit detach_timeout; ///< send detach request, timeout for replica's commit timer_unit wait_data_timeout; ///< amount of time replica waits for the next commit timer_unit synch_timeout; ///< amount of time a master waits for the commit result mco_ha_notifying notifying_callback; ///< pointer to notification callback routine void * notifying_context; ///< user-defined argument for notification callback routine#ifdef MCO_CFG_HA_2PHASE_COMMIT ///< special commit interface mco_HA_ReplicaFailCallback replica_fail_callback; ///< Replica Fail Callback Routine#endif //MCO_CFG_HA_2PHASE_COMMIT}mco_connection_param_t;typedef struct { mco_bool is_master;}mco_HA_replica_stat_t;/** * HA error handler parameter structure * MCO_RET errcode - error code caused the callback; * mco_channel_h ch - pointer to replica IO channel. If it not equal to NULL then the replica * channel was deleted from the list; */typedef struct ha_error_ { MCO_RET errcode; ///< error code invoked the handler mco_channel_h IOchannel; ///< pointer to the detached replica channel. ///< if(IOchannel!=0) ///< then the replica channel was deleted from the channel's list}ha_error_t, *ha_error_h;/** Error handler prototype */typedef void (*mco_HA_ErrorHandler)(ha_error_h HAerror);typedef struct{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -