提交 d3c12027 编写于 作者: S Shengliang Guan

TD-1843

上级 bd0f7fff
......@@ -20,6 +20,7 @@
#include "tconfig.h"
#include "tglobal.h"
#include "tfile.h"
#include "tstep.h"
#include "twal.h"
#include "trpc.h"
#include "dnode.h"
......@@ -46,17 +47,9 @@ static int32_t dnodeInitStorage();
static void dnodeCleanupStorage();
static void dnodeSetRunStatus(SRunStatus status);
static void dnodeCheckDataDirOpenned(char *dir);
static int32_t dnodeInitComponents();
static void dnodeCleanupComponents(int32_t stepId);
static int dnodeCreateDir(const char *dir);
typedef struct {
const char *const name;
int32_t (*init)();
void (*cleanup)();
} SDnodeComponent;
static const SDnodeComponent tsDnodeComponents[] = {
static SStep tsDnodeSteps[] = {
{"tfile", tfInit, tfCleanup},
{"rpc", rpcInit, rpcCleanup},
{"storage", dnodeInitStorage, dnodeCleanupStorage},
......@@ -88,24 +81,14 @@ static int dnodeCreateDir(const char *dir) {
return 0;
}
static void dnodeCleanupComponents(int32_t stepId) {
for (int32_t i = stepId; i >= 0; i--) {
if (tsDnodeComponents[i].cleanup) {
(*tsDnodeComponents[i].cleanup)();
}
}
static void dnodeCleanupComponents() {
int32_t stepSize = sizeof(tsDnodeSteps) / sizeof(SStep);
taosStepCleanup(tsDnodeSteps, stepSize);
}
static int32_t dnodeInitComponents() {
int32_t code = 0;
for (int32_t i = 0; i < sizeof(tsDnodeComponents) / sizeof(tsDnodeComponents[0]); i++) {
if (tsDnodeComponents[i].init() != 0) {
dnodeCleanupComponents(i);
code = -1;
break;
}
}
return code;
int32_t stepSize = sizeof(tsDnodeSteps) / sizeof(SStep);
return taosStepInit(tsDnodeSteps, stepSize);
}
int32_t dnodeInitSystem() {
......@@ -152,7 +135,7 @@ int32_t dnodeInitSystem() {
void dnodeCleanUpSystem() {
if (dnodeGetRunStatus() != TSDB_RUN_STATUS_STOPPED) {
dnodeSetRunStatus(TSDB_RUN_STATUS_STOPPED);
dnodeCleanupComponents(sizeof(tsDnodeComponents) / sizeof(tsDnodeComponents[0]) - 1);
dnodeCleanupComponents();
taos_cleanup();
taosCloseLog();
}
......
......@@ -21,6 +21,7 @@
#include "tgrant.h"
#include "ttimer.h"
#include "tglobal.h"
#include "tstep.h"
#include "mnode.h"
#include "dnode.h"
#include "mnodeDef.h"
......@@ -37,16 +38,10 @@
#include "mnodeShow.h"
#include "mnodeProfile.h"
typedef struct {
const char *const name;
int (*init)();
void (*cleanup)();
} SMnodeComponent;
void *tsMnodeTmr = NULL;
static bool tsMgmtIsRunning = false;
static const SMnodeComponent tsMnodeComponents[] = {
static SStep tsMnodeSteps[] = {
{"sdbref", sdbInitRef, sdbCleanUpRef},
{"profile", mnodeInitProfile, mnodeCleanupProfile},
{"cluster", mnodeInitCluster, mnodeCleanupCluster},
......@@ -67,22 +62,14 @@ static void mnodeInitTimer();
static void mnodeCleanupTimer();
static bool mnodeNeedStart() ;
static void mnodeCleanupComponents(int32_t stepId) {
for (int32_t i = stepId; i >= 0; i--) {
tsMnodeComponents[i].cleanup();
}
static void mnodeCleanupComponents() {
int32_t stepSize = sizeof(tsMnodeSteps) / sizeof(SStep);
taosStepCleanup(tsMnodeSteps, stepSize);
}
static int32_t mnodeInitComponents() {
int32_t code = 0;
for (int32_t i = 0; i < sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]); i++) {
if (tsMnodeComponents[i].init() != 0) {
mnodeCleanupComponents(i);
code = -1;
break;
}
}
return code;
int32_t stepSize = sizeof(tsMnodeSteps) / sizeof(SStep);
return taosStepInit(tsMnodeSteps, stepSize);
}
int32_t mnodeStartSystem() {
......@@ -132,7 +119,7 @@ void mnodeCleanupSystem() {
dnodeFreeMReadQueue();
dnodeFreeMPeerQueue();
mnodeCleanupTimer();
mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1);
mnodeCleanupComponents();
mInfo("mnode is cleaned up");
}
......
......@@ -24,7 +24,6 @@ typedef struct {
const char *const name;
int32_t (*initFp)();
void (*cleanupFp)();
int32_t step;
} SStep;
int32_t taosStepInit(SStep *pSteps, int32_t stepSize);
......
......@@ -28,11 +28,11 @@ static void vnodeCleanupHash(void);
static void vnodeIncRef(void *ptNode);
static SStep tsVnodeSteps[] = {
{"vsync", syncInit, syncCleanUp, 0},
{"vwrite", vnodeInitWrite, vnodeCleanupWrite, 1},
{"vread", vnodeInitRead, vnodeCleanupRead, 2},
{"vhash", vnodeInitHash, vnodeCleanupHash, 3},
{"vqueue", tsdbInitCommitQueue, tsdbDestroyCommitQueue, 4}
{"vsync", syncInit, syncCleanUp},
{"vwrite", vnodeInitWrite, vnodeCleanupWrite},
{"vread", vnodeInitRead, vnodeCleanupRead},
{"vhash", vnodeInitHash, vnodeCleanupHash},
{"vqueue", tsdbInitCommitQueue, tsdbDestroyCommitQueue}
};
int32_t vnodeInitMgmt() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册