TDengine/source/libs/sync/inc/syncEnv.h

69 lines
1.9 KiB
C
Raw Normal View History

2022-02-26 18:24:50 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_LIBS_SYNC_ENV_H
#define _TD_LIBS_SYNC_ENV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "syncInt.h"
#define TIMER_MAX_MS 0x7FFFFFFF
#define ENV_TICK_TIMER_MS 1000
#define PING_TIMER_MS 5000
#define ELECT_TIMER_MS_MIN 2500
#define HEARTBEAT_TIMER_MS 1000
#define HEARTBEAT_TICK_NUM 20
2022-03-07 06:18:46 +00:00
2022-02-26 18:24:50 +00:00
typedef struct SSyncEnv {
uint8_t isStart;
2022-03-12 04:29:44 +00:00
// tick timer
tmr_h pEnvTickTimer;
int32_t envTickTimerMS;
2022-03-12 09:02:15 +00:00
uint64_t envTickTimerLogicClock; // if use queue, should pass logic clock into queue item
2022-03-12 04:29:44 +00:00
uint64_t envTickTimerLogicClockUser;
TAOS_TMR_CALLBACK FpEnvTickTimer; // Timer Fp
uint64_t envTickTimerCounter;
// timer manager
2022-02-28 06:10:34 +00:00
tmr_h pTimerManager;
2022-03-12 04:29:44 +00:00
// other resources shared by SyncNodes
// ...
2022-02-26 18:24:50 +00:00
} SSyncEnv;
2022-10-31 15:40:43 +00:00
SSyncEnv* syncEnv();
2022-11-02 02:24:55 +00:00
bool syncIsInit();
2022-02-28 08:36:57 +00:00
2022-10-31 15:40:43 +00:00
int64_t syncNodeAdd(SSyncNode* pNode);
2022-11-01 01:02:48 +00:00
void syncNodeRemove(int64_t rid);
2022-10-31 15:40:43 +00:00
SSyncNode* syncNodeAcquire(int64_t rid);
void syncNodeRelease(SSyncNode* pNode);
2022-02-26 18:24:50 +00:00
int64_t syncHbTimerDataAdd(SSyncHbTimerData* pData);
void syncHbTimerDataRemove(int64_t rid);
SSyncHbTimerData* syncHbTimerDataAcquire(int64_t rid);
void syncHbTimerDataRelease(SSyncHbTimerData* pData);
2022-02-26 18:24:50 +00:00
#ifdef __cplusplus
}
#endif
#endif /*_TD_LIBS_SYNC_ENV_H*/