2022-04-14 05:53:45 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-11-02 12:13:29 +00:00
|
|
|
#include "cos.h"
|
2024-08-21 07:54:39 +00:00
|
|
|
#include "monitor.h"
|
2024-11-25 08:05:32 +00:00
|
|
|
#include "tsdb.h"
|
2022-04-26 11:04:26 +00:00
|
|
|
#include "vnd.h"
|
2022-04-14 05:53:45 +00:00
|
|
|
|
2023-11-29 10:01:31 +00:00
|
|
|
static volatile int32_t VINIT = 0;
|
2022-04-14 05:53:45 +00:00
|
|
|
|
2024-12-19 06:51:21 +00:00
|
|
|
int vnodeInit(StopDnodeFp stopDnodeFp) {
|
2024-07-19 08:12:38 +00:00
|
|
|
if (atomic_val_compare_exchange_32(&VINIT, 0, 1)) {
|
2022-04-14 05:53:45 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 06:51:21 +00:00
|
|
|
TAOS_CHECK_RETURN(vnodeAsyncOpen());
|
2024-08-15 03:55:20 +00:00
|
|
|
TAOS_CHECK_RETURN(walInit(stopDnodeFp));
|
2022-04-14 05:53:45 +00:00
|
|
|
|
2024-08-21 07:54:39 +00:00
|
|
|
monInitVnode();
|
|
|
|
|
|
2022-04-14 05:53:45 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vnodeCleanup() {
|
2024-07-19 08:12:38 +00:00
|
|
|
if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return;
|
2024-09-10 06:35:43 +00:00
|
|
|
vnodeAsyncClose();
|
2022-06-01 11:57:03 +00:00
|
|
|
walCleanUp();
|
2022-07-09 07:44:37 +00:00
|
|
|
smaCleanUp();
|
2022-04-14 05:53:45 +00:00
|
|
|
}
|