TD-1843
This commit is contained in:
parent
8b4e85dd09
commit
4cc2e9038d
|
@ -19,9 +19,12 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "dnode.h"
|
||||
|
||||
void dnodeReportStep(char *name, char *desc, int8_t finished);
|
||||
void dnodeSendStartupStep(SRpcMsg *pMsg);
|
||||
int32_t dnodeStepInit(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeStepCleanup(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeReportStep(char *name, char *desc, int8_t finished);
|
||||
void dnodeSendStartupStep(SRpcMsg *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "tconfig.h"
|
||||
#include "tglobal.h"
|
||||
#include "tfile.h"
|
||||
#include "tstep.h"
|
||||
#include "twal.h"
|
||||
#include "trpc.h"
|
||||
#include "dnode.h"
|
||||
|
@ -83,12 +82,12 @@ static int dnodeCreateDir(const char *dir) {
|
|||
|
||||
static void dnodeCleanupComponents() {
|
||||
int32_t stepSize = sizeof(tsDnodeSteps) / sizeof(SStep);
|
||||
taosStepCleanup(tsDnodeSteps, stepSize);
|
||||
dnodeStepCleanup(tsDnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
static int32_t dnodeInitComponents() {
|
||||
int32_t stepSize = sizeof(tsDnodeSteps) / sizeof(SStep);
|
||||
return taosStepInit(tsDnodeSteps, stepSize);
|
||||
return dnodeStepInit(tsDnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
int32_t dnodeInitSystem() {
|
||||
|
|
|
@ -58,8 +58,6 @@ int32_t dnodeInitServer() {
|
|||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMPeerQueue;
|
||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMPeerQueue;
|
||||
|
||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_NETWORK_TEST] = dnodeSendStartupStep;
|
||||
|
||||
SRpcInit rpcInit;
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.localPort = tsDnodeDnodePort;
|
||||
|
@ -94,8 +92,9 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
|||
.pCont = NULL,
|
||||
.contLen = 0
|
||||
};
|
||||
|
||||
|
||||
if (pMsg->pCont == NULL) return;
|
||||
if (pMsg->msgType == TSDB_MSG_TYPE_NETWORK_TEST) return dnodeSendStartupStep(pMsg);
|
||||
|
||||
if (dnodeGetRunStatus() != TSDB_RUN_STATUS_RUNING) {
|
||||
rspMsg.code = TSDB_CODE_APP_NOT_READY;
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
#include "taosmsg.h"
|
||||
#include "dnodeInt.h"
|
||||
#include "dnodeStep.h"
|
||||
|
||||
static SStartupStep tsStartupStep;
|
||||
|
||||
|
@ -39,7 +41,43 @@ void dnodeSendStartupStep(SRpcMsg *pMsg) {
|
|||
if (step > 10) pStep->finished = 1;
|
||||
#endif
|
||||
|
||||
dDebug("startup msg is sent, step:%s desc:%s finished:%d", pStep->name, pStep->desc, pStep->finished);
|
||||
|
||||
SRpcMsg rpcRsp = {.handle = pMsg->handle, .pCont = pStep, .contLen = sizeof(SStartupStep)};
|
||||
rpcSendResponse(&rpcRsp);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
}
|
||||
|
||||
void taosStepCleanupImp(SStep *pSteps, int32_t stepId) {
|
||||
for (int32_t step = stepId; step >= 0; step--) {
|
||||
SStep *pStep = pSteps + step;
|
||||
dDebug("step:%s will cleanup", pStep->name);
|
||||
if (pStep->cleanupFp != NULL) {
|
||||
(*pStep->cleanupFp)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t dnodeStepInit(SStep *pSteps, int32_t stepSize) {
|
||||
for (int32_t step = 0; step < stepSize; step++) {
|
||||
SStep *pStep = pSteps + step;
|
||||
if (pStep->initFp == NULL) continue;
|
||||
|
||||
dnodeReportStep(pStep->name, "Start initialization", 0);
|
||||
|
||||
int32_t code = (*pStep->initFp)();
|
||||
if (code != 0) {
|
||||
dDebug("step:%s will init", pStep->name);
|
||||
taosStepCleanupImp(pSteps, step);
|
||||
return code;
|
||||
}
|
||||
|
||||
dnodeReportStep(pStep->name, "Initialization complete", step + 1 >= stepSize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dnodeStepCleanup(SStep *pSteps, int32_t stepSize) {
|
||||
return taosStepCleanupImp(pSteps, stepSize - 1);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,14 @@ void dnodeDelayReprocessMWriteMsg(void *pMsg);
|
|||
|
||||
void dnodeSendStatusMsgToMnode();
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int32_t (*initFp)();
|
||||
void (*cleanupFp)();
|
||||
} SStep;
|
||||
|
||||
int32_t dnodeStepInit(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeStepCleanup(SStep *pSteps, int32_t stepSize);
|
||||
void dnodeReportStep(char *name, char *desc, int8_t finished);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "tgrant.h"
|
||||
#include "ttimer.h"
|
||||
#include "tglobal.h"
|
||||
#include "tstep.h"
|
||||
#include "mnode.h"
|
||||
#include "dnode.h"
|
||||
#include "mnodeDef.h"
|
||||
|
@ -64,12 +63,12 @@ static bool mnodeNeedStart() ;
|
|||
|
||||
static void mnodeCleanupComponents() {
|
||||
int32_t stepSize = sizeof(tsMnodeSteps) / sizeof(SStep);
|
||||
taosStepCleanup(tsMnodeSteps, stepSize);
|
||||
dnodeStepCleanup(tsMnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
static int32_t mnodeInitComponents() {
|
||||
int32_t stepSize = sizeof(tsMnodeSteps) / sizeof(SStep);
|
||||
return taosStepInit(tsMnodeSteps, stepSize);
|
||||
return dnodeStepInit(tsMnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
int32_t mnodeStartSystem() {
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* 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 TDENGINE_TSTEP_H
|
||||
#define TDENGINE_TSTEP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const char *const name;
|
||||
int32_t (*initFp)();
|
||||
void (*cleanupFp)();
|
||||
} SStep;
|
||||
|
||||
int32_t taosStepInit(SStep *pSteps, int32_t stepSize);
|
||||
void taosStepCleanup(SStep *pSteps, int32_t stepSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_TUTIL_H
|
|
@ -355,7 +355,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
|
|||
pRpcConn = taosNetInitRpc(secretEncrypt, spi);
|
||||
if (NULL == pRpcConn) {
|
||||
uError("failed to init client rpc");
|
||||
return -1;
|
||||
return TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
}
|
||||
|
||||
memset(&epSet, 0, sizeof(SRpcEpSet));
|
||||
|
@ -376,7 +376,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
|
|||
|
||||
if ((rspMsg.code != 0) || (rspMsg.msgType != TSDB_MSG_TYPE_NETWORK_TEST + 1)) {
|
||||
uDebug("ret code 0x%x %s", rspMsg.code, tstrerror(rspMsg.code));
|
||||
return -1;
|
||||
return rspMsg.code;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
|
@ -406,7 +406,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
|
|||
|
||||
SStartupStep *pStep = malloc(sizeof(SStartupStep));
|
||||
while (1) {
|
||||
int32_t code = taosNetCheckRpc(host, port, 20, 0, pStep);
|
||||
int32_t code = taosNetCheckRpc(host, port + TSDB_PORT_DNODEDNODE, 20, 0, pStep);
|
||||
if (code > 0) {
|
||||
code = taosNetParseStartup(pStep);
|
||||
}
|
||||
|
@ -414,9 +414,11 @@ static void taosNetTestStartup(char *host, int32_t port) {
|
|||
if (code > 0) {
|
||||
uDebug("continue check startup step");
|
||||
} else {
|
||||
if (code < 0) {
|
||||
uError("failed to check startup step, code:0x%x %s", code, tstrerror(code));
|
||||
}
|
||||
break;
|
||||
}
|
||||
taosMsleep(500);
|
||||
}
|
||||
|
||||
free(pStep);
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "tstep.h"
|
||||
#include "tulog.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
void taosStepCleanupImp(SStep *pSteps, int32_t stepId) {
|
||||
for (int32_t step = stepId; step >= 0; step--) {
|
||||
SStep *pStep = pSteps + step;
|
||||
uDebug("step:%s will cleanup", pStep->name);
|
||||
if (pStep->cleanupFp != NULL) {
|
||||
(*pStep->cleanupFp)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t taosStepInit(SStep *pSteps, int32_t stepSize) {
|
||||
for (int32_t step = 0; step < stepSize; step++) {
|
||||
SStep *pStep = pSteps + step;
|
||||
if (pStep->initFp == NULL) continue;
|
||||
|
||||
int32_t code = (*pStep->initFp)();
|
||||
if (code != 0) {
|
||||
uDebug("step:%s will init", pStep->name);
|
||||
taosStepCleanupImp(pSteps, step);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void taosStepCleanup(SStep *pSteps, int32_t stepSize) {
|
||||
return taosStepCleanupImp(pSteps, stepSize - 1);
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "tstep.h"
|
||||
#include "dnode.h"
|
||||
#include "vnodeStatus.h"
|
||||
#include "vnodeRead.h"
|
||||
#include "vnodeWrite.h"
|
||||
|
@ -37,12 +37,12 @@ static SStep tsVnodeSteps[] = {
|
|||
|
||||
int32_t vnodeInitMgmt() {
|
||||
int32_t stepSize = sizeof(tsVnodeSteps) / sizeof(SStep);
|
||||
return taosStepInit(tsVnodeSteps, stepSize);
|
||||
return dnodeStepInit(tsVnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
void vnodeCleanupMgmt() {
|
||||
int32_t stepSize = sizeof(tsVnodeSteps) / sizeof(SStep);
|
||||
taosStepCleanup(tsVnodeSteps, stepSize);
|
||||
dnodeStepCleanup(tsVnodeSteps, stepSize);
|
||||
}
|
||||
|
||||
static int32_t vnodeInitHash() {
|
||||
|
|
Loading…
Reference in New Issue