落盘机制修改
This commit is contained in:
@@ -56,6 +56,7 @@ static void set_default_config(AppConfig *cfg)
|
||||
cfg->mode = MODE_MASTER;
|
||||
cfg->master_port = 8888;
|
||||
cfg->persistence = PERSIST_NONE;
|
||||
cfg->oplog_sync_mode = OPLOG_SYNC_NONE;
|
||||
cfg->allocator = ALLOC_JEMALLOC;
|
||||
cfg->leak_mode = MEMLEAK_DETECT_OFF;
|
||||
cfg->replica_mode = REPLICA_DISABLE;
|
||||
@@ -87,6 +88,16 @@ static void parse_persistence(const char *s, PersistenceType *out)
|
||||
else if (!strcasecmp(s, "none")) *out = PERSIST_NONE;
|
||||
}
|
||||
|
||||
static void parse_oplog_sync_mode(const char *s, OplogSyncMode *out)
|
||||
{
|
||||
if (!s || !out) return;
|
||||
if (!strcasecmp(s, "every_sec") || !strcasecmp(s, "everysec")) {
|
||||
*out = OPLOG_SYNC_EVERY_SEC;
|
||||
} else if (!strcasecmp(s, "none")) {
|
||||
*out = OPLOG_SYNC_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_allocator(const char *s, AllocatorType *out)
|
||||
{
|
||||
if (!s || !out) return;
|
||||
@@ -188,6 +199,15 @@ const char *persistence_to_string(PersistenceType p)
|
||||
}
|
||||
}
|
||||
|
||||
const char *oplog_sync_mode_to_string(OplogSyncMode m)
|
||||
{
|
||||
switch (m) {
|
||||
case OPLOG_SYNC_NONE: return "none";
|
||||
case OPLOG_SYNC_EVERY_SEC: return "every_sec";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char *allocator_to_string(AllocatorType a)
|
||||
{
|
||||
switch (a) {
|
||||
@@ -337,6 +357,15 @@ void persist_load(xmlNodePtr *root, AppConfig *out_cfg){
|
||||
}
|
||||
}
|
||||
|
||||
xmlNodePtr oplog_sync_node = find_child(pers, "oplog_sync");
|
||||
if (oplog_sync_node) {
|
||||
xmlChar *txt = xmlNodeGetContent(oplog_sync_node);
|
||||
if (txt) {
|
||||
parse_oplog_sync_mode((char *)txt, &out_cfg->oplog_sync_mode);
|
||||
xmlFree(txt);
|
||||
}
|
||||
}
|
||||
|
||||
xmlNodePtr array_node = find_child(pers, "array");
|
||||
if (array_node) {
|
||||
xmlChar *txt = xmlNodeGetContent(array_node);
|
||||
|
||||
@@ -20,6 +20,11 @@ typedef enum {
|
||||
PERSIST_NONE
|
||||
} PersistenceType;
|
||||
|
||||
typedef enum {
|
||||
OPLOG_SYNC_NONE,
|
||||
OPLOG_SYNC_EVERY_SEC
|
||||
} OplogSyncMode;
|
||||
|
||||
typedef enum {
|
||||
REPLICA_DISABLE,
|
||||
REPLICA_ENABLE
|
||||
@@ -53,6 +58,7 @@ typedef struct {
|
||||
char array_file[256];
|
||||
char rbtree_file[256];
|
||||
char hash_file[256];
|
||||
OplogSyncMode oplog_sync_mode;
|
||||
|
||||
AllocatorType allocator;
|
||||
MemLeakDetectMode leak_mode;
|
||||
@@ -68,6 +74,7 @@ int config_load(const char *filename, AppConfig *out_cfg);
|
||||
const char *log_level_to_string(LogLevel lvl);
|
||||
const char *server_mode_to_string(ServerMode mode);
|
||||
const char *persistence_to_string(PersistenceType p);
|
||||
const char *oplog_sync_mode_to_string(OplogSyncMode m);
|
||||
const char *allocator_to_string(AllocatorType a);
|
||||
const char *leakage_to_string(MemLeakDetectMode a);
|
||||
const char *replica_to_string(ReplicaMode a);
|
||||
|
||||
Reference in New Issue
Block a user