提交 3d663ad8 编写于 作者: H Hongze Cheng

refactor more

上级 8c89576d
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
extern "C" { extern "C" {
#endif #endif
int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk); int tdInitMount(SDiskCfg *pDiskCfg, int ndisk);
void tdDestroyTiers(); void tdDestroyMount();
int tdUpdateDiskInfos(); int tdUpdateDiskInfos();
void tdGetPrimaryPath(char *dst); void tdGetPrimaryPath(char *dst);
......
...@@ -62,7 +62,7 @@ typedef struct STiers { ...@@ -62,7 +62,7 @@ typedef struct STiers {
static struct STiers tdTiers; static struct STiers tdTiers;
static struct STiers *pTiers = &tdTiers; static struct STiers *pTiers = &tdTiers;
int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk) { int tdInitMount(SDiskCfg *pDiskCfg, int ndisk) {
ASSERT(ndisk > 0); ASSERT(ndisk > 0);
memset((void *)pTiers, 0, sizeof(*pTiers)); memset((void *)pTiers, 0, sizeof(*pTiers));
...@@ -77,26 +77,26 @@ int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk) { ...@@ -77,26 +77,26 @@ int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk) {
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
if (pTiers->map == NULL) { if (pTiers->map == NULL) {
terrno = TSDB_CODE_COM_OUT_OF_MEMORY; terrno = TSDB_CODE_COM_OUT_OF_MEMORY;
tdDestroyTiers(); tdDestroyMount();
return -1; return -1;
} }
for (int idisk = 0; idisk < ndisk; idisk++) { for (int idisk = 0; idisk < ndisk; idisk++) {
if (tdAddDisk(pDiskCfg + idisk) < 0) { if (tdAddDisk(pDiskCfg + idisk) < 0) {
tdDestroyTiers(); tdDestroyMount();
return -1; return -1;
} }
} }
if (tdCheckTiers() < 0) { if (tdCheckTiers() < 0) {
tdDestroyTiers(); tdDestroyMount();
return -1; return -1;
} }
return 0; return 0;
} }
void tdDestroyTiers() { void tdDestroyMount() {
taosHashCleanup(pTiers->map); taosHashCleanup(pTiers->map);
pTiers->map = NULL; pTiers->map = NULL;
...@@ -144,13 +144,13 @@ static SDisk *tdGetPrimaryDisk() { return DISK_AT(0, 0); } ...@@ -144,13 +144,13 @@ static SDisk *tdGetPrimaryDisk() { return DISK_AT(0, 0); }
static int tdCheckTiers() { static int tdCheckTiers() {
ASSERT(pTiers->nLevel > 0); ASSERT(pTiers->nLevel > 0);
if (tdGetPrimaryDisk(pTiers) == NULL) { if (tdGetPrimaryDisk(pTiers) == NULL) {
terrno = TSDB_CODE_DND_LACK_PRIMARY_DISK; terrno = TSDB_CODE_COM_LACK_PRIMARY_DISK;
return -1; return -1;
} }
for (int i = 0; i < pTiers->nLevel; i++) { for (int i = 0; i < pTiers->nLevel; i++) {
if (pTiers->tiers[i].nDisks == 0) { if (pTiers->tiers[i].nDisks == 0) {
terrno = TSDB_CODE_DND_NO_DISK_AT_TIER; terrno = TSDB_CODE_COM_NO_DISK_AT_TIER;
return -1; return -1;
} }
} }
...@@ -179,7 +179,7 @@ static SDisk *tdAssignDisk(int level) { ...@@ -179,7 +179,7 @@ static SDisk *tdAssignDisk(int level) {
} }
if (pDisk == NULL) { if (pDisk == NULL) {
terrno = TSDB_CODE_DND_NO_DISK_SPACE; terrno = TSDB_CODE_COM_NO_DISK_SPACE;
tdUnLockTiers(pTiers); tdUnLockTiers(pTiers);
return NULL; return NULL;
} }
...@@ -266,7 +266,7 @@ static int tdCheckDisk(char *dirName) { ...@@ -266,7 +266,7 @@ static int tdCheckDisk(char *dirName) {
if (S_ISDIR(pstat.st_mode)) { if (S_ISDIR(pstat.st_mode)) {
return 0; return 0;
} else { } else {
terrno = TSDB_CODE_DND_DISK_NOT_DIRECTORY; terrno = TSDB_CODE_COM_DISK_NOT_DIRECTORY;
return -1; return -1;
} }
} }
...@@ -292,7 +292,7 @@ static int tdAddDisk(SDiskCfg *pCfg) { ...@@ -292,7 +292,7 @@ static int tdAddDisk(SDiskCfg *pCfg) {
SDisk * pDisk = NULL; SDisk * pDisk = NULL;
if (pCfg->level < 0 || pCfg->level >= TSDB_MAX_TIERS) { if (pCfg->level < 0 || pCfg->level >= TSDB_MAX_TIERS) {
terrno = TSDB_CODE_DND_INVALID_DISK_TIER; terrno = TSDB_CODE_COM_INVALID_DISK_TIER;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
...@@ -306,13 +306,13 @@ static int tdAddDisk(SDiskCfg *pCfg) { ...@@ -306,13 +306,13 @@ static int tdAddDisk(SDiskCfg *pCfg) {
diskid.level = pCfg->level; diskid.level = pCfg->level;
if (pTier->nDisks >= TSDB_MAX_DISKS_PER_TIER) { if (pTier->nDisks >= TSDB_MAX_DISKS_PER_TIER) {
terrno = TSDB_CODE_DND_TOO_MANY_DISKS; terrno = TSDB_CODE_COM_TOO_MANY_DISKS;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
if (tdGetDiskByName(dirName) != NULL) { if (tdGetDiskByName(dirName) != NULL) {
terrno = TSDB_CODE_DND_DISK_ALREADY_EXISTS; terrno = TSDB_CODE_COM_DISK_ALREADY_EXISTS;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
...@@ -324,13 +324,13 @@ static int tdAddDisk(SDiskCfg *pCfg) { ...@@ -324,13 +324,13 @@ static int tdAddDisk(SDiskCfg *pCfg) {
if (pCfg->primary) { if (pCfg->primary) {
if (pCfg->level != 0) { if (pCfg->level != 0) {
terrno = TSDB_CODE_DND_INVALID_DISK_TIER; terrno = TSDB_CODE_COM_INVALID_DISK_TIER;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
if (tdGetPrimaryDisk() != NULL) { if (tdGetPrimaryDisk() != NULL) {
terrno = TSDB_CODE_DND_DUPLICATE_PRIMARY_DISK; terrno = TSDB_CODE_COM_DUPLICATE_PRIMARY_DISK;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
...@@ -343,7 +343,7 @@ static int tdAddDisk(SDiskCfg *pCfg) { ...@@ -343,7 +343,7 @@ static int tdAddDisk(SDiskCfg *pCfg) {
} else { } else {
diskid.did = pTier->nDisks + 1; diskid.did = pTier->nDisks + 1;
if (diskid.did >= TSDB_MAX_DISKS_PER_TIER) { if (diskid.did >= TSDB_MAX_DISKS_PER_TIER) {
terrno = TSDB_CODE_DND_TOO_MANY_DISKS; terrno = TSDB_CODE_COM_TOO_MANY_DISKS;
uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno));
return -1; return -1;
} }
......
...@@ -183,7 +183,7 @@ static void dnodeCheckDataDirOpenned(char *dir) { ...@@ -183,7 +183,7 @@ static void dnodeCheckDataDirOpenned(char *dir) {
} }
static int32_t dnodeInitStorage() { static int32_t dnodeInitStorage() {
if (tdInitTiers(tsDiskCfg, tsDiskCfgNum) < 0) { if (tdInitMount(tsDiskCfg, tsDiskCfgNum) < 0) {
dError("failed to add disks to dnode tier since %s", tstrerror(terrno)); dError("failed to add disks to dnode tier since %s", tstrerror(terrno));
return -1; return -1;
} }
...@@ -230,7 +230,7 @@ static int32_t dnodeInitStorage() { ...@@ -230,7 +230,7 @@ static int32_t dnodeInitStorage() {
return 0; return 0;
} }
static void dnodeCleanupStorage() { tdDestroyTiers(); } static void dnodeCleanupStorage() { tdDestroyMount(); }
bool dnodeIsFirstDeploy() { bool dnodeIsFirstDeploy() {
return strcmp(tsFirst, tsLocalEp) == 0; return strcmp(tsFirst, tsLocalEp) == 0;
......
...@@ -80,6 +80,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, 0, 0x0107, "Ref ID is ...@@ -80,6 +80,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, 0, 0x0107, "Ref ID is
TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, 0, 0x0108, "Invalid Ref ID") TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, 0, 0x0108, "Invalid Ref ID")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, 0, 0x0109, "Ref is already there") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, 0, 0x0109, "Ref is already there")
TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, 0, 0x010A, "Ref is not there") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, 0, 0x010A, "Ref is not there")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_INVALID_DISK_TIER, 0, 0x010B, "Invalid disk tier setting")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_TOO_MANY_DISKS, 0, 0x010C, "Too many disks in one tier")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_DISK_ALREADY_EXISTS, 0, 0x010D, "Disk already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_DISK_NOT_DIRECTORY, 0, 0x010E, "Disk is not a directory")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_NO_DISK_SPACE, 0, 0x010F, "Dnode no disk space")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_DUPLICATE_PRIMARY_DISK, 0, 0x0110, "Duplicate primary disk")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_LACK_PRIMARY_DISK, 0, 0x0111, "Lack primary disk")
TAOS_DEFINE_ERROR(TSDB_CODE_COM_NO_DISK_AT_TIER, 0, 0x0112, "No disk at tier")
//client //client
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_SQL, 0, 0x0200, "Invalid SQL statement") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_SQL, 0, 0x0200, "Invalid SQL statement")
...@@ -188,14 +196,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message no ...@@ -188,14 +196,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message no
TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "Dnode out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "Dnode out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "No permission for disk files in dnode") TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "No permission for disk files in dnode")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "Invalid message length") TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "Invalid message length")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_DISK_TIER, 0, 0x0404, "Invalid disk tier setting")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_TOO_MANY_DISKS, 0, 0x0405, "Too many disks in one tier")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_ALREADY_EXISTS, 0, 0x0406, "Disk already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_NOT_DIRECTORY, 0, 0x0407, "Disk is not a directory")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_SPACE, 0, 0x0408, "Dnode no disk space")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_DUPLICATE_PRIMARY_DISK, 0, 0x0409, "Duplicate primary disk")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_LACK_PRIMARY_DISK, 0, 0x040A, "Lack primary disk")
TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_AT_TIER, 0, 0x040B, "No disk at tier")
// vnode // vnode
TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress") TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册