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")
install(DIRECTORY libcaf_opencl/caf/ DESTINATION include/caf
FILES_MATCHING PATTERN "*.hpp")
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
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
......@@ -404,6 +408,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
set(LIBCAF_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/" "${LIBCAF_INCLUDE_DIRS}")
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
if(NOT CAF_NO_UNIT_TESTS)
enable_testing()
......@@ -496,6 +505,12 @@ if(NOT CAF_NO_OPENCL)
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
if(NOT CAF_NO_PYTHON AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_python/CMakeLists.txt")
add_subdirectory(libcaf_python)
......@@ -675,6 +690,7 @@ invertYesNo(CAF_NO_EXCEPTIONS CAF_BUILD_WITH_EXCEPTIONS)
invertYesNo(CAF_NO_MEM_MANAGEMENT CAF_BUILD_MEM_MANAGEMENT)
invertYesNo(CAF_NO_BENCHMARKS CAF_BUILD_BENCHMARKS)
invertYesNo(CAF_NO_OPENCL CAF_BUILD_OPENCL)
invertYesNo(CAF_NO_CRDT CAF_BUILD_CRDT)
invertYesNo(CAF_NO_PYTHON CAF_BUILD_PYTHON)
# collect all compiler flags
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
......@@ -701,6 +717,7 @@ if(NOT CAF_NO_SUMMARY)
"\nBuild benchmarks: ${CAF_BUILD_BENCHMARKS}"
"\nBuild opencl: ${CAF_BUILD_OPENCL}"
"\nBuild Python: ${CAF_BUILD_PYTHON}"
"\nBuild CRDT: ${CAF_BUILD_CRDT}"
"\n"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${ALL_CXX_FLAGS}"
......
......@@ -65,6 +65,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--no-curl-examples build without libcurl examples
--no-unit-tests build without unit tests
--no-opencl build without OpenCL module
--no-crdt build without CRDT module
--no-benchmarks build without benchmarks
--no-tools build without CAF tools such as caf-run
--no-io build without I/O module
......@@ -335,6 +336,9 @@ while [ $# -ne 0 ]; do
--no-opencl)
append_cache_entry CAF_NO_OPENCL BOOL yes
;;
--no-crdt)
append_cache_entry CAF_NO_CRDT BOOL yes
;;
--build-static)
append_cache_entry CAF_BUILD_STATIC BOOL yes
;;
......
......@@ -46,3 +46,8 @@ max-consecutive-reads=50
; heartbeat message interval in ms (0 disables heartbeating)
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 {
actor_config& cfg;
void operator()(Ts... xs) {
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:
scheduler,
middleman,
opencl_manager,
replicator,
num_ids
};
......@@ -267,6 +268,13 @@ public:
/// Returns `true` if the opencl module is available, `false` otherwise.
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
/// everything to the scheduler.
scoped_execution_unit* dummy_execution_unit();
......@@ -520,6 +528,7 @@ private:
io::middleman* middleman_;
scoped_execution_unit dummy_execution_unit_;
opencl::manager* opencl_manager_;
crdt::replicator* replicator_;
bool await_actors_before_shutdown_;
strong_actor_ptr config_serv_;
strong_actor_ptr spawn_serv_;
......
......@@ -271,6 +271,10 @@ public:
std::string opencl_device_ids;
// -- config parameters of the replication module ----------------------------
std::string replication_hosts;
// -- factories --------------------------------------------------------------
value_factory_string_map value_factories_by_name;
......
......@@ -138,6 +138,14 @@ class manager;
} // namespace opencl
// -- Replication classes ------------------------------------------------------
namespace crdt {
class replicator;
} // namespace crdt
// -- scheduler classes --------------------------------------------------------
namespace scheduler {
......
......@@ -205,6 +205,9 @@ actor_system::actor_system(actor_system_config& cfg)
auto& clptr = modules_[module::opencl_manager];
if (clptr)
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];
using test = scheduler::test_coordinator;
using share = scheduler::coordinator<policy::work_sharing>;
......@@ -357,6 +360,16 @@ opencl::manager& actor_system::opencl_manager() const {
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() {
return &dummy_execution_unit_;
}
......
......@@ -154,6 +154,9 @@ actor_system_config::actor_system_config()
opt_group(options_, "opencl")
.add(opencl_device_ids, "device-ids",
"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
error_renderers.emplace(atom("system"), render_sec);
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