Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
hycdong committed Feb 23, 2021
2 parents fc8bfda + c057d35 commit 25bda88
Show file tree
Hide file tree
Showing 136 changed files with 3,767 additions and 31,514 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ message (STATUS "dsn Installation directory: CMAKE_INSTALL_PREFIX = " ${CMAKE_IN
# install rdsn/include to ${CMAKE_INCLUDE_PREFIX}/include
install(DIRECTORY include/ DESTINATION include)

# NOTE: dsn_types.h is not actually a thrift-generated file. As pegasus may reference it,
# we should copy also this file to the path the same as other thrift-generated files.
install(FILES include/dsn/cpp/serialization_helper/dsn_types.h DESTINATION include)
# TODO(wutao1): remove this line after dsn.layer2_types.h is removed from repo.
install(FILES include/dsn/cpp/serialization_helper/dsn.layer2_types.h DESTINATION include)

include_directories(${DSN_PROJECT_DIR}/include)
include_directories(${DSN_PROJECT_DIR}/include/dsn/cpp/serialization_helper)
include_directories(${DSN_PROJECT_DIR}/src)
Expand Down
3 changes: 3 additions & 0 deletions bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,7 @@ function(dsn_common_setup)
dsn_setup_compiler_flags()
dsn_setup_include_path()
dsn_setup_thirdparty_libs()

include(${DSN_PROJECT_DIR}/bin/thrift_utils.cmake)

endfunction(dsn_common_setup)
79 changes: 79 additions & 0 deletions bin/thrift_utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
##############################################################################
# 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.
##############################################################################

find_program(THRIFT_COMPILER
NAME
thrift
PATHS
${DSN_THIRDPARTY_ROOT}/bin
NO_DEFAULT_PATH
)

set(THRIFT_GENERATED_FILE_PATH ${CMAKE_BINARY_DIR}/thrift-gen CACHE INTERNAL "Where the thrift generated sources locate")
if(NOT EXISTS ${THRIFT_GENERATED_FILE_PATH})
file(MAKE_DIRECTORY ${THRIFT_GENERATED_FILE_PATH})
endif()
message(STATUS "THRIFT_GENERATED_FILE_PATH=${THRIFT_GENERATED_FILE_PATH}")
include_directories(${THRIFT_GENERATED_FILE_PATH})

# THRIFT_GENERATE_CPP is used to generate sources using the thrift compiler.
#
# Example:
#
# thrift_generate_cpp(
# REQUEST_META_THRIFT_SRCS
# REQUEST_META_THRIFT_HDRS
# ${CMAKE_CURRENT_SOURCE_DIR}/request_meta.thrift
# )
# add_library(
# dsn_rpc
# ${REQUEST_META_THRIFT_SRCS}
# ...
# )
function(THRIFT_GENERATE_CPP SRCS HDRS thrift_file)
if(NOT EXISTS ${thrift_file})
message(FATAL_ERROR "thrift file ${thrift_file} does not exist")
endif()

message(STATUS "THRIFT_GENERATE_CPP: ${thrift_file}")

exec_program(${THRIFT_COMPILER}
ARGS -gen cpp:moveable_types --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}
OUTPUT_VARIABLE __thrift_OUT
RETURN_VALUE THRIFT_RETURN)
if(NOT ${THRIFT_RETURN} EQUAL "0")
message(STATUS "COMMAND: ${THRIFT_COMPILER} -gen cpp:moveable_types --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}")
message(FATAL_ERROR "thrift-compiler exits with " ${THRIFT_RETURN} ": " ${__thrift_OUT})
endif()

get_filename_component(__thrift_name ${thrift_file} NAME_WE)

set(${SRCS})
set(${HDRS})
file(GLOB __result_src "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}_types.cpp")
file(GLOB __result_hdr "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}_types.h")
list(APPEND ${SRCS} ${__result_src})
list(APPEND ${HDRS} ${__result_hdr})
# Sets the variables in global scope.
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)

