提交 4910ea29 编写于 作者: S Shengliang Guan

rename some variables

上级 2bdccc20
...@@ -27,7 +27,7 @@ extern "C" { ...@@ -27,7 +27,7 @@ extern "C" {
(dataLen) -= (valLen); \ (dataLen) -= (valLen); \
(pData) = (char *)(pData) + (valLen); \ (pData) = (char *)(pData) + (valLen); \
} else { \ } else { \
code = TSDB_CODE_SDB_INVAID_RAW_DATA_LEN; \ code = TSDB_CODE_SDB_INVALID_DATA_LEN; \
} \ } \
} }
...@@ -38,7 +38,7 @@ extern "C" { ...@@ -38,7 +38,7 @@ extern "C" {
(dataLen) -= sizeof(int32_t); \ (dataLen) -= sizeof(int32_t); \
(pData) = (char *)(pData) + sizeof(int32_t); \ (pData) = (char *)(pData) + sizeof(int32_t); \
} else { \ } else { \
code = TSDB_CODE_SDB_INVAID_RAW_DATA_LEN; \ code = TSDB_CODE_SDB_INVALID_DATA_LEN; \
} \ } \
} }
...@@ -49,7 +49,7 @@ extern "C" { ...@@ -49,7 +49,7 @@ extern "C" {
(dataLen) -= sizeof(int64_t); \ (dataLen) -= sizeof(int64_t); \
(pData) = (char *)(pData) + sizeof(int64_t); \ (pData) = (char *)(pData) + sizeof(int64_t); \
} else { \ } else { \
code = TSDB_CODE_SDB_INVAID_RAW_DATA_LEN; \ code = TSDB_CODE_SDB_INVALID_DATA_LEN; \
} \ } \
} }
...@@ -121,11 +121,11 @@ typedef struct { ...@@ -121,11 +121,11 @@ typedef struct {
SdbInsertFp insertFp; SdbInsertFp insertFp;
SdbUpdateFp updateFp; SdbUpdateFp updateFp;
SdbDeleteFp deleteFp; SdbDeleteFp deleteFp;
} SSdbHandle; } SSdbTable;
int32_t sdbInit(); int32_t sdbInit();
void sdbCleanup(); void sdbCleanup();
void sdbSetHandle(SSdbHandle handle); void sdbSetTable(SSdbTable table);
int32_t sdbRead(); int32_t sdbRead();
int32_t sdbWrite(SSdbRaw *pRaw); int32_t sdbWrite(SSdbRaw *pRaw);
......
...@@ -134,15 +134,16 @@ int32_t* taosGetErrno(); ...@@ -134,15 +134,16 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314) //"failed to init components") #define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314) //"failed to init components")
#define TSDB_CODE_SDB_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0320) #define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0320)
#define TSDB_CODE_SDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0321) #define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0321)
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0322) #define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0322)
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323) #define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0323)
#define TSDB_CODE_SDB_INVAID_RAW_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0324) #define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0324)
#define TSDB_CODE_SDB_INVAID_RAW_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0325) #define TSDB_CODE_SDB_INVALID_ACTION_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325)
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326) #define TSDB_CODE_SDB_INVALID_STATUS_TYPE TAOS_DEF_ERROR_CODE(0, 0x0326)
#define TSDB_CODE_SDB_INVAID_META_ROW TAOS_DEF_ERROR_CODE(0, 0x0327) #define TSDB_CODE_SDB_INVALID_DATA_VER TAOS_DEF_ERROR_CODE(0, 0x0327)
#define TSDB_CODE_SDB_INVAID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0328) #define TSDB_CODE_SDB_INVALID_DATA_LEN TAOS_DEF_ERROR_CODE(0, 0x0328)
#define TSDB_CODE_SDB_INVALID_META_ROW TAOS_DEF_ERROR_CODE(0, 0x0329)
#define TSDB_CODE_MND_DNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0330) //"DNode already exists") #define TSDB_CODE_MND_DNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0330) //"DNode already exists")
#define TSDB_CODE_MND_DNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0331) //"DNode does not exist") #define TSDB_CODE_MND_DNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0331) //"DNode does not exist")
......
...@@ -47,7 +47,7 @@ static SSdbRaw *mnodeAcctActionEncode(SAcctObj *pAcct) { ...@@ -47,7 +47,7 @@ static SSdbRaw *mnodeAcctActionEncode(SAcctObj *pAcct) {
static SAcctObj *mnodeAcctActionDecode(SSdbRaw *pRaw) { static SAcctObj *mnodeAcctActionDecode(SSdbRaw *pRaw) {
if (pRaw->sver != ACCT_VER) { if (pRaw->sver != ACCT_VER) {
terrno = TSDB_CODE_SDB_INVAID_RAW_DATA_VER; terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
return NULL; return NULL;
} }
...@@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() { ...@@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() {
} }
int32_t mnodeInitAcct() { int32_t mnodeInitAcct() {
SSdbHandle handle = {.sdbType = SDB_ACCT, SSdbTable table = {.sdbType = SDB_ACCT,
.keyType = SDB_KEY_BINARY, .keyType = SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)mnodeCreateDefaultAcct, .deployFp = (SdbDeployFp)mnodeCreateDefaultAcct,
.encodeFp = (SdbEncodeFp)mnodeAcctActionEncode, .encodeFp = (SdbEncodeFp)mnodeAcctActionEncode,
.decodeFp = (SdbDecodeFp)mnodeAcctActionDecode, .decodeFp = (SdbDecodeFp)mnodeAcctActionDecode,
.insertFp = (SdbInsertFp)mnodeAcctActionInsert, .insertFp = (SdbInsertFp)mnodeAcctActionInsert,
.updateFp = (SdbUpdateFp)mnodeAcctActionUpdate, .updateFp = (SdbUpdateFp)mnodeAcctActionUpdate,
.deleteFp = (SdbDeleteFp)mnodeAcctActionDelete}; .deleteFp = (SdbDeleteFp)mnodeAcctActionDelete};
sdbSetHandle(handle); sdbSetTable(table);
return 0; return 0;
} }
......
...@@ -45,7 +45,7 @@ static SSdbRaw *mnodeUserActionEncode(SUserObj *pUser) { ...@@ -45,7 +45,7 @@ static SSdbRaw *mnodeUserActionEncode(SUserObj *pUser) {
static SUserObj *mnodeUserActionDecode(SSdbRaw *pRaw) { static SUserObj *mnodeUserActionDecode(SSdbRaw *pRaw) {
if (pRaw->sver != USER_VER) { if (pRaw->sver != USER_VER) {
terrno = TSDB_CODE_SDB_INVAID_RAW_DATA_VER; terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
return NULL; return NULL;
} }
...@@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) { ...@@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) {
} }
int32_t mnodeInitUser() { int32_t mnodeInitUser() {
SSdbHandle handle = {.sdbType = SDB_USER, SSdbTable table = {.sdbType = SDB_USER,
.keyType = SDB_KEY_BINARY, .keyType = SDB_KEY_BINARY,
.deployFp = (SdbDeployFp)mnodeCreateDefaultUsers, .deployFp = (SdbDeployFp)mnodeCreateDefaultUsers,
.encodeFp = (SdbEncodeFp)mnodeUserActionEncode, .encodeFp = (SdbEncodeFp)mnodeUserActionEncode,
.decodeFp = (SdbDecodeFp)mnodeUserActionDecode, .decodeFp = (SdbDecodeFp)mnodeUserActionDecode,
.insertFp = (SdbInsertFp)mnodeUserActionInsert, .insertFp = (SdbInsertFp)mnodeUserActionInsert,
.updateFp = (SdbUpdateFp)mnodeUserActionUpdate, .updateFp = (SdbUpdateFp)mnodeUserActionUpdate,
.deleteFp = (SdbDeleteFp)mnodeUserActionDelete}; .deleteFp = (SdbDeleteFp)mnodeUserActionDelete};
sdbSetHandle(handle); sdbSetTable(table);
return 0; return 0;
} }
......
...@@ -21,17 +21,20 @@ static SSdbMgr tsSdb = {0}; ...@@ -21,17 +21,20 @@ static SSdbMgr tsSdb = {0};
static int32_t sdbCreateDir() { static int32_t sdbCreateDir() {
if (!taosMkDir(tsSdb.currDir)) { if (!taosMkDir(tsSdb.currDir)) {
mError("failed to create dir:%s", tsSdb.currDir); terrno = TAOS_SYSTEM_ERROR(errno);
return TAOS_SYSTEM_ERROR(errno); mError("failed to create dir:%s since %s", tsSdb.currDir, terrstr());
return -1;
} }
if (!taosMkDir(tsSdb.syncDir)) { if (!taosMkDir(tsSdb.syncDir)) {
mError("failed to create dir:%s", tsSdb.syncDir); terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", tsSdb.syncDir, terrstr());
return -1; return -1;
} }
if (!taosMkDir(tsSdb.tmpDir)) { if (!taosMkDir(tsSdb.tmpDir)) {
mError("failed to create dir:%s", tsSdb.tmpDir); terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to create dir:%s since %s", tsSdb.tmpDir, terrstr());
return -1; return -1;
} }
...@@ -41,8 +44,10 @@ static int32_t sdbCreateDir() { ...@@ -41,8 +44,10 @@ static int32_t sdbCreateDir() {
static int32_t sdbRunDeployFp() { static int32_t sdbRunDeployFp() {
for (int32_t i = SDB_START; i < SDB_MAX; ++i) { for (int32_t i = SDB_START; i < SDB_MAX; ++i) {
SdbDeployFp fp = tsSdb.deployFps[i]; SdbDeployFp fp = tsSdb.deployFps[i];
if (fp) { if (fp == NULL) continue;
(*fp)(); if ((*fp)() != 0) {
mError("failed to deploy sdb:%d since %s", i, terrstr());
return -1;
} }
} }
...@@ -51,11 +56,13 @@ static int32_t sdbRunDeployFp() { ...@@ -51,11 +56,13 @@ static int32_t sdbRunDeployFp() {
static SHashObj *sdbGetHash(int32_t sdb) { static SHashObj *sdbGetHash(int32_t sdb) {
if (sdb >= SDB_MAX || sdb <= SDB_START) { if (sdb >= SDB_MAX || sdb <= SDB_START) {
terrno = TSDB_CODE_SDB_INVALID_TABLE_TYPE;
return NULL; return NULL;
} }
SHashObj *hash = tsSdb.hashObjs[sdb]; SHashObj *hash = tsSdb.hashObjs[sdb];
if (hash == NULL) { if (hash == NULL) {
terrno = TSDB_CODE_SDB_APP_ERROR;
return NULL; return NULL;
} }
...@@ -112,7 +119,7 @@ static int32_t sdbReadDataFile() { ...@@ -112,7 +119,7 @@ static int32_t sdbReadDataFile() {
} }
if (ret < sizeof(SSdbRaw)) { if (ret < sizeof(SSdbRaw)) {
code = TSDB_CODE_SDB_INTERNAL_ERROR; code = TSDB_CODE_SDB_APP_ERROR;
mError("failed to read file:%s since %s", file, tstrerror(code)); mError("failed to read file:%s since %s", file, tstrerror(code));
break; break;
} }
...@@ -159,7 +166,7 @@ static int32_t sdbWriteDataFile() { ...@@ -159,7 +166,7 @@ static int32_t sdbWriteDataFile() {
taosWriteFile(fd, pRaw, sizeof(SSdbRaw) + pRaw->dataLen); taosWriteFile(fd, pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
} else { } else {
taosHashCancelIterate(hash, pRow); taosHashCancelIterate(hash, pRow);
code = TSDB_CODE_SDB_INTERNAL_ERROR; code = TSDB_CODE_SDB_APP_ERROR;
break; break;
} }
...@@ -232,7 +239,7 @@ void sdbUnDeploy() {} ...@@ -232,7 +239,7 @@ void sdbUnDeploy() {}
int32_t sdbInit() { int32_t sdbInit() {
char path[PATH_MAX + 100]; char path[PATH_MAX + 100];
snprintf(path, PATH_MAX + 100, "%s%scurrent%s", tsMnodeDir, TD_DIRSEP, TD_DIRSEP); snprintf(path, PATH_MAX + 100, "%s%scur%s", tsMnodeDir, TD_DIRSEP, TD_DIRSEP);
tsSdb.currDir = strdup(path); tsSdb.currDir = strdup(path);
snprintf(path, PATH_MAX + 100, "%s%ssync%s", tsMnodeDir, TD_DIRSEP, TD_DIRSEP); snprintf(path, PATH_MAX + 100, "%s%ssync%s", tsMnodeDir, TD_DIRSEP, TD_DIRSEP);
...@@ -293,15 +300,15 @@ void sdbCleanup() { ...@@ -293,15 +300,15 @@ void sdbCleanup() {
} }
} }
void sdbSetHandle(SSdbHandle handle) { void sdbSetTable(SSdbTable table) {
ESdbType sdb = handle.sdbType; ESdbType sdb = table.sdbType;
tsSdb.keyTypes[sdb] = handle.keyType; tsSdb.keyTypes[sdb] = table.keyType;
tsSdb.insertFps[sdb] = handle.insertFp; tsSdb.insertFps[sdb] = table.insertFp;
tsSdb.updateFps[sdb] = handle.updateFp; tsSdb.updateFps[sdb] = table.updateFp;
tsSdb.deleteFps[sdb] = handle.deleteFp; tsSdb.deleteFps[sdb] = table.deleteFp;
tsSdb.deployFps[sdb] = handle.deployFp; tsSdb.deployFps[sdb] = table.deployFp;
tsSdb.encodeFps[sdb] = handle.encodeFp; tsSdb.encodeFps[sdb] = table.encodeFp;
tsSdb.decodeFps[sdb] = handle.decodeFp; tsSdb.decodeFps[sdb] = table.decodeFp;
} }
#if 0 #if 0
......
...@@ -61,7 +61,7 @@ SSdbRaw *trnActionEncode(STrans *pTrans) { ...@@ -61,7 +61,7 @@ SSdbRaw *trnActionEncode(STrans *pTrans) {
STrans *trnActionDecode(SSdbRaw *pRaw) { STrans *trnActionDecode(SSdbRaw *pRaw) {
if (pRaw->sver != TRN_VER) { if (pRaw->sver != TRN_VER) {
terrno = TSDB_CODE_SDB_INVAID_RAW_DATA_VER; terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
return NULL; return NULL;
} }
...@@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) { ...@@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
} }
int32_t trnInit() { int32_t trnInit() {
SSdbHandle handle = {.sdbType = SDB_TRANS, SSdbTable table = {.sdbType = SDB_TRANS,
.keyType = SDB_KEY_INT32, .keyType = SDB_KEY_INT32,
.encodeFp = (SdbEncodeFp)trnActionEncode, .encodeFp = (SdbEncodeFp)trnActionEncode,
.decodeFp = (SdbDecodeFp)trnActionDecode, .decodeFp = (SdbDecodeFp)trnActionDecode,
.insertFp = (SdbInsertFp)trnActionInsert, .insertFp = (SdbInsertFp)trnActionInsert,
.updateFp = (SdbUpdateFp)trnActionUpdate, .updateFp = (SdbUpdateFp)trnActionUpdate,
.deleteFp = (SdbDeleteFp)trnActionDelete}; .deleteFp = (SdbDeleteFp)trnActionDelete};
sdbSetHandle(handle); sdbSetTable(table);
return 0; return 0;
} }
......
...@@ -144,15 +144,16 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_START_SYNC, "failed to start sync" ...@@ -144,15 +144,16 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_START_SYNC, "failed to start sync"
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_CREATE_DIR, "failed to create mnode dir") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_CREATE_DIR, "failed to create mnode dir")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_INIT_STEP, "failed to init components") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FAILED_TO_INIT_STEP, "failed to init components")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INTERNAL_ERROR, "Unexpected generic error in sdb") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_APP_ERROR, "Unexpected generic error in sdb")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OUT_OF_MEMORY, "Out of memory in sdb")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_ALREADY_THERE, "Object already there") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_ALREADY_THERE, "Object already there")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_NOT_THERE, "Object not there") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_NOT_THERE, "Object not there")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVAID_RAW_DATA_VER, "Invalid raw data version")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVAID_RAW_DATA_LEN, "Invalid raw data len")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_TABLE_TYPE, "Invalid table type") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_TABLE_TYPE, "Invalid table type")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVAID_META_ROW, "Invalid meta row") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_KEY_TYPE, "Invalid key type")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVAID_KEY_TYPE, "Invalid key type") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_ACTION_TYPE, "Invalid action type")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_STATUS_TYPE, "Invalid status type")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_DATA_VER, "Invalid raw data version")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_DATA_LEN, "Invalid raw data len")
TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_META_ROW, "Invalid meta row")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, "DNode already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, "DNode already exists")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, "DNode does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, "DNode does not exist")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册