-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMaindef.hpp
87 lines (80 loc) · 4.38 KB
/
Maindef.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef MAINDEFHPP
#define MAINDEFHPP
#include<string>
using namespace std;
//-------------------------------------------------------------------------------------------------
#define ULL unsigned long long
//-------------------------------------------------------------------------------------------------
const static string EXENAME="dmirror";
const static int ROLE_MAINBASE=1;
const static int ROLE_WATCHER=2;
const static int ROLE_SENDER=3;
//-------------------------------------------------------------------------------------------------
const static int STATE_NULL=0;
const static int STATE_TO_MASTER_WAIT_SLAVE_OK=1;
const static int STATE_MASTER=2;
const static int STATE_MASTER_TO_SLAVE1=3;
const static int STATE_MASTER_TO_SLAVE2=4;
const static int STATE_SLAVE=5;
//-------------------------------------------------------------------------------------------------
//HTTP/TCP/UNIX_SOCKET
const static int LISTEN_QUEUE_LENGTH=128;
const unsigned int SOCKET_READ_BUFFER_LENGTH=4096;
const string TELNET_END_TOKEN="\r\n";
const string NC_END_TOKEN="\n";
const static int HTTP_PROTOCOL=1;
const static int UNIX_SOCKET_PROTOCOL=2;
const static string HTTP_COMMAND_SET_MASTER="setmaster";
const static string HTTP_COMMAND_SET_SLAVE="setslave";
const static string HTTP_COMMAND_GET_STATE="getstate";
const static string HTTP_COMMAND_GET_STATUS="getstatus";
const static string HTTP_COMMAND_SHOW_CONF="showconf";
const static string HTTP_COMMAND_UPDATE_CONF="updateconf";
const static string UNIX_SOCKET_COMMAND_START_WATCHER="startwatcher";
const static string UNIX_SOCKET_COMMAND_STOP_WATCHER="stopwatcher";
const static string UNIX_SOCKET_COMMAND_START_SENDER1="startsender1";//include send all
const static string UNIX_SOCKET_COMMAND_START_SENDER2="startsender2";//no include send all
const static string UNIX_SOCKET_COMMAND_STOP_SENDER="stopsender";
const static string UNIX_SOCKET_COMMAND_SET_SENDER_UPDATE_MODE_TRUE="setsenderupdatemodetrue";
const static string UNIX_SOCKET_COMMAND_SET_SENDER_UPDATE_MODE_FALSE="setsenderupdatemodefalse";
const static string UNIX_SOCKET_COMMAND_GET_SENDER_LAST_READ_TIME="getlastreadtime";
const static string UNIX_SOCKET_COMMAND_GET_WATCHER_STATUS="getwatcherstatus";
const static string UNIX_SOCKET_COMMAND_GET_SENDER_STATUS="getsenderstatus";
const static string UNIX_SOCKET_COMMAND_UPDATE_CONF="updateconf";
const static string MAINBASE_UNIX_SOCKET_FILENAME="mainbase.socket";
const static string WATCHER_UNIX_SOCKET_FILENAME="watcher.socket";
const static string SENDER_UNIX_SOCKET_FILENAME="sender.socket";
typedef bool (*COMMAND_FUNCTION)(const string& command,string& res);
//-------------------------------------------------------------------------------------------------
//TIMER
const static int MAINBASE_LOOP_TIME_INTERVAL_MS=1000;
const static int PROCESSES_MONITOR_TIME_INTERVAL_MS=3000;
const static int SENDER_LOOP_TIME_INTERVAL_MS=1000;
//-------------------------------------------------------------------------------------------------
//INOTIFY
const static int INOTIFY_READ_BUFFER_SIZE=16384;
//-------------------------------------------------------------------------------------------------
//RLOG
const static string RLOG_SURFIX=".rlog";
const static int MASTER_WAIT_RLOG_NO_CHANGE_TO_SLAVE_TIME=5;
const static int RLOG_BATCH_PROCESS_TIMEOUT=2;
const static int SYNC_SAFE=1;
const static int SYNC_DANGER_RLOG_OVERFLOW=-1;
const static int SYNC_DANGER_INOTIFY_OVERFLOW=-2;
//-------------------------------------------------------------------------------------------------
//SENDER
const static string STAT_FILE_NAME="stat.dat";
const static string RSYNC_PARAMS="-r --delete --delete-after --ignore-errors";
const static string RSYNC_LIST_FILE_NAME="sender_rsync.list";
const static string RSYNC_EXCLUDE_FILE_NAME="sender_rsync_exclude.list";
const static string RSYNC_ERROR_FILE_NAME="sender_rsync.error";
//-------------------------------------------------------------------------------------------------
const static string MAINBASE_LOG_FILE_NAME="mainbase.";
const static string WATCHER_LOG_FILE_NAME="watcher.";
const static string SENDER_LOG_FILE_NAME="sender.";
const static string LOG_SURFIX=".log";
const static int LOG_FILE_MAX_SIZE=256*1024*1024;
//-------------------------------------------------------------------------------------------------
void kobe_printf(const char* format,...);
//-------------------------------------------------------------------------------------------------
#endif