提交 c31c27a8 编写于 作者: H hzcheng

Merge branch 'develop' into feature/2.0tsdb

......@@ -78,8 +78,10 @@ typedef struct {
// --------- TSDB TABLE configuration
typedef struct {
ETableType type;
char * name;
STableId tableId;
int32_t sversion;
char * sname; // super table name
int64_t superUid;
STSchema * schema;
STSchema * tagSchema;
......@@ -91,6 +93,8 @@ int tsdbTableSetSuperUid(STableCfg *config, int64_t uid);
int tsdbTableSetSchema(STableCfg *config, STSchema *pSchema, bool dup);
int tsdbTableSetTagSchema(STableCfg *config, STSchema *pSchema, bool dup);
int tsdbTableSetTagValue(STableCfg *config, SDataRow row, bool dup);
int tsdbTableSetName(STableCfg *config, char *name, bool dup);
int tsdbTableSetSName(STableCfg *config, char *sname, bool dup);
void tsdbClearTableCfg(STableCfg *config);
int32_t tsdbGetTableTagVal(tsdb_repo_t *repo, STableId id, int32_t col, int16_t* type, int16_t* bytes, char** val);
......
......@@ -402,8 +402,10 @@ static int32_t mgmtCreateDnode(uint32_t ip) {
int32_t code = sdbInsertRow(&oper);
if (code != TSDB_CODE_SUCCESS) {
int dnodeId = pDnode->dnodeId;
tfree(pDnode);
code = TSDB_CODE_SDB_ERROR;
mError("failed to create dnode:%d, result:%s", dnodeId, tstrerror(code));
return TSDB_CODE_SDB_ERROR;
}
mPrint("dnode:%d is created, result:%s", pDnode->dnodeId, tstrerror(code));
......
......@@ -62,6 +62,7 @@ typedef struct {
// ---------- TSDB TABLE DEFINITION
typedef struct STable {
int8_t type;
char * name;
STableId tableId;
int64_t superUid; // Super table UID
int32_t sversion;
......
......@@ -462,10 +462,35 @@ int tsdbTableSetTagValue(STableCfg *config, SDataRow row, bool dup) {
return 0;
}
int tsdbTableSetName(STableCfg *config, char *name, bool dup) {
if (dup) {
config->name = strdup(name);
if (config->name == NULL) return -1;
} else {
config->name = name;
}
return 0;
}
int tsdbTableSetSName(STableCfg *config, char *sname, bool dup) {
if (config->type != TSDB_CHILD_TABLE) return -1;
if (dup) {
config->sname = strdup(sname);
if (config->sname == NULL) return -1;
} else {
config->sname = sname;
}
return 0;
}
void tsdbClearTableCfg(STableCfg *config) {
if (config->schema) tdFreeSchema(config->schema);
if (config->tagSchema) tdFreeSchema(config->tagSchema);
if (config->tagValues) tdFreeDataRow(config->tagValues);
tfree(config->name);
tfree(config->sname);
}
int tsdbInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
......
......@@ -39,6 +39,11 @@ void *tsdbEncodeTable(STable *pTable, int *contLen) {
void *ptr = ret;
T_APPEND_MEMBER(ptr, pTable, STable, type);
// Encode name
*(int *)ptr = strlen(pTable->name);
ptr = (char *)ptr + sizeof(int);
memcpy(ptr, pTable->name, strlen(pTable->name));
ptr = (char *)ptr + strlen(pTable->name);
T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, uid);
T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, tid);
T_APPEND_MEMBER(ptr, pTable, STable, superUid);
......@@ -72,6 +77,12 @@ STable *tsdbDecodeTable(void *cont, int contLen) {
void *ptr = cont;
T_READ_MEMBER(ptr, int8_t, pTable->type);
int len = *(int *)ptr;
ptr = (char *)ptr + sizeof(int);
pTable->name = calloc(1, len + 1);
if (pTable->name == NULL) return NULL;
memcpy(pTable->name, ptr, len);
ptr = (char *)ptr + len;
T_READ_MEMBER(ptr, int64_t, pTable->tableId.uid);
T_READ_MEMBER(ptr, int32_t, pTable->tableId.tid);
T_READ_MEMBER(ptr, int64_t, pTable->superUid);
......@@ -252,7 +263,8 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
super->schema = tdDupSchema(pCfg->schema);
super->tagSchema = tdDupSchema(pCfg->tagSchema);
super->tagVal = tdDataRowDup(pCfg->tagValues);
super->name = strdup(pCfg->sname);
// index the first tag column
STColumn* pColSchema = schemaColAt(super->tagSchema, 0);
super->pIndex = tSkipListCreate(TSDB_SUPER_TABLE_SL_LEVEL, pColSchema->type, pColSchema->bytes,
......@@ -277,6 +289,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
}
table->tableId = pCfg->tableId;
table->name = strdup(pCfg->name);
if (IS_CREATE_STABLE(pCfg)) { // TSDB_CHILD_TABLE
table->type = TSDB_CHILD_TABLE;
table->superUid = pCfg->superUid;
......@@ -374,6 +387,7 @@ static int tsdbFreeTable(STable *pTable) {
tsdbFreeMemTable(pTable->mem);
tsdbFreeMemTable(pTable->imem);
tfree(pTable->name);
free(pTable);
return 0;
}
......@@ -468,6 +482,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
static int tsdbEstimateTableEncodeSize(STable *pTable) {
int size = 0;
size += T_MEMBER_SIZE(STable, type);
size += sizeof(int) + strlen(pTable->name);
size += T_MEMBER_SIZE(STable, tableId);
size += T_MEMBER_SIZE(STable, superUid);
size += T_MEMBER_SIZE(STable, sversion);
......
......@@ -126,6 +126,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
tdSchemaAppendCol(pDestSchema, pSchema[i].type, htons(pSchema[i].colId), htons(pSchema[i].bytes));
}
tsdbTableSetSchema(&tCfg, pDestSchema, false);
tsdbTableSetName(&tCfg, pTable->tableId, false);
if (numOfTags != 0) {
STSchema *pDestTagSchema = tdNewSchema(numOfTags);
......@@ -133,6 +134,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
tdSchemaAppendCol(pDestTagSchema, pSchema[i].type, htons(pSchema[i].colId), htons(pSchema[i].bytes));
}
tsdbTableSetTagSchema(&tCfg, pDestTagSchema, false);
tsdbTableSetSName(&tCfg, pTable->superTableId, false);
char *pTagData = pTable->data + totalCols * sizeof(SSchema);
int accumBytes = 0;
......
......@@ -208,7 +208,10 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
}
}
if (count == 0) return 0;
if (count == 0) {
if (pWal->keep) code = walRenew(pWal);
return code;
}
if ( count != (maxId-minId+1) ) {
wError("wal:%s, messed up, count:%d max:%d min:%d", opath, count, maxId, minId);
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2
system sh/deploy.sh -n dnode3 -m 192.168.0.1 -i 192.168.0.3
system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3
system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3
system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3
system sh/exec_up.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode2 -s start
sql connect
sleep 2000
sql create dnode 192.168.0.2
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册