Commit 19a9d0d2 authored by Marian Triebe's avatar Marian Triebe

Add replication submodule

parent 813fed9b
...@@ -379,7 +379,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") ...@@ -379,7 +379,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
install(DIRECTORY libcaf_opencl/caf/ DESTINATION include/caf install(DIRECTORY libcaf_opencl/caf/ DESTINATION include/caf
FILES_MATCHING PATTERN "*.hpp") FILES_MATCHING PATTERN "*.hpp")
endif() endif()
#install includes from crdt
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_crdt/CMakeLists.txt")
install(DIRECTORY libcaf_crdt/caf/ DESTINATION include/caf
FILES_MATCHING PATTERN "*.hpp")
endif()
# process cmake_uninstall.cmake.in # process cmake_uninstall.cmake.in
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
...@@ -404,6 +408,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt") ...@@ -404,6 +408,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
set(LIBCAF_INCLUDE_DIRS set(LIBCAF_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/" "${LIBCAF_INCLUDE_DIRS}") "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/" "${LIBCAF_INCLUDE_DIRS}")
endif() endif()
# path to caf crdt headers
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_crdt/CMakeLists.txt")
set(LIBCAF_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/libcaf_crdt/" "${LIBCAF_INCLUDE_DIRS}")
endif()
# enable tests if not disabled # enable tests if not disabled
if(NOT CAF_NO_UNIT_TESTS) if(NOT CAF_NO_UNIT_TESTS)
enable_testing() enable_testing()
...@@ -496,6 +505,12 @@ if(NOT CAF_NO_OPENCL) ...@@ -496,6 +505,12 @@ if(NOT CAF_NO_OPENCL)
endif() endif()
endif() endif()
# build crdt library if not told otherwise
if(NOT CAF_NO_CRDT)
add_optional_caf_lib(crdt)
add_optional_caf_binaries(libcaf_crdt/examples)
endif()
# build Python binding if not being told otherwise # build Python binding if not being told otherwise
if(NOT CAF_NO_PYTHON AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_python/CMakeLists.txt") if(NOT CAF_NO_PYTHON AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_python/CMakeLists.txt")
add_subdirectory(libcaf_python) add_subdirectory(libcaf_python)
...@@ -675,6 +690,7 @@ invertYesNo(CAF_NO_EXCEPTIONS CAF_BUILD_WITH_EXCEPTIONS) ...@@ -675,6 +690,7 @@ invertYesNo(CAF_NO_EXCEPTIONS CAF_BUILD_WITH_EXCEPTIONS)
invertYesNo(CAF_NO_MEM_MANAGEMENT CAF_BUILD_MEM_MANAGEMENT) invertYesNo(CAF_NO_MEM_MANAGEMENT CAF_BUILD_MEM_MANAGEMENT)
invertYesNo(CAF_NO_BENCHMARKS CAF_BUILD_BENCHMARKS) invertYesNo(CAF_NO_BENCHMARKS CAF_BUILD_BENCHMARKS)
invertYesNo(CAF_NO_OPENCL CAF_BUILD_OPENCL) invertYesNo(CAF_NO_OPENCL CAF_BUILD_OPENCL)
invertYesNo(CAF_NO_CRDT CAF_BUILD_CRDT)
invertYesNo(CAF_NO_PYTHON CAF_BUILD_PYTHON) invertYesNo(CAF_NO_PYTHON CAF_BUILD_PYTHON)
# collect all compiler flags # collect all compiler flags
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
...@@ -701,6 +717,7 @@ if(NOT CAF_NO_SUMMARY) ...@@ -701,6 +717,7 @@ if(NOT CAF_NO_SUMMARY)
"\nBuild benchmarks: ${CAF_BUILD_BENCHMARKS}" "\nBuild benchmarks: ${CAF_BUILD_BENCHMARKS}"
"\nBuild opencl: ${CAF_BUILD_OPENCL}" "\nBuild opencl: ${CAF_BUILD_OPENCL}"
"\nBuild Python: ${CAF_BUILD_PYTHON}" "\nBuild Python: ${CAF_BUILD_PYTHON}"
"\nBuild CRDT: ${CAF_BUILD_CRDT}"
"\n" "\n"
"\nCXX: ${CMAKE_CXX_COMPILER}" "\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${ALL_CXX_FLAGS}" "\nCXXFLAGS: ${ALL_CXX_FLAGS}"
......
...@@ -65,6 +65,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... ...@@ -65,6 +65,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--no-curl-examples build without libcurl examples --no-curl-examples build without libcurl examples
--no-unit-tests build without unit tests --no-unit-tests build without unit tests
--no-opencl build without OpenCL module --no-opencl build without OpenCL module
--no-crdt build without CRDT module
--no-benchmarks build without benchmarks --no-benchmarks build without benchmarks
--no-tools build without CAF tools such as caf-run --no-tools build without CAF tools such as caf-run
--no-io build without I/O module --no-io build without I/O module
...@@ -335,6 +336,9 @@ while [ $# -ne 0 ]; do ...@@ -335,6 +336,9 @@ while [ $# -ne 0 ]; do
--no-opencl) --no-opencl)
append_cache_entry CAF_NO_OPENCL BOOL yes append_cache_entry CAF_NO_OPENCL BOOL yes
;; ;;
--no-crdt)
append_cache_entry CAF_NO_CRDT BOOL yes
;;
--build-static) --build-static)
append_cache_entry CAF_BUILD_STATIC BOOL yes append_cache_entry CAF_BUILD_STATIC BOOL yes
;; ;;
......
...@@ -46,3 +46,8 @@ max-consecutive-reads=50 ...@@ -46,3 +46,8 @@ max-consecutive-reads=50
; heartbeat message interval in ms (0 disables heartbeating) ; heartbeat message interval in ms (0 disables heartbeating)
heartbeat-interval=0 heartbeat-interval=0
; when loading replication::replicator
[replicator]
; connect to other nodes on init, format is host:port, seperate nodes with ','
nodes="127.0.0.1:1337"
port=1337
...@@ -175,7 +175,7 @@ struct dyn_spawn_class_helper { ...@@ -175,7 +175,7 @@ struct dyn_spawn_class_helper {
actor_config& cfg; actor_config& cfg;
void operator()(Ts... xs) { void operator()(Ts... xs) {
CAF_ASSERT(cfg.host); CAF_ASSERT(cfg.host);
result = cfg.host->system().spawn_class<T, no_spawn_options>(cfg, xs...); result = cfg.host->system().spawn_class<T, hidden>(cfg, xs...);
} }
}; };
......
...@@ -138,6 +138,7 @@ public: ...@@ -138,6 +138,7 @@ public:
scheduler, scheduler,
middleman, middleman,
opencl_manager, opencl_manager,
replicator,
num_ids num_ids
}; };
...@@ -267,6 +268,13 @@ public: ...@@ -267,6 +268,13 @@ public:
/// Returns `true` if the opencl module is available, `false` otherwise. /// Returns `true` if the opencl module is available, `false` otherwise.
bool has_opencl_manager() const; bool has_opencl_manager() const;
/// Returns the replicator instance from replication module.
/// @throws `std::logic_error` if module is not loaded.
crdt::replicator& replicator() const;
/// Returns `true` if the replication module is available, `false` otherwise.
bool has_replicator() const;
/// Returns a dummy execution unit that forwards /// Returns a dummy execution unit that forwards
/// everything to the scheduler. /// everything to the scheduler.
scoped_execution_unit* dummy_execution_unit(); scoped_execution_unit* dummy_execution_unit();
...@@ -520,6 +528,7 @@ private: ...@@ -520,6 +528,7 @@ private:
io::middleman* middleman_; io::middleman* middleman_;
scoped_execution_unit dummy_execution_unit_; scoped_execution_unit dummy_execution_unit_;
opencl::manager* opencl_manager_; opencl::manager* opencl_manager_;
crdt::replicator* replicator_;
bool await_actors_before_shutdown_; bool await_actors_before_shutdown_;
strong_actor_ptr config_serv_; strong_actor_ptr config_serv_;
strong_actor_ptr spawn_serv_; strong_actor_ptr spawn_serv_;
......
...@@ -271,6 +271,10 @@ public: ...@@ -271,6 +271,10 @@ public:
std::string opencl_device_ids; std::string opencl_device_ids;
// -- config parameters of the replication module ----------------------------
std::string replication_hosts;
// -- factories -------------------------------------------------------------- // -- factories --------------------------------------------------------------
value_factory_string_map value_factories_by_name; value_factory_string_map value_factories_by_name;
......
...@@ -138,6 +138,14 @@ class manager; ...@@ -138,6 +138,14 @@ class manager;
} // namespace opencl } // namespace opencl
// -- Replication classes ------------------------------------------------------
namespace crdt {
class replicator;
} // namespace crdt
// -- scheduler classes -------------------------------------------------------- // -- scheduler classes --------------------------------------------------------
namespace scheduler { namespace scheduler {
......
...@@ -205,6 +205,9 @@ actor_system::actor_system(actor_system_config& cfg) ...@@ -205,6 +205,9 @@ actor_system::actor_system(actor_system_config& cfg)
auto& clptr = modules_[module::opencl_manager]; auto& clptr = modules_[module::opencl_manager];
if (clptr) if (clptr)
opencl_manager_ = reinterpret_cast<opencl::manager*>(clptr->subtype_ptr()); opencl_manager_ = reinterpret_cast<opencl::manager*>(clptr->subtype_ptr());
auto& rptr = modules_[module::replicator];
if (rptr)
replicator_ = reinterpret_cast<crdt::replicator*>(rptr->subtype_ptr());
auto& sched = modules_[module::scheduler]; auto& sched = modules_[module::scheduler];
using test = scheduler::test_coordinator; using test = scheduler::test_coordinator;
using share = scheduler::coordinator<policy::work_sharing>; using share = scheduler::coordinator<policy::work_sharing>;
...@@ -357,6 +360,16 @@ opencl::manager& actor_system::opencl_manager() const { ...@@ -357,6 +360,16 @@ opencl::manager& actor_system::opencl_manager() const {
return *opencl_manager_; return *opencl_manager_;
} }
bool actor_system::has_replicator() const {
return replicator_ != nullptr;
}
crdt::replicator& actor_system::replicator() const {
if (! replicator_)
CAF_RAISE_ERROR("cannot access replicator: module not loaded");
return *replicator_;
}
scoped_execution_unit* actor_system::dummy_execution_unit() { scoped_execution_unit* actor_system::dummy_execution_unit() {
return &dummy_execution_unit_; return &dummy_execution_unit_;
} }
......
...@@ -154,6 +154,9 @@ actor_system_config::actor_system_config() ...@@ -154,6 +154,9 @@ actor_system_config::actor_system_config()
opt_group(options_, "opencl") opt_group(options_, "opencl")
.add(opencl_device_ids, "device-ids", .add(opencl_device_ids, "device-ids",
"restricts which OpenCL devices are accessed by CAF"); "restricts which OpenCL devices are accessed by CAF");
opt_group(options_, "replication")
.add(replication_hosts, "nodes",
"connects to other CAF nodes at init");
// add renderers for default error categories // add renderers for default error categories
error_renderers.emplace(atom("system"), render_sec); error_renderers.emplace(atom("system"), render_sec);
error_renderers.emplace(atom("exit"), render_exit_reason); error_renderers.emplace(atom("exit"), render_exit_reason);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment