diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h index 78f91cca64c7a22c43246f1eb8390466f2150d06..67b4f8692e412f161239fa0e1c3f156c36acc50c 100644 --- a/include/common/taosmsg.h +++ b/include/common/taosmsg.h @@ -361,6 +361,8 @@ typedef struct { } SConnectRsp; typedef struct { + char user[TSDB_USER_LEN]; + char pass[TSDB_KEY_LEN]; int32_t maxUsers; int32_t maxDbs; int32_t maxTimeSeries; @@ -372,12 +374,6 @@ typedef struct { int64_t maxInbound; int64_t maxOutbound; int8_t accessState; // Configured only by command -} SAcctCfg; - -typedef struct { - char user[TSDB_USER_LEN]; - char pass[TSDB_KEY_LEN]; - SAcctCfg cfg; } SCreateAcctMsg, SAlterAcctMsg; typedef struct { diff --git a/include/util/taoserror.h b/include/util/taoserror.h index c3f3e3b98b5414ae0f7b08e0b977b70764d8216f..cf8cd510c5e848ae3310f0e70873c9598b0266c9 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -166,6 +166,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_NO_USER_FROM_CONN TAOS_DEF_ERROR_CODE(0, 0x0354) //"Can not get user from conn") #define TSDB_CODE_MND_TOO_MANY_USERS TAOS_DEF_ERROR_CODE(0, 0x0355) //"Too many users") +#define TSDB_CODE_MND_MNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0348) //"Mnode already exists") +#define TSDB_CODE_MND_MNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0349) //"Mnode not there") + #define TSDB_CODE_MND_TABLE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) //"Table already exists") #define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) //"Table name too long") #define TSDB_CODE_MND_INVALID_TABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x0362) //"Table does not exist") diff --git a/include/util/tstep.h b/include/util/tstep.h index ffc3f6ccf71ee37f00fdc23e394b4a2083aa6603..e4ce7f584b368b87c5e0636abed30d9e201b7f83 100644 --- a/include/util/tstep.h +++ b/include/util/tstep.h @@ -20,14 +20,15 @@ extern "C" { #endif +typedef struct SSteps SSteps; typedef int32_t (*InitFp)(); typedef void (*CleanupFp)(); typedef void (*ReportFp)(char *name, char *desc); -struct SSteps *taosStepInit(int32_t maxsize, ReportFp fp); -int32_t taosStepExec(struct SSteps *steps); -void taosStepCleanup(struct SSteps *steps); -int32_t taosStepAdd(struct SSteps *steps, char *name, InitFp initFp, CleanupFp cleanupFp); +SSteps *taosStepInit(int32_t maxsize, ReportFp fp); +int32_t taosStepExec(SSteps *steps); +void taosStepCleanup(SSteps *steps); +int32_t taosStepAdd(SSteps *steps, char *name, InitFp initFp, CleanupFp cleanupFp); #ifdef __cplusplus } diff --git a/source/server/mnode/inc/mnodeAcct.h b/source/server/mnode/inc/mnodeAcct.h new file mode 100644 index 0000000000000000000000000000000000000000..b9d76cef25284c2686035e5a7c5b394ec065514f --- /dev/null +++ b/source/server/mnode/inc/mnodeAcct.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_ACCT_H_ +#define _TD_MNODE_ACCT_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_ACCT_H_*/ diff --git a/source/server/mnode/inc/mnodeAuth.h b/source/server/mnode/inc/mnodeAuth.h new file mode 100644 index 0000000000000000000000000000000000000000..56c7f3532cf1a087addcac8deab1a563c058ec5b --- /dev/null +++ b/source/server/mnode/inc/mnodeAuth.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_AUTH_H_ +#define _TD_MNODE_AUTH_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_AUTH_H_*/ diff --git a/source/server/mnode/inc/mnodeBalance.h b/source/server/mnode/inc/mnodeBalance.h new file mode 100644 index 0000000000000000000000000000000000000000..c106f41fc968740709153fa682b77d473a1272ed --- /dev/null +++ b/source/server/mnode/inc/mnodeBalance.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_BALANCE_H_ +#define _TD_MNODE_BALANCE_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_BALANCE_H_*/ diff --git a/source/server/mnode/inc/mnodeCluster.h b/source/server/mnode/inc/mnodeCluster.h new file mode 100644 index 0000000000000000000000000000000000000000..50f0c79a864f295fbea26694e3c34d6324838ef5 --- /dev/null +++ b/source/server/mnode/inc/mnodeCluster.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_CLUSTER_H_ +#define _TD_MNODE_CLUSTER_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_CLUSTER_H_*/ diff --git a/source/server/mnode/inc/mnodeDb.h b/source/server/mnode/inc/mnodeDb.h new file mode 100644 index 0000000000000000000000000000000000000000..70eb24cb7c2ff3122b5af17660c2e5e1e719a0cb --- /dev/null +++ b/source/server/mnode/inc/mnodeDb.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_DATABASE_H_ +#define _TD_MNODE_DATABASE_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_DATABASE_H_*/ diff --git a/source/server/mnode/inc/mnodeDef.h b/source/server/mnode/inc/mnodeDef.h new file mode 100644 index 0000000000000000000000000000000000000000..d615ea2fcf7e20ac2052bd8eec49696cfe318a9a --- /dev/null +++ b/source/server/mnode/inc/mnodeDef.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_DEF_H_ +#define _TD_MNODE_DEF_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_DEF_H_*/ diff --git a/source/server/mnode/inc/mnodeDnode.h b/source/server/mnode/inc/mnodeDnode.h new file mode 100644 index 0000000000000000000000000000000000000000..64b3b22853d3c091dccb53de19f7a1bdee7f801b --- /dev/null +++ b/source/server/mnode/inc/mnodeDnode.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_DNODE_H_ +#define _TD_MNODE_DNODE_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_DNODE_H_*/ diff --git a/source/server/mnode/inc/mnodeInt.h b/source/server/mnode/inc/mnodeInt.h index 646331b076b5a9f3dc9b3d898ebc72d1f6289c47..77cc8e4024c8ce3619b239059f82a96647806432 100644 --- a/source/server/mnode/inc/mnodeInt.h +++ b/source/server/mnode/inc/mnodeInt.h @@ -16,17 +16,23 @@ #ifndef _TD_MNODE_INT_H_ #define _TD_MNODE_INT_H_ +#include "mnodeDef.h" + #ifdef __cplusplus extern "C" { #endif -#include "os.h" -#include "taosmsg.h" -#include "trpc.h" -#include "mnode.h" +tmr_h mnodeGetTimer(); +int32_t mnodeGetDnodeId(); +char *mnodeGetClusterId(); +bool mnodeIsRunning(); + +void mnodeSendMsgToDnode(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg); +void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg); +void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell); #ifdef __cplusplus } #endif -#endif /*_TD_MNODE_INT_H_*/ \ No newline at end of file +#endif /*_TD_MNODE_INT_H_*/ diff --git a/source/server/mnode/inc/mnodeMnode.h b/source/server/mnode/inc/mnodeMnode.h new file mode 100644 index 0000000000000000000000000000000000000000..49c0ed898213338d27c15d0e7e30c4fac1fbe175 --- /dev/null +++ b/source/server/mnode/inc/mnodeMnode.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_MNODE_H_ +#define _TD_MNODE_MNODE_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_MNODE_H_*/ diff --git a/source/server/mnode/src/mnodeMain.c b/source/server/mnode/inc/mnodeSdb.h similarity index 62% rename from source/server/mnode/src/mnodeMain.c rename to source/server/mnode/inc/mnodeSdb.h index 8e5b4692e3a4f46c8e6eb62f9fa72a28f3b7b3f2..1f84a600a4da3c191def07f2612516c3bcdfa808 100644 --- a/source/server/mnode/src/mnodeMain.c +++ b/source/server/mnode/inc/mnodeSdb.h @@ -13,20 +13,21 @@ * along with this program. If not, see . */ -#include "mnodeInt.h" - -int32_t mnodeInit(SMnodePara para) { return 0; } +#ifndef _TD_MNODE_SDB_H_ +#define _TD_MNODE_SDB_H_ -void mnodeCleanup() {} - -int32_t mnodeDeploy(struct SMInfos *minfos) { return 0; } +#include "mnodeInt.h" -void mnodeUnDeploy() {} +#ifdef __cplusplus +extern "C" { +#endif -bool mnodeIsServing() { return false; } +int32_t sdbInit(); +void sdbCleanup(); -int32_t mnodeGetStatistics(SMnodeStat *stat) { return 0; } -int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { return 0; } +#ifdef __cplusplus +} +#endif -void mnodeProcessMsg(SRpcMsg *rpcMsg) {} +#endif /*_TD_MNODE_INT_H_*/ diff --git a/source/server/mnode/inc/mnodeSync.h b/source/server/mnode/inc/mnodeSync.h new file mode 100644 index 0000000000000000000000000000000000000000..e797e1b3de153f2895c8a2424849a648598eff72 --- /dev/null +++ b/source/server/mnode/inc/mnodeSync.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_SYNC_H_ +#define _TD_MNODE_SYNC_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_SYNC_H_*/ diff --git a/source/server/mnode/inc/mnodeTable.h b/source/server/mnode/inc/mnodeTable.h new file mode 100644 index 0000000000000000000000000000000000000000..82715f0189bf3818828bfebd9e65864218e473c5 --- /dev/null +++ b/source/server/mnode/inc/mnodeTable.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_TABLE_H_ +#define _TD_MNODE_TABLE_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_TABLE_H_*/ diff --git a/source/server/mnode/inc/mnodeUser.h b/source/server/mnode/inc/mnodeUser.h new file mode 100644 index 0000000000000000000000000000000000000000..aca7c2071b99517ade8b9e52ea0889709576f57b --- /dev/null +++ b/source/server/mnode/inc/mnodeUser.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_USER_H_ +#define _TD_MNODE_USER_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_USER_H_*/ diff --git a/source/server/mnode/inc/mnodeVgroup.h b/source/server/mnode/inc/mnodeVgroup.h new file mode 100644 index 0000000000000000000000000000000000000000..49428315033d34924c399e4f67ce528b086f5f3b --- /dev/null +++ b/source/server/mnode/inc/mnodeVgroup.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_VGROUP_H_ +#define _TD_MNODE_VGROUP_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_VGROUP_H_*/ diff --git a/source/server/mnode/inc/mnodeWorker.h b/source/server/mnode/inc/mnodeWorker.h new file mode 100644 index 0000000000000000000000000000000000000000..ca19944d8f80ba9cbdcb72996e4b2db9852019c5 --- /dev/null +++ b/source/server/mnode/inc/mnodeWorker.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef _TD_MNODE_WORKER_H_ +#define _TD_MNODE_WORKER_H_ + +#include "mnodeInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MNODE_WORKER_H_*/ diff --git a/source/server/mnode/src/mnodeAcct.c b/source/server/mnode/src/mnodeAcct.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeAcct.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeAuth.c b/source/server/mnode/src/mnodeAuth.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeAuth.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeBalance.c b/source/server/mnode/src/mnodeBalance.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeBalance.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeCluster.c b/source/server/mnode/src/mnodeCluster.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeCluster.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeDb.c b/source/server/mnode/src/mnodeDb.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeDb.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeDnode.c b/source/server/mnode/src/mnodeDnode.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeDnode.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeMnode.c b/source/server/mnode/src/mnodeMnode.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeMnode.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeSdb.c b/source/server/mnode/src/mnodeSdb.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeSdb.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeSync.c b/source/server/mnode/src/mnodeSync.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeSync.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeTable.c b/source/server/mnode/src/mnodeTable.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeTable.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeUser.c b/source/server/mnode/src/mnodeUser.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeUser.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeVgruop.c b/source/server/mnode/src/mnodeVgruop.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeVgruop.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mnodeWorker.c b/source/server/mnode/src/mnodeWorker.c new file mode 100644 index 0000000000000000000000000000000000000000..608008663063386d5100b2345960ab22113f3241 --- /dev/null +++ b/source/server/mnode/src/mnodeWorker.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "mnodeInt.h" diff --git a/source/server/mnode/src/mondeInt.c b/source/server/mnode/src/mondeInt.c new file mode 100644 index 0000000000000000000000000000000000000000..d7b39f18f2cfb0b2510b96d76e003c04e7411b83 --- /dev/null +++ b/source/server/mnode/src/mondeInt.c @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "tglobal.h" +#include "tstep.h" +#include "mnodeInt.h" + +#include "mnodeCluster.h" +#include "mnodeDb.h" +#include "mnodeDnode.h" +#include "mnodeFunc.h" +#include "mnodeMnode.h" +#include "mnodeProfile.h" +#include "mnodeSdb.h" +#include "mnodeShow.h" +#include "mnodeTable.h" +#include "mnodeUser.h" +#include "mnodeVgroup.h" +#include "mnodeWorker.h" +#include "mnodeDb.h" +#include "mnodeRaft.h" + +static struct { + int32_t state; + int32_t dnodeId; + char clusterId[TSDB_CLUSTER_ID_LEN]; + tmr_h timer; + SMnodeFp fp; + SSteps * steps; +} tsMint; + +tmr_h mnodeGetTimer() { return tsMint.timer; } + +int32_t mnodeGetDnodeId() { return tsMint.dnodeId; } + +char *mnodeGetClusterId() { return tsMint.clusterId; } + +bool mnodeIsServing() { return tsMint.state == TAOS_MN_STATUS_READY; } + +void mnodeSendMsgToDnode(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg) { + (*tsMint.fp.SendMsgToDnode)(epSet, rpcMsg); +} + +void mnodeSendMsgToMnode(struct SRpcMsg *rpcMsg) { return (*tsMint.fp.SendMsgToMnode)(rpcMsg); } + +void mnodeSendRedirectMsg(struct SRpcMsg *rpcMsg, bool forShell) { (*tsMint.fp.SendRedirectMsg)(rpcMsg, forShell); } + +int32_t mnodeGetStatistics(SMnodeStat *stat) { return 0; } + +static int32_t mnodeSetPara(SMnodePara para) { + tsMint.fp = para.fp; + tsMint.dnodeId = para.dnodeId; + strncpy(tsMint.clusterId, para.clusterId, TSDB_CLUSTER_ID_LEN); + + if (tsMint.fp.GetDnodeEp == NULL) return -1; + if (tsMint.fp.SendMsgToDnode == NULL) return -1; + if (tsMint.fp.SendMsgToMnode == NULL) return -1; + if (tsMint.fp.SendRedirectMsg == NULL) return -1; + if (tsMint.dnodeId < 0) return -1; + + return 0; +} + +static bool mnodeNeedDeploy() { + if (tsMint.dnodeId > 0) return false; + if (tsMint.clusterId[0] != 0) return false; + if (strcmp(tsFirst, tsLocalEp) != 0) return false; + return true; +} + +static bool mnodeIsDeployed() { + struct stat dirstat; + char filename[PATH_MAX + 20] = {0}; + snprintf(filename, sizeof(filename), "%s/wal/wal0", tsMnodeDir); + + return (stat(filename, &dirstat) == 0); +} + +int32_t mnodeDeploy(struct SMInfos *pMinfos) { + if (pMinfos == NULL) { // first deploy + tsMint.dnodeId = 1; + bool getuid = taosGetSystemUid(tsMint.clusterId); + if (!getuid) { + strcpy(tsMint.clusterId, "tdengine3.0"); + mError("deploy new mnode but failed to get uid, set to default val %s", tsMint.clusterId); + } else { + mDebug("deploy new mnode and uid is %s", tsMint.clusterId); + } + } else { // todo + } + + if (mkdir(tsMnodeDir, 0755) != 0 && errno != EEXIST) { + mError("failed to init mnode dir:%s, reason:%s", tsMnodeDir, strerror(errno)); + return -1; + } + + return 0; +} + +void mnodeUnDeploy() { + if (remove(tsMnodeDir) != 0) { + mInfo("failed to remove mnode file, reason:%s", strerror(errno)); + } else { + mInfo("mnode file is removed"); + } +} + +static int32_t mnodeInitTimer() { + if (tsMint.timer == NULL) { + tsMint.timer = taosTmrInit(tsMaxShellConns, 200, 3600000, "MND"); + } + + return 0; +} + +static void mnodeCleanupTimer() { + if (tsMint.timer != NULL) { + taosTmrCleanUp(tsMint.timer); + tsMint.timer = NULL; + } +} + +static int32_t mnodeInitSteps() { + struct SSteps *steps = taosStepInit(20, NULL); + if (steps == NULL) return -1; + + taosStepAdd(steps, "mnode-timer", mnodeInitTimer, NULL); + taosStepAdd(steps, "mnode-worker", mnodeInitWorker, NULL); + taosStepAdd(steps, "mnode-sdbref", sdbInitRef, sdbCleanUpRef); + taosStepAdd(steps, "mnode-profile", mnodeInitProfile, mnodeCleanupProfile); + taosStepAdd(steps, "mnode-funcs", mnodeInitFuncs, mnodeCleanupFuncs); + taosStepAdd(steps, "mnode-dnodes", mnodeInitDnodes, mnodeCleanupDnodes); + taosStepAdd(steps, "mnode-dbs", mnodeInitDbs, mnodeCleanupDbs); + taosStepAdd(steps, "mnode-vgroups", mnodeInitVgroups, mnodeCleanupVgroups); + taosStepAdd(steps, "mnode-tables", mnodeInitTables, mnodeCleanupTables); + taosStepAdd(steps, "mnode-mnodes", mnodeInitMnodes, mnodeCleanupMnodes); + taosStepAdd(steps, "mnode-sdb", sdbInit, sdbCleanUp); + taosStepAdd(steps, "mnode-balance", bnInit, bnCleanUp); + taosStepAdd(steps, "mnode-grant", grantInit, grantCleanUp); + taosStepAdd(steps, "mnode-show", mnodeInitShow, mnodeCleanUpShow); + taosStepAdd(steps, "mnode-kv", mnodeInitKv, mnodeCleanupKv); + taosStepAdd(steps, "mnode-raft", mnodeInitRaft, mnodeCleanupRaft); + taosStepAdd(steps, "mnode-cluster", mnodeInitCluster, mnodeCleanupCluster); + taosStepAdd(steps, "mnode-users", mnodeInitUsers, mnodeCleanupUsers); + taosStepAdd(steps, "mnode-worker", NULL, mnodeCleanupWorker); + taosStepAdd(steps, "mnode-timer", NULL, mnodeCleanupTimer); + + tsMint.steps = steps; + return taosStepExec(tsMint.steps); +} + +static void mnodeCleanupSteps() { taosStepCleanup(tsMint.steps); } + + +int32_t mnodeInit(SMnodePara para) { + int32_t code = 0; + if (tsMint.state != TAOS_MN_STATUS_UNINIT) { + return 0; + } else { + tsMint.state = TAOS_MN_STATUS_INIT; + } + + code = mnodeSetPara(para); + if (code != 0) { + tsMint.state = TAOS_MN_STATUS_UNINIT; + return code; + } + + + + bool needDeploy = mnodeNeedDeploy(); + bool deployed = mnodeIsDeployed(); + + if (!deployed) { + if (needDeploy) { + code = mnodeDeploy(NULL); + if (code != 0) { + tsMint.state = TAOS_MN_STATUS_UNINIT; + return code; + } + } else { + tsMint.state = TAOS_MN_STATUS_UNINIT; + return 0; + } + } + + mInfo("starting to initialize mnode ..."); + + code = mnodeInitSteps(); + if (code != 0) { + tsMint.state = TAOS_MN_STATUS_UNINIT; + return -1; + } + + // todo + grantReset(TSDB_GRANT_ALL, 0); + sdbUpdateSync(NULL); + + tsMint.state = TAOS_MN_STATUS_READY; + mInfo("mnode is initialized successfully"); + return 0; +} + +void mnodeCleanup() { + if (tsMint.state != TAOS_MN_STATUS_UNINIT && tsMint.state != TAOS_MN_STATUS_CLOSING) { + mInfo("starting to clean up mnode"); + tsMint.state = TAOS_MN_STATUS_CLOSING; + + mnodeCleanupSteps(); + + tsMint.state = TAOS_MN_STATUS_UNINIT; + mInfo("mnode is cleaned up"); + } +} + +int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { return 0; } + +void mnodeProcessMsg(SRpcMsg *rpcMsg) {} \ No newline at end of file diff --git a/source/util/src/tstep.c b/source/util/src/tstep.c index 656ac658a01455f6538eab9f0ac39c9255919738..8162fb76ed717fb45eef6249ce38c9226f683d46 100644 --- a/source/util/src/tstep.c +++ b/source/util/src/tstep.c @@ -18,7 +18,7 @@ #include "ulog.h" #include "tstep.h" -typedef struct SStepObj { +typedef struct { char * name; InitFp initFp; CleanupFp cleanupFp;