You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by la...@apache.org on 2022/07/26 07:06:20 UTC

[incubator-pegasus] branch master updated: refactor: Move some common files out of rdsn directory (#1079)

This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new b8e4cd6e1 refactor: Move some common files out of rdsn directory (#1079)
b8e4cd6e1 is described below

commit b8e4cd6e139edb7707b9224d554700f17885c118
Author: Yingchun Lai <la...@apache.org>
AuthorDate: Tue Jul 26 15:06:16 2022 +0800

    refactor: Move some common files out of rdsn directory (#1079)
---
 .gitignore                                      |  17 +++++++++-----
 .licenserc.yaml                                 |   8 +++----
 {src/rdsn => docs}/CONTRIBUTING.md              |   0
 src/rdsn/README.md => docs/rdsn-README.md       |   0
 {src/rdsn => docs}/resources/arch.png           | Bin
 {src/rdsn => docs}/resources/config.png         | Bin
 {src/rdsn => docs}/resources/rdsn-layer1.jpg    | Bin
 {src/rdsn => docs}/resources/rdsn-layer2.jpg    | Bin
 {src/rdsn => docs}/resources/rdsn-layer3.jpg    | Bin
 {src/rdsn => docs}/resources/rdsn-state-all.jpg | Bin
 {src/rdsn => docs}/resources/rdsn.jpg           | Bin
 {src/rdsn => docs}/resources/viz.png            | Bin
 {src/rdsn/src => idl}/dsn.layer2.thrift         |   1 +
 {src/rdsn/src => idl}/dsn.thrift                |   0
 {src/idl => idl}/rrdb.thrift                    |   0
 run.sh                                          |   7 ++----
 {src/rdsn => scripts}/compile_thrift.py         |  15 +++++--------
 {src/idl => scripts}/recompile_thrift.sh        |  12 ++++------
 src/idl/dsn.thrift                              |  28 ------------------------
 src/rdsn/src/common/backup.thrift               |   4 ++--
 src/rdsn/src/common/bulk_load.thrift            |   4 ++--
 src/rdsn/src/common/consensus.thrift            |   4 ++--
 src/rdsn/src/common/duplication.thrift          |   4 ++--
 src/rdsn/src/common/meta_admin.thrift           |   4 ++--
 src/rdsn/src/common/metadata.thrift             |   4 ++--
 src/rdsn/src/common/partition_split.thrift      |   4 ++--
 src/rdsn/src/common/replica_admin.thrift        |   4 ++--
 src/rdsn/src/failure_detector/fd.thrift         |   2 +-
 src/rdsn/src/nfs/nfs.thrift                     |   2 +-
 src/rdsn/src/runtime/security/security.thrift   |   2 +-
 30 files changed, 47 insertions(+), 79 deletions(-)

diff --git a/.gitignore b/.gitignore
index e70e26a5b..934806e33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,7 +16,14 @@
 # under the License.
 
 src/.matchfile
+src/base/rrdb_types.cpp
+src/include/rrdb/rrdb_types.h
+src/rdsn/builder/
+src/rdsn/include/dsn/cpp/serialization_helper/dsn.layer2_types.h
+src/rdsn/src/runtime/dsn.layer2_types.cpp
+src/runtime
 src/builder
+
 onebox/
 .zk_install/
 *.data/
@@ -263,9 +270,7 @@ package-lock.json
 #go
 go-client/bin
 
-# rdsn
-rdsn/builder
-thirdparty/build
-thirdparty/output
-rdsn/cmake-build-debug
-rdsn/test_reports
+thirdparty/output/
+
+#macOS
+.DS_Store
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 83badcf1d..9750ec90b 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -94,9 +94,11 @@ header:
     - 'src/rdsn/src/utils/test/config-empty.ini'
     # The MIT License (MIT), Copyright (c) 2015 Microsoft Corporation
     - 'cmake_modules/BaseFunctions.cmake'
+    - 'docs/rdsn-README.md'
+    - 'idl/dsn.layer2.thrift'
+    - 'idl/dsn.thrift'
+    - 'scripts/compile_thrift.py'
     - 'scripts/learn_stat.py'
-    - 'src/rdsn/README.md'
-    - 'src/rdsn/compile_thrift.py'
     - 'src/rdsn/include/dsn/c/api_common.h'
     - 'src/rdsn/include/dsn/c/api_layer1.h'
     - 'src/rdsn/include/dsn/c/api_task.h'
@@ -234,8 +236,6 @@ header:
     - 'src/rdsn/src/common/test/duplication_common_test.cpp'
     - 'src/rdsn/src/common/test/main.cpp'
     - 'src/rdsn/src/common/test/run.sh'
-    - 'src/rdsn/src/dsn.layer2.thrift'
-    - 'src/rdsn/src/dsn.thrift'
     - 'src/rdsn/src/failure_detector/failure_detector.cpp'
     - 'src/rdsn/src/failure_detector/failure_detector_multimaster.cpp'
     - 'src/rdsn/src/failure_detector/fd.thrift'
diff --git a/src/rdsn/CONTRIBUTING.md b/docs/CONTRIBUTING.md
similarity index 100%
rename from src/rdsn/CONTRIBUTING.md
rename to docs/CONTRIBUTING.md
diff --git a/src/rdsn/README.md b/docs/rdsn-README.md
similarity index 100%
rename from src/rdsn/README.md
rename to docs/rdsn-README.md
diff --git a/src/rdsn/resources/arch.png b/docs/resources/arch.png
similarity index 100%
rename from src/rdsn/resources/arch.png
rename to docs/resources/arch.png
diff --git a/src/rdsn/resources/config.png b/docs/resources/config.png
similarity index 100%
rename from src/rdsn/resources/config.png
rename to docs/resources/config.png
diff --git a/src/rdsn/resources/rdsn-layer1.jpg b/docs/resources/rdsn-layer1.jpg
similarity index 100%
rename from src/rdsn/resources/rdsn-layer1.jpg
rename to docs/resources/rdsn-layer1.jpg
diff --git a/src/rdsn/resources/rdsn-layer2.jpg b/docs/resources/rdsn-layer2.jpg
similarity index 100%
rename from src/rdsn/resources/rdsn-layer2.jpg
rename to docs/resources/rdsn-layer2.jpg
diff --git a/src/rdsn/resources/rdsn-layer3.jpg b/docs/resources/rdsn-layer3.jpg
similarity index 100%
rename from src/rdsn/resources/rdsn-layer3.jpg
rename to docs/resources/rdsn-layer3.jpg
diff --git a/src/rdsn/resources/rdsn-state-all.jpg b/docs/resources/rdsn-state-all.jpg
similarity index 100%
rename from src/rdsn/resources/rdsn-state-all.jpg
rename to docs/resources/rdsn-state-all.jpg
diff --git a/src/rdsn/resources/rdsn.jpg b/docs/resources/rdsn.jpg
similarity index 100%
rename from src/rdsn/resources/rdsn.jpg
rename to docs/resources/rdsn.jpg
diff --git a/src/rdsn/resources/viz.png b/docs/resources/viz.png
similarity index 100%
rename from src/rdsn/resources/viz.png
rename to docs/resources/viz.png
diff --git a/src/rdsn/src/dsn.layer2.thrift b/idl/dsn.layer2.thrift
similarity index 98%
rename from src/rdsn/src/dsn.layer2.thrift
rename to idl/dsn.layer2.thrift
index 20e76c64a..4bf1a8ab2 100644
--- a/src/rdsn/src/dsn.layer2.thrift
+++ b/idl/dsn.layer2.thrift
@@ -26,6 +26,7 @@
 
 include "dsn.thrift"
 
+# TODO(yingchun): reuse the idls for server and all client libs
 namespace cpp dsn
 
 struct partition_configuration
diff --git a/src/rdsn/src/dsn.thrift b/idl/dsn.thrift
similarity index 100%
rename from src/rdsn/src/dsn.thrift
rename to idl/dsn.thrift
diff --git a/src/idl/rrdb.thrift b/idl/rrdb.thrift
similarity index 100%
rename from src/idl/rrdb.thrift
rename to idl/rrdb.thrift
diff --git a/run.sh b/run.sh
index a9217148e..ebb65e1fb 100755
--- a/run.sh
+++ b/run.sh
@@ -249,9 +249,8 @@ function run_build()
     fi
 
     echo "INFO: Start build rdsn..."
-    cd $ROOT/src/rdsn
     echo "Gen rdsn thrift"
-    python3 compile_thrift.py
+    python3 $ROOT/scripts/compile_thrift.py
     BUILD_DIR="$ROOT/src/rdsn/builder"
     if [ "$CLEAR" == "YES" ]; then
         echo "Clear $BUILD_DIR ..."
@@ -285,9 +284,7 @@ function run_build()
 
     echo "INFO: start build pegasus..."
     echo "Gen pegasus thrift"
-    pushd $ROOT/src/idl
-    sh recompile_thrift.sh
-    popd
+    sh scripts/recompile_thrift.sh
 
     cd "$ROOT/src"
     PEGASUS_GIT_COMMIT="non-git-repo"
diff --git a/src/rdsn/compile_thrift.py b/scripts/compile_thrift.py
similarity index 92%
rename from src/rdsn/compile_thrift.py
rename to scripts/compile_thrift.py
index 1f1320b32..54dab7c87 100755
--- a/src/rdsn/compile_thrift.py
+++ b/scripts/compile_thrift.py
@@ -36,7 +36,7 @@ the default thrift generator
 thrift_description = [
     {
         "name": "dsn.layer2",
-        "path": "src",
+        "path": "idl",
         "include_fix": {
             "_types.h": {
                 "add": ["<dsn/cpp/serialization_helper/dsn_types.h>"],
@@ -48,8 +48,8 @@ thrift_description = [
             }
         },
         "file_move": {
-            "_types.h": "include/dsn/cpp/serialization_helper",
-            "_types.cpp": "src/runtime"
+            "_types.h": "src/rdsn/include/dsn/cpp/serialization_helper",
+            "_types.cpp": "src/rdsn/src/runtime"
         }
     },
 ]
@@ -219,8 +219,8 @@ def add_hook(name, path, func, args):
 
 
 if __name__ == "__main__":
-    thrift_exe = os.getcwd() + "/../../thirdparty/output/bin/thrift"
     root_dir = os.getcwd()
+    thrift_exe = root_dir + "/thirdparty/output/bin/thrift"
     print("thrift_exe = " + thrift_exe)
     print("root_dir = " + root_dir)
 
@@ -230,11 +230,8 @@ if __name__ == "__main__":
 
     ctor_kv_pair = "  kv_pair(const std::string& _key, const std::string& _val): key(_key), value(_val) {\n  }"
     ctor_configuration_proposal_action = "  configuration_proposal_action(::dsn::rpc_address t, ::dsn::rpc_address n, config_type::type tp): target(t), node(n), type(tp) {}"
-    add_hook("simple_kv", "src/replica/storage/simple_kv", constructor_hook,
-             ["simple_kv_types.h", "kv_pair", ctor_kv_pair])
-    add_hook("replication", "src/", constructor_hook,
-             ["replication_types.h", "configuration_proposal_action", ctor_configuration_proposal_action])
-    add_hook("dsn.layer2", "src", replace_hook, ["dsn.layer2_types.h", {
+
+    add_hook("dsn.layer2", "idl", replace_hook, ["dsn.layer2_types.h", {
              r"dsn\.layer2_TYPES_H": 'dsn_layer2_TYPES_H'}])
 
     for i in thrift_description:
diff --git a/src/idl/recompile_thrift.sh b/scripts/recompile_thrift.sh
similarity index 79%
rename from src/idl/recompile_thrift.sh
rename to scripts/recompile_thrift.sh
index 9791901d0..ecfef7518 100755
--- a/src/idl/recompile_thrift.sh
+++ b/scripts/recompile_thrift.sh
@@ -17,7 +17,7 @@
 # under the License.
 
 cd `dirname $0`
-THIRDPARTY_ROOT=../../thirdparty
+THIRDPARTY_ROOT=../thirdparty
 
 if [ ! -d "$THIRDPARTY_ROOT" ]; then
   echo "ERROR: THIRDPARTY_ROOT not set"
@@ -28,16 +28,12 @@ TMP_DIR=./tmp
 rm -rf $TMP_DIR
 
 mkdir -p $TMP_DIR
-$THIRDPARTY_ROOT/output/bin/thrift --gen cpp:moveable_types -out $TMP_DIR rrdb.thrift
+$THIRDPARTY_ROOT/output/bin/thrift --gen cpp:moveable_types -out $TMP_DIR ../idl/rrdb.thrift
 
-sed 's/#include "dsn_types.h"/#include <dsn\/service_api_cpp.h>/' $TMP_DIR/rrdb_types.h > ../include/rrdb/rrdb_types.h
-sed 's/#include "rrdb_types.h"/#include <rrdb\/rrdb_types.h>/' $TMP_DIR/rrdb_types.cpp > ../base/rrdb_types.cpp
+sed 's/#include "dsn_types.h"/#include <dsn\/service_api_cpp.h>/' $TMP_DIR/rrdb_types.h > ../src/include/rrdb/rrdb_types.h
+sed 's/#include "rrdb_types.h"/#include <rrdb\/rrdb_types.h>/' $TMP_DIR/rrdb_types.cpp > ../src/base/rrdb_types.cpp
 
 rm -rf $TMP_DIR
 
-echo
-echo "You should manually modify these files:"
-echo "  src/include/rrdb/rrdb.code.definition.h"
-echo "  src/include/rrdb/rrdb.client.h"
 echo
 echo "done"
diff --git a/src/idl/dsn.thrift b/src/idl/dsn.thrift
deleted file mode 100644
index cd9eb3c70..000000000
--- a/src/idl/dsn.thrift
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-namespace cpp dsn
-
-// place holder
-struct blob
-{
-}
-
-struct task_code
-{
-}
diff --git a/src/rdsn/src/common/backup.thrift b/src/rdsn/src/common/backup.thrift
index c107ff3af..994174371 100644
--- a/src/rdsn/src/common/backup.thrift
+++ b/src/rdsn/src/common/backup.thrift
@@ -15,8 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 
 namespace cpp dsn.replication
 
diff --git a/src/rdsn/src/common/bulk_load.thrift b/src/rdsn/src/common/bulk_load.thrift
index 7a2f3d88a..a439a8917 100644
--- a/src/rdsn/src/common/bulk_load.thrift
+++ b/src/rdsn/src/common/bulk_load.thrift
@@ -15,8 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 include "metadata.thrift"
 
 namespace cpp dsn.replication
diff --git a/src/rdsn/src/common/consensus.thrift b/src/rdsn/src/common/consensus.thrift
index 595bd85f8..9caca11ca 100644
--- a/src/rdsn/src/common/consensus.thrift
+++ b/src/rdsn/src/common/consensus.thrift
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 include "metadata.thrift"
 
 namespace cpp dsn.replication
diff --git a/src/rdsn/src/common/duplication.thrift b/src/rdsn/src/common/duplication.thrift
index bb506558e..7338e5145 100644
--- a/src/rdsn/src/common/duplication.thrift
+++ b/src/rdsn/src/common/duplication.thrift
@@ -15,8 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 
 namespace cpp dsn.replication
 
diff --git a/src/rdsn/src/common/meta_admin.thrift b/src/rdsn/src/common/meta_admin.thrift
index c61140c2d..a08d85c4e 100644
--- a/src/rdsn/src/common/meta_admin.thrift
+++ b/src/rdsn/src/common/meta_admin.thrift
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 include "metadata.thrift"
 
 namespace cpp dsn.replication
diff --git a/src/rdsn/src/common/metadata.thrift b/src/rdsn/src/common/metadata.thrift
index 91a2a0269..30fe79ca2 100644
--- a/src/rdsn/src/common/metadata.thrift
+++ b/src/rdsn/src/common/metadata.thrift
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 
 namespace cpp dsn.replication
 
diff --git a/src/rdsn/src/common/partition_split.thrift b/src/rdsn/src/common/partition_split.thrift
index 3c9c3eaa8..481d86b0a 100644
--- a/src/rdsn/src/common/partition_split.thrift
+++ b/src/rdsn/src/common/partition_split.thrift
@@ -15,8 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 include "metadata.thrift"
 
 namespace cpp dsn.replication
diff --git a/src/rdsn/src/common/replica_admin.thrift b/src/rdsn/src/common/replica_admin.thrift
index 1397e1dc9..785e696d2 100644
--- a/src/rdsn/src/common/replica_admin.thrift
+++ b/src/rdsn/src/common/replica_admin.thrift
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
-include "../dsn.layer2.thrift"
+include "../../../../idl/dsn.thrift"
+include "../../../../idl/dsn.layer2.thrift"
 include "metadata.thrift"
 
 namespace cpp dsn.replication
diff --git a/src/rdsn/src/failure_detector/fd.thrift b/src/rdsn/src/failure_detector/fd.thrift
index 15917cd55..5edc0f504 100644
--- a/src/rdsn/src/failure_detector/fd.thrift
+++ b/src/rdsn/src/failure_detector/fd.thrift
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
+include "../../../../idl/dsn.thrift"
 
 namespace cpp dsn.fd
 
diff --git a/src/rdsn/src/nfs/nfs.thrift b/src/rdsn/src/nfs/nfs.thrift
index 175d5143b..16a0e2fce 100644
--- a/src/rdsn/src/nfs/nfs.thrift
+++ b/src/rdsn/src/nfs/nfs.thrift
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-include "../dsn.thrift"
+include "../../../../idl/dsn.thrift"
 
 namespace cpp dsn.service
 
diff --git a/src/rdsn/src/runtime/security/security.thrift b/src/rdsn/src/runtime/security/security.thrift
index f4da82b9d..79ed4550e 100644
--- a/src/rdsn/src/runtime/security/security.thrift
+++ b/src/rdsn/src/runtime/security/security.thrift
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-include "../../dsn.thrift"
+include "../../../../../idl/dsn.thrift"
 
 namespace cpp dsn.security
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org