more code
This commit is contained in:
parent
7e61fc1291
commit
e5021e77ea
|
@ -20,6 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct SDnodeTier;
|
||||||
|
|
||||||
// cluster
|
// cluster
|
||||||
extern char tsFirst[];
|
extern char tsFirst[];
|
||||||
extern char tsSecond[];
|
extern char tsSecond[];
|
||||||
|
@ -156,6 +158,9 @@ extern char gitinfo[];
|
||||||
extern char gitinfoOfInternal[];
|
extern char gitinfoOfInternal[];
|
||||||
extern char buildinfo[];
|
extern char buildinfo[];
|
||||||
|
|
||||||
|
// dnode
|
||||||
|
extern struct SDnodeTier *pDnodeTier;
|
||||||
|
|
||||||
// log
|
// log
|
||||||
extern int32_t tsAsyncLog;
|
extern int32_t tsAsyncLog;
|
||||||
extern int32_t tsNumOfLogLines;
|
extern int32_t tsNumOfLogLines;
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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 _TD_TPATH_H_
|
||||||
|
#define _TD_TPATH_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "taosdef.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetMnodeRootDir(char *rootDir, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/mnode", rootDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetDnodeRootDir(char *rootDir, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/dnode", rootDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetVnodeRootDir(char *rootDir, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/vnode", rootDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetVnodeBackRootDir(char *rootDir, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/vnode_bak", rootDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetVnodeDir(char *rootDir, int vid, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/vnode/vnode%d", rootDir, vid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tdGetVnodeBackDir(char *rootDir, int vid, char *dirName) {
|
||||||
|
snprintf(dirName, TSDB_FILENAME_LEN, "%s/vnode_bak/vnode%d", rootDir, vid);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _TD_TPATH_H_
|
|
@ -32,8 +32,9 @@
|
||||||
#include "dnodeMPeer.h"
|
#include "dnodeMPeer.h"
|
||||||
#include "dnodeShell.h"
|
#include "dnodeShell.h"
|
||||||
#include "dnodeTelemetry.h"
|
#include "dnodeTelemetry.h"
|
||||||
|
#include "tpath.h"
|
||||||
|
|
||||||
SDnodeTier *pDnodeTier = NULL;
|
struct SDnodeTier *pDnodeTier = NULL;
|
||||||
|
|
||||||
static int32_t dnodeInitStorage();
|
static int32_t dnodeInitStorage();
|
||||||
static void dnodeCleanupStorage();
|
static void dnodeCleanupStorage();
|
||||||
|
@ -181,32 +182,38 @@ static int32_t dnodeInitStorage() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dnodeCreateDir(tsDataDir) < 0) {
|
|
||||||
dError("failed to create dir: %s, reason: %s", tsDataDir, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
sprintf(tsMnodeDir, "%s/mnode", tsDataDir);
|
|
||||||
sprintf(tsVnodeDir, "%s/vnode", tsDataDir);
|
|
||||||
sprintf(tsDnodeDir, "%s/dnode", tsDataDir);
|
|
||||||
sprintf(tsVnodeBakDir, "%s/vnode_bak", tsDataDir);
|
|
||||||
|
|
||||||
//TODO(dengyihao): no need to init here
|
//TODO(dengyihao): no need to init here
|
||||||
|
tdGetMnodeRootDir(DNODE_PRIMARY_DISK(pDnodeTier)->dir, tsMnodeDir);
|
||||||
if (dnodeCreateDir(tsMnodeDir) < 0) {
|
if (dnodeCreateDir(tsMnodeDir) < 0) {
|
||||||
dError("failed to create dir: %s, reason: %s", tsMnodeDir, strerror(errno));
|
dError("failed to create dir: %s, reason: %s", tsMnodeDir, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//TODO(dengyihao): no need to init here
|
|
||||||
if (dnodeCreateDir(tsVnodeDir) < 0) {
|
tdGetDnodeRootDir(DNODE_PRIMARY_DISK(pDnodeTier)->dir, tsDnodeDir);
|
||||||
dError("failed to create dir: %s, reason: %s", tsVnodeDir, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (dnodeCreateDir(tsDnodeDir) < 0) {
|
if (dnodeCreateDir(tsDnodeDir) < 0) {
|
||||||
dError("failed to create dir: %s, reason: %s", tsDnodeDir, strerror(errno));
|
dError("failed to create dir: %s, reason: %s", tsDnodeDir, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (dnodeCreateDir(tsVnodeBakDir) < 0) {
|
|
||||||
dError("failed to create dir: %s, reason: %s", tsVnodeBakDir, strerror(errno));
|
for (int i = 0; i < pDnodeTier->nTiers; i++) {
|
||||||
return -1;
|
char dirName[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
|
STier *pTier = pDnodeTier->tiers + i;
|
||||||
|
for (int j = 0; j < pTier->nDisks; j++) {
|
||||||
|
SDisk *pDisk = dnodeGetDisk(pDnodeTier, i, j);
|
||||||
|
|
||||||
|
tdGetVnodeRootDir(dirName, pDisk->dir);
|
||||||
|
if (dnodeCreateDir(dirName) < 0) {
|
||||||
|
dError("failed to create dir: %s, reason: %s", dirName, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tdGetVnodeBackRootDir(dirName, pDisk->dir);
|
||||||
|
if (dnodeCreateDir(dirName) < 0) {
|
||||||
|
dError("failed to create dir: %s, reason: %s", dirName, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeCheckDataDirOpenned(tsDnodeDir);
|
dnodeCheckDataDirOpenned(tsDnodeDir);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "vnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
|
#include "tpath.h"
|
||||||
|
|
||||||
#define TSDB_VNODE_VERSION_CONTENT_LEN 31
|
#define TSDB_VNODE_VERSION_CONTENT_LEN 31
|
||||||
|
|
||||||
|
@ -395,17 +396,28 @@ void vnodeRelease(void *pVnodeRaw) {
|
||||||
if (pVnode->dropped) {
|
if (pVnode->dropped) {
|
||||||
char rootDir[TSDB_FILENAME_LEN] = {0};
|
char rootDir[TSDB_FILENAME_LEN] = {0};
|
||||||
char newDir[TSDB_FILENAME_LEN] = {0};
|
char newDir[TSDB_FILENAME_LEN] = {0};
|
||||||
sprintf(rootDir, "%s/vnode%d", tsVnodeDir, vgId);
|
|
||||||
sprintf(newDir, "%s/vnode%d", tsVnodeBakDir, vgId);
|
|
||||||
|
|
||||||
if (0 == tsEnableVnodeBak) {
|
for (int i = 0; i < pDnodeTier->nTiers; i++) {
|
||||||
vInfo("vgId:%d, vnode backup not enabled", pVnode->vgId);
|
STier *pTier = pDnodeTier->tiers + i;
|
||||||
} else {
|
for (int j = 0; j < pTier->nDisks; j++) {
|
||||||
taosRemoveDir(newDir);
|
SDisk *pDisk = pTier->disks[j];
|
||||||
taosRename(rootDir, newDir);
|
|
||||||
|
tdGetVnodeDir(pDisk->dir, vgId, rootDir);
|
||||||
|
tdGetVnodeBackDir(pDisk->dir, vgId, newDir);
|
||||||
|
|
||||||
|
if (access(rootDir, F_OK) == 0) {
|
||||||
|
if (0 == tsEnableVnodeBak) {
|
||||||
|
vInfo("vgId:%d, vnode backup not enabled", pVnode->vgId);
|
||||||
|
} else {
|
||||||
|
taosRemoveDir(newDir);
|
||||||
|
taosRename(rootDir, newDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosRemoveDir(rootDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRemoveDir(rootDir);
|
|
||||||
dnodeSendStatusMsgToMnode();
|
dnodeSendStatusMsgToMnode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue