diff --git a/include/server/dnode/dnode.h b/include/server/dnode/dnode.h
index 08658f354283fc5d370ce27234440852d93fba19..76a3d3ea1b8e6f767fe3f511f2a84bfe75ca4013 100644
--- a/include/server/dnode/dnode.h
+++ b/include/server/dnode/dnode.h
@@ -32,7 +32,7 @@ struct Dnode *dnodeCreateInstance();
*
* @param dnode, instance of dnode module.
*/
-void dnodeCleanupInstance(struct Dnode *dnode);
+void dnodeDropInstance(struct Dnode *dnode);
/**
* Send messages to other dnodes, such as create vnode message.
diff --git a/include/server/mnode/mnode.h b/include/server/mnode/mnode.h
index f6c067f784ac081ac8a7975ec2b06e4bcdb27969..7a06880a16b3896b19fe16cd00abda9b4ee5b254 100644
--- a/include/server/mnode/mnode.h
+++ b/include/server/mnode/mnode.h
@@ -82,7 +82,7 @@ struct Mnode *mnodeCreateInstance(SMnodePara para);
*
* @param mnode, instance of mnode module.
*/
-void mnodeCleanupInstance(struct Mnode *vnode);
+void mnodeDropInstance(struct Mnode *vnode);
/**
* Deploy mnode instances in dnode.
diff --git a/include/server/vnode/vnode.h b/include/server/vnode/vnode.h
index 8aebd5aa9b9e5de3df0ac0901debc7b424dd8f35..ee015788d3a93123269ed81549df4d7a40573177 100644
--- a/include/server/vnode/vnode.h
+++ b/include/server/vnode/vnode.h
@@ -71,7 +71,7 @@ struct Vnode *vnodeCreateInstance(SVnodePara para);
*
* @param vnode, instance of vnode module.
*/
-void vnodeCleanupInstance(struct Vnode *vnode);
+void vnodeDropInstance(struct Vnode *vnode);
typedef struct {
int32_t unused;
diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt
index 9e5d6126baf1899fb284150da9f03b9e37348613..0eda9d637df074d3a4ad9a522ce8ce9d63bc8a94 100644
--- a/source/os/CMakeLists.txt
+++ b/source/os/CMakeLists.txt
@@ -4,4 +4,11 @@ target_include_directories(
os
PUBLIC "${CMAKE_SOURCE_DIR}/include/os"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
+)
+target_link_libraries(
+ os
+ PUBLIC pthread
+ PUBLIC dl
+ PUBLIC rt
+ PUBLIC m
)
\ No newline at end of file
diff --git a/source/server/CMakeLists.txt b/source/server/CMakeLists.txt
index d80c7876db5416aa8e63d553a6d0160fd51bdcdf..1f6da54ebe4964adf651afbb59011913cc95a5ed 100644
--- a/source/server/CMakeLists.txt
+++ b/source/server/CMakeLists.txt
@@ -7,5 +7,5 @@ aux_source_directory(. TAOSD_SRC)
add_executable(taosd ${TAOSD_SRC})
target_link_libraries(
taosd
- PUBLIC os
+ PUBLIC dnode
)
\ No newline at end of file
diff --git a/source/server/dnode/CMakeLists.txt b/source/server/dnode/CMakeLists.txt
index cf7482eca670af68c0bd336e69507a800ac36b15..e627ca94e815baf5781f50b51a9c8d2decd797d7 100644
--- a/source/server/dnode/CMakeLists.txt
+++ b/source/server/dnode/CMakeLists.txt
@@ -2,11 +2,7 @@ aux_source_directory(src DNODE_SRC)
add_library(dnode ${DNODE_SRC})
target_link_libraries(
dnode
- PUBLIC os
PUBLIC cjson
- PUBLIC util
- PUBLIC common
- PUBLIC transport
PUBLIC mnode
PUBLIC vnode
)
diff --git a/source/server/dnode/src/dnodeInt.c b/source/server/dnode/src/dnodeInt.c
index 2f805bb882f932a2745128cf744059d2de29730d..f38d9665acc548b270b08a2b60962fd3a8742445 100644
--- a/source/server/dnode/src/dnodeInt.c
+++ b/source/server/dnode/src/dnodeInt.c
@@ -65,7 +65,7 @@ static int32_t dnodeInitVnodeModule(Dnode *dnode, struct Vnode** out) {
static void dnodeCleanupVnodeModule(Dnode *dnode, struct Vnode **out) {
struct Vnode *vnode = *out;
*out = NULL;
- vnodeCleanupInstance(vnode);
+ vnodeDropInstance(vnode);
}
static int32_t dnodeInitMnodeModule(Dnode *dnode, struct Mnode **out) {
@@ -90,7 +90,7 @@ static int32_t dnodeInitMnodeModule(Dnode *dnode, struct Mnode **out) {
static void dnodeCleanupMnodeModule(Dnode *dnode, struct Mnode **out) {
struct Mnode *mnode = *out;
*out = NULL;
- mnodeCleanupInstance(mnode);
+ mnodeDropInstance(mnode);
}
Dnode *dnodeCreateInstance() {
@@ -223,7 +223,7 @@ Dnode *dnodeCreateInstance() {
return dnode;
}
-void dnodeCleanupInstance(Dnode *dnode) {
+void dnodeDropInstance(Dnode *dnode) {
if (dnode->main->runStatus != TD_RUN_STAT_STOPPED) {
dnode->main->runStatus = TD_RUN_STAT_STOPPED;
taosStepCleanup(dnode->steps);
diff --git a/source/server/dnode/src/dnodeMain.c b/source/server/dnode/src/dnodeMain.c
index 8836b633e47d2630961efbb9ca3ae90807085b31..7854fe2b4b9c2081fb4f80e4606806d29f57a00e 100644
--- a/source/server/dnode/src/dnodeMain.c
+++ b/source/server/dnode/src/dnodeMain.c
@@ -112,7 +112,9 @@ void dnodeCleanupMain(DnMain **out) {
main->dnodeTimer = NULL;
}
+#if 0
taos_cleanup();
+#endif
taosCloseLog();
taosStopCacheRefreshWorker();
diff --git a/source/server/mnode/CMakeLists.txt b/source/server/mnode/CMakeLists.txt
index 689d6f7f2a9a614d279a5971c1ecbd176d872445..331a717bf581616c8e2a4a6c9b610d69c7c6f12d 100644
--- a/source/server/mnode/CMakeLists.txt
+++ b/source/server/mnode/CMakeLists.txt
@@ -4,4 +4,8 @@ target_include_directories(
mnode
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/mnode"
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
+)
+target_link_libraries(
+ mnode
+ PUBLIC transport
)
\ No newline at end of file
diff --git a/source/server/mnode/inc/mnodeInt.h b/source/server/mnode/inc/mnodeInt.h
index 60b748f0ea3f4f68fdce1cd51a234534d275d987..646331b076b5a9f3dc9b3d898ebc72d1f6289c47 100644
--- a/source/server/mnode/inc/mnodeInt.h
+++ b/source/server/mnode/inc/mnodeInt.h
@@ -20,6 +20,11 @@
extern "C" {
#endif
+#include "os.h"
+#include "taosmsg.h"
+#include "trpc.h"
+#include "mnode.h"
+
#ifdef __cplusplus
}
#endif
diff --git a/source/server/vnode/src/vnode.c b/source/server/mnode/src/mnodeMain.c
similarity index 50%
rename from source/server/vnode/src/vnode.c
rename to source/server/mnode/src/mnodeMain.c
index 6dea4a4e57392be988126c579648f39a8270b9bf..3747534e361087973304631d04bdba87ef552c5c 100644
--- a/source/server/vnode/src/vnode.c
+++ b/source/server/mnode/src/mnodeMain.c
@@ -11,4 +11,26 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
\ No newline at end of file
+ */
+
+#include "mnodeInt.h"
+
+struct Mnode *mnodeCreateInstance(SMnodePara para) {
+ return NULL;
+}
+
+void mnodeDropInstance(struct Mnode *vnode) {}
+
+int32_t mnodeDeploy(struct Mnode *mnode, struct SMInfos *minfos) { return 0; }
+
+void mnodeUnDeploy(struct Mnode *mnode) {}
+
+bool mnodeIsServing(struct Mnode *mnode) { return false; }
+
+int32_t mnodeGetStatistics(struct Mnode *mnode, SMnodeStat *stat) { return 0; }
+
+int32_t mnodeRetriveAuth(struct Mnode *mnode, char *user, char *spi, char *encrypt, char *secret, char *ckey) {
+ return 0;
+}
+
+void mnodeProcessMsg(struct Mnode *mnode, SRpcMsg *rpcMsg) {}
diff --git a/source/server/main.c b/source/server/server.c
similarity index 59%
rename from source/server/main.c
rename to source/server/server.c
index 75449ecd1a1c3b5589e801d52e1ed2928114e8ac..b5c8992b65a0fc510a92140003d9c858b0664c6f 100644
--- a/source/server/main.c
+++ b/source/server/server.c
@@ -13,8 +13,25 @@
* along with this program. If not, see .
*/
#include "os.h"
+#include "tulog.h"
+#include "trpc.h"
+#include "dnode.h"
int main(int argc, char const *argv[]) {
- printf("Hello world!\n");
+ struct Dnode *dnode = dnodeCreateInstance();
+ if (dnode == NULL) {
+ uInfo("Failed to start TDengine, please check the log at:%s", tsLogDir);
+ exit(EXIT_FAILURE);
+ }
+
+ uInfo("Started TDengine service successfully.");
+
+ // if (tsem_wait(&exitSem) != 0) {
+ // syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
+ // }
+
+ dnodeDropInstance(dnode);
+
+ uInfo("TDengine is shut down!");
return 0;
}
diff --git a/source/server/vnode/CMakeLists.txt b/source/server/vnode/CMakeLists.txt
index 75d24ed64e2b5e48c9a587170018fd69fca675f9..03421b26282a0123dd80b5773717f8233cffbff8 100644
--- a/source/server/vnode/CMakeLists.txt
+++ b/source/server/vnode/CMakeLists.txt
@@ -9,9 +9,10 @@ target_include_directories(
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
-target_include_directories(
+target_link_libraries(
vnode
- PRIVATE meta
- PRIVATE tq
- PRIVATE tsdb
+ PUBLIC transport
+ PUBLIC meta
+ PUBLIC tq
+ PUBLIC tsdb
)
\ No newline at end of file
diff --git a/source/server/vnode/inc/vnodeInt.h b/source/server/vnode/inc/vnodeInt.h
index 855eb66c8afa8c4db060c6b1873b1ac4e9a459b6..12568d21b843f52773e1dbca9027e7a1a663869e 100644
--- a/source/server/vnode/inc/vnodeInt.h
+++ b/source/server/vnode/inc/vnodeInt.h
@@ -20,6 +20,11 @@
extern "C" {
#endif
+#include "os.h"
+#include "taosmsg.h"
+#include "trpc.h"
+#include "vnode.h"
+
#ifdef __cplusplus
}
#endif
diff --git a/source/server/mnode/src/mnode.c b/source/server/vnode/src/vnodeMain.c
similarity index 57%
rename from source/server/mnode/src/mnode.c
rename to source/server/vnode/src/vnodeMain.c
index 6dea4a4e57392be988126c579648f39a8270b9bf..0f26041787840af69e817e30acea03bb04605c9e 100644
--- a/source/server/mnode/src/mnode.c
+++ b/source/server/vnode/src/vnodeMain.c
@@ -11,4 +11,20 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
\ No newline at end of file
+ */
+
+#include "vnodeInt.h"
+
+struct Vnode *vnodeCreateInstance(SVnodePara para) {
+ return NULL;
+}
+
+void vnodeDropInstance(struct Vnode *vnode) {}
+
+int32_t vnodeGetStatistics(struct Vnode *vnode, SVnodeStat *stat) { return 0; }
+
+void vnodeGetStatus(struct Vnode *vnode, struct SStatusMsg *status) {}
+
+void vnodeSetAccess(struct Vnode *vnode, struct SVgroupAccess *access, int32_t numOfVnodes) {}
+
+void vnodeProcessMsg(struct Vnode *vnode, SRpcMsg *msg) {}
diff --git a/source/util/src/tstep.c b/source/util/src/tstep.c
new file mode 100644
index 0000000000000000000000000000000000000000..97cd3290da842636a85c5ed6cf4b52e73881bd74
--- /dev/null
+++ b/source/util/src/tstep.c
@@ -0,0 +1,85 @@
+/*
+ * 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 "tulog.h"
+#include "tstep.h"
+
+SSteps *taosStepInit(int32_t maxsize) {
+ SSteps *steps = calloc(1, sizeof(SSteps));
+ if (steps == NULL) return NULL;
+
+ steps->maxsize = maxsize;
+ steps->cursize = 0;
+ steps->steps = calloc(maxsize, sizeof(SStepObj));
+
+ return steps;
+}
+
+int32_t taosStepAdd(SSteps *steps, SStepObj *step) {
+ if (steps == NULL) return - 1;
+
+ if (steps->cursize >= steps->maxsize) {
+ uError("failed to add step since up to the maxsize");
+ return -1;
+ }
+
+ steps->steps[steps->cursize++] = *step;
+ return 0;
+}
+
+static void taosStepCleanupImp(SSteps *steps, int32_t pos) {
+ for (int32_t s = pos; s >= 0; s--) {
+ SStepObj *step = steps->steps + s;
+ uDebug("step:%s will cleanup", step->name);
+ if (step->cleanupFp != NULL) {
+ (*step->cleanupFp)(step->self);
+ }
+ }
+}
+
+int32_t taosStepExec(SSteps *steps) {
+ if (steps == NULL) return -1;
+
+ for (int32_t s = 0; s < steps->cursize; s++) {
+ SStepObj *step = steps->steps + s;
+ if (step->initFp == NULL) continue;
+
+ if (step->reportFp != NULL) {
+ (*step->reportFp)(step->parent, step->name, "start initialize");
+ }
+
+ int32_t code = (*step->initFp)(step->parent, step->self);
+ if (code != 0) {
+ uDebug("step:%s will cleanup", step->name);
+ taosStepCleanupImp(steps, s);
+ return code;
+ }
+
+ uInfo("step:%s is initialized", step->name);
+
+ if (step->reportFp != NULL) {
+ (*step->reportFp)(step->parent, step->name, "initialize completed");
+ }
+ }
+
+ return 0;
+}
+
+void taosStepCleanup(SSteps *steps) {
+ if (steps == NULL) return;
+ taosStepCleanupImp(steps, steps->cursize - 1);
+}
\ No newline at end of file