# install the thrift generated headers to include/
install(FILES ${__result_hdr} DESTINATION include)
endfunction()
75 changes: 0 additions & 75 deletions compile_thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,6 @@
"_types.cpp": "src/runtime"
}
},
{
"name": "fd",
"path": "src/failure_detector",
"file_move": {
"_types.h": "include/dsn/dist/failure_detector"
},
"include_fix": {
"_types.h": {
"add": ["<dsn/service_api_cpp.h>"],
"remove": ["\"dsn_types.h\""]
},
"_types.cpp": {
"add": ["<dsn/dist/failure_detector/fd_types.h>"],
"remove": ["\"fd_types.h\""]
},
}
},
{
"name": "replication",
"path": "src/",
"file_move": {
"_types.h": "include/dsn/dist/replication",
"_types.cpp": "src/common"
},
"include_fix": {
"_types.h": {
"add": ["<dsn/cpp/serialization_helper/dsn.layer2_types.h>"],
"remove": ["\"dsn_types.h\"", "\"dsn.layer2_types.h\""]
},
"_types.cpp": {
"add": ["<dsn/dist/replication/replication_types.h>"],
"remove": ["\"replication_types.h\""]
},
},
},
{
"name": "nfs",
"path": "src/nfs",
"include_fix": {
"_types.h": {
"add": ["<dsn/service_api_cpp.h>"],
"remove": ["\"dsn_types.h\""]
}
}
},
{
"name": "simple_kv",
"path": "src/replica/storage/simple_kv"
},
{
"name": "command",
"path": "src/remote_cmd",
"file_move": {
"_types.h": "src/remote_cmd",
"_types.cpp": "src/remote_cmd"
}
},
{
"name": "security",
"path": "src/runtime/security",
"file_move": {
"_types.h": "src/runtime/security",
"_types.cpp": "src/runtime/security"
},
"include_fix": {
"_types.h": {
"add": ["<dsn/cpp/serialization_helper/dsn_types.h>"],
"remove": ["\"dsn_types.h\""]
},
"_types.cpp": {
"add": ["\"security_types.h\""],
"remove": ["\"security_types.h\""]
}
}
}
]


Expand Down
13 changes: 8 additions & 5 deletions include/dsn/cpp/rpc_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ class rpc_read_stream : public binary_reader
void set_read_msg(message_ex *msg)
{
_msg = msg;
if (nullptr != _msg) {
::dsn::blob bb;
bool r = ((::dsn::message_ex *)_msg)->read_next(bb);
dassert(r, "read msg must have one segment of buffer ready");

::dsn::blob bb;
bool r = ((::dsn::message_ex *)_msg)->read_next(bb);
dassert(r, "read msg must have one segment of buffer ready");

init(std::move(bb));
init(std::move(bb));
}
}

~rpc_read_stream()
Expand Down Expand Up @@ -84,6 +85,8 @@ class rpc_write_stream : public binary_writer
// buffers at the same time.
// e.g., alloc1, commit1, alloc2, commit2 is ok
// while alloc1, alloc2, commit2, commit 1 is invalid
// TODO(zhaoliwei): remove functions and variables below, because msg is not implemented by tls
// memory now
void commit_buffer()
{
if (!_last_write_next_committed) {
Expand Down
97 changes: 0 additions & 97 deletions include/dsn/cpp/serialization_helper/dsn.layer2_types.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions include/dsn/dist/failure_detector/failure_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class failure_detector : public failure_detector_service,
{
public:
failure_detector();
virtual ~failure_detector() { unregister_ctrl_commands(); }
virtual ~failure_detector();

virtual void on_ping(const beacon_msg &beacon, ::dsn::rpc_replier<beacon_ack> &reply);

Expand All @@ -109,7 +109,7 @@ class failure_detector : public failure_detector_service,
uint32_t grace_seconds,
bool use_allow_list = false);

error_code stop();
void stop();

uint32_t get_lease_ms() const { return _lease_milliseconds; }
uint32_t get_grace_ms() const { return _grace_milliseconds; }
Expand Down
3 changes: 2 additions & 1 deletion include/dsn/dist/failure_detector/fd.code.definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#pragma once

#include <dsn/tool-api/task_code.h>
#include <dsn/dist/failure_detector/fd_types.h>
#include <dsn/service_api_cpp.h>
#include "fd_types.h"

namespace dsn {
namespace fd {
Expand Down
Loading

0 comments on commit 25bda88

Please sign in to comment.