forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpika_define.h
123 lines (99 loc) · 2.43 KB
/
pika_define.h
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_DEFINE_H_
#define PIKA_DEFINE_H_
#define PIKA_MAX_WORKER_THREAD_NUM 24
const std::string kPikaVersion = "2.2.0";
const std::string kPikaPidFile = "pika.pid";
struct ClientInfo {
int fd;
std::string ip_port;
int last_interaction;
};
struct WorkerCronTask {
int task;
std::string ip_port;
};
typedef WorkerCronTask MonitorCronTask;
//task define
#define TASK_KILL 0
#define TASK_KILLALL 1
//slave item
struct SlaveItem {
int64_t sid;
std::string ip_port;
int port;
pthread_t sender_tid;
int hb_fd;
int stage;
void* sender;
struct timeval create_time;
};
#define PIKA_MIN_RESERVED_FDS 5000
#define SLAVE_ITEM_STAGE_ONE 1
#define SLAVE_ITEM_STAGE_TWO 2
//repl_state_
#define PIKA_REPL_NO_CONNECT 0
#define PIKA_REPL_CONNECT 1
#define PIKA_REPL_CONNECTING 2
#define PIKA_REPL_CONNECTED 3
#define PIKA_REPL_WAIT_DBSYNC 4
#define PIKA_REPL_ERROR 5
//role
#define PIKA_ROLE_SINGLE 0
#define PIKA_ROLE_SLAVE 1
#define PIKA_ROLE_MASTER 2
/*
* The size of Binlogfile
*/
//static uint64_t kBinlogSize = 128;
//static const uint64_t kBinlogSize = 1024 * 1024 * 100;
enum RecordType {
kZeroType = 0,
kFullType = 1,
kFirstType = 2,
kMiddleType = 3,
kLastType = 4,
kEof = 5,
kBadRecord = 6,
kOldRecord = 7
};
/*
* the block size that we read and write from write2file
* the default size is 64KB
*/
static const size_t kBlockSize = 64 * 1024;
/*
* Header is Type(1 byte), length (3 bytes), time (4 bytes)
*/
static const size_t kHeaderSize = 1 + 3 + 4;
/*
* the size of memory when we use memory mode
* the default memory size is 2GB
*/
const int64_t kPoolSize = 1073741824;
const std::string kBinlogPrefix = "write2file";
const size_t kBinlogPrefixLen = 10;
const std::string kManifest = "manifest";
/*
* define common character
*
*/
#define COMMA ','
/*
* define reply between master and slave
*
*/
const std::string kInnerReplOk = "ok";
const std::string kInnerReplWait = "wait";
const unsigned int kMaxBitOpInputKey = 12800;
const int kMaxBitOpInputBit = 21;
/*
* db sync
*/
const uint32_t kDBSyncMaxGap = 50;
const std::string kDBSyncModule = "document";
const std::string kBgsaveInfoFile = "info";
#endif