smaUtil.c 2.1 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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/>.
 */

#include "sma.h"

K
kailixu 已提交
18
void tdRSmaQTaskInfoGetFullPath(int32_t vgId, tb_uid_t suid, int8_t level, const char *path, char *outputName) {
K
kailixu 已提交
19 20
  tdRSmaGetDirName(vgId, path, VNODE_RSMA_DIR, true, outputName);
  int32_t rsmaLen = strlen(outputName);
K
kailixu 已提交
21
  snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8 "%s%" PRIi64, level, TD_DIRSEP, suid);
22 23
}

K
kailixu 已提交
24
void tdRSmaGetDirName(int32_t vgId, const char *pdname, const char *dname, bool endWithSep, char *outputName) {
C
Cary Xu 已提交
25
  if (pdname) {
C
Cary Xu 已提交
26 27 28 29 30 31 32
    if (endWithSep) {
      snprintf(outputName, TSDB_FILENAME_LEN, "%s%svnode%svnode%d%s%s%s", pdname, TD_DIRSEP, TD_DIRSEP, vgId, TD_DIRSEP,
               dname, TD_DIRSEP);
    } else {
      snprintf(outputName, TSDB_FILENAME_LEN, "%s%svnode%svnode%d%s%s", pdname, TD_DIRSEP, TD_DIRSEP, vgId, TD_DIRSEP,
               dname);
    }
C
Cary Xu 已提交
33
  } else {
K
kailixu 已提交
34
#if 0
C
Cary Xu 已提交
35 36 37 38 39
    if (endWithSep) {
      snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname, TD_DIRSEP);
    } else {
      snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname);
    }
K
kailixu 已提交
40
#endif
C
Cary Xu 已提交
41
  }
C
Cary Xu 已提交
42
}
C
Cary Xu 已提交
43

C
Cary Xu 已提交
44
// smaXXXUtil ================
K
kailixu 已提交
45
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { return taosAcquireRef(rsetId, refId); }
C
Cary Xu 已提交
46

C
Cary Xu 已提交
47
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
C
Cary Xu 已提交
48
  if (taosReleaseRef(rsetId, refId) < 0) {
C
Cary Xu 已提交
49
    smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
C
Cary Xu 已提交
50 51 52 53
    return TSDB_CODE_FAILED;
  }

  return TSDB_CODE_SUCCESS;
C
Cary Xu 已提交
54
}