Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ranger): Ranger directory #98

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_subdirectory(http)
add_subdirectory(meta)
add_subdirectory(nfs)
add_subdirectory(perf_counter)
add_subdirectory(ranger)
add_subdirectory(redis_protocol)
add_subdirectory(remote_cmd)
add_subdirectory(replica)
Expand Down
26 changes: 7 additions & 19 deletions src/aio/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,24 @@
# THE SOFTWARE.

set(MY_PROJ_NAME dsn_aio_test)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC "")

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
dsn_runtime
dsn_meta_server
dsn_ranger
dsn_replication_common
gtest
dsn_runtime
dsn_aio
test_utils
gtest
rocksdb
lz4
zstd
snappy)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

# Extra files that will be installed
set(MY_BINPLACES
"${CMAKE_CURRENT_SOURCE_DIR}/config.ini"
"${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
"${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
"${CMAKE_CURRENT_SOURCE_DIR}/copy_source.txt"
)

config.ini
clear.sh
run.sh
copy_source.txt)
dsn_add_test()
2 changes: 1 addition & 1 deletion src/common/json_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "consensus_types.h"
#include "replica_admin_types.h"
#include "common/replication_enums.h"
#include "runtime/ranger/access_type.h"
#include "ranger/access_type.h"

#define JSON_ENCODE_ENTRY(out, prefix, T) \
out.Key(#T); \
Expand Down
26 changes: 7 additions & 19 deletions src/failure_detector/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@
# THE SOFTWARE.

set(MY_PROJ_NAME dsn.failure_detector.tests)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC "")

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
dsn_runtime
dsn_meta_server
dsn_ranger
dsn_replica_server
dsn_replication_common
dsn.failure_detector
Expand All @@ -45,17 +38,12 @@ set(MY_PROJ_LIBS
lz4
zstd
snappy)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

# Extra files that will be installed
set(MY_BINPLACES
"${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
"${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
"${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini"
"${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test.ini"
"${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test-failed.ini"
"${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter"
)

run.sh
clear.sh
config-test.ini
config-whitelist-test.ini
config-whitelist-test-failed.ini
gtest.filter)
dsn_add_test()
15 changes: 2 additions & 13 deletions src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
# THE SOFTWARE.

set(MY_PROJ_NAME dsn_meta_server)

set(DUPLICATION_SRC
duplication/duplication_info.cpp
duplication/meta_duplication_service.cpp
)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
duplication/meta_duplication_service.cpp)
set(MY_PROJ_SRC "${DUPLICATION_SRC}")

set(MY_PROJ_LIBS
dsn_ranger
dsn_replication_common
dsn.block_service
dsn.block_service.local
Expand All @@ -51,14 +46,8 @@ set(MY_PROJ_LIBS
lz4
zstd
snappy)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

# Extra files that will be installed
set(MY_BINPLACES "")

add_definitions(-DDSN_MOCK_TEST)

dsn_add_shared_library()

add_subdirectory(test)
13 changes: 0 additions & 13 deletions src/meta/meta_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include "meta_options.h"

#include <stddef.h>
#include <map>
#include <utility>

Expand Down Expand Up @@ -55,18 +54,6 @@ DSN_DEFINE_string(meta_server,
"",
"white list of replica-servers in meta-server");

std::string meta_options::concat_path_unix_style(const std::string &prefix,
const std::string &postfix)
{
size_t pos1 = prefix.size(); // last_valid_pos + 1
while (pos1 > 0 && prefix[pos1 - 1] == '/')
pos1--;
size_t pos2 = 0; // first non '/' position
while (pos2 < postfix.size() && postfix[pos2] == '/')
pos2++;
return prefix.substr(0, pos1) + "/" + postfix.substr(pos2);
}

void meta_options::initialize()
{
utils::split_args(FLAGS_meta_state_service_parameters, meta_state_service_args);
Expand Down
4 changes: 0 additions & 4 deletions src/meta/meta_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ class meta_options

public:
void initialize();

public:
static std::string concat_path_unix_style(const std::string &prefix,
const std::string &postfix);
};
} // namespace replication
} // namespace dsn
11 changes: 6 additions & 5 deletions src/meta/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@
#include "meta_split_service.h"
#include "partition_split_types.h"
#include "remote_cmd/remote_command.h"
#include "runtime/ranger/ranger_resource_policy_manager.h"
#include "ranger/ranger_resource_policy_manager.h"
#include "runtime/rpc/rpc_holder.h"
#include "runtime/task/async_calls.h"
#include "server_load_balancer.h"
#include "server_state.h"
#include "utils/autoref_ptr.h"
#include "utils/command_manager.h"
#include "utils/factory_store.h"
#include "utils/filesystem.h"
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/string_conv.h"
Expand Down Expand Up @@ -224,7 +225,7 @@ error_code meta_service::remote_storage_initialize()
utils::split_args(FLAGS_cluster_root, slices, '/');
std::string current = "";
for (unsigned int i = 0; i != slices.size(); ++i) {
current = meta_options::concat_path_unix_style(current, slices[i]);
current = utils::filesystem::concat_path_unix_style(current, slices[i]);
task_ptr tsk =
_storage->create_node(current, LPC_META_CALLBACK, [&err](error_code ec) { err = ec; });
tsk->wait();
Expand Down Expand Up @@ -445,16 +446,16 @@ error_code meta_service::start()
LOG_INFO("initialize backup handler");
_backup_handler = std::make_shared<backup_service>(
this,
meta_options::concat_path_unix_style(_cluster_root, "backup"),
utils::filesystem::concat_path_unix_style(_cluster_root, "backup"),
FLAGS_cold_backup_root,
[](backup_service *bs) { return std::make_shared<policy_context>(bs); });
}

