diff --git a/.gitignore b/.gitignore index 8bde111260..d8b0291558 100755 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,8 @@ __not_found__ thirdparties/rocksdb/lib/ thirdparties/rocksdb/include/ thirdparties/rocksdb/rocksdb/ + +/external +/bazel-* +/compile_commands.json +/.cache/ diff --git a/0001-support-generate-compile_commands.json.patch b/0001-support-generate-compile_commands.json.patch new file mode 100644 index 0000000000..fc7ebeebdc --- /dev/null +++ b/0001-support-generate-compile_commands.json.patch @@ -0,0 +1,414 @@ +From 04701122f73b683f08c8f6243f66a65ad99095b7 Mon Sep 17 00:00:00 2001 +From: Hanqing Wu +Date: Wed, 13 Apr 2022 10:40:15 +0800 +Subject: [PATCH] support generate compile_commands.json + +--- + .gitignore | 5 + + WORKSPACE | 27 +++-- + external/bazel/gflags.BUILD | 34 ------- + external/bazel/glog.BUILD | 98 ------------------- + external/bazel/gtest.BUILD | 30 ------ + external/bazel/leveldb.BUILD | 98 ------------------- + .../bazel => thirdparties}/etcdclient.BUILD | 0 + {external/bazel => thirdparties}/gmock.BUILD | 0 + .../bazel => thirdparties}/jsoncpp.BUILD | 0 + .../bazel => thirdparties}/rocksdb.BUILD | 0 + 10 files changed, 25 insertions(+), 267 deletions(-) + delete mode 100644 external/bazel/gflags.BUILD + delete mode 100644 external/bazel/glog.BUILD + delete mode 100644 external/bazel/gtest.BUILD + delete mode 100644 external/bazel/leveldb.BUILD + rename {external/bazel => thirdparties}/etcdclient.BUILD (100%) + rename {external/bazel => thirdparties}/gmock.BUILD (100%) + rename {external/bazel => thirdparties}/jsoncpp.BUILD (100%) + rename {external/bazel => thirdparties}/rocksdb.BUILD (100%) + +diff --git a/.gitignore b/.gitignore +index 8bde1112..d8b02915 100755 +--- a/.gitignore ++++ b/.gitignore +@@ -109,3 +109,8 @@ __not_found__ + thirdparties/rocksdb/lib/ + thirdparties/rocksdb/include/ + thirdparties/rocksdb/rocksdb/ ++ ++/external ++/bazel-* ++/compile_commands.json ++/.cache/ +diff --git a/WORKSPACE b/WORKSPACE +index eb1d8a5f..625aada6 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -16,8 +16,7 @@ + + workspace(name = "curve") + +-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +-load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") ++load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + + # skylib +@@ -78,7 +77,7 @@ bind( + #import the gtest files. + new_git_repository( + name = "com_google_googletest", +- build_file = "bazel/gmock.BUILD", ++ build_file = "//:thirdparties/gmock.BUILD", + remote = "https://github.com/google/googletest", + tag = "release-1.8.0", + ) +@@ -117,7 +116,7 @@ bind( + + http_archive( + name = "com_github_google_leveldb", +- build_file = "bazel/leveldb.BUILD", ++ build_file = "@com_github_apache_brpc//:leveldb.BUILD", + strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6", + urls = ["https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"], + ) +@@ -158,7 +157,7 @@ bind( + # jsoncpp + new_git_repository( + name = "jsoncpp", +- build_file = "bazel/jsoncpp.BUILD", ++ build_file = "//:thirdparties/jsoncpp.BUILD", + remote = "https://github.com/open-source-parsers/jsoncpp.git", + tag = "1.8.4", + ) +@@ -170,7 +169,7 @@ bind( + + new_local_repository( + name = "etcdclient", +- build_file = "external/bazel/etcdclient.BUILD", ++ build_file = "//:thirdparties/etcdclient.BUILD", + path = "thirdparties/etcdclient", + ) + +@@ -233,6 +232,20 @@ http_archive( + # RocksDB + new_local_repository( + name = "rocksdb", +- build_file = "external/bazel/rocksdb.BUILD", ++ build_file = "//:thirdparties/rocksdb.BUILD", + path = "thirdparties/rocksdb", + ) ++ ++# Hedron's Compile Commands Extractor for Bazel ++# https://github.com/hedronvision/bazel-compile-commands-extractor ++http_archive( ++ name = "hedron_compile_commands", ++ ++ # Replace the commit hash in both places (below) with the latest, rather than using the stale one here. ++ # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). ++ url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/af9af15f7bc16fc3e407e2231abfcb62907d258f.tar.gz", ++ strip_prefix = "bazel-compile-commands-extractor-af9af15f7bc16fc3e407e2231abfcb62907d258f", ++ # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." ++) ++load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") ++hedron_compile_commands_setup() +diff --git a/external/bazel/gflags.BUILD b/external/bazel/gflags.BUILD +deleted file mode 100644 +index de6d2d02..00000000 +--- a/external/bazel/gflags.BUILD ++++ /dev/null +@@ -1,34 +0,0 @@ +-# +-# Copyright (c) 2020 NetEase Inc. +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# http://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +-# +- +-# Bazel (http://bazel.io/) BUILD file for gflags. +-# +-# See INSTALL.md for instructions for adding gflags to a Bazel workspace. +- +-licenses(["notice"]) +- +-exports_files(["src/gflags_completions.sh", "COPYING.txt"]) +- +-config_setting( +- name = "x64_windows", +- values = {"cpu": "x64_windows"}, +-) +- +-load(":bazel/gflags.bzl", "gflags_sources", "gflags_library") +- +-(hdrs, srcs) = gflags_sources(namespace=["gflags", "google"]) +-gflags_library(hdrs=hdrs, srcs=srcs, threads=0) +-gflags_library(hdrs=hdrs, srcs=srcs, threads=1) +diff --git a/external/bazel/glog.BUILD b/external/bazel/glog.BUILD +deleted file mode 100644 +index 77d88ea7..00000000 +--- a/external/bazel/glog.BUILD ++++ /dev/null +@@ -1,98 +0,0 @@ +-# +-# Copyright (c) 2020 NetEase Inc. +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# http://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +-# +- +-cc_library( +- name = "glog", +- srcs = [ +- "config.h", +- "src/base/commandlineflags.h", +- "src/base/googleinit.h", +- "src/base/mutex.h", +- "src/demangle.cc", +- "src/demangle.h", +- "src/logging.cc", +- "src/raw_logging.cc", +- "src/signalhandler.cc", +- "src/symbolize.cc", +- "src/symbolize.h", +- "src/utilities.cc", +- "src/utilities.h", +- "src/vlog_is_on.cc", +- ] + glob(["src/stacktrace*.h"]), +- hdrs = [ +- "src/glog/log_severity.h", +- "src/glog/logging.h", +- "src/glog/raw_logging.h", +- "src/glog/stl_logging.h", +- "src/glog/vlog_is_on.h", +- ], +- copts = [ +- "-Wno-sign-compare", +- "-U_XOPEN_SOURCE", +- ], +- includes = ["./src"], +- linkopts = ["-lpthread"] + select({ +- ":libunwind": ["-lunwind"], +- "//conditions:default": [], +- }), +- visibility = ["//visibility:public"], +- deps = [ +- "@com_github_gflags_gflags//:gflags", +- ], +-) +- +-config_setting( +- name = "libunwind", +- values = { +- "define": "libunwind=true", +- }, +-) +- +-genrule( +- name = "run_configure", +- srcs = [ +- "README", +- "Makefile.in", +- "config.guess", +- "config.sub", +- "install-sh", +- "ltmain.sh", +- "missing", +- "libglog.pc.in", +- "src/config.h.in", +- "src/glog/logging.h.in", +- "src/glog/raw_logging.h.in", +- "src/glog/stl_logging.h.in", +- "src/glog/vlog_is_on.h.in", +- ], +- outs = [ +- "config.h", +- "src/glog/logging.h", +- "src/glog/raw_logging.h", +- "src/glog/stl_logging.h", +- "src/glog/vlog_is_on.h", +- ], +- tools = [ +- "configure", +- ], +- cmd = "$(location :configure)" + +- "&& cp -v src/config.h $(location config.h) " + +- "&& cp -v src/glog/logging.h $(location src/glog/logging.h) " + +- "&& cp -v src/glog/raw_logging.h $(location src/glog/raw_logging.h) " + +- "&& cp -v src/glog/stl_logging.h $(location src/glog/stl_logging.h) " + +- "&& cp -v src/glog/vlog_is_on.h $(location src/glog/vlog_is_on.h) " +- , +-) +diff --git a/external/bazel/gtest.BUILD b/external/bazel/gtest.BUILD +deleted file mode 100644 +index f88075d5..00000000 +--- a/external/bazel/gtest.BUILD ++++ /dev/null +@@ -1,30 +0,0 @@ +-# +-# Copyright (c) 2020 NetEase Inc. +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# http://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +-# +- +-cc_library( +- name = "main", +- srcs = glob( +- ["src/*.cc"], +- exclude = ["src/gtest-all.cc"] +- ), +- hdrs = glob([ +- "include/**/*.h", +- "src/*.h" +- ]), +- copts = ["-Iexternal/gtest/include"], +- linkopts = ["-pthread"], +- visibility = ["//visibility:public"], +-) +diff --git a/external/bazel/leveldb.BUILD b/external/bazel/leveldb.BUILD +deleted file mode 100644 +index 9b0f56f5..00000000 +--- a/external/bazel/leveldb.BUILD ++++ /dev/null +@@ -1,98 +0,0 @@ +-# +-# Copyright (c) 2020 NetEase Inc. +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# http://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +-# +- +-package(default_visibility = ["//visibility:public"]) +- +- +-config_setting( +- name = "darwin", +- values = {"cpu": "darwin"}, +- visibility = ["//visibility:public"], +-) +- +-SOURCES = ["db/builder.cc", +- "db/c.cc", +- "db/dbformat.cc", +- "db/db_impl.cc", +- "db/db_iter.cc", +- "db/dumpfile.cc", +- "db/filename.cc", +- "db/log_reader.cc", +- "db/log_writer.cc", +- "db/memtable.cc", +- "db/repair.cc", +- "db/table_cache.cc", +- "db/version_edit.cc", +- "db/version_set.cc", +- "db/write_batch.cc", +- "table/block_builder.cc", +- "table/block.cc", +- "table/filter_block.cc", +- "table/format.cc", +- "table/iterator.cc", +- "table/merger.cc", +- "table/table_builder.cc", +- "table/table.cc", +- "table/two_level_iterator.cc", +- "util/arena.cc", +- "util/bloom.cc", +- "util/cache.cc", +- "util/coding.cc", +- "util/comparator.cc", +- "util/crc32c.cc", +- "util/env.cc", +- "util/env_posix.cc", +- "util/filter_policy.cc", +- "util/hash.cc", +- "util/histogram.cc", +- "util/logging.cc", +- "util/options.cc", +- "util/status.cc", +- "port/port_posix.cc", +- "port/port_posix_sse.cc", +- "helpers/memenv/memenv.cc", +- ] +- +-cc_library( +- name = "leveldb", +- srcs = SOURCES, +- hdrs = glob([ +- "helpers/memenv/*.h", +- "util/*.h", +- "port/*.h", +- "port/win/*.h", +- "table/*.h", +- "db/*.h", +- "include/leveldb/*.h" +- ], +- exclude = [ +- "**/*test.*", +- ]), +- includes = [ +- "include/", +- ], +- copts = [ +- "-fno-builtin-memcmp", +- "-DLEVELDB_PLATFORM_POSIX=1", +- "-DLEVELDB_ATOMIC_PRESENT", +- ], +- defines = [ +- "LEVELDB_PLATFORM_POSIX", +- ] + select({ +- ":darwin": ["OS_MACOSX"], +- "//conditions:default": [], +- }), +-) +diff --git a/external/bazel/etcdclient.BUILD b/thirdparties/etcdclient.BUILD +similarity index 100% +rename from external/bazel/etcdclient.BUILD +rename to thirdparties/etcdclient.BUILD +diff --git a/external/bazel/gmock.BUILD b/thirdparties/gmock.BUILD +similarity index 100% +rename from external/bazel/gmock.BUILD +rename to thirdparties/gmock.BUILD +diff --git a/external/bazel/jsoncpp.BUILD b/thirdparties/jsoncpp.BUILD +similarity index 100% +rename from external/bazel/jsoncpp.BUILD +rename to thirdparties/jsoncpp.BUILD +diff --git a/external/bazel/rocksdb.BUILD b/thirdparties/rocksdb.BUILD +similarity index 100% +rename from external/bazel/rocksdb.BUILD +rename to thirdparties/rocksdb.BUILD +-- +2.34.0 + diff --git a/README.md b/README.md index aecf3c1007..e3fd42abdd 100644 --- a/README.md +++ b/README.md @@ -1,150 +1,66 @@ -[中文版](README_cn.md) +## 生成compile_commands.json +1. 应用patch,`git am < 0001-support-generate-compile_commands.json.patch`(这个类似于cherry-pick,会把patch合入) - + 或者 `patch -p1 < 0001-support-generate-compile_commands.json.patch` -# CURVE +2. 清楚之前的编译缓存,`bazel clean` +3. 编译整个项目,`bazel build //...` +4. 生成compile_commands.json,`bazel run @hedron_compile_commands//:refresh_all` (更多使用方式可以参考https://github.com/hedronvision/bazel-compile-commands-extractor) -[![Docs](https://img.shields.io/badge/docs-latest-green.svg)](https://github.com/opencurve/curve/tree/master/docs) -[![Releases](https://img.shields.io/github/v/release/opencurve/curve?include_prereleases)](https://github.com/opencurve/curve/releases) -[![LICENSE](https://img.shields.io/badge/licence-Apache--2.0%2FGPL-blue)](https://github.com/opencurve/curve/blob/master/LICENSE) + 过程中可能会有如下报错: -Curve is a distributed storage system designed and developed by NetEase, featured with high performance, easy operation and cloud native. Curve is compose of CurveBS(Curve Block Storage) and CurveFS(Curve FileSystem). CurveBS supports snapshot, clone, and recover, also supports virtual machines with qemu and physical machine with nbd. CurveFS supports POSIX based on Fuse. + ![](docs/images/clangd/clangd_error.png) -## Curve Architecture -The architecture overview of Curve is as follows: + 需要把之前手动生成的pb.h/cc文件删除(proto目录、curvefs/proto目录下) + + 如果没有其他问题,会在工程目录下生成compile_command.json文件 - +## vscode clangd 配置 -Curve supports deployment in private cloud and public cloud environment, and can also be used in hybrid cloud. The deployment architecture in private cloud environment is as follows: +1. 卸载或禁用ms-vscode.cpptools +2. 搜索clangd并安装 +3. 在设置中,对clangd.arguments加入如下参数 + + ```json + "clangd.arguments": [ + "-j=4", + "--background-index", + "--all-scopes-completion", + "--pch-storage=disk", + "--completion-style=detailed", + "--header-insertion=iwyu", + "--malloc-trim", + "--query-driver=/usr/bin/clang++-11" + ] + ``` - +4. 第一次需要手动启动clangd -The CurveFS shared file storage system can be elastically scaled to public cloud storage, which can provide users with greater capacity elasticity, lower costs, and better performance experience: + 按F1打开命令面板,选择 `clangd: Manually activate extension` - +5. 【可选】可以在工程目录下新建.clangd文件(或者放到 `~/.config/clangd/config.yaml`),开启更多的检查和提示 -## Curve Block Service vs Ceph Block Device + ``` + Diagnostics: + ClangTidy: + Add: [performance-*, modernize-*, readability-*,bugprone-*,] + Remove: [modernize-use-trailing-return-type] + CheckOptions: + readability-identifier-naming.VariableCase: camelBack + UnusedIncludes: Strict + + # 下面几个可以设置为True,可以在对应的地方显示函数形参名称和auto推导出的类型 + InlayHints: + Enabled: False + ParameterNames: False + DeducedTypes: False + ``` -Curve: v1.2.0 +### clangd 官网 -Ceph: L/N -### Performance -Curve random read and write performance far exceeds Ceph in the block storage scenario. +https://clangd.llvm.org/installation -Environment:3 replicas on a 6-node cluster, each node has 20xSATA SSD, 2xE5-2660 v4 and 256GB memory. +### clangd 配置说明 -Single Vol: - - -Multi Vols: - - -### Stability -The stability of the common abnormal Curve is better than that of Ceph in the block storage scenario. -| Fault Case | One Disk Failure | Slow Disk Detect | One Server Failure | Server Suspend Animation | -| :----: | :----: | :----: | :----: | :----: | -| Ceph | jitter 7s | Continuous io jitter | jitter 7s | unrecoverable | -| Curve | jitter 4s | no effect | jitter 4s | jitter 4s | -### Ops -Curve ops is more friendly than Curve in the block storage scenario. -| Ops scenarios | Upgrade clients | Balance | -| :----: | :----: | :----: | -| Ceph | do not support live upgrade | via plug-in with IO influence | -| Curve | support live upgrade with second jitter | auto with no influence on IO | - -## Design Documentation - -- Wanna have a glance at Curve? Click here for [Intro to Curve](https://www.opencurve.io/)! -- Want more details about CurveBS? Our documentation for every component: - - [NEBD](docs/en/nebd_en.md) - - [MDS](docs/en/mds_en.md) - - [Chunkserver](docs/en/chunkserver_design_en.md) - - [Snapshotcloneserver](docs/en/snapshotcloneserver_en.md) - - [CURVE quality control](docs/en/quality_en.md) - - [CURVE monitoring](docs/en/monitor_en.md) - - [Client](docs/en/client_en.md) - - [Client Python API](docs/en/curve-client-python-api_en.md) -- Application based on CurveBS - - [Work with k8s](docs/en/k8s_csi_interface_en.md) -- Want more details about CurveFS? Our documentation for every component(Chinese version only, English version will be uploaded soon): - - [Architecture design](docs/cn/curvefs_architecture.md) - - [Client design](docs/cn/curvefs-client-design.md) - - [Metadata management](docs/cn/curvefs-metaserver-overview.md) - - [Data caching](https://github.com/opencurve/curve-meetup-slides/blob/main/CurveFS/Curve%E6%94%AF%E6%8C%81S3%20%E6%95%B0%E6%8D%AE%E7%BC%93%E5%AD%98%E6%96%B9%E6%A1%88.pdf) - - [Space allocation](https://github.com/opencurve/curve-meetup-slides/blob/main/CurveFS/Curve%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E7%A9%BA%E9%97%B4%E5%88%86%E9%85%8D%E6%96%B9%E6%A1%88.pdf) - - [more details](https://github.com/opencurve/curve-meetup-slides/tree/main/CurveFS) - -## Quick Start of CurveBS - -In order to improve the operation and maintenance convenience of Curve, we designed and developed the [CurveAdm](https://github.com/opencurve/curveadm) project, which is mainly used for deploying and managing Curve clusters. Currently, it supports the deployment of CurveBS & CurveFS (scaleout, upgrade and other functions are under development), please refer to the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki) for related documentation, and install the CurveAdm tool according to the manual before deploying the Curve cluster. - -### Deploy an all-in-one environment (to try how CURVE works) -Please refer to the CurveBS cluster deployment steps in the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki/curvebs-cluster-deployment) , for the single-machine experience environment, please use the template about "cluster topology file for single-machine deployment". - - -[Deploy on single machine - deprecated method](docs/en/deploy_en.md#deploy-on-single-machine) - -### Deploy multi-machine cluster (try it in production environment) -Please refer to the CurveBS cluster deployment steps in the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki/curvebs-cluster-deployment) , please use the template about "cluster topology file for multi-machine deployment". - - -[Deploy on multiple machines - deprecated method](docs/en/deploy_en.md#deploy-on-multiple-machines) - -### curve_ops_tool introduction - -[curve_ops_tool introduction](docs/en/curve_ops_tool_en.md) - -## Quick Start of CurveFS -In order to improve the operation and maintenance convenience of Curve, we designed and developed the [CurveAdm](https://github.com/opencurve/curveadm) project, which is mainly used for deploying and managing Curve clusters. Currently, it supports the deployment of CurveBS & CurveFS (scaleout, upgrade and other functions are under development), please refer to the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki) for related documentation, and install the CurveAdm tool according to the manual before deploying the Curve cluster. - -Detail for deploying CurveFS cluster: [CurveFS ​​deployment](https://github.com/opencurve/curveadm/wiki/curvefs-cluster-deployment) - -### curvefs_tool introduction - -[curvefs_tool introduction](curvefs/src/tools#readme) - - -## For Developers - -### Deploy build and development environment - -[development environment deployment](docs/en/build_and_run_en.md) - -### Compile test cases and run -[test cases compiling and running](docs/en/build_and_run_en.md#test-case-compilation-and-execution) - -### FIO curve block storage engine -Fio curve engine is added, you can clone https://github.com/opencurve/fio and compile the fio tool with our engine(depend on nebd lib), fio command line example: `./fio --thread --rw=randwrite --bs=4k --ioengine=nebd --nebd=cbd:pool//pfstest_test_ --iodepth=10 --runtime=120 --numjobs=10 --time_based --group_reporting --name=curve-fio-test` - -### Coding style guides -CURVE is coded following [Google C++ Style Guide strictly](https://google.github.io/styleguide/cppguide.html). Please follow this guideline if you're trying to contribute your codes. - -### Code coverage requirement -1. Unit tests: Incremental line coverage ≥ 80%, incremental branch coverage ≥ 70% -2. Integration tests: Measure together with unit tests, and should fulfill the same requirement -3. Exception tests: Not required yet - -### Other processes - -After finishing the development of your code, you should submit a pull request to master branch of CURVE and fill out a pull request template. The pull request will trigger the CI automatically, and the code will only be merged after passing the CI and being reviewed. The Jenkins username and password of CI is netease/netease. If the CI fails to run, you can login to the Jenkins platform to view the reason for the failure. - -For more detail, please refer to [CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). - -## Release Cycle -- CURVE release cycle:Half a year for major version, 1~2 months for minor version - -- Versioning format: We use a sequence of three digits and a suffix (x.y.z{-suffix}), x is the major version, y is the minor version, and z is for bugfix. The suffix is for distinguishing beta (-beta), RC (-rc) and GA version (without any suffix). Major version x will increase 1 every half year, and y will increase every 1~2 months. After a version is released, number z will increase if there's any bugfix. - -## Branch - -All the developments will be done under master branch. If there's any new version to establish, a new branch release-x.y will be pulled from the master, and the new version will be released from this branch. - -## Feedback & Contact - -- [Github Issues](https://github.com/openCURVE/CURVE/issues):You are sincerely welcomed to issue any bugs you came across or any suggestions through Github issues. If you have any question you can refer to our FAQ or join our user group for more details. -- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):Frequently asked question in our user group, and we'll keep working on it. -- User group:We use Wechat group currently. -- [Double Week Meetings](https://github.com/opencurve/curve-meetup-slides/tree/main/2022): We have an online community meeting every two weeks which talk about what Curve is doing and planning to do. The time and links of the meeting are public in the user group and [Double Week Meetings](https://github.com/opencurve/curve-meetup-slides/tree/main/2022). - - +https://clangd.llvm.org/config diff --git a/README_en.md b/README_en.md new file mode 100644 index 0000000000..aecf3c1007 --- /dev/null +++ b/README_en.md @@ -0,0 +1,150 @@ +[中文版](README_cn.md) + + + + +# CURVE + +[![Docs](https://img.shields.io/badge/docs-latest-green.svg)](https://github.com/opencurve/curve/tree/master/docs) +[![Releases](https://img.shields.io/github/v/release/opencurve/curve?include_prereleases)](https://github.com/opencurve/curve/releases) +[![LICENSE](https://img.shields.io/badge/licence-Apache--2.0%2FGPL-blue)](https://github.com/opencurve/curve/blob/master/LICENSE) + +Curve is a distributed storage system designed and developed by NetEase, featured with high performance, easy operation and cloud native. Curve is compose of CurveBS(Curve Block Storage) and CurveFS(Curve FileSystem). CurveBS supports snapshot, clone, and recover, also supports virtual machines with qemu and physical machine with nbd. CurveFS supports POSIX based on Fuse. + +## Curve Architecture +The architecture overview of Curve is as follows: + + + +Curve supports deployment in private cloud and public cloud environment, and can also be used in hybrid cloud. The deployment architecture in private cloud environment is as follows: + + + +The CurveFS shared file storage system can be elastically scaled to public cloud storage, which can provide users with greater capacity elasticity, lower costs, and better performance experience: + + + +## Curve Block Service vs Ceph Block Device + +Curve: v1.2.0 + +Ceph: L/N +### Performance +Curve random read and write performance far exceeds Ceph in the block storage scenario. + +Environment:3 replicas on a 6-node cluster, each node has 20xSATA SSD, 2xE5-2660 v4 and 256GB memory. + +Single Vol: + + +Multi Vols: + + +### Stability +The stability of the common abnormal Curve is better than that of Ceph in the block storage scenario. +| Fault Case | One Disk Failure | Slow Disk Detect | One Server Failure | Server Suspend Animation | +| :----: | :----: | :----: | :----: | :----: | +| Ceph | jitter 7s | Continuous io jitter | jitter 7s | unrecoverable | +| Curve | jitter 4s | no effect | jitter 4s | jitter 4s | +### Ops +Curve ops is more friendly than Curve in the block storage scenario. +| Ops scenarios | Upgrade clients | Balance | +| :----: | :----: | :----: | +| Ceph | do not support live upgrade | via plug-in with IO influence | +| Curve | support live upgrade with second jitter | auto with no influence on IO | + +## Design Documentation + +- Wanna have a glance at Curve? Click here for [Intro to Curve](https://www.opencurve.io/)! +- Want more details about CurveBS? Our documentation for every component: + - [NEBD](docs/en/nebd_en.md) + - [MDS](docs/en/mds_en.md) + - [Chunkserver](docs/en/chunkserver_design_en.md) + - [Snapshotcloneserver](docs/en/snapshotcloneserver_en.md) + - [CURVE quality control](docs/en/quality_en.md) + - [CURVE monitoring](docs/en/monitor_en.md) + - [Client](docs/en/client_en.md) + - [Client Python API](docs/en/curve-client-python-api_en.md) +- Application based on CurveBS + - [Work with k8s](docs/en/k8s_csi_interface_en.md) +- Want more details about CurveFS? Our documentation for every component(Chinese version only, English version will be uploaded soon): + - [Architecture design](docs/cn/curvefs_architecture.md) + - [Client design](docs/cn/curvefs-client-design.md) + - [Metadata management](docs/cn/curvefs-metaserver-overview.md) + - [Data caching](https://github.com/opencurve/curve-meetup-slides/blob/main/CurveFS/Curve%E6%94%AF%E6%8C%81S3%20%E6%95%B0%E6%8D%AE%E7%BC%93%E5%AD%98%E6%96%B9%E6%A1%88.pdf) + - [Space allocation](https://github.com/opencurve/curve-meetup-slides/blob/main/CurveFS/Curve%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E7%A9%BA%E9%97%B4%E5%88%86%E9%85%8D%E6%96%B9%E6%A1%88.pdf) + - [more details](https://github.com/opencurve/curve-meetup-slides/tree/main/CurveFS) + +## Quick Start of CurveBS + +In order to improve the operation and maintenance convenience of Curve, we designed and developed the [CurveAdm](https://github.com/opencurve/curveadm) project, which is mainly used for deploying and managing Curve clusters. Currently, it supports the deployment of CurveBS & CurveFS (scaleout, upgrade and other functions are under development), please refer to the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki) for related documentation, and install the CurveAdm tool according to the manual before deploying the Curve cluster. + +### Deploy an all-in-one environment (to try how CURVE works) +Please refer to the CurveBS cluster deployment steps in the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki/curvebs-cluster-deployment) , for the single-machine experience environment, please use the template about "cluster topology file for single-machine deployment". + + +[Deploy on single machine - deprecated method](docs/en/deploy_en.md#deploy-on-single-machine) + +### Deploy multi-machine cluster (try it in production environment) +Please refer to the CurveBS cluster deployment steps in the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki/curvebs-cluster-deployment) , please use the template about "cluster topology file for multi-machine deployment". + + +[Deploy on multiple machines - deprecated method](docs/en/deploy_en.md#deploy-on-multiple-machines) + +### curve_ops_tool introduction + +[curve_ops_tool introduction](docs/en/curve_ops_tool_en.md) + +## Quick Start of CurveFS +In order to improve the operation and maintenance convenience of Curve, we designed and developed the [CurveAdm](https://github.com/opencurve/curveadm) project, which is mainly used for deploying and managing Curve clusters. Currently, it supports the deployment of CurveBS & CurveFS (scaleout, upgrade and other functions are under development), please refer to the [CurveAdm User Manual](https://github.com/opencurve/curveadm/wiki) for related documentation, and install the CurveAdm tool according to the manual before deploying the Curve cluster. + +Detail for deploying CurveFS cluster: [CurveFS ​​deployment](https://github.com/opencurve/curveadm/wiki/curvefs-cluster-deployment) + +### curvefs_tool introduction + +[curvefs_tool introduction](curvefs/src/tools#readme) + + +## For Developers + +### Deploy build and development environment + +[development environment deployment](docs/en/build_and_run_en.md) + +### Compile test cases and run +[test cases compiling and running](docs/en/build_and_run_en.md#test-case-compilation-and-execution) + +### FIO curve block storage engine +Fio curve engine is added, you can clone https://github.com/opencurve/fio and compile the fio tool with our engine(depend on nebd lib), fio command line example: `./fio --thread --rw=randwrite --bs=4k --ioengine=nebd --nebd=cbd:pool//pfstest_test_ --iodepth=10 --runtime=120 --numjobs=10 --time_based --group_reporting --name=curve-fio-test` + +### Coding style guides +CURVE is coded following [Google C++ Style Guide strictly](https://google.github.io/styleguide/cppguide.html). Please follow this guideline if you're trying to contribute your codes. + +### Code coverage requirement +1. Unit tests: Incremental line coverage ≥ 80%, incremental branch coverage ≥ 70% +2. Integration tests: Measure together with unit tests, and should fulfill the same requirement +3. Exception tests: Not required yet + +### Other processes + +After finishing the development of your code, you should submit a pull request to master branch of CURVE and fill out a pull request template. The pull request will trigger the CI automatically, and the code will only be merged after passing the CI and being reviewed. The Jenkins username and password of CI is netease/netease. If the CI fails to run, you can login to the Jenkins platform to view the reason for the failure. + +For more detail, please refer to [CONTRIBUTING](https://github.com/opencurve/curve/blob/master/CONTRIBUTING.md). + +## Release Cycle +- CURVE release cycle:Half a year for major version, 1~2 months for minor version + +- Versioning format: We use a sequence of three digits and a suffix (x.y.z{-suffix}), x is the major version, y is the minor version, and z is for bugfix. The suffix is for distinguishing beta (-beta), RC (-rc) and GA version (without any suffix). Major version x will increase 1 every half year, and y will increase every 1~2 months. After a version is released, number z will increase if there's any bugfix. + +## Branch + +All the developments will be done under master branch. If there's any new version to establish, a new branch release-x.y will be pulled from the master, and the new version will be released from this branch. + +## Feedback & Contact + +- [Github Issues](https://github.com/openCURVE/CURVE/issues):You are sincerely welcomed to issue any bugs you came across or any suggestions through Github issues. If you have any question you can refer to our FAQ or join our user group for more details. +- [FAQ](https://github.com/openCURVE/CURVE/wiki/CURVE-FAQ):Frequently asked question in our user group, and we'll keep working on it. +- User group:We use Wechat group currently. +- [Double Week Meetings](https://github.com/opencurve/curve-meetup-slides/tree/main/2022): We have an online community meeting every two weeks which talk about what Curve is doing and planning to do. The time and links of the meeting are public in the user group and [Double Week Meetings](https://github.com/opencurve/curve-meetup-slides/tree/main/2022). + + diff --git a/WORKSPACE b/WORKSPACE index eb1d8a5f58..625aada675 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,8 +16,7 @@ workspace(name = "curve") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # skylib @@ -78,7 +77,7 @@ bind( #import the gtest files. new_git_repository( name = "com_google_googletest", - build_file = "bazel/gmock.BUILD", + build_file = "//:thirdparties/gmock.BUILD", remote = "https://github.com/google/googletest", tag = "release-1.8.0", ) @@ -117,7 +116,7 @@ bind( http_archive( name = "com_github_google_leveldb", - build_file = "bazel/leveldb.BUILD", + build_file = "@com_github_apache_brpc//:leveldb.BUILD", strip_prefix = "leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6", urls = ["https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"], ) @@ -158,7 +157,7 @@ bind( # jsoncpp new_git_repository( name = "jsoncpp", - build_file = "bazel/jsoncpp.BUILD", + build_file = "//:thirdparties/jsoncpp.BUILD", remote = "https://github.com/open-source-parsers/jsoncpp.git", tag = "1.8.4", ) @@ -170,7 +169,7 @@ bind( new_local_repository( name = "etcdclient", - build_file = "external/bazel/etcdclient.BUILD", + build_file = "//:thirdparties/etcdclient.BUILD", path = "thirdparties/etcdclient", ) @@ -233,6 +232,20 @@ http_archive( # RocksDB new_local_repository( name = "rocksdb", - build_file = "external/bazel/rocksdb.BUILD", + build_file = "//:thirdparties/rocksdb.BUILD", path = "thirdparties/rocksdb", ) + +# Hedron's Compile Commands Extractor for Bazel +# https://github.com/hedronvision/bazel-compile-commands-extractor +http_archive( + name = "hedron_compile_commands", + + # Replace the commit hash in both places (below) with the latest, rather than using the stale one here. + # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). + url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/af9af15f7bc16fc3e407e2231abfcb62907d258f.tar.gz", + strip_prefix = "bazel-compile-commands-extractor-af9af15f7bc16fc3e407e2231abfcb62907d258f", + # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." +) +load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") +hedron_compile_commands_setup() diff --git a/docs/images/clangd/clangd_error.png b/docs/images/clangd/clangd_error.png new file mode 100644 index 0000000000..c725a35b3f Binary files /dev/null and b/docs/images/clangd/clangd_error.png differ diff --git a/external/bazel/gflags.BUILD b/external/bazel/gflags.BUILD deleted file mode 100644 index de6d2d020f..0000000000 --- a/external/bazel/gflags.BUILD +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 2020 NetEase Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Bazel (http://bazel.io/) BUILD file for gflags. -# -# See INSTALL.md for instructions for adding gflags to a Bazel workspace. - -licenses(["notice"]) - -exports_files(["src/gflags_completions.sh", "COPYING.txt"]) - -config_setting( - name = "x64_windows", - values = {"cpu": "x64_windows"}, -) - -load(":bazel/gflags.bzl", "gflags_sources", "gflags_library") - -(hdrs, srcs) = gflags_sources(namespace=["gflags", "google"]) -gflags_library(hdrs=hdrs, srcs=srcs, threads=0) -gflags_library(hdrs=hdrs, srcs=srcs, threads=1) diff --git a/external/bazel/glog.BUILD b/external/bazel/glog.BUILD deleted file mode 100644 index 77d88ea7ff..0000000000 --- a/external/bazel/glog.BUILD +++ /dev/null @@ -1,98 +0,0 @@ -# -# Copyright (c) 2020 NetEase Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cc_library( - name = "glog", - srcs = [ - "config.h", - "src/base/commandlineflags.h", - "src/base/googleinit.h", - "src/base/mutex.h", - "src/demangle.cc", - "src/demangle.h", - "src/logging.cc", - "src/raw_logging.cc", - "src/signalhandler.cc", - "src/symbolize.cc", - "src/symbolize.h", - "src/utilities.cc", - "src/utilities.h", - "src/vlog_is_on.cc", - ] + glob(["src/stacktrace*.h"]), - hdrs = [ - "src/glog/log_severity.h", - "src/glog/logging.h", - "src/glog/raw_logging.h", - "src/glog/stl_logging.h", - "src/glog/vlog_is_on.h", - ], - copts = [ - "-Wno-sign-compare", - "-U_XOPEN_SOURCE", - ], - includes = ["./src"], - linkopts = ["-lpthread"] + select({ - ":libunwind": ["-lunwind"], - "//conditions:default": [], - }), - visibility = ["//visibility:public"], - deps = [ - "@com_github_gflags_gflags//:gflags", - ], -) - -config_setting( - name = "libunwind", - values = { - "define": "libunwind=true", - }, -) - -genrule( - name = "run_configure", - srcs = [ - "README", - "Makefile.in", - "config.guess", - "config.sub", - "install-sh", - "ltmain.sh", - "missing", - "libglog.pc.in", - "src/config.h.in", - "src/glog/logging.h.in", - "src/glog/raw_logging.h.in", - "src/glog/stl_logging.h.in", - "src/glog/vlog_is_on.h.in", - ], - outs = [ - "config.h", - "src/glog/logging.h", - "src/glog/raw_logging.h", - "src/glog/stl_logging.h", - "src/glog/vlog_is_on.h", - ], - tools = [ - "configure", - ], - cmd = "$(location :configure)" + - "&& cp -v src/config.h $(location config.h) " + - "&& cp -v src/glog/logging.h $(location src/glog/logging.h) " + - "&& cp -v src/glog/raw_logging.h $(location src/glog/raw_logging.h) " + - "&& cp -v src/glog/stl_logging.h $(location src/glog/stl_logging.h) " + - "&& cp -v src/glog/vlog_is_on.h $(location src/glog/vlog_is_on.h) " - , -) diff --git a/external/bazel/gtest.BUILD b/external/bazel/gtest.BUILD deleted file mode 100644 index f88075d55b..0000000000 --- a/external/bazel/gtest.BUILD +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright (c) 2020 NetEase Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -cc_library( - name = "main", - srcs = glob( - ["src/*.cc"], - exclude = ["src/gtest-all.cc"] - ), - hdrs = glob([ - "include/**/*.h", - "src/*.h" - ]), - copts = ["-Iexternal/gtest/include"], - linkopts = ["-pthread"], - visibility = ["//visibility:public"], -) diff --git a/external/bazel/leveldb.BUILD b/external/bazel/leveldb.BUILD deleted file mode 100644 index 9b0f56f5d6..0000000000 --- a/external/bazel/leveldb.BUILD +++ /dev/null @@ -1,98 +0,0 @@ -# -# Copyright (c) 2020 NetEase Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package(default_visibility = ["//visibility:public"]) - - -config_setting( - name = "darwin", - values = {"cpu": "darwin"}, - visibility = ["//visibility:public"], -) - -SOURCES = ["db/builder.cc", - "db/c.cc", - "db/dbformat.cc", - "db/db_impl.cc", - "db/db_iter.cc", - "db/dumpfile.cc", - "db/filename.cc", - "db/log_reader.cc", - "db/log_writer.cc", - "db/memtable.cc", - "db/repair.cc", - "db/table_cache.cc", - "db/version_edit.cc", - "db/version_set.cc", - "db/write_batch.cc", - "table/block_builder.cc", - "table/block.cc", - "table/filter_block.cc", - "table/format.cc", - "table/iterator.cc", - "table/merger.cc", - "table/table_builder.cc", - "table/table.cc", - "table/two_level_iterator.cc", - "util/arena.cc", - "util/bloom.cc", - "util/cache.cc", - "util/coding.cc", - "util/comparator.cc", - "util/crc32c.cc", - "util/env.cc", - "util/env_posix.cc", - "util/filter_policy.cc", - "util/hash.cc", - "util/histogram.cc", - "util/logging.cc", - "util/options.cc", - "util/status.cc", - "port/port_posix.cc", - "port/port_posix_sse.cc", - "helpers/memenv/memenv.cc", - ] - -cc_library( - name = "leveldb", - srcs = SOURCES, - hdrs = glob([ - "helpers/memenv/*.h", - "util/*.h", - "port/*.h", - "port/win/*.h", - "table/*.h", - "db/*.h", - "include/leveldb/*.h" - ], - exclude = [ - "**/*test.*", - ]), - includes = [ - "include/", - ], - copts = [ - "-fno-builtin-memcmp", - "-DLEVELDB_PLATFORM_POSIX=1", - "-DLEVELDB_ATOMIC_PRESENT", - ], - defines = [ - "LEVELDB_PLATFORM_POSIX", - ] + select({ - ":darwin": ["OS_MACOSX"], - "//conditions:default": [], - }), -) diff --git a/external/bazel/etcdclient.BUILD b/thirdparties/etcdclient.BUILD similarity index 100% rename from external/bazel/etcdclient.BUILD rename to thirdparties/etcdclient.BUILD diff --git a/external/bazel/gmock.BUILD b/thirdparties/gmock.BUILD similarity index 100% rename from external/bazel/gmock.BUILD rename to thirdparties/gmock.BUILD diff --git a/external/bazel/jsoncpp.BUILD b/thirdparties/jsoncpp.BUILD similarity index 100% rename from external/bazel/jsoncpp.BUILD rename to thirdparties/jsoncpp.BUILD diff --git a/external/bazel/rocksdb.BUILD b/thirdparties/rocksdb.BUILD similarity index 100% rename from external/bazel/rocksdb.BUILD rename to thirdparties/rocksdb.BUILD