_bulk_load_svc = std::make_unique<bulk_load_service>(
this, meta_options::concat_path_unix_style(_cluster_root, "bulk_load"));
this, utils::filesystem::concat_path_unix_style(_cluster_root, "bulk_load"));

// initialize the server_state
_state->initialize(this, meta_options::concat_path_unix_style(_cluster_root, "apps"));
_state->initialize(this, utils::filesystem::concat_path_unix_style(_cluster_root, "apps"));
while ((err = _state->initialize_data_structure()) != ERR_OK) {
if (err == ERR_OBJECT_NOT_FOUND && FLAGS_recover_from_replica_server) {
LOG_INFO("can't find apps from remote storage, and "
Expand Down
23 changes: 8 additions & 15 deletions src/meta/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@
# THE SOFTWARE.

set(MY_PROJ_NAME dsn.meta.test)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
file(GLOB MY_PROJ_SRC
${PROJECT_SOURCE_DIR}/src/meta/*.cpp
${PROJECT_SOURCE_DIR}/src/meta/duplication/*.cpp
)
${PROJECT_SOURCE_DIR}/src/meta/duplication/*.cpp)
set(MY_PROJ_SRC ${MY_PROJ_SRC} misc/misc.cpp)

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
dsn.replication.zookeeper_provider
dsn_replication_common
Expand All @@ -47,18 +38,20 @@ set(MY_PROJ_LIBS
dsn_dist_cmd
dsn_http
dsn_meta_server
dsn_ranger
dsn_runtime
dsn_aio
zookeeper
hashtable
gtest
hdfs)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

# Extra files that will be installed
set(MY_BINPLACES clear.sh run.sh config-test.ini suite1 suite2)

set(MY_BINPLACES
clear.sh
run.sh
config-test.ini
suite1
suite2)
dsn_add_test()

add_subdirectory(balancer_simulator)
Expand Down
22 changes: 5 additions & 17 deletions src/meta/test/balancer_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,14 @@
# THE SOFTWARE.

set(MY_PROJ_NAME sim_lb)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC ../misc/misc.cpp)

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
dsn_meta_server
dsn_replication_common
dsn_runtime
hashtable
gtest)

dsn_runtime
dsn_meta_server
dsn_ranger
dsn_replication_common
gtest)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)

# Extra files that will be installed
set(MY_BINPLACES "")

dsn_add_test()
4 changes: 2 additions & 2 deletions src/meta/test/meta_bulk_load_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "gtest/gtest.h"
#include "meta/meta_bulk_load_service.h"
#include "meta/meta_data.h"
#include "meta/meta_options.h"
#include "meta/meta_server_failure_detector.h"
#include "meta/meta_service.h"
#include "meta/meta_state_service_utils.h"
Expand All @@ -54,6 +53,7 @@
#include "utils/blob.h"
#include "utils/error_code.h"
#include "utils/fail_point.h"
#include "utils/filesystem.h"
#include "utils/fmt_logging.h"

namespace dsn {
Expand Down Expand Up @@ -344,7 +344,7 @@ class bulk_load_service_test : public meta_test_base

// initialize bulk load service
_ms->_bulk_load_svc = std::make_unique<bulk_load_service>(
_ms.get(), meta_options::concat_path_unix_style(_ms->_cluster_root, "bulk_load"));
_ms.get(), utils::filesystem::concat_path_unix_style(_ms->_cluster_root, "bulk_load"));
mock_bulk_load_on_remote_storage(
app_id_set, app_bulk_load_info_map, partition_bulk_load_info_map);

Expand Down
5 changes: 3 additions & 2 deletions src/meta/test/meta_partition_guardian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "gtest/gtest.h"
#include "meta/greedy_load_balancer.h"
#include "meta/meta_data.h"
#include "meta/meta_options.h"
#include "meta/meta_server_failure_detector.h"
#include "meta/meta_service.h"
#include "meta/partition_guardian.h"
Expand All @@ -62,6 +61,7 @@
#include "runtime/task/task.h"
#include "utils/autoref_ptr.h"
#include "utils/error_code.h"
#include "utils/filesystem.h"

namespace dsn {
namespace replication {
Expand Down Expand Up @@ -179,7 +179,8 @@ void meta_partition_guardian_test::cure_test()
svc->_balancer.reset(new dummy_balancer(svc.get()));

server_state *state = svc->_state.get();
state->initialize(svc.get(), meta_options::concat_path_unix_style(svc->_cluster_root, "apps"));
state->initialize(svc.get(),
utils::filesystem::concat_path_unix_style(svc->_cluster_root, "apps"));
dsn::app_info info;
info.is_stateful = true;
info.status = dsn::app_status::AS_CREATING;
Expand Down
Loading
Loading