├── .clang-format ├── .github └── workflows │ ├── check_license_header.yaml │ ├── compilation.yaml │ ├── cpp_actions.yaml │ ├── cpp_always_pass_actions.yaml │ ├── issue_ref.yaml │ └── non_cpp_actions.yaml ├── .gitignore ├── .licenserc.yaml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin ├── FindDL.cmake ├── FindJemalloc.cmake ├── FindRT.cmake ├── compiler_info.cmake ├── dsn.cmake └── thrift_utils.cmake ├── compile_thrift.py ├── include └── dsn │ ├── c │ ├── api_common.h │ ├── api_layer1.h │ ├── api_task.h │ ├── api_utilities.h │ └── app_model.h │ ├── cpp │ ├── json_helper.h │ ├── message_utils.h │ ├── pipeline.h │ ├── rpc_holder.h │ ├── rpc_stream.h │ ├── serialization.h │ ├── serialization_helper │ │ ├── dsn.layer2_types.h │ │ ├── dsn_types.h │ │ └── thrift_helper.h │ ├── serverlet.h │ └── service_app.h │ ├── dist │ ├── block_service.h │ ├── common.h │ ├── distributed_lock_service.h │ ├── failure_detector.h │ ├── failure_detector │ │ ├── failure_detector.h │ │ ├── fd.client.h │ │ ├── fd.code.definition.h │ │ └── fd.server.h │ ├── failure_detector_multimaster.h │ ├── fmt_logging.h │ ├── meta_state_service.h │ ├── nfs_node.h │ ├── remote_command.h │ ├── replication.h │ └── replication │ │ ├── duplication_common.h │ │ ├── meta_service_app.h │ │ ├── mutation_duplicator.h │ │ ├── mutation_log_tool.h │ │ ├── partition_resolver.h │ │ ├── replica_base.h │ │ ├── replica_envs.h │ │ ├── replica_test_utils.h │ │ ├── replication.codes.h │ │ ├── replication_app_base.h │ │ ├── replication_ddl_client.h │ │ ├── replication_enums.h │ │ ├── replication_other_types.h │ │ ├── replication_service_app.h │ │ ├── replication_types.h │ │ └── storage_serverlet.h │ ├── http │ └── http_server.h │ ├── perf_counter │ ├── perf_counter.h │ ├── perf_counter_utils.h │ ├── perf_counter_wrapper.h │ └── perf_counters.h │ ├── service_api_c.h │ ├── service_api_cpp.h │ ├── tool-api │ ├── aio_task.h │ ├── async_calls.h │ ├── auto_codes.h │ ├── command_manager.h │ ├── env_provider.h │ ├── file_io.h │ ├── future_types.h │ ├── global_config.h │ ├── gpid.h │ ├── group_address.h │ ├── logging_provider.h │ ├── message_parser.h │ ├── network.h │ ├── rpc_address.h │ ├── rpc_message.h │ ├── task.h │ ├── task_code.h │ ├── task_queue.h │ ├── task_spec.h │ ├── task_tracker.h │ ├── task_worker.h │ ├── thread_access_checker.h │ ├── threadpool_code.h │ ├── threadpool_spec.h │ ├── timer_service.h │ ├── uniq_timestamp_us.h │ └── zlocks.h │ ├── tool │ ├── nativerun.h │ ├── node_scoper.h │ ├── providers.common.h │ └── simulator.h │ ├── tool_api.h │ ├── toollet │ ├── fault_injector.h │ ├── profiler.h │ └── tracer.h │ ├── utility │ ├── TokenBucket.h │ ├── absl │ │ ├── base │ │ │ └── internal │ │ │ │ └── invoke.h │ │ └── utility │ │ │ └── utility.h │ ├── alloc.h │ ├── apply.h │ ├── autoref_ptr.h │ ├── binary_reader.h │ ├── binary_writer.h │ ├── blob.h │ ├── casts.h │ ├── chrono_literals.h │ ├── clock.h │ ├── config_api.h │ ├── config_helper.h │ ├── configuration.h │ ├── crc.h │ ├── customizable_id.h │ ├── defer.h │ ├── dlib.h │ ├── endians.h │ ├── enum_helper.h │ ├── error_code.h │ ├── errors.h │ ├── exp_delay.h │ ├── extensible_object.h │ ├── factory_store.h │ ├── fail_point.h │ ├── filesystem.h │ ├── fixed_size_buffer_pool.h │ ├── flags.h │ ├── function_traits.h │ ├── hpc_locks │ │ ├── autoresetevent.h │ │ ├── autoreseteventcondvar.h │ │ ├── benaphore.h │ │ ├── bitfield.h │ │ ├── readme.txt │ │ ├── rwlock.h │ │ └── sema.h │ ├── join_point.h │ ├── link.h │ ├── long_adder.h │ ├── math.h │ ├── metrics.h │ ├── nth_element.h │ ├── optional.h │ ├── output_utils.h │ ├── ports.h │ ├── preloadable.h │ ├── priority_queue.h │ ├── process_utils.h │ ├── rand.h │ ├── safe_strerror_posix.h │ ├── singleton.h │ ├── singleton_store.h │ ├── smart_pointers.h │ ├── string_conv.h │ ├── string_splitter.h │ ├── string_view.h │ ├── strings.h │ ├── synchronize.h │ ├── sys_exit_hook.h │ ├── timer.h │ ├── utils.h │ └── work_queue.h │ └── utils │ ├── latency_tracer.h │ ├── time_utils.h │ ├── token_bucket_throttling_controller.h │ └── token_buckets.h ├── resources ├── arch.png ├── config.png ├── rdsn-layer1.jpg ├── rdsn-layer2.jpg ├── rdsn-layer3.jpg ├── rdsn-state-all.jpg ├── rdsn.jpg └── viz.png ├── run.sh ├── scripts └── linux │ ├── build.sh │ ├── clear_zk.sh │ ├── install.sh │ ├── learn_stat.py │ ├── run-clang-format.py │ ├── run-clang-format.sh │ ├── start_zk.sh │ └── stop_zk.sh ├── src ├── CMakeLists.txt ├── aio │ ├── CMakeLists.txt │ ├── aio_provider.cpp │ ├── aio_provider.h │ ├── aio_task.cpp │ ├── disk_engine.cpp │ ├── disk_engine.h │ ├── file_io.cpp │ ├── native_linux_aio_provider.cpp │ ├── native_linux_aio_provider.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── aio.cpp │ │ ├── clear.sh │ │ ├── config.ini │ │ ├── copy_source.txt │ │ ├── main.cpp │ │ └── run.sh ├── block_service │ ├── CMakeLists.txt │ ├── block_service_manager.cpp │ ├── block_service_manager.h │ ├── directio_writable_file.cpp │ ├── directio_writable_file.h │ ├── fds │ │ ├── CMakeLists.txt │ │ ├── fds_service.cpp │ │ └── fds_service.h │ ├── hdfs │ │ ├── CMakeLists.txt │ │ ├── hdfs_service.cpp │ │ └── hdfs_service.h │ ├── local │ │ ├── CMakeLists.txt │ │ ├── local_service.cpp │ │ └── local_service.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── block_service_manager_test.cpp │ │ ├── block_service_mock.h │ │ ├── clear.sh │ │ ├── config-test.ini │ │ ├── fds_service_test.cpp │ │ ├── hdfs_service_test.cpp │ │ ├── local_service_test.cpp │ │ ├── main.cpp │ │ └── run.sh ├── client │ ├── CMakeLists.txt │ ├── partition_resolver.cpp │ ├── partition_resolver_manager.cpp │ ├── partition_resolver_manager.h │ ├── partition_resolver_simple.cpp │ ├── partition_resolver_simple.h │ └── replication_ddl_client.cpp ├── common │ ├── CMakeLists.txt │ ├── backup.thrift │ ├── backup_common.cpp │ ├── backup_common.h │ ├── bulk_load.thrift │ ├── bulk_load_common.cpp │ ├── bulk_load_common.h │ ├── common.cpp │ ├── consensus.thrift │ ├── duplication.thrift │ ├── duplication_common.cpp │ ├── fs_manager.cpp │ ├── fs_manager.h │ ├── manual_compact.h │ ├── meta_admin.thrift │ ├── metadata.thrift │ ├── partition_split.thrift │ ├── partition_split_common.h │ ├── replica_admin.thrift │ ├── replication_common.cpp │ ├── replication_common.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── common_test.cpp │ │ ├── config-test.ini │ │ ├── duplication_common_test.cpp │ │ ├── fs_manager_test.cpp │ │ ├── main.cpp │ │ ├── replication_common_test.cpp │ │ └── run.sh ├── dsn.layer2.thrift ├── dsn.thrift ├── failure_detector │ ├── CMakeLists.txt │ ├── failure_detector.cpp │ ├── failure_detector_multimaster.cpp │ ├── fd.thrift │ └── test │ │ ├── CMakeLists.txt │ │ ├── clear.sh │ │ ├── config-test.ini │ │ ├── config-whitelist-test-failed.ini │ │ ├── config-whitelist-test.ini │ │ ├── failure_detector.cpp │ │ ├── gtest.filter │ │ ├── main.cpp │ │ └── run.sh ├── http │ ├── CMakeLists.txt │ ├── builtin_http_calls.cpp │ ├── builtin_http_calls.h │ ├── config_http_service.cpp │ ├── http_call_registry.h │ ├── http_message_parser.cpp │ ├── http_message_parser.h │ ├── http_server.cpp │ ├── http_server_impl.h │ ├── perf_counter_http_service.cpp │ ├── pprof_http_service.cpp │ ├── pprof_http_service.h │ ├── service_version.cpp │ ├── service_version.h │ ├── test │ │ ├── CMakeLists.txt │ │ ├── http_server_test.cpp │ │ ├── perf_counter_http_service_test.cpp │ │ ├── run.sh │ │ └── uri_decoder_test.cpp │ ├── uri_decoder.cpp │ └── uri_decoder.h ├── meta │ ├── CMakeLists.txt │ ├── app_balance_policy.cpp │ ├── app_balance_policy.h │ ├── app_env_validator.cpp │ ├── app_env_validator.h │ ├── backup_engine.cpp │ ├── backup_engine.h │ ├── cluster_balance_policy.cpp │ ├── cluster_balance_policy.h │ ├── distributed_lock_service_simple.cpp │ ├── distributed_lock_service_simple.h │ ├── dump_file.h │ ├── duplication │ │ ├── duplication_info.cpp │ │ ├── duplication_info.h │ │ ├── meta_duplication_service.cpp │ │ └── meta_duplication_service.h │ ├── greedy_load_balancer.cpp │ ├── greedy_load_balancer.h │ ├── load_balance_policy.cpp │ ├── load_balance_policy.h │ ├── meta_backup_service.cpp │ ├── meta_backup_service.h │ ├── meta_bulk_load_ingestion_context.cpp │ ├── meta_bulk_load_ingestion_context.h │ ├── meta_bulk_load_service.cpp │ ├── meta_bulk_load_service.h │ ├── meta_data.cpp │ ├── meta_data.h │ ├── meta_http_service.cpp │ ├── meta_http_service.h │ ├── meta_options.cpp │ ├── meta_options.h │ ├── meta_rpc_types.h │ ├── meta_server_failure_detector.cpp │ ├── meta_server_failure_detector.h │ ├── meta_service.cpp │ ├── meta_service.h │ ├── meta_service_app.cpp │ ├── meta_split_service.cpp │ ├── meta_split_service.h │ ├── meta_state_service_simple.cpp │ ├── meta_state_service_simple.h │ ├── meta_state_service_utils.cpp │ ├── meta_state_service_utils.h │ ├── meta_state_service_utils_impl.h │ ├── meta_state_service_zookeeper.cpp │ ├── meta_state_service_zookeeper.h │ ├── partition_guardian.cpp │ ├── partition_guardian.h │ ├── server_load_balancer.cpp │ ├── server_load_balancer.h │ ├── server_state.cpp │ ├── server_state.h │ ├── server_state_restore.cpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── backup_test.cpp │ │ ├── balancer_simulator │ │ ├── CMakeLists.txt │ │ └── balancer_simulator.cpp │ │ ├── balancer_validator.cpp │ │ ├── clear.sh │ │ ├── cluster_balance_policy_test.cpp │ │ ├── config-test.ini │ │ ├── copy_replica_operation_test.cpp │ │ ├── dummy_balancer.h │ │ ├── dump_file.cpp │ │ ├── duplication_info_test.cpp │ │ ├── ford_fulkerson_test.cpp │ │ ├── json_compacity.cpp │ │ ├── main.cpp │ │ ├── meta_app_envs_test.cpp │ │ ├── meta_app_operation_test.cpp │ │ ├── meta_backup_test.cpp │ │ ├── meta_bulk_load_ingestion_test.cpp │ │ ├── meta_bulk_load_service_test.cpp │ │ ├── meta_data.cpp │ │ ├── meta_duplication_service_test.cpp │ │ ├── meta_http_service_test.cpp │ │ ├── meta_mauanl_compaction_test.cpp │ │ ├── meta_partition_guardian_test.cpp │ │ ├── meta_service_test.cpp │ │ ├── meta_service_test_app.h │ │ ├── meta_split_service_test.cpp │ │ ├── meta_state │ │ ├── CMakeLists.txt │ │ ├── clear.cmd │ │ ├── clear.sh │ │ ├── config-test.ini │ │ ├── gtest.filter │ │ ├── main.cpp │ │ ├── meta_state_service.cpp │ │ └── run.sh │ │ ├── meta_state_service_utils_test.cpp │ │ ├── meta_test_base.cpp │ │ ├── meta_test_base.h │ │ ├── misc │ │ ├── misc.cpp │ │ └── misc.h │ │ ├── run.sh │ │ ├── server_state_restore_test.cpp │ │ ├── server_state_test.cpp │ │ ├── state_sync_test.cpp │ │ ├── suite1 │ │ ├── suite2 │ │ └── update_configuration_test.cpp ├── nfs │ ├── CMakeLists.txt │ ├── nfs.thrift │ ├── nfs_client_impl.cpp │ ├── nfs_client_impl.h │ ├── nfs_code_definition.h │ ├── nfs_node.cpp │ ├── nfs_node_impl.cpp │ ├── nfs_node_simple.h │ ├── nfs_server_impl.cpp │ ├── nfs_server_impl.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── clear.sh │ │ ├── config.ini │ │ ├── main.cpp │ │ ├── nfs_test_file1 │ │ ├── nfs_test_file2 │ │ └── run.sh ├── perf_counter │ ├── CMakeLists.txt │ ├── builtin_counters.cpp │ ├── builtin_counters.h │ ├── perf_counter.cpp │ ├── perf_counter_atomic.h │ ├── perf_counters.cpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── clear.sh │ │ ├── main.cpp │ │ ├── perf_counter_test.cpp │ │ ├── perf_counters_test.cpp │ │ └── run.sh ├── remote_cmd │ ├── CMakeLists.txt │ ├── command.thrift │ └── remote_command.cpp ├── replica │ ├── CMakeLists.txt │ ├── backup │ │ ├── cold_backup_context.cpp │ │ ├── cold_backup_context.h │ │ ├── replica_backup_manager.cpp │ │ ├── replica_backup_manager.h │ │ ├── replica_backup_server.cpp │ │ ├── replica_backup_server.h │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── config-test.ini │ │ │ ├── main.cpp │ │ │ ├── replica_backup_manager_test.cpp │ │ │ └── run.sh │ ├── bulk_load │ │ ├── replica_bulk_loader.cpp │ │ ├── replica_bulk_loader.h │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── config-test.ini │ │ │ ├── main.cpp │ │ │ ├── replica_bulk_loader_test.cpp │ │ │ └── run.sh │ ├── disk_cleaner.cpp │ ├── disk_cleaner.h │ ├── duplication │ │ ├── duplication_pipeline.cpp │ │ ├── duplication_pipeline.h │ │ ├── duplication_sync_timer.cpp │ │ ├── duplication_sync_timer.h │ │ ├── load_from_private_log.cpp │ │ ├── load_from_private_log.h │ │ ├── mutation_batch.cpp │ │ ├── mutation_batch.h │ │ ├── replica_duplicator.cpp │ │ ├── replica_duplicator.h │ │ ├── replica_duplicator_manager.cpp │ │ ├── replica_duplicator_manager.h │ │ ├── replica_follower.cpp │ │ ├── replica_follower.h │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── config-test.ini │ │ │ ├── duplication_sync_timer_test.cpp │ │ │ ├── duplication_test_base.h │ │ │ ├── load_from_private_log_test.cpp │ │ │ ├── log.1.0.all_loaded_are_write_empties │ │ │ ├── log.1.0.handle_real_private_log │ │ │ ├── log.1.0.handle_real_private_log2 │ │ │ ├── main.cpp │ │ │ ├── mutation_batch_test.cpp │ │ │ ├── replica_duplicator_manager_test.cpp │ │ │ ├── replica_duplicator_test.cpp │ │ │ ├── replica_follower_test.cpp │ │ │ ├── replica_http_service_test.cpp │ │ │ ├── run.sh │ │ │ └── ship_mutation_test.cpp │ ├── log_block.cpp │ ├── log_block.h │ ├── log_file.cpp │ ├── log_file.h │ ├── log_file_stream.h │ ├── mutation.cpp │ ├── mutation.h │ ├── mutation_cache.cpp │ ├── mutation_cache.h │ ├── mutation_log.cpp │ ├── mutation_log.h │ ├── mutation_log_replay.cpp │ ├── mutation_log_utils.cpp │ ├── mutation_log_utils.h │ ├── prepare_list.cpp │ ├── prepare_list.h │ ├── replica.cpp │ ├── replica.h │ ├── replica_2pc.cpp │ ├── replica_backup.cpp │ ├── replica_check.cpp │ ├── replica_chkpt.cpp │ ├── replica_config.cpp │ ├── replica_context.cpp │ ├── replica_context.h │ ├── replica_disk_migrator.cpp │ ├── replica_disk_migrator.h │ ├── replica_failover.cpp │ ├── replica_http_service.cpp │ ├── replica_http_service.h │ ├── replica_init.cpp │ ├── replica_learn.cpp │ ├── replica_restore.cpp │ ├── replica_stub.cpp │ ├── replica_stub.h │ ├── replica_test_utils.cpp │ ├── replica_throttle.cpp │ ├── replication_app_base.cpp │ ├── replication_service_app.cpp │ ├── split │ │ ├── replica_split_manager.cpp │ │ ├── replica_split_manager.h │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── config-test.ini │ │ │ ├── main.cpp │ │ │ ├── replica_split_test.cpp │ │ │ └── run.sh │ ├── storage │ │ ├── CMakeLists.txt │ │ └── simple_kv │ │ │ ├── CMakeLists.txt │ │ │ ├── clear.sh │ │ │ ├── config.ini │ │ │ ├── run.sh │ │ │ ├── simple_kv.app.example.h │ │ │ ├── simple_kv.client.h │ │ │ ├── simple_kv.code.definition.h │ │ │ ├── simple_kv.main.cpp │ │ │ ├── simple_kv.server.h │ │ │ ├── simple_kv.server.impl.cpp │ │ │ ├── simple_kv.server.impl.h │ │ │ ├── simple_kv.thrift │ │ │ └── test │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── addcase.sh │ │ │ ├── case-000.act │ │ │ ├── case-000.ini │ │ │ ├── case-001.act │ │ │ ├── case-001.ini │ │ │ ├── case-002.act │ │ │ ├── case-002.ini │ │ │ ├── case-003.act │ │ │ ├── case-003.ini │ │ │ ├── case-004.act │ │ │ ├── case-004.ini │ │ │ ├── case-005.act │ │ │ ├── case-005.ini │ │ │ ├── case-006.act │ │ │ ├── case-006.ini │ │ │ ├── case-100.act │ │ │ ├── case-100.ini │ │ │ ├── case-101.act │ │ │ ├── case-101.ini │ │ │ ├── case-102.act │ │ │ ├── case-102.ini │ │ │ ├── case-103.act │ │ │ ├── case-103.ini │ │ │ ├── case-104.act │ │ │ ├── case-104.ini │ │ │ ├── case-105.act │ │ │ ├── case-105.ini │ │ │ ├── case-106.act │ │ │ ├── case-106.ini │ │ │ ├── case-107.act │ │ │ ├── case-107.ini │ │ │ ├── case-108.act │ │ │ ├── case-108.ini │ │ │ ├── case-109.act │ │ │ ├── case-109.ini │ │ │ ├── case-200.act │ │ │ ├── case-200.ini │ │ │ ├── case-201.act │ │ │ ├── case-201.ini │ │ │ ├── case-202-0.act │ │ │ ├── case-202-0.ini │ │ │ ├── case-202-1.act │ │ │ ├── case-202-1.ini │ │ │ ├── case-203-0.act │ │ │ ├── case-203-0.ini │ │ │ ├── case-204.act │ │ │ ├── case-204.ini │ │ │ ├── case-205.act │ │ │ ├── case-205.ini │ │ │ ├── case-206.act │ │ │ ├── case-206.ini │ │ │ ├── case-207.act │ │ │ ├── case-207.ini │ │ │ ├── case-208.act │ │ │ ├── case-208.ini │ │ │ ├── case-209.act │ │ │ ├── case-209.ini │ │ │ ├── case-210.act │ │ │ ├── case-210.ini │ │ │ ├── case-211.act │ │ │ ├── case-211.ini │ │ │ ├── case-212.act │ │ │ ├── case-212.ini │ │ │ ├── case-213.act │ │ │ ├── case-213.ini │ │ │ ├── case-214.act │ │ │ ├── case-214.ini │ │ │ ├── case-215.act │ │ │ ├── case-215.ini │ │ │ ├── case-216.act │ │ │ ├── case-216.ini │ │ │ ├── case-300-0.act │ │ │ ├── case-300-0.ini │ │ │ ├── case-300-1.act │ │ │ ├── case-300-1.ini │ │ │ ├── case-300-2.act │ │ │ ├── case-300-2.ini │ │ │ ├── case-301.act │ │ │ ├── case-301.ini │ │ │ ├── case-302.act │ │ │ ├── case-302.ini │ │ │ ├── case-303.act │ │ │ ├── case-303.ini │ │ │ ├── case-304.act │ │ │ ├── case-304.ini │ │ │ ├── case-305.act │ │ │ ├── case-305.ini │ │ │ ├── case-306.act │ │ │ ├── case-306.ini │ │ │ ├── case-307.act │ │ │ ├── case-307.ini │ │ │ ├── case-400.act │ │ │ ├── case-400.ini │ │ │ ├── case-401.act │ │ │ ├── case-401.ini │ │ │ ├── case-402.act │ │ │ ├── case-402.ini │ │ │ ├── case-600.act │ │ │ ├── case-600.ini │ │ │ ├── case-601.act │ │ │ ├── case-601.ini │ │ │ ├── case-602.act │ │ │ ├── case-602.ini │ │ │ ├── case-603.act │ │ │ ├── case-603.ini │ │ │ ├── case.cpp │ │ │ ├── case.h │ │ │ ├── checker.cpp │ │ │ ├── checker.h │ │ │ ├── clear.sh │ │ │ ├── client.cpp │ │ │ ├── client.h │ │ │ ├── common.cpp │ │ │ ├── common.h │ │ │ ├── config.ini │ │ │ ├── injector.cpp │ │ │ ├── injector.h │ │ │ ├── rep_tests.pdf │ │ │ ├── run.sh │ │ │ ├── simple_kv.main.cpp │ │ │ ├── simple_kv.server.impl.cpp │ │ │ └── simple_kv.server.impl.h │ └── test │ │ ├── CMakeLists.txt │ │ ├── backup_block_service_mock.h │ │ ├── clear.sh │ │ ├── cold_backup_context_test.cpp │ │ ├── config-test.ini │ │ ├── log_block_test.cpp │ │ ├── log_file_test.cpp │ │ ├── main.cpp │ │ ├── mock_utils.h │ │ ├── mutation_log_learn_test.cpp │ │ ├── mutation_log_test.cpp │ │ ├── open_replica_test.cpp │ │ ├── replica_disk_migrate_test.cpp │ │ ├── replica_disk_test.cpp │ │ ├── replica_disk_test_base.h │ │ ├── replica_learn_test.cpp │ │ ├── replica_test.cpp │ │ ├── replica_test_base.h │ │ ├── replication_service_test_app.h │ │ ├── run.sh │ │ └── throttling_controller_test.cpp ├── runtime │ ├── CMakeLists.txt │ ├── build_config.h │ ├── core_main.cpp │ ├── dsn.layer2_types.cpp │ ├── env.sim.cpp │ ├── env.sim.h │ ├── fault_injector.cpp │ ├── global_config.cpp │ ├── message_utils.cpp │ ├── nativerun.cpp │ ├── profiler.cpp │ ├── profiler_header.h │ ├── providers.common.cpp │ ├── rpc │ │ ├── CMakeLists.txt │ │ ├── asio_net_provider.cpp │ │ ├── asio_net_provider.h │ │ ├── asio_rpc_session.cpp │ │ ├── asio_rpc_session.h │ │ ├── dsn_message_parser.cpp │ │ ├── dsn_message_parser.h │ │ ├── message_parser.cpp │ │ ├── message_parser_manager.h │ │ ├── network.cpp │ │ ├── network.sim.cpp │ │ ├── network.sim.h │ │ ├── raw_message_parser.cpp │ │ ├── raw_message_parser.h │ │ ├── request_meta.thrift │ │ ├── rpc_engine.cpp │ │ ├── rpc_engine.h │ │ ├── rpc_message.cpp │ │ ├── rpc_task.cpp │ │ ├── thrift_message_parser.cpp │ │ └── thrift_message_parser.h │ ├── scheduler.cpp │ ├── scheduler.h │ ├── security │ │ ├── CMakeLists.txt │ │ ├── access_controller.cpp │ │ ├── access_controller.h │ │ ├── client_negotiation.cpp │ │ ├── client_negotiation.h │ │ ├── init.cpp │ │ ├── init.h │ │ ├── kinit_context.cpp │ │ ├── kinit_context.h │ │ ├── meta_access_controller.cpp │ │ ├── meta_access_controller.h │ │ ├── negotiation.cpp │ │ ├── negotiation.h │ │ ├── negotiation_manager.cpp │ │ ├── negotiation_manager.h │ │ ├── negotiation_utils.h │ │ ├── replica_access_controller.cpp │ │ ├── replica_access_controller.h │ │ ├── sasl_client_wrapper.cpp │ │ ├── sasl_client_wrapper.h │ │ ├── sasl_init.cpp │ │ ├── sasl_init.h │ │ ├── sasl_server_wrapper.cpp │ │ ├── sasl_server_wrapper.h │ │ ├── sasl_wrapper.cpp │ │ ├── sasl_wrapper.h │ │ ├── security.thrift │ │ ├── server_negotiation.cpp │ │ └── server_negotiation.h │ ├── service_api_c.cpp │ ├── service_engine.cpp │ ├── service_engine.h │ ├── sim_clock.h │ ├── simulator.cpp │ ├── task │ │ ├── CMakeLists.txt │ │ ├── hpc_task_queue.cpp │ │ ├── hpc_task_queue.h │ │ ├── simple_task_queue.cpp │ │ ├── simple_task_queue.h │ │ ├── task.cpp │ │ ├── task_code.cpp │ │ ├── task_engine.cpp │ │ ├── task_engine.h │ │ ├── task_engine.sim.cpp │ │ ├── task_engine.sim.h │ │ ├── task_queue.cpp │ │ ├── task_spec.cpp │ │ ├── task_tracker.cpp │ │ └── task_worker.cpp │ ├── test │ │ ├── CMakeLists.txt │ │ ├── async_call.cpp │ │ ├── clear.sh │ │ ├── client_negotiation_test.cpp │ │ ├── command.txt │ │ ├── config-test-corrupt-message.ini │ │ ├── config-test-sim.ini │ │ ├── config-test.ini │ │ ├── corrupt_message.cpp │ │ ├── gtest.filter │ │ ├── lpc.cpp │ │ ├── main.cpp │ │ ├── message_reader_test.cpp │ │ ├── message_utils_test.cpp │ │ ├── meta_access_controller_test.cpp │ │ ├── negotiation_manager_test.cpp │ │ ├── netprovider.cpp │ │ ├── pipeline_test.cpp │ │ ├── replica_access_controller_test.cpp │ │ ├── rpc.cpp │ │ ├── rpc_holder_test.cpp │ │ ├── rpc_message.cpp │ │ ├── run.sh │ │ ├── server_negotiation_test.cpp │ │ ├── service_api_c.cpp │ │ ├── sim_lock.cpp │ │ ├── task_engine.cpp │ │ ├── task_test.cpp │ │ ├── test_utils.h │ │ └── thrift_message_parser_test.cpp │ ├── threadpool_code.cpp │ ├── tool_api.cpp │ ├── tracer.cpp │ └── zlocks.cpp ├── tools │ ├── CMakeLists.txt │ └── mutation_log_tool.cpp ├── utils │ ├── CMakeLists.txt │ ├── alloc.cpp │ ├── binary_reader.cpp │ ├── binary_writer.cpp │ ├── clock.cpp │ ├── command_manager.cpp │ ├── config_api.cpp │ ├── configuration.cpp │ ├── coredump.h │ ├── coredump.posix.cpp │ ├── crc.cpp │ ├── error_code.cpp │ ├── fail_point.cpp │ ├── fail_point_impl.h │ ├── filesystem.cpp │ ├── flags.cpp │ ├── gpid.cpp │ ├── latency_tracer.cpp │ ├── lockp.std.h │ ├── logging.cpp │ ├── long_adder.cpp │ ├── long_adder_bench │ │ ├── CMakeLists.txt │ │ └── long_adder_bench.cpp │ ├── math.cpp │ ├── memutil.h │ ├── metrics.cpp │ ├── output_utils.cpp │ ├── process_utils.cpp │ ├── rand.cpp │ ├── rpc_address.cpp │ ├── safe_strerror_posix.cpp │ ├── shared_io_service.cpp │ ├── shared_io_service.h │ ├── simple_logger.cpp │ ├── simple_logger.h │ ├── string_view.cpp │ ├── strings.cpp │ ├── test │ │ ├── CMakeLists.txt │ │ ├── TokenBucketTest.cpp │ │ ├── TokenBucketTest.h │ │ ├── address.cpp │ │ ├── autoref_ptr_test.cpp │ │ ├── binary_reader_test.cpp │ │ ├── clear.sh │ │ ├── command_manager.cpp │ │ ├── config-bad-section.ini │ │ ├── config-dup-key.ini │ │ ├── config-dup-section.ini │ │ ├── config-empty.ini │ │ ├── config-no-key.ini │ │ ├── config-no-section.ini │ │ ├── config-null-section.ini │ │ ├── config-sample.ini │ │ ├── config-unmatch-section.ini │ │ ├── configuration.cpp │ │ ├── endian_test.cpp │ │ ├── env.cpp │ │ ├── fail_point_test.cpp │ │ ├── file_system_test.cpp │ │ ├── file_utils.cpp │ │ ├── flag_test.cpp │ │ ├── fmt_logging_test.cpp │ │ ├── hostname_test.cpp │ │ ├── join_point_test.cpp │ │ ├── json_helper_test.cpp │ │ ├── latency_tracer_test.cpp │ │ ├── lock.std.cpp │ │ ├── logger.cpp │ │ ├── logging.cpp │ │ ├── long_adder_test.cpp │ │ ├── main.cpp │ │ ├── memutil_test.cpp │ │ ├── metrics_test.cpp │ │ ├── nth_element_bench │ │ │ ├── CMakeLists.txt │ │ │ └── nth_element_bench.cpp │ │ ├── nth_element_test.cpp │ │ ├── nth_element_utils.h │ │ ├── output_utils_test.cpp │ │ ├── percentile_utils.h │ │ ├── priority_queue.cpp │ │ ├── rand_test.cpp │ │ ├── run.sh │ │ ├── sema.cpp │ │ ├── smart_pointers_test.cpp │ │ ├── string_conv_test.cpp │ │ ├── string_view_test.cpp │ │ ├── time_utils_test.cpp │ │ ├── token_bucket_throttling_controller_test.cpp │ │ ├── token_buckets_test.cpp │ │ └── utils.cpp │ ├── thread_access_checker.cpp │ ├── throttling_controller.cpp │ ├── throttling_controller.h │ ├── time_utils.cpp │ ├── token_bucket_throttling_controller.cpp │ ├── token_buckets.cpp │ ├── utils.cpp │ └── zlock_provider.h └── zookeeper │ ├── CMakeLists.txt │ ├── distributed_lock_service_zookeeper.cpp │ ├── distributed_lock_service_zookeeper.h │ ├── lock_struct.cpp │ ├── lock_struct.h │ ├── lock_types.h │ ├── test │ ├── CMakeLists.txt │ ├── clear.sh │ ├── config-test.ini │ ├── distributed_lock_zookeeper.cpp │ ├── main.cpp │ └── run.sh │ ├── zookeeper_error.cpp │ ├── zookeeper_error.h │ ├── zookeeper_session.cpp │ ├── zookeeper_session.h │ ├── zookeeper_session_mgr.cpp │ └── zookeeper_session_mgr.h └── thirdparty ├── CMakeLists.txt ├── fix_fds_for_macos.patch ├── fix_s2_for_aarch64.patch └── fix_thrift_for_cpp11.patch /.github/workflows/check_license_header.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | --- 18 | name: License Check 19 | on: 20 | pull_request: 21 | push: 22 | branches: 23 | - master 24 | - 'v[0-9]+.*' # release branch 25 | - ci-test # testing branch for github action 26 | - '*dev' # developing branch 27 | jobs: 28 | license-check: 29 | name: Check License Header 30 | runs-on: ubuntu-latest 31 | steps: 32 | - name: "Checkout" 33 | uses: actions/checkout@v2 34 | - name: Check License Header 35 | uses: apache/skywalking-eyes@v0.3.0 36 | with: 37 | # Optional: set the log level. The default value is `info`. 38 | # log: debug 39 | # Optional: set the config file. The default value is `.licenserc.yaml`. 40 | config: .licenserc.yaml 41 | -------------------------------------------------------------------------------- /.github/workflows/issue_ref.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | name: Issue Check 21 | 22 | on: 23 | pull_request: 24 | types: ['opened', 'edited', 'reopened', 'synchronize'] 25 | 26 | jobs: 27 | title: 28 | name: Issue check 29 | runs-on: ubuntu-latest 30 | 31 | steps: 32 | - name: Check for ticket 33 | uses: neofinancial/ticket-check-action@v1.3.0 34 | with: 35 | token: ${{ secrets.GITHUB_TOKEN }} 36 | ticketPrefix: '#' 37 | bodyURLRegex: 'http(s?):\/\/(github.com)(\/apache)(\/incubator-pegasus)(\/issues)\/\d+' 38 | -------------------------------------------------------------------------------- /.github/workflows/non_cpp_actions.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | --- 18 | name: Non-cpp Code Lint 19 | 20 | on: 21 | # run on each pull request 22 | pull_request: 23 | types: [ synchronize, opened, reopened ] 24 | branches: 25 | - master 26 | - 'v[0-9]+.*' # release branch 27 | - ci-test # testing branch for github action 28 | - '*dev' # developing branch 29 | 30 | # for manually triggering workflow 31 | workflow_dispatch: 32 | 33 | defaults: 34 | run: 35 | shell: bash 36 | 37 | jobs: 38 | semantic_title: 39 | name: Lint PR title 40 | runs-on: ubuntu-latest 41 | steps: 42 | - uses: amannn/action-semantic-pull-request@v4.3.0 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | 46 | markdown-link-check: 47 | name: Check Markdown links 48 | runs-on: ubuntu-latest 49 | steps: 50 | - uses: actions/checkout@v2 51 | - uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2015 Microsoft Corporation 4 | # 5 | # -=- Robust Distributed System Nucleus (rDSN) -=- 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | 25 | .matchfile 26 | .kdev4/ 27 | .zk_install/ 28 | .idea 29 | .vscode/ 30 | 31 | gcov_report/ 32 | bin/Linux/thrift 33 | builder/ 34 | install/ 35 | test_reports/ 36 | Dockerfile 37 | include/thrift/ 38 | DSN_ROOT 39 | 40 | rdsn.github.config 41 | rdsn.github.creator 42 | rdsn.github.creator.user* 43 | rdsn.github.files 44 | rdsn.github.includes 45 | rDSN.github.* 46 | update_qt_config.sh 47 | zookeeper-3.4.6.tar.gz 48 | zookeeper-3.4.6/ 49 | 50 | thirdparty/build 51 | thirdparty/src 52 | thirdparty/output 53 | 54 | packages/ 55 | cmake-build-debug/ 56 | -------------------------------------------------------------------------------- /include/dsn/cpp/serialization_helper/dsn_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include -------------------------------------------------------------------------------- /include/dsn/dist/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #pragma once 21 | 22 | namespace dsn { 23 | /// Returns the cluster name (i.e, "onebox") if it's configured under 24 | /// "replication" section: 25 | /// [replication] 26 | /// cluster_name = "onebox" 27 | extern const char *get_current_cluster_name(); 28 | } // namespace dsn 29 | -------------------------------------------------------------------------------- /include/dsn/dist/failure_detector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * What is this file about? 30 | * 31 | * Revision history: 32 | * xxxx-xx-xx, author, first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | -------------------------------------------------------------------------------- /include/dsn/dist/remote_command.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | namespace dsn { 24 | namespace dist { 25 | namespace cmd { 26 | 27 | /// Calls a remote command to the remote server. 28 | task_ptr async_call_remote(rpc_address remote, 29 | const std::string &cmd, 30 | const std::vector &arguments, 31 | std::function callback, 32 | std::chrono::milliseconds timeout = std::chrono::milliseconds(0)); 33 | 34 | /// Registers the server-side RPC handler of remote commands. 35 | bool register_remote_command_rpc(); 36 | 37 | } // namespace cmd 38 | } // namespace dist 39 | } // namespace dsn 40 | -------------------------------------------------------------------------------- /include/dsn/dist/replication.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * What is this file about? 30 | * 31 | * Revision history: 32 | * xxxx-xx-xx, author, first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | #include 40 | #include 41 | -------------------------------------------------------------------------------- /include/dsn/dist/replication/replication_types.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | // WARN: This is a legacy file. Please do not include it when you make any modification. 21 | 22 | #include "meta_admin_types.h" 23 | #include "partition_split_types.h" 24 | #include "duplication_types.h" 25 | #include "bulk_load_types.h" 26 | #include "backup_types.h" 27 | #include "consensus_types.h" 28 | #include "replica_admin_types.h" 29 | -------------------------------------------------------------------------------- /include/dsn/perf_counter/perf_counter_utils.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace dsn { 25 | 26 | struct perf_counter_metric 27 | { 28 | std::string name; 29 | std::string type; 30 | double value; 31 | perf_counter_metric() : value(0) {} 32 | perf_counter_metric(const char *n, dsn_perf_counter_type_t t, double v) 33 | : name(n), type(dsn_counter_type_to_string(t)), value(v) 34 | { 35 | } 36 | DEFINE_JSON_SERIALIZATION(name, type, value) 37 | }; 38 | 39 | /// used for command of querying perf counter 40 | struct perf_counter_info 41 | { 42 | std::string result; // OK or ERROR 43 | int64_t timestamp; // in seconds 44 | std::string timestamp_str; 45 | std::vector counters; 46 | perf_counter_info() : timestamp(0) {} 47 | DEFINE_JSON_SERIALIZATION(result, timestamp, timestamp_str, counters) 48 | }; 49 | 50 | } // namespace dsn 51 | -------------------------------------------------------------------------------- /include/dsn/service_api_cpp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * cpp development library atop zion's c service api 30 | * 31 | * Revision history: 32 | * Mar., 2015, @imzhenyu (Zhenyu Guo), first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | -------------------------------------------------------------------------------- /include/dsn/tool-api/auto_codes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * What is this file about? 30 | * 31 | * Revision history: 32 | * xxxx-xx-xx, author, first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | -------------------------------------------------------------------------------- /include/dsn/tool-api/future_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | #pragma once 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace dsn { 33 | typedef std::function err_callback; 34 | typedef future_task error_code_future; 35 | typedef dsn::ref_ptr error_code_future_ptr; 36 | } 37 | -------------------------------------------------------------------------------- /include/dsn/tool/providers.common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * What is this file about? 30 | * 31 | * Revision history: 32 | * xxxx-xx-xx, author, first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | 40 | namespace dsn { 41 | namespace tools { 42 | extern void register_common_providers(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /include/dsn/utility/apply.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | namespace dsn { 32 | 33 | using absl::apply; 34 | 35 | } // namespace dsn 36 | -------------------------------------------------------------------------------- /include/dsn/utility/clock.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace utils { 24 | 25 | class clock 26 | { 27 | public: 28 | clock() = default; 29 | virtual ~clock() = default; 30 | 31 | // Gets current time in nanoseconds. 32 | virtual uint64_t now_ns() const; 33 | 34 | // Gets singleton instance. eager singleton, which is thread safe 35 | static const clock *instance(); 36 | 37 | // Resets the global clock implementation (not thread-safety) 38 | static void mock(clock *mock_clock); 39 | 40 | private: 41 | static std::unique_ptr _clock; 42 | }; 43 | 44 | } // namespace utils 45 | } // namespace dsn 46 | -------------------------------------------------------------------------------- /include/dsn/utility/hpc_locks/readme.txt: -------------------------------------------------------------------------------- 1 | from: https://github.com/imzhenyu/cpp11-on-multicore 2 | originally from: https://github.com/preshing/cpp11-on-multicore with certain changes 3 | -------------------------------------------------------------------------------- /include/dsn/utility/math.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | namespace dsn { 24 | namespace utils { 25 | 26 | double mean_stddev(const std::vector &result_set, bool partial_sample); 27 | 28 | } // namespace utils 29 | } // namespace dsn 30 | -------------------------------------------------------------------------------- /include/dsn/utility/preloadable.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace utils { 24 | 25 | template 26 | class preloadable 27 | { 28 | protected: 29 | preloadable() {} 30 | DISALLOW_COPY_AND_ASSIGN(preloadable); 31 | 32 | public: 33 | static T s_instance; 34 | }; 35 | 36 | template 37 | T preloadable::s_instance; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /include/dsn/utility/safe_strerror_posix.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace dsn { 10 | namespace utils { 11 | 12 | // This file declares safe, portable alternatives to the POSIX strerror() 13 | // function. strerror() is inherently unsafe in multi-threaded apps and should 14 | // never be used. Doing so can cause crashes. Additionally, the thread-safe 15 | // alternative strerror_r varies in semantics across platforms. Use these 16 | // functions instead. 17 | 18 | // Thread-safe strerror function with dependable semantics that never fails. 19 | // It will write the string form of error "err" to buffer buf of length len. 20 | // If there is an error calling the OS's strerror_r() function then a message to 21 | // that effect will be printed into buf, truncating if necessary. The final 22 | // result is always null-terminated. The value of errno is never changed. 23 | // 24 | // Use this instead of strerror_r(). 25 | void safe_strerror_r(int err, char *buf, size_t len); 26 | 27 | // Calls safe_strerror_r with a buffer of suitable size and returns the result 28 | // in a C++ string. 29 | // 30 | // Use this instead of strerror(). Note though that safe_strerror_r will be 31 | // more robust in the case of heap corruption errors, since it doesn't need to 32 | // allocate a string. 33 | std::string safe_strerror(int err); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /include/dsn/utility/singleton.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace utils { 24 | 25 | /** 26 | * Someone can derived from class `singleton` if he wants to make it's class to be a singleton. 27 | * And it is strongly recommended that making constuctor and destructor to be private. 28 | * So that the lifecycle of this singleton instance is maintained by the base class `singleton` 29 | */ 30 | 31 | template 32 | class singleton : private boost::noncopyable 33 | { 34 | public: 35 | singleton() = default; 36 | 37 | static T &instance() 38 | { 39 | static T _instance; 40 | return _instance; 41 | } 42 | }; 43 | 44 | } // namespace utils 45 | } // namespace dsn 46 | -------------------------------------------------------------------------------- /include/dsn/utility/sys_exit_hook.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | 24 | enum sys_exit_type 25 | { 26 | SYS_EXIT_NORMAL, 27 | SYS_EXIT_BREAK, // Ctrl-C/Break,Shutdown,LogOff, see SetConsoleCtrlHandler 28 | SYS_EXIT_EXCEPTION, 29 | 30 | SYS_EXIT_INVALID 31 | }; 32 | 33 | ENUM_BEGIN(sys_exit_type, SYS_EXIT_INVALID) 34 | ENUM_REG(SYS_EXIT_NORMAL) 35 | ENUM_REG(SYS_EXIT_BREAK) 36 | ENUM_REG(SYS_EXIT_EXCEPTION) 37 | ENUM_END(sys_exit_type) 38 | 39 | namespace tools { 40 | DSN_API extern join_point sys_exit; 41 | } 42 | 43 | } // namespace dsn 44 | -------------------------------------------------------------------------------- /include/dsn/utils/token_buckets.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace dsn { 26 | namespace utils { 27 | 28 | class token_buckets 29 | { 30 | public: 31 | std::shared_ptr get_token_bucket(const std::string &name); 32 | 33 | private: 34 | utils::rw_lock_nr _buckets_lock; 35 | // token_name->token_ptr 36 | std::unordered_map> _token_buckets; 37 | 38 | friend class token_buckets_test; 39 | }; 40 | } // namespace utils 41 | } // namespace dsn 42 | -------------------------------------------------------------------------------- /resources/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/arch.png -------------------------------------------------------------------------------- /resources/config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/config.png -------------------------------------------------------------------------------- /resources/rdsn-layer1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/rdsn-layer1.jpg -------------------------------------------------------------------------------- /resources/rdsn-layer2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/rdsn-layer2.jpg -------------------------------------------------------------------------------- /resources/rdsn-layer3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/rdsn-layer3.jpg -------------------------------------------------------------------------------- /resources/rdsn-state-all.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/rdsn-state-all.jpg -------------------------------------------------------------------------------- /resources/rdsn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/rdsn.jpg -------------------------------------------------------------------------------- /resources/viz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/resources/viz.png -------------------------------------------------------------------------------- /scripts/linux/clear_zk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # 27 | # Options: 28 | # INSTALL_DIR 29 | 30 | if [ -z "$INSTALL_DIR" ] 31 | then 32 | echo "ERROR: no INSTALL_DIR specified" 33 | exit 1 34 | fi 35 | 36 | cd $INSTALL_DIR 37 | 38 | ZOOKEEPER_HOME=`pwd`/apache-zookeeper-3.7.0-bin 39 | 40 | if [ -d "$ZOOKEEPER_HOME" ] 41 | then 42 | $ZOOKEEPER_HOME/bin/zkServer.sh stop 43 | rm -rf $ZOOKEEPER_HOME/data &>/dev/null 44 | echo "Clearing zookeeper ... CLEARED" 45 | fi 46 | -------------------------------------------------------------------------------- /scripts/linux/run-clang-format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") 28 | PROJECT_DIR=$(dirname $(dirname "${SCRIPT_DIR}")) 29 | python ${SCRIPT_DIR}/run-clang-format.py \ 30 | --clang-format-executable=clang-format-3.9 \ 31 | -i \ 32 | -r ${PROJECT_DIR}/src ${PROJECT_DIR}/include 33 | -------------------------------------------------------------------------------- /scripts/linux/stop_zk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # 27 | # Options: 28 | # INSTALL_DIR 29 | 30 | if [ -z "$INSTALL_DIR" ] 31 | then 32 | echo "ERROR: no INSTALL_DIR specified" 33 | exit 1 34 | fi 35 | 36 | cd $INSTALL_DIR 37 | 38 | ZOOKEEPER_HOME=`pwd`/apache-zookeeper-3.7.0-bin 39 | 40 | if [ -d "$ZOOKEEPER_HOME" ] 41 | then 42 | $ZOOKEEPER_HOME/bin/zkServer.sh stop 43 | fi 44 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(UNIX) 2 | add_compile_options(-fPIC) 3 | endif() 4 | add_subdirectory(runtime) 5 | add_subdirectory(aio) 6 | add_subdirectory(zookeeper) 7 | add_subdirectory(perf_counter) 8 | add_subdirectory(failure_detector) 9 | add_subdirectory(remote_cmd) 10 | add_subdirectory(nfs) 11 | add_subdirectory(block_service) 12 | add_subdirectory(http) 13 | add_subdirectory(client) 14 | add_subdirectory(common) 15 | add_subdirectory(replica) 16 | add_subdirectory(meta) 17 | add_subdirectory(tools) 18 | add_subdirectory(utils) 19 | -------------------------------------------------------------------------------- /src/aio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_aio) 2 | 3 | #Source files under CURRENT project directory will be automatically included. 4 | #You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | #Search mode for source files under CURRENT project directory ? 8 | #"GLOB_RECURSE" for recursive search 9 | #"GLOB" for non - recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS dsn_runtime) 13 | 14 | #Extra files that will be installed 15 | set(MY_BINPLACES "") 16 | 17 | dsn_add_static_library() 18 | 19 | add_subdirectory(test) 20 | -------------------------------------------------------------------------------- /src/aio/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_aio_test) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS gtest dsn_runtime dsn_aio) 13 | 14 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 15 | 16 | # Extra files that will be installed 17 | set(MY_BINPLACES 18 | "${CMAKE_CURRENT_SOURCE_DIR}/config.ini" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 21 | "${CMAKE_CURRENT_SOURCE_DIR}/copy_source.txt" 22 | ) 23 | 24 | dsn_add_test() 25 | -------------------------------------------------------------------------------- /src/aio/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf data dsn_aio_test.xml copy_dest.txt 28 | -------------------------------------------------------------------------------- /src/aio/test/config.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [apps..default] 26 | run = true 27 | count = 1 28 | 29 | [apps.mimic] 30 | type = dsn.app.mimic 31 | arguments = 32 | ports = 20101 33 | pools = THREAD_POOL_DEFAULT, THREAD_POOL_TEST_SERVER 34 | run = true 35 | count = 1 36 | 37 | [threadpool.THREAD_POOL_TEST_SERVER] 38 | partitioned = false 39 | 40 | [core] 41 | enable_default_app_mimic = true 42 | tool = nativerun 43 | pause_on_start = false 44 | logging_start_level = LOG_LEVEL_DEBUG 45 | logging_factory_name = dsn::tools::simple_logger 46 | -------------------------------------------------------------------------------- /src/aio/test/copy_source.txt: -------------------------------------------------------------------------------- 1 | 2 | help 3 | help engine 4 | help unexist-cmd 5 | engine 6 | task-code 7 | config-dump config-dump.ini 8 | test-cmd this is test argument 9 | unexist-cmd arg1 arg2 10 | 11 | -------------------------------------------------------------------------------- /src/aio/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | 21 | GTEST_API_ int main(int argc, char **argv) 22 | { 23 | testing::InitGoogleTest(&argc, argv); 24 | dsn_run_config("config.ini", false); 25 | int g_test_ret = RUN_ALL_TESTS(); 26 | #ifndef ENABLE_GCOV 27 | dsn_exit(g_test_ret); 28 | #endif 29 | return g_test_ret; 30 | } 31 | -------------------------------------------------------------------------------- /src/aio/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn_aio_test.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_aio_test 34 | -------------------------------------------------------------------------------- /src/block_service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | ############################################################################## 19 | 20 | set(MY_PROJ_NAME dsn.block_service) 21 | 22 | # Source files under CURRENT project directory will be automatically included. 23 | # You can manually set MY_PROJ_SRC to include source files under other directories. 24 | set(MY_PROJ_SRC "") 25 | 26 | # Search mode for source files under CURRENT project directory? 27 | # "GLOB_RECURSE" for recursive search 28 | # "GLOB" for non-recursive search 29 | set(MY_SRC_SEARCH_MODE "GLOB") 30 | 31 | set(MY_PROJ_LIBS "") 32 | 33 | # Extra files that will be installed 34 | set(MY_BINPLACES "") 35 | 36 | set(MY_BOOST_LIBS Boost::system Boost::filesystem) 37 | 38 | dsn_add_static_library() 39 | 40 | add_subdirectory(fds) 41 | add_subdirectory(hdfs) 42 | add_subdirectory(local) 43 | add_subdirectory(test) 44 | -------------------------------------------------------------------------------- /src/block_service/directio_writable_file.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace dist { 24 | namespace block_service { 25 | 26 | class direct_io_writable_file 27 | { 28 | public: 29 | explicit direct_io_writable_file(const std::string &file_path); 30 | ~direct_io_writable_file(); 31 | 32 | bool initialize(); 33 | bool write(const char *s, size_t n); 34 | bool finalize(); 35 | 36 | private: 37 | DISALLOW_COPY_AND_ASSIGN(direct_io_writable_file); 38 | 39 | std::string _file_path; 40 | int _fd; 41 | uint32_t _file_size; 42 | 43 | // page size aligned buffer 44 | void *_buffer; 45 | // buffer size 46 | uint32_t _buffer_size; 47 | // buffer offset 48 | uint32_t _offset; 49 | }; 50 | 51 | } // namespace block_service 52 | } // namespace dist 53 | } // namespace dsn 54 | -------------------------------------------------------------------------------- /src/block_service/fds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.block_service.fds) 2 | 3 | #Source files under CURRENT project directory will be automatically included. 4 | #You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | #Search mode for source files under CURRENT project directory ? 8 | #"GLOB_RECURSE" for recursive search 9 | #"GLOB" for non - recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS "") 13 | 14 | #Extra files that will be installed 15 | set(MY_BINPLACES "") 16 | 17 | dsn_add_static_library() 18 | target_include_directories(dsn.block_service.fds PRIVATE ${DSN_THIRDPARTY_ROOT}/include/fds) 19 | -------------------------------------------------------------------------------- /src/block_service/hdfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.block_service.hdfs) 2 | 3 | set(DIRECTIO_SRC 4 | ../directio_writable_file.cpp 5 | ) 6 | 7 | #Source files under CURRENT project directory will be automatically included. 8 | #You can manually set MY_PROJ_SRC to include source files under other directories. 9 | set(MY_PROJ_SRC "${DIRECTIO_SRC}") 10 | 11 | #Search mode for source files under CURRENT project directory ? 12 | #"GLOB_RECURSE" for recursive search 13 | #"GLOB" for non - recursive search 14 | set(MY_SRC_SEARCH_MODE "GLOB") 15 | 16 | set(MY_PROJ_LIBS hdfs) 17 | 18 | #Extra files that will be installed 19 | set(MY_BINPLACES "") 20 | 21 | dsn_add_static_library() 22 | 23 | target_link_libraries(${MY_PROJ_NAME} PUBLIC hdfs ${JAVA_JVM_LIBRARY}) 24 | -------------------------------------------------------------------------------- /src/block_service/local/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.block_service.local) 2 | 3 | #Source files under CURRENT project directory will be automatically included. 4 | #You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | #Search mode for source files under CURRENT project directory ? 8 | #"GLOB_RECURSE" for recursive search 9 | #"GLOB" for non - recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS "") 13 | 14 | #Extra files that will be installed 15 | set(MY_BINPLACES "") 16 | 17 | dsn_add_static_library() 18 | -------------------------------------------------------------------------------- /src/block_service/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | ############################################################################## 19 | 20 | set(MY_PROJ_NAME dsn_block_service_test) 21 | 22 | set(MY_SRC_SEARCH_MODE "GLOB") 23 | 24 | set(MY_PROJ_LIBS 25 | dsn_replication_common 26 | dsn.block_service 27 | dsn.block_service.local 28 | dsn.block_service.fds 29 | dsn.block_service.hdfs 30 | dsn_runtime 31 | galaxy-fds-sdk-cpp 32 | PocoNet 33 | PocoFoundation 34 | PocoNetSSL 35 | PocoJSON 36 | gtest 37 | gtest_main 38 | hdfs 39 | ) 40 | 41 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 42 | 43 | set(MY_BINPLACES 44 | config-test.ini 45 | run.sh 46 | clear.sh 47 | ) 48 | 49 | dsn_add_test() 50 | -------------------------------------------------------------------------------- /src/block_service/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################## 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | ############################################################################## 20 | 21 | rm -rf log.* *.log data dsn_block_service_test.xml randomfile* rename_dir* test_dir 22 | -------------------------------------------------------------------------------- /src/block_service/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | #include 21 | 22 | int g_test_count = 0; 23 | int g_test_ret = 0; 24 | 25 | class gtest_app : public dsn::service_app 26 | { 27 | public: 28 | gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {} 29 | 30 | dsn::error_code start(const std::vector &args) override 31 | { 32 | g_test_ret = RUN_ALL_TESTS(); 33 | g_test_count = 1; 34 | return dsn::ERR_OK; 35 | } 36 | 37 | dsn::error_code stop(bool) override { return dsn::ERR_OK; } 38 | }; 39 | 40 | GTEST_API_ int main(int argc, char **argv) 41 | { 42 | testing::InitGoogleTest(&argc, argv); 43 | 44 | dsn::service_app::register_factory("replica"); 45 | 46 | dsn_run_config("config-test.ini", false); 47 | while (g_test_count == 0) { 48 | std::this_thread::sleep_for(std::chrono::seconds(1)); 49 | } 50 | 51 | dsn_exit(g_test_ret); 52 | } 53 | -------------------------------------------------------------------------------- /src/block_service/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ############################################################################## 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | ############################################################################## 21 | 22 | if [ -z "${REPORT_DIR}" ]; then 23 | REPORT_DIR="." 24 | fi 25 | 26 | ./clear.sh 27 | output_xml="${REPORT_DIR}/dsn_block_service_test.xml" 28 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_block_service_test 29 | -------------------------------------------------------------------------------- /src/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_client) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS "") 13 | 14 | # Extra files that will be installed 15 | set(MY_BINPLACES "") 16 | 17 | dsn_add_static_library() 18 | -------------------------------------------------------------------------------- /src/common/bulk_load_common.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include "bulk_load_common.h" 19 | 20 | namespace dsn { 21 | namespace replication { 22 | const std::string bulk_load_constant::BULK_LOAD_INFO("bulk_load_info"); 23 | const int32_t bulk_load_constant::BULK_LOAD_REQUEST_INTERVAL = 10; 24 | const std::string bulk_load_constant::BULK_LOAD_METADATA("bulk_load_metadata"); 25 | const std::string bulk_load_constant::BULK_LOAD_LOCAL_ROOT_DIR("bulk_load"); 26 | const int32_t bulk_load_constant::PROGRESS_FINISHED = 100; 27 | } // namespace replication 28 | } // namespace dsn 29 | -------------------------------------------------------------------------------- /src/common/common.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | 21 | namespace dsn { 22 | DSN_DEFINE_string("replication", cluster_name, "", "name of this cluster"); 23 | 24 | /*extern*/ const char *get_current_cluster_name() 25 | { 26 | dassert(strlen(FLAGS_cluster_name) != 0, "cluster_name is not set"); 27 | return FLAGS_cluster_name; 28 | } 29 | } // namespace dsn 30 | -------------------------------------------------------------------------------- /src/common/manual_compact.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "meta_admin_types.h" 21 | #include 22 | 23 | namespace dsn { 24 | namespace replication { 25 | typedef rpc_holder 26 | start_manual_compact_rpc; 27 | typedef rpc_holder 28 | query_manual_compact_rpc; 29 | } // namespace replication 30 | } // namespace dsn 31 | -------------------------------------------------------------------------------- /src/common/partition_split_common.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "partition_split_types.h" 21 | #include 22 | 23 | namespace dsn { 24 | namespace replication { 25 | typedef rpc_holder start_split_rpc; 26 | typedef rpc_holder control_split_rpc; 27 | typedef rpc_holder query_split_rpc; 28 | typedef rpc_holder register_child_rpc; 29 | typedef rpc_holder notify_stop_split_rpc; 30 | typedef rpc_holder query_child_state_rpc; 31 | } // namespace replication 32 | } // namespace dsn 33 | -------------------------------------------------------------------------------- /src/common/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_replication_common_test) 2 | 3 | set(MY_SRC_SEARCH_MODE "GLOB") 4 | 5 | set(MY_PROJ_LIBS 6 | dsn_replication_common 7 | dsn_runtime 8 | gtest 9 | ) 10 | 11 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 12 | 13 | set(MY_BINPLACES 14 | config-test.ini 15 | run.sh 16 | ) 17 | 18 | dsn_add_test() 19 | -------------------------------------------------------------------------------- /src/common/test/common_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace dsn { 24 | TEST(duplication_common, get_current_cluster_name) 25 | { 26 | ASSERT_STREQ(get_current_cluster_name(), "master-cluster"); 27 | } 28 | } // namespace dsn 29 | -------------------------------------------------------------------------------- /src/common/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | exit_if_fail() { 28 | if [ $1 != 0 ]; then 29 | echo $2 30 | exit 1 31 | fi 32 | } 33 | 34 | ./dsn_replication_common_test 35 | 36 | exit_if_fail $? "run unit test failed" 37 | -------------------------------------------------------------------------------- /src/dsn.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | namespace cpp dsn 28 | 29 | // place holder 30 | struct rpc_address 31 | { 32 | } 33 | 34 | // place holder 35 | struct blob 36 | { 37 | } 38 | 39 | // place holder 40 | struct error_code 41 | { 42 | } 43 | 44 | // place holder 45 | struct task_code 46 | { 47 | } 48 | 49 | // placeholder 50 | struct gpid 51 | { 52 | } 53 | -------------------------------------------------------------------------------- /src/failure_detector/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.failure_detector) 2 | 3 | thrift_generate_cpp( 4 | FD_THRIFT_SRCS 5 | FD_THRIFT_HDRS 6 | ${CMAKE_CURRENT_SOURCE_DIR}/fd.thrift 7 | ) 8 | 9 | seT(MY_PROJ_SRC ${FD_THRIFT_SRCS}) 10 | 11 | 12 | # Search mode for source files under CURRENT project directory? 13 | # "GLOB_RECURSE" for recursive search 14 | # "GLOB" for non-recursive search 15 | set(MY_SRC_SEARCH_MODE "GLOB") 16 | 17 | set(MY_PROJ_LIBS 18 | PocoFoundation 19 | PocoJSON) 20 | 21 | # Extra files that will be installed 22 | set(MY_BINPLACES "") 23 | 24 | dsn_add_static_library() 25 | 26 | add_subdirectory(test) 27 | 28 | -------------------------------------------------------------------------------- /src/failure_detector/fd.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | include "../dsn.thrift" 28 | 29 | namespace cpp dsn.fd 30 | 31 | struct beacon_msg 32 | { 33 | 1: i64 time; 34 | 2: dsn.rpc_address from_addr; 35 | 3: dsn.rpc_address to_addr; 36 | 4: optional i64 start_time; 37 | } 38 | 39 | struct beacon_ack 40 | { 41 | 1: i64 time; 42 | 2: dsn.rpc_address this_node; 43 | 3: dsn.rpc_address primary_node; 44 | 4: bool is_master; 45 | 5: bool allowed; 46 | } 47 | 48 | struct config_master_message 49 | { 50 | 1: dsn.rpc_address master; 51 | 2: bool is_register; 52 | } 53 | -------------------------------------------------------------------------------- /src/failure_detector/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.failure_detector.tests) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS 13 | dsn_runtime 14 | dsn_meta_server 15 | dsn_replica_server 16 | dsn_replication_common 17 | dsn.failure_detector 18 | gtest 19 | hashtable 20 | ) 21 | 22 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 23 | 24 | # Extra files that will be installed 25 | set(MY_BINPLACES 26 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 27 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 28 | "${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini" 29 | "${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test.ini" 30 | "${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test-failed.ini" 31 | "${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter" 32 | ) 33 | 34 | dsn_add_test() 35 | -------------------------------------------------------------------------------- /src/failure_detector/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf log.* *.log data 28 | -------------------------------------------------------------------------------- /src/failure_detector/test/gtest.filter: -------------------------------------------------------------------------------- 1 | config-test.ini -fd.not_in_whitelist 2 | config-whitelist-test.ini -fd.not_in_whitelist 3 | config-whitelist-test-failed.ini fd.not_in_whitelist 4 | -------------------------------------------------------------------------------- /src/http/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | ############################################################################## 19 | 20 | set(MY_PROJ_NAME dsn_http) 21 | 22 | set(MY_PROJ_SRC ${PROJECT_SOURCE_DIR}/thirdparty/build/Source/http-parser/http_parser.c) 23 | 24 | set(MY_SRC_SEARCH_MODE "GLOB") 25 | 26 | set(MY_PROJ_LIBS "") 27 | 28 | dsn_add_static_library() 29 | 30 | add_subdirectory(test) 31 | -------------------------------------------------------------------------------- /src/http/http_server_impl.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace dsn { 25 | 26 | class http_server : public serverlet 27 | { 28 | public: 29 | http_server(); 30 | 31 | ~http_server() override = default; 32 | 33 | void serve(message_ex *msg); 34 | }; 35 | 36 | extern void http_response_reply(const http_response &resp, message_ex *req); 37 | 38 | } // namespace dsn 39 | -------------------------------------------------------------------------------- /src/http/service_version.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include "service_version.h" 19 | 20 | namespace dsn { 21 | 22 | service_version app_version; 23 | 24 | } // namespace dsn 25 | -------------------------------------------------------------------------------- /src/http/service_version.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | 24 | struct service_version 25 | { 26 | std::string version; 27 | std::string git_commit; 28 | }; 29 | 30 | extern service_version app_version; 31 | 32 | } // namespace dsn 33 | -------------------------------------------------------------------------------- /src/http/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_http_test) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | set(MY_SRC_SEARCH_MODE "GLOB") 6 | 7 | set(MY_PROJ_LIBS 8 | dsn_http 9 | dsn_runtime 10 | gtest 11 | gtest_main 12 | ) 13 | 14 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 15 | 16 | set(MY_BINPLACES 17 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 18 | ) 19 | 20 | dsn_add_test() 21 | -------------------------------------------------------------------------------- /src/http/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | output_xml="${REPORT_DIR}/dsn_http_test.xml" 32 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_http_test 33 | -------------------------------------------------------------------------------- /src/http/uri_decoder.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | namespace dsn { 24 | namespace uri { 25 | 26 | /// \brief Decodes a sequence according to the percent decoding rules. 27 | /// \returns the decoded uri path 28 | error_with decode(const string_view &encoded_uri); 29 | 30 | } // namespace uri 31 | } // namespace dsn 32 | -------------------------------------------------------------------------------- /src/meta/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_meta_server) 2 | 3 | set(DUPLICATION_SRC 4 | duplication/duplication_info.cpp 5 | duplication/meta_duplication_service.cpp 6 | ) 7 | 8 | # Source files under CURRENT project directory will be automatically included. 9 | # You can manually set MY_PROJ_SRC to include source files under other directories. 10 | set(MY_PROJ_SRC "${DUPLICATION_SRC}") 11 | 12 | set(MY_PROJ_LIBS 13 | dsn_replication_common 14 | dsn.block_service 15 | dsn.block_service.local 16 | dsn.block_service.fds 17 | dsn.block_service.hdfs 18 | dsn.failure_detector 19 | dsn.replication.zookeeper_provider 20 | dsn_dist_cmd 21 | dsn_http 22 | dsn_runtime 23 | dsn_aio 24 | zookeeper 25 | galaxy-fds-sdk-cpp 26 | PocoNet 27 | PocoFoundation 28 | PocoNetSSL 29 | PocoJSON 30 | crypto 31 | hdfs 32 | ) 33 | 34 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 35 | 36 | # Extra files that will be installed 37 | set(MY_BINPLACES "") 38 | 39 | dsn_add_shared_library() 40 | 41 | add_subdirectory(test) 42 | -------------------------------------------------------------------------------- /src/meta/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.meta.test) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | file(GLOB MY_PROJ_SRC 6 | ${PROJECT_SOURCE_DIR}/src/meta/*.cpp 7 | ${PROJECT_SOURCE_DIR}/src/meta/duplication/*.cpp 8 | ) 9 | set(MY_PROJ_SRC ${MY_PROJ_SRC} misc/misc.cpp) 10 | 11 | # Search mode for source files under CURRENT project directory? 12 | # "GLOB_RECURSE" for recursive search 13 | # "GLOB" for non-recursive search 14 | set(MY_SRC_SEARCH_MODE "GLOB") 15 | 16 | set(MY_PROJ_LIBS 17 | dsn.replication.zookeeper_provider 18 | dsn_replication_common 19 | dsn.block_service 20 | dsn.block_service.local 21 | dsn.block_service.fds 22 | dsn.block_service.hdfs 23 | dsn.failure_detector 24 | dsn_dist_cmd 25 | dsn_http 26 | dsn_runtime 27 | dsn_aio 28 | zookeeper 29 | hashtable 30 | galaxy-fds-sdk-cpp 31 | PocoNet 32 | PocoFoundation 33 | PocoNetSSL 34 | PocoJSON 35 | crypto 36 | gtest 37 | ssl 38 | hdfs) 39 | 40 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 41 | 42 | # Extra files that will be installed 43 | set(MY_BINPLACES clear.sh run.sh config-test.ini suite1 suite2) 44 | 45 | add_definitions(-DDSN_MOCK_TEST) 46 | dsn_add_test() 47 | 48 | add_subdirectory(balancer_simulator) 49 | add_subdirectory(meta_state) 50 | -------------------------------------------------------------------------------- /src/meta/test/balancer_simulator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME sim_lb) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC ../misc/misc.cpp) 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS 13 | dsn_meta_server 14 | dsn_replication_common 15 | dsn_runtime 16 | hashtable 17 | gtest) 18 | 19 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 20 | 21 | # Extra files that will be installed 22 | set(MY_BINPLACES "") 23 | 24 | dsn_add_test() 25 | -------------------------------------------------------------------------------- /src/meta/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | rm -rf core data/ meta_state.dump* zoolog.log backup_data *.xml test_policy_name test_backup_root block_service/ 27 | -------------------------------------------------------------------------------- /src/meta/test/dummy_balancer.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "meta/meta_service.h" 21 | #include "meta/server_load_balancer.h" 22 | 23 | namespace dsn { 24 | namespace replication { 25 | 26 | class dummy_balancer : public server_load_balancer 27 | { 28 | public: 29 | dummy_balancer(meta_service *s) : server_load_balancer(s) {} 30 | virtual bool balance(meta_view view, migration_list &list) { return false; } 31 | virtual bool check(meta_view view, migration_list &list) { return false; } 32 | virtual void report(const migration_list &list, bool balance_checker) {} 33 | virtual std::string get_balance_operation_count(const std::vector &args) 34 | { 35 | return std::string("unknown"); 36 | } 37 | virtual void score(meta_view view, double &primary_stddev, double &total_stddev) {} 38 | }; 39 | 40 | } // namespace replication 41 | } // namespace dsn 42 | -------------------------------------------------------------------------------- /src/meta/test/meta_state/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_meta_state_tests) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS 13 | dsn_meta_server 14 | dsn_replica_server 15 | dsn_replication_common 16 | dsn_runtime 17 | hashtable 18 | gtest 19 | ) 20 | 21 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 22 | 23 | # Extra files that will be installed 24 | set(MY_BINPLACES 25 | "run.sh" 26 | "clear.sh" 27 | "clear.cmd" 28 | "config-test.ini" 29 | "gtest.filter" 30 | ) 31 | 32 | dsn_add_test() 33 | -------------------------------------------------------------------------------- /src/meta/test/meta_state/clear.cmd: -------------------------------------------------------------------------------- 1 | rem The MIT License (MIT) 2 | rem 3 | rem Copyright (c) 2015 Microsoft Corporation 4 | rem 5 | rem -=- Robust Distributed System Nucleus (rDSN) -=- 6 | rem 7 | rem Permission is hereby granted, free of charge, to any person obtaining a copy 8 | rem of this software and associated documentation files (the "Software"), to deal 9 | rem in the Software without restriction, including without limitation the rights 10 | rem to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | rem copies of the Software, and to permit persons to whom the Software is 12 | rem furnished to do so, subject to the following conditions: 13 | rem 14 | rem The above copyright notice and this permission notice shall be included in 15 | rem all copies or substantial portions of the Software. 16 | rem 17 | rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | rem IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | rem FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | rem AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | rem LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | rem OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | rem THE SOFTWARE. 24 | 25 | @ECHO OFF 26 | @rmdir /Q /S data 27 | @rmdir /Q /S nfs_test_dir* 28 | DEL /Q *.tmp 29 | DEL /Q command.copy.txt 30 | -------------------------------------------------------------------------------- /src/meta/test/meta_state/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf client core* log.* *.log data 28 | -------------------------------------------------------------------------------- /src/meta/test/meta_state/gtest.filter: -------------------------------------------------------------------------------- 1 | config-test.ini * 2 | -------------------------------------------------------------------------------- /src/meta/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn.meta.test.1.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn.meta.test 34 | -------------------------------------------------------------------------------- /src/meta/test/suite1: -------------------------------------------------------------------------------- 1 | 4 2 | 127.0.0.1:1 3 | 127.0.0.1:2 4 | 127.0.0.1:3 5 | 127.0.0.1:4 6 | 2 7 | 1 6 8 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 9 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 10 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 11 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 12 | 3 127.0.0.1:2 127.0.0.1:1 127.0.0.1:3 13 | 3 127.0.0.1:3 127.0.0.1:1 127.0.0.1:2 14 | 2 5 15 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 16 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 17 | 3 127.0.0.1:2 127.0.0.1:1 127.0.0.1:3 18 | 3 127.0.0.1:3 127.0.0.1:2 127.0.0.1:1 19 | 3 127.0.0.1:4 127.0.0.1:1 127.0.0.1:2 20 | -------------------------------------------------------------------------------- /src/meta/test/suite2: -------------------------------------------------------------------------------- 1 | 4 2 | 127.0.0.1:1 3 | 127.0.0.1:2 4 | 127.0.0.1:3 5 | 127.0.0.1:4 6 | 2 7 | 1 7 8 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 9 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 10 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 11 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 12 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 13 | 3 127.0.0.1:2 127.0.0.1:1 127.0.0.1:3 14 | 3 127.0.0.1:3 127.0.0.1:1 127.0.0.1:2 15 | 2 5 16 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 17 | 3 127.0.0.1:1 127.0.0.1:2 127.0.0.1:3 18 | 3 127.0.0.1:2 127.0.0.1:1 127.0.0.1:3 19 | 3 127.0.0.1:3 127.0.0.1:2 127.0.0.1:1 20 | 3 127.0.0.1:4 127.0.0.1:1 127.0.0.1:2 21 | -------------------------------------------------------------------------------- /src/nfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_nfs) 2 | 3 | thrift_generate_cpp( 4 | NFS_THRIFT_SRCS 5 | NFS_THRIFT_HDRS 6 | ${CMAKE_CURRENT_SOURCE_DIR}/nfs.thrift 7 | ) 8 | 9 | set(MY_PROJ_SRC ${NFS_THRIFT_SRCS}) 10 | 11 | # Search mode for source files under CURRENT project directory? 12 | # "GLOB_RECURSE" for recursive search 13 | # "GLOB" for non-recursive search 14 | set(MY_SRC_SEARCH_MODE "GLOB") 15 | 16 | set(MY_PROJ_LIBS dsn_aio) 17 | 18 | # Extra files that will be installed 19 | set(MY_BINPLACES "") 20 | 21 | dsn_add_static_library() 22 | 23 | add_subdirectory(test) 24 | -------------------------------------------------------------------------------- /src/nfs/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_nfs_test) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS dsn_nfs dsn_runtime gtest dsn_aio) 13 | 14 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 15 | 16 | # Extra files that will be installed 17 | set(MY_BINPLACES 18 | "${CMAKE_CURRENT_SOURCE_DIR}/nfs_test_file1" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/nfs_test_file2" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/config.ini" 21 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 22 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 23 | ) 24 | 25 | dsn_add_test() 26 | -------------------------------------------------------------------------------- /src/nfs/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf data nfs_test_dir nfs_test_dir_copy dsn_nfs_test.xml 28 | -------------------------------------------------------------------------------- /src/nfs/test/config.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [apps..default] 26 | run = true 27 | count = 1 28 | 29 | [apps.mimic] 30 | type = dsn.app.mimic 31 | arguments = 32 | ports = 20101 33 | pools = THREAD_POOL_DEFAULT 34 | run = true 35 | count = 1 36 | 37 | [core] 38 | enable_default_app_mimic = true 39 | tool = nativerun 40 | pause_on_start = false 41 | logging_start_level = LOG_LEVEL_DEBUG 42 | logging_factory_name = dsn::tools::simple_logger 43 | -------------------------------------------------------------------------------- /src/nfs/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn_nfs_test.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_nfs_test 34 | -------------------------------------------------------------------------------- /src/perf_counter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.perf_counter) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | # Search mode for source files under CURRENT project directory? 6 | # "GLOB_RECURSE" for recursive search 7 | # "GLOB" for non-recursive search 8 | set(MY_SRC_SEARCH_MODE "GLOB") 9 | 10 | set(MY_PROJ_LIBS "") 11 | 12 | # Extra files that will be installed 13 | set(MY_BINPLACES "") 14 | 15 | dsn_add_object() 16 | 17 | add_subdirectory(test) 18 | -------------------------------------------------------------------------------- /src/perf_counter/builtin_counters.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | namespace dsn { 21 | class builtin_counters : public dsn::utils::singleton 22 | { 23 | public: 24 | builtin_counters(); 25 | ~builtin_counters(); 26 | void update_counters(); 27 | 28 | private: 29 | dsn::perf_counter_wrapper _memused_virt; 30 | dsn::perf_counter_wrapper _memused_res; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /src/perf_counter/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_perf_counter_test) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS gtest dsn_runtime) 13 | 14 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 15 | 16 | # Extra files that will be installed 17 | set(MY_BINPLACES 18 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 20 | ) 21 | 22 | dsn_add_test() 23 | -------------------------------------------------------------------------------- /src/perf_counter/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf data dsn_perf_counter_test.xml 28 | -------------------------------------------------------------------------------- /src/perf_counter/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | 21 | GTEST_API_ int main(int argc, char **argv) 22 | { 23 | testing::InitGoogleTest(&argc, argv); 24 | return RUN_ALL_TESTS(); 25 | } 26 | -------------------------------------------------------------------------------- /src/perf_counter/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn_perf_counter_test.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_perf_counter_test 34 | -------------------------------------------------------------------------------- /src/remote_cmd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_dist_cmd) 2 | 3 | thrift_generate_cpp( 4 | COMMAND_THRIFT_SRCS 5 | COMMAND_THRIFT_HDRS 6 | ${CMAKE_CURRENT_SOURCE_DIR}/command.thrift 7 | ) 8 | 9 | seT(MY_PROJ_SRC ${COMMAND_THRIFT_SRCS}) 10 | 11 | set(MY_SRC_SEARCH_MODE "GLOB") 12 | 13 | dsn_add_static_library() 14 | -------------------------------------------------------------------------------- /src/remote_cmd/command.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | namespace cpp dsn.dist.cmd 28 | 29 | struct command 30 | { 31 | 1:string cmd; 32 | 2:list arguments; 33 | } 34 | -------------------------------------------------------------------------------- /src/replica/backup/replica_backup_server.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include "common/backup_common.h" 24 | 25 | namespace dsn { 26 | namespace replication { 27 | 28 | class replica_stub; 29 | 30 | // A server distributes the cold-backup task to the targeted replica. 31 | class replica_backup_server 32 | { 33 | public: 34 | explicit replica_backup_server(const replica_stub *rs); 35 | 36 | private: 37 | void on_cold_backup(backup_rpc rpc); 38 | 39 | void on_clear_cold_backup(const backup_clear_request &request); 40 | 41 | private: 42 | const replica_stub *_stub; 43 | }; 44 | 45 | } // namespace replication 46 | } // namespace dsn 47 | -------------------------------------------------------------------------------- /src/replica/backup/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_replica_backup_test) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | set(MY_SRC_SEARCH_MODE "GLOB") 6 | 7 | set(MY_PROJ_LIBS dsn_meta_server 8 | dsn_replica_server 9 | dsn_replication_common 10 | dsn.block_service 11 | dsn.block_service.local 12 | dsn.block_service.fds 13 | dsn_utils 14 | hashtable 15 | gtest 16 | ) 17 | 18 | set(MY_BOOST_LIBS Boost::system Boost::filesystem) 19 | 20 | set(MY_BINPLACES 21 | config-test.ini 22 | run.sh 23 | ) 24 | 25 | dsn_add_test() 26 | -------------------------------------------------------------------------------- /src/replica/backup/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | #include 21 | 22 | int g_test_count = 0; 23 | int g_test_ret = 0; 24 | 25 | class gtest_app : public dsn::service_app 26 | { 27 | public: 28 | gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {} 29 | 30 | dsn::error_code start(const std::vector &args) override 31 | { 32 | g_test_ret = RUN_ALL_TESTS(); 33 | g_test_count = 1; 34 | return dsn::ERR_OK; 35 | } 36 | 37 | dsn::error_code stop(bool) override { return dsn::ERR_OK; } 38 | }; 39 | 40 | GTEST_API_ int main(int argc, char **argv) 41 | { 42 | testing::InitGoogleTest(&argc, argv); 43 | 44 | dsn::service_app::register_factory("replica"); 45 | 46 | dsn_run_config("config-test.ini", false); 47 | while (g_test_count == 0) { 48 | std::this_thread::sleep_for(std::chrono::seconds(1)); 49 | } 50 | 51 | dsn_exit(g_test_ret); 52 | } 53 | -------------------------------------------------------------------------------- /src/replica/backup/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | ./dsn_replica_backup_test 28 | 29 | if [ $? -ne 0 ]; then 30 | tail -n 100 data/log/log.1.txt 31 | if [ -f core ]; then 32 | gdb ./dsn_replica_backup_test core -ex "bt" 33 | fi 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /src/replica/bulk_load/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_replica_bulk_load_test) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | set(MY_SRC_SEARCH_MODE "GLOB") 6 | 7 | set(MY_PROJ_LIBS dsn_meta_server 8 | dsn_replica_server 9 | dsn_replication_common 10 | dsn_runtime 11 | hashtable 12 | gtest 13 | ) 14 | 15 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 16 | 17 | set(MY_BINPLACES 18 | config-test.ini 19 | run.sh 20 | ) 21 | 22 | dsn_add_test() 23 | -------------------------------------------------------------------------------- /src/replica/bulk_load/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | #include 21 | 22 | int g_test_count = 0; 23 | int g_test_ret = 0; 24 | 25 | class gtest_app : public dsn::service_app 26 | { 27 | public: 28 | gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {} 29 | 30 | dsn::error_code start(const std::vector &args) override 31 | { 32 | g_test_ret = RUN_ALL_TESTS(); 33 | g_test_count = 1; 34 | return dsn::ERR_OK; 35 | } 36 | 37 | dsn::error_code stop(bool) override { return dsn::ERR_OK; } 38 | }; 39 | 40 | GTEST_API_ int main(int argc, char **argv) 41 | { 42 | testing::InitGoogleTest(&argc, argv); 43 | 44 | dsn::service_app::register_factory("replica"); 45 | 46 | dsn_run_config("config-test.ini", false); 47 | while (g_test_count == 0) { 48 | std::this_thread::sleep_for(std::chrono::seconds(1)); 49 | } 50 | 51 | dsn_exit(g_test_ret); 52 | } 53 | -------------------------------------------------------------------------------- /src/replica/bulk_load/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | ./dsn_replica_bulk_load_test 28 | 29 | if [ $? -ne 0 ]; then 30 | tail -n 100 data/log/log.1.txt 31 | if [ -f core ]; then 32 | gdb ./dsn_replica_bulk_load_test core -ex "bt" 33 | fi 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /src/replica/duplication/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_replica_dup_test) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | set(MY_SRC_SEARCH_MODE "GLOB") 6 | 7 | set(MY_PROJ_LIBS dsn_meta_server 8 | dsn_replica_server 9 | dsn.replication.zookeeper_provider 10 | dsn_replication_common 11 | dsn.failure_detector 12 | dsn_utils 13 | zookeeper 14 | hashtable 15 | gtest 16 | ) 17 | 18 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 19 | 20 | set(MY_BINPLACES 21 | config-test.ini 22 | log.1.0.handle_real_private_log 23 | log.1.0.all_loaded_are_write_empties 24 | log.1.0.handle_real_private_log2 25 | run.sh 26 | ) 27 | 28 | dsn_add_test() 29 | -------------------------------------------------------------------------------- /src/replica/duplication/test/log.1.0.all_loaded_are_write_empties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/src/replica/duplication/test/log.1.0.all_loaded_are_write_empties -------------------------------------------------------------------------------- /src/replica/duplication/test/log.1.0.handle_real_private_log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/src/replica/duplication/test/log.1.0.handle_real_private_log -------------------------------------------------------------------------------- /src/replica/duplication/test/log.1.0.handle_real_private_log2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/src/replica/duplication/test/log.1.0.handle_real_private_log2 -------------------------------------------------------------------------------- /src/replica/duplication/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | #include 21 | 22 | int g_test_count = 0; 23 | int g_test_ret = 0; 24 | 25 | class gtest_app : public dsn::service_app 26 | { 27 | public: 28 | gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {} 29 | 30 | dsn::error_code start(const std::vector &args) override 31 | { 32 | g_test_ret = RUN_ALL_TESTS(); 33 | g_test_count = 1; 34 | return dsn::ERR_OK; 35 | } 36 | 37 | dsn::error_code stop(bool) override { return dsn::ERR_OK; } 38 | }; 39 | 40 | GTEST_API_ int main(int argc, char **argv) 41 | { 42 | testing::InitGoogleTest(&argc, argv); 43 | 44 | dsn::service_app::register_factory("replica"); 45 | 46 | dsn_run_config("config-test.ini", false); 47 | while (g_test_count == 0) { 48 | std::this_thread::sleep_for(std::chrono::seconds(1)); 49 | } 50 | 51 | dsn_exit(g_test_ret); 52 | } 53 | -------------------------------------------------------------------------------- /src/replica/duplication/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | ./dsn_replica_dup_test 28 | 29 | if [ $? -ne 0 ]; then 30 | tail -n 100 data/log/log.1.txt 31 | if [ -f core ]; then 32 | gdb ./dsn_replica_dup_test core -ex "bt" 33 | fi 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /src/replica/split/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_replica_split_test) 2 | 3 | set(MY_PROJ_SRC "") 4 | 5 | set(MY_SRC_SEARCH_MODE "GLOB") 6 | 7 | set(MY_PROJ_LIBS dsn_meta_server 8 | dsn_replica_server 9 | dsn_replication_common 10 | dsn_runtime 11 | hashtable 12 | gtest 13 | ) 14 | 15 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 16 | 17 | set(MY_BINPLACES 18 | config-test.ini 19 | run.sh 20 | ) 21 | 22 | dsn_add_test() 23 | -------------------------------------------------------------------------------- /src/replica/split/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | 20 | #include 21 | 22 | int g_test_count = 0; 23 | int g_test_ret = 0; 24 | 25 | class gtest_app : public dsn::service_app 26 | { 27 | public: 28 | gtest_app(const dsn::service_app_info *info) : ::dsn::service_app(info) {} 29 | 30 | dsn::error_code start(const std::vector &args) override 31 | { 32 | g_test_ret = RUN_ALL_TESTS(); 33 | g_test_count = 1; 34 | return dsn::ERR_OK; 35 | } 36 | 37 | dsn::error_code stop(bool) override { return dsn::ERR_OK; } 38 | }; 39 | 40 | GTEST_API_ int main(int argc, char **argv) 41 | { 42 | testing::InitGoogleTest(&argc, argv); 43 | 44 | dsn::service_app::register_factory("replica"); 45 | 46 | dsn_run_config("config-test.ini", false); 47 | while (g_test_count == 0) { 48 | std::this_thread::sleep_for(std::chrono::seconds(1)); 49 | } 50 | 51 | dsn_exit(g_test_ret); 52 | } 53 | -------------------------------------------------------------------------------- /src/replica/split/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | ./dsn_replica_split_test 28 | 29 | if [ $? -ne 0 ]; then 30 | tail -n 100 data/log/log.1.txt 31 | if [ -f core ]; then 32 | gdb ./dsn_replica_split_test core -ex "bt" 33 | fi 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /src/replica/storage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(simple_kv) 2 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.replication.simple_kv) 2 | 3 | thrift_generate_cpp( 4 | SIMPLE_KV_THRIFT_SRCS 5 | SIMPLE_KV_THRIFT_HDRS 6 | ${CMAKE_CURRENT_SOURCE_DIR}/simple_kv.thrift 7 | ) 8 | 9 | set(MY_PROJ_SRC ${SIMPLE_KV_THRIFT_SRCS}) 10 | 11 | # Search mode for source files under CURRENT project directory? 12 | # "GLOB_RECURSE" for recursive search 13 | # "GLOB" for non-recursive search 14 | set(MY_SRC_SEARCH_MODE "GLOB") 15 | 16 | set(MY_PROJ_LIBS dsn_replica_server dsn_meta_server dsn_client dsn_runtime hashtable) 17 | 18 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 19 | 20 | set(INI_FILES "") 21 | file(GLOB 22 | RES_FILES 23 | "${CMAKE_CURRENT_SOURCE_DIR}/*.ini" 24 | "${CMAKE_CURRENT_SOURCE_DIR}/*.sh" 25 | ) 26 | 27 | # Extra files that will be installed 28 | set(MY_BINPLACES ${RES_FILES}) 29 | 30 | dsn_add_test() 31 | 32 | add_subdirectory(test) 33 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf data core* out 28 | 29 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/simple_kv.thrift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | namespace cpp dsn.replication.application 28 | 29 | struct kv_pair 30 | { 31 | 1:string key; 32 | 2:string value; 33 | } 34 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.rep_tests.simple_kv) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_PROJ_LIBS dsn_replica_server 9 | dsn_meta_server 10 | dsn_replication_common 11 | dsn_client 12 | dsn.failure_detector 13 | dsn.replication.zookeeper_provider 14 | dsn_runtime 15 | zookeeper 16 | hashtable 17 | gtest 18 | ) 19 | 20 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 21 | 22 | # Extra files that will be installed 23 | FILE(GLOB CASE_FILES "case-*") 24 | set(MY_BINPLACES 25 | "run.sh" 26 | "clear.sh" 27 | "addcase.sh" 28 | "${CASE_FILES}" 29 | ) 30 | 31 | dsn_add_test() 32 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/README.md: -------------------------------------------------------------------------------- 1 | 26 | 27 | Case Classification: 28 | 000~099: nomal operation 29 | 100~199: RPC fault/failure between replica servers 30 | 200~299: AIO fault/failure in replica servers 31 | 300~399: RPC fault/failure between replica server and meta server 32 | 400~499: mixed fault/failure of above 33 | 500~599: test cases of failure detector module 34 | 600~699: regression testing 35 | 36 | Run case: 37 | ./run.sh 38 | for example: 39 | ./run.sh 000 40 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/addcase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ $# -ne 2 ]; then 28 | echo "USAGE: $0 " 29 | echo " e.g.: $0 106 100" 30 | exit 1 31 | fi 32 | 33 | id=$1 34 | 35 | if [ -f case-${id}.act ]; then 36 | echo "case ${id} already exists" 37 | exit 1 38 | fi 39 | 40 | old=$2 41 | cp case-${old}.act case-${id}.act 42 | cp case-${old}.ini case-${id}.ini 43 | 44 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/case-300-1.act: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2015 Microsoft Corporation 4 | # 5 | # -=- Robust Distributed System Nucleus (rDSN) -=- 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | 25 | # Case Description: 26 | # - normal recover 27 | 28 | set:load_balance_for_test=1,not_exit_on_log_failure=1 29 | 30 | # on meta server the config is the same with the exit state last time 31 | config:{3,r1,[r2,r3]} 32 | 33 | # and the states will be normal again, ballot will increase as old primary elected as leader 34 | state:{{r1,pri,4,2},{r2,sec,4,2},{r3,sec,4,2}} 35 | 36 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/case-301.act: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2015 Microsoft Corporation 4 | # 5 | # -=- Robust Distributed System Nucleus (rDSN) -=- 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | 25 | # Case Description: 26 | # occasionally loss of rpc message have no impact on meta server 27 | 28 | set:load_balance_for_test=1,not_exit_on_log_failure=1 29 | 30 | inject:on_rpc_call:rpc_name=rpc_config_proposal,from=m,to=r1 31 | 32 | state:{{r1,ina,0,0}} 33 | config:{1,r1,[]} 34 | state:{{r1,pri,1,0}} 35 | config:{3,r1,[r2,r3]} 36 | state:{{r1,pri,3,0},{r2,sec,3,0},{r3,sec,3,0}} 37 | 38 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/case-401.act: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2015 Microsoft Corporation 4 | # 5 | # -=- Robust Distributed System Nucleus (rDSN) -=- 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | 25 | # Case Description: 26 | # - test the inactive of primary 27 | 28 | set:load_balance_for_test=1,not_exit_on_log_failure=1 29 | 30 | config:{1,r1,[]} 31 | set:disable_load_balance=1 32 | 33 | # this write will be notified with not enough member 34 | client:begin_write:id=1,key=t1,value=v1,timeout=0 35 | client:end_write:id=1,err=ERR_TIMEOUT,resp=0 36 | 37 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf data core* 28 | 29 | -------------------------------------------------------------------------------- /src/replica/storage/simple_kv/test/rep_tests.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/src/replica/storage/simple_kv/test/rep_tests.pdf -------------------------------------------------------------------------------- /src/replica/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.replica.test) 2 | 3 | #Source files under CURRENT project directory will be automatically included. 4 | #You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | #Search mode for source files under CURRENT project directory ? 8 | #"GLOB_RECURSE" for recursive search 9 | #"GLOB" for non - recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS dsn_meta_server 13 | dsn_replica_server 14 | dsn.replication.zookeeper_provider 15 | dsn_replication_common 16 | dsn.block_service 17 | dsn.block_service.local 18 | dsn.block_service.fds 19 | dsn.block_service.hdfs 20 | dsn.failure_detector 21 | dsn_http 22 | dsn_runtime 23 | zookeeper 24 | hashtable 25 | gtest) 26 | 27 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 28 | 29 | #Extra files that will be installed 30 | set(MY_BINPLACES clear.sh run.sh config-test.ini) 31 | dsn_add_test() 32 | -------------------------------------------------------------------------------- /src/replica/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | 20 | rm -rf core.* data/ log.* replica.* tag* test* test_cluster/ 21 | -------------------------------------------------------------------------------- /src/replica/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn.replica.test.1.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn.replica.test 34 | -------------------------------------------------------------------------------- /src/runtime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(test) 2 | add_subdirectory(rpc) 3 | add_subdirectory(task) 4 | add_subdirectory(security) 5 | 6 | # TODO(zlw) remove perf_counter from dsn_runtime after the refactor by WuTao 7 | add_library(dsn_runtime STATIC 8 | $ 9 | $ 10 | $ 11 | $ 12 | core_main.cpp 13 | dsn.layer2_types.cpp 14 | env.sim.cpp 15 | fault_injector.cpp 16 | global_config.cpp 17 | message_utils.cpp 18 | nativerun.cpp 19 | profiler.cpp 20 | providers.common.cpp 21 | scheduler.cpp 22 | service_api_c.cpp 23 | service_engine.cpp 24 | simulator.cpp 25 | threadpool_code.cpp 26 | tool_api.cpp 27 | tracer.cpp 28 | zlocks.cpp 29 | ) 30 | target_link_libraries(dsn_runtime PRIVATE dsn_utils sasl2 gssapi_krb5 krb5) 31 | define_file_basename_for_sources(dsn_runtime) 32 | install(TARGETS dsn_runtime DESTINATION "lib") 33 | -------------------------------------------------------------------------------- /src/runtime/rpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.rpc) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_PROJ_LIBS "") 9 | 10 | # Extra files that will be installed 11 | set(MY_BINPLACES "") 12 | 13 | thrift_generate_cpp( 14 | REQUEST_META_THRIFT_SRCS 15 | REQUEST_META_THRIFT_HDRS 16 | ${CMAKE_CURRENT_SOURCE_DIR}/request_meta.thrift 17 | ) 18 | 19 | set(MY_PROJ_SRC ${REQUEST_META_THRIFT_SRCS}) 20 | 21 | dsn_add_object() 22 | -------------------------------------------------------------------------------- /src/runtime/rpc/request_meta.thrift: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | namespace cpp dsn 19 | 20 | // Metadata field of the request in rDSN's thrift protocol (version 1). 21 | // TODO(wutao1): add design doc of the thrift protocol. 22 | struct thrift_request_meta_v1 23 | { 24 | // The replica's gpid. 25 | 1:optional i32 app_id; 26 | 2:optional i32 partition_index; 27 | 28 | // The timeout of this request that's set on client side. 29 | 3:optional i32 client_timeout; 30 | 31 | // The hash value calculated from the hash key. 32 | 4:optional i64 client_partition_hash; 33 | 34 | // Whether it is a backup request. If true, this request (only if it's a read) can be handled by 35 | // a secondary replica, which does not guarantee strong consistency. 36 | 5:optional bool is_backup_request; 37 | } 38 | -------------------------------------------------------------------------------- /src/runtime/security/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.security) 2 | 3 | thrift_generate_cpp( 4 | SECURITY_THRIFT_SRCS 5 | SECURITY_THRIFT_HDRS 6 | ${CMAKE_CURRENT_SOURCE_DIR}/security.thrift 7 | ) 8 | 9 | set(MY_PROJ_SRC ${SECURITY_THRIFT_SRCS}) 10 | 11 | # Search mode for source files under CURRENT project directory? 12 | # "GLOB_RECURSE" for recursive search 13 | # "GLOB" for non-recursive search 14 | set(MY_SRC_SEARCH_MODE "GLOB") 15 | 16 | set(MY_PROJ_INC_PATH "") 17 | 18 | set(MY_PROJ_LIBS "") 19 | 20 | set(MY_PROJ_LIB_PATH "") 21 | 22 | # Extra files that will be installed 23 | set(MY_BINPLACES "") 24 | 25 | dsn_add_object() 26 | -------------------------------------------------------------------------------- /src/runtime/security/client_negotiation.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "negotiation.h" 21 | 22 | namespace dsn { 23 | namespace security { 24 | 25 | // client_negotiation negotiates a session on client side. 26 | class client_negotiation : public negotiation 27 | { 28 | public: 29 | explicit client_negotiation(rpc_session_ptr session); 30 | 31 | void start() override; 32 | void handle_response(error_code err, const negotiation_response &&response); 33 | 34 | private: 35 | void on_recv_mechanisms(const negotiation_response &resp); 36 | void on_mechanism_selected(const negotiation_response &resp); 37 | void on_challenge(const negotiation_response &resp); 38 | 39 | void list_mechanisms(); 40 | void select_mechanism(const std::string &mechanism); 41 | void send(negotiation_status::type status, const blob &msg = blob()); 42 | void succ_negotiation(); 43 | 44 | friend class client_negotiation_test; 45 | }; 46 | 47 | } // namespace security 48 | } // namespace dsn 49 | -------------------------------------------------------------------------------- /src/runtime/security/init.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace security { 24 | // init security(kerberos and sasl) 25 | bool init(bool is_server); 26 | 27 | // init security only for zookeeper client(kerberos and sasl) 28 | bool init_for_zookeeper_client(); 29 | } // namespace security 30 | } // namespace dsn 31 | -------------------------------------------------------------------------------- /src/runtime/security/kinit_context.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace security { 24 | extern error_s run_kinit(); 25 | extern const std::string &get_username(); 26 | } // namespace security 27 | } // namespace dsn 28 | -------------------------------------------------------------------------------- /src/runtime/security/meta_access_controller.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "access_controller.h" 21 | 22 | #include 23 | 24 | namespace dsn { 25 | class message_ex; 26 | namespace security { 27 | 28 | class meta_access_controller : public access_controller 29 | { 30 | public: 31 | meta_access_controller(); 32 | bool allowed(message_ex *msg) override; 33 | 34 | private: 35 | void register_allowed_list(const std::string &rpc_code); 36 | 37 | std::unordered_set _allowed_rpc_code_list; 38 | }; 39 | } // namespace security 40 | } // namespace dsn 41 | -------------------------------------------------------------------------------- /src/runtime/security/replica_access_controller.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "access_controller.h" 22 | 23 | namespace dsn { 24 | namespace security { 25 | class replica_access_controller : public access_controller 26 | { 27 | public: 28 | explicit replica_access_controller(const std::string &name); 29 | bool allowed(message_ex *msg) override; 30 | void update(const std::string &users) override; 31 | 32 | private: 33 | utils::rw_lock_nr _lock; // [ 34 | std::unordered_set _users; 35 | std::string _env_users; 36 | // ] 37 | std::string _name; 38 | 39 | friend class replica_access_controller_test; 40 | }; 41 | } // namespace security 42 | } // namespace dsn 43 | -------------------------------------------------------------------------------- /src/runtime/security/sasl_client_wrapper.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "sasl_wrapper.h" 21 | 22 | namespace dsn { 23 | namespace security { 24 | 25 | // sasl_client_wrapper is a simple wrapper over cyrus-sasl's sasl_client_xxx API. 26 | class sasl_client_wrapper : public sasl_wrapper 27 | { 28 | public: 29 | sasl_client_wrapper() = default; 30 | ~sasl_client_wrapper() override = default; 31 | 32 | error_s init(); 33 | error_s start(const std::string &mechanism, const blob &input, blob &output); 34 | error_s step(const blob &input, blob &output); 35 | }; 36 | 37 | } // namespace security 38 | } // namespace dsn 39 | -------------------------------------------------------------------------------- /src/runtime/security/sasl_init.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace dsn { 23 | namespace security { 24 | // you must have already initialized kerberos before call init_sasl 25 | error_s init_sasl(bool is_server); 26 | } // namespace security 27 | } // namespace dsn 28 | -------------------------------------------------------------------------------- /src/runtime/security/sasl_server_wrapper.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include "sasl_wrapper.h" 21 | 22 | namespace dsn { 23 | namespace security { 24 | class sasl_server_wrapper : public sasl_wrapper 25 | { 26 | public: 27 | sasl_server_wrapper() = default; 28 | ~sasl_server_wrapper() = default; 29 | 30 | error_s init(); 31 | error_s start(const std::string &mechanism, const blob &input, blob &output); 32 | error_s step(const blob &input, blob &output); 33 | }; 34 | } // namespace security 35 | } // namespace dsn 36 | -------------------------------------------------------------------------------- /src/runtime/sim_clock.h: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "scheduler.h" 22 | 23 | namespace dsn { 24 | namespace tools { 25 | 26 | class sim_clock : public utils::clock 27 | { 28 | public: 29 | sim_clock() = default; 30 | virtual ~sim_clock() = default; 31 | 32 | // Gets simulated time in nanoseconds. 33 | virtual uint64_t now_ns() const { return scheduler::instance().now_ns(); } 34 | }; 35 | 36 | } // namespace tools 37 | } // namespace dsn 38 | -------------------------------------------------------------------------------- /src/runtime/task/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.task) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_PROJ_LIBS "") 9 | 10 | # Extra files that will be installed 11 | set(MY_BINPLACES "") 12 | 13 | dsn_add_object() 14 | -------------------------------------------------------------------------------- /src/runtime/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_runtime_tests) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_PROJ_LIBS gtest 9 | dsn_runtime 10 | dsn_aio 11 | ) 12 | 13 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 14 | 15 | # Extra files that will be installed 16 | set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-test-corrupt-message.ini" 17 | "${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini" 18 | "${CMAKE_CURRENT_SOURCE_DIR}/config-test-sim.ini" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/command.txt" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 21 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 22 | "${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter" 23 | ) 24 | add_definitions(-Wno-dangling-else) 25 | dsn_add_test() 26 | -------------------------------------------------------------------------------- /src/runtime/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf core* log.* nfs_test_dir* *.tmp data 28 | 29 | -------------------------------------------------------------------------------- /src/runtime/test/command.txt: -------------------------------------------------------------------------------- 1 | 2 | help 3 | help engine 4 | help unexist-cmd 5 | engine 6 | task-code 7 | config-dump config-dump.ini 8 | test-cmd this is test argument 9 | unexist-cmd arg1 arg2 10 | 11 | -------------------------------------------------------------------------------- /src/runtime/test/gtest.filter: -------------------------------------------------------------------------------- 1 | config-test.ini -core.corrupt_message:core.aio*:core.operation_failed:tools_hpc.* 2 | config-test-sim.ini -core.corrupt_message:core.aio*:core.operation_failed:tools_hpc.*:tools_simulator.*:task_test.signal_finished_task 3 | config-test-sim.ini tools_simulator.* 4 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.replication.tool) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS "") 13 | 14 | set(MY_BINPLACES "") 15 | 16 | dsn_add_static_library() 17 | -------------------------------------------------------------------------------- /src/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_utils) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 9 | 10 | set(MY_PROJ_LIBS crypto) 11 | 12 | # Extra files that will be installed 13 | set(MY_BINPLACES "") 14 | 15 | if (APPLE) 16 | dsn_add_static_library() 17 | else() 18 | dsn_add_shared_library() 19 | endif() 20 | 21 | add_subdirectory(long_adder_bench) 22 | add_subdirectory(test) 23 | -------------------------------------------------------------------------------- /src/utils/clock.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | DSN_API uint64_t dsn_now_ns() { return dsn::utils::clock::instance()->now_ns(); } 24 | 25 | namespace dsn { 26 | namespace utils { 27 | 28 | std::unique_ptr clock::_clock = make_unique(); 29 | 30 | const clock *clock::instance() { return _clock.get(); } 31 | 32 | uint64_t clock::now_ns() const { return get_current_physical_time_ns(); } 33 | 34 | void clock::mock(clock *mock_clock) { _clock.reset(mock_clock); } 35 | 36 | } // namespace utils 37 | } // namespace dsn 38 | -------------------------------------------------------------------------------- /src/utils/coredump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * What is this file about? 30 | * 31 | * Revision history: 32 | * xxxx-xx-xx, author, first version 33 | * xxxx-xx-xx, author, fix bug about xxx 34 | */ 35 | 36 | #pragma once 37 | 38 | #include 39 | 40 | namespace dsn { 41 | namespace utils { 42 | 43 | class coredump 44 | { 45 | public: 46 | static void init(); 47 | static void write(); 48 | }; 49 | } // namespace utils 50 | } // namespace dsn 51 | -------------------------------------------------------------------------------- /src/utils/gpid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | #include 27 | #include 28 | #include 29 | 30 | namespace dsn { 31 | 32 | bool gpid::parse_from(const char *str) 33 | { 34 | return sscanf(str, "%d.%d", &_value.u.app_id, &_value.u.partition_index) == 2; 35 | } 36 | 37 | static __thread fixed_size_buffer_pool<8, 64> bf; 38 | const char *gpid::to_string() const 39 | { 40 | char *b = bf.next(); 41 | snprintf(b, bf.get_chunk_size(), "%d.%d", _value.u.app_id, _value.u.partition_index); 42 | return b; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/utils/long_adder_bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | set(MY_PROJ_NAME long_adder_bench) 19 | project(${MY_PROJ_NAME} C CXX) 20 | 21 | # Source files under CURRENT project directory will be automatically included. 22 | # You can manually set MY_PROJ_SRC to include source files under other directories. 23 | set(MY_PROJ_SRC "") 24 | 25 | # Search mode for source files under CURRENT project directory? 26 | # "GLOB_RECURSE" for recursive search 27 | # "GLOB" for non-recursive search 28 | set(MY_SRC_SEARCH_MODE "GLOB") 29 | 30 | set(MY_PROJ_LIBS dsn_runtime dsn_utils) 31 | 32 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 33 | 34 | # Extra files that will be installed 35 | set(MY_BINPLACES "") 36 | 37 | dsn_add_executable() 38 | 39 | dsn_install_executable() 40 | -------------------------------------------------------------------------------- /src/utils/memutil.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Abseil Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | namespace dsn { 18 | namespace strings_internal { 19 | 20 | // This is significantly faster for case-sensitive matches with very 21 | // few possible matches. See unit test for benchmarks. 22 | const char *memmatch(const char *phaystack, size_t haylen, const char *pneedle, size_t neelen); 23 | 24 | } // namespace strings_internal 25 | } // namespace dsn 26 | -------------------------------------------------------------------------------- /src/utils/rand.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | 21 | namespace dsn { 22 | namespace rand { 23 | 24 | thread_local std::ranlux48_base g_thread_local_rng(std::random_device{}()); 25 | 26 | /*extern*/ uint64_t next_u64(uint64_t min, uint64_t max) 27 | { 28 | return std::uniform_int_distribution(min, max)(g_thread_local_rng); 29 | } 30 | 31 | /*extern*/ void reseed_thread_local_rng(uint64_t seed) { g_thread_local_rng.seed(seed); } 32 | 33 | } // namespace rand 34 | } // namespace dsn 35 | -------------------------------------------------------------------------------- /src/utils/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn_utils_tests) 2 | 3 | # Search mode for source files under CURRENT project directory? 4 | # "GLOB_RECURSE" for recursive search 5 | # "GLOB" for non-recursive search 6 | set(MY_SRC_SEARCH_MODE "GLOB") 7 | 8 | set(MY_PROJ_LIBS dsn_runtime 9 | dsn_utils 10 | gtest 11 | ) 12 | 13 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 14 | 15 | # Extra files that will be installed 16 | set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-bad-section.ini" 17 | "${CMAKE_CURRENT_SOURCE_DIR}/config-dup-key.ini" 18 | "${CMAKE_CURRENT_SOURCE_DIR}/config-dup-section.ini" 19 | "${CMAKE_CURRENT_SOURCE_DIR}/config-empty.ini" 20 | "${CMAKE_CURRENT_SOURCE_DIR}/config-no-key.ini" 21 | "${CMAKE_CURRENT_SOURCE_DIR}/config-no-section.ini" 22 | "${CMAKE_CURRENT_SOURCE_DIR}/config-null-section.ini" 23 | "${CMAKE_CURRENT_SOURCE_DIR}/config-sample.ini" 24 | "${CMAKE_CURRENT_SOURCE_DIR}/config-unmatch-section.ini" 25 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 26 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 27 | ) 28 | add_subdirectory(nth_element_bench) 29 | add_definitions(-Wno-dangling-else) 30 | dsn_add_test() 31 | -------------------------------------------------------------------------------- /src/utils/test/TokenBucketTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace folly { 23 | 24 | struct TokenBucketTest : public ::testing::TestWithParam> 25 | { 26 | }; 27 | 28 | } // namespace folly 29 | -------------------------------------------------------------------------------- /src/utils/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf dsn.utils.tests.xml log*.txt 28 | -------------------------------------------------------------------------------- /src/utils/test/config-bad-section.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [core] = 1 26 | run = true 27 | count = 1 28 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 29 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 30 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 31 | 32 | -------------------------------------------------------------------------------- /src/utils/test/config-dup-key.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [core] 26 | run = true 27 | count = 1 28 | count = 2 29 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 30 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 31 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 32 | 33 | -------------------------------------------------------------------------------- /src/utils/test/config-dup-section.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [core] 26 | run = true 27 | count = 1 28 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 29 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 30 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 31 | 32 | [core] 33 | count = 2 34 | 35 | -------------------------------------------------------------------------------- /src/utils/test/config-empty.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiaoMi/rdsn/bf76b99a2eea075a29def280a38efea043eb86db/src/utils/test/config-empty.ini -------------------------------------------------------------------------------- /src/utils/test/config-no-key.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [core] 26 | = true 27 | count = 1 28 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 29 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 30 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 31 | 32 | -------------------------------------------------------------------------------- /src/utils/test/config-no-section.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | run = true 26 | count = 1 27 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 28 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 29 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 30 | 31 | -------------------------------------------------------------------------------- /src/utils/test/config-null-section.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [ ] 26 | run = true 27 | count = 1 28 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 29 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 30 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 31 | 32 | -------------------------------------------------------------------------------- /src/utils/test/config-unmatch-section.ini: -------------------------------------------------------------------------------- 1 | ; The MIT License (MIT) 2 | ; 3 | ; Copyright (c) 2015 Microsoft Corporation 4 | ; 5 | ; -=- Robust Distributed System Nucleus (rDSN) -=- 6 | ; 7 | ; Permission is hereby granted, free of charge, to any person obtaining a copy 8 | ; of this software and associated documentation files (the "Software"), to deal 9 | ; in the Software without restriction, including without limitation the rights 10 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ; copies of the Software, and to permit persons to whom the Software is 12 | ; furnished to do so, subject to the following conditions: 13 | ; 14 | ; The above copyright notice and this permission notice shall be included in 15 | ; all copies or substantial portions of the Software. 16 | ; 17 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | ; THE SOFTWARE. 24 | 25 | [core 26 | run = true 27 | count = 1 28 | ;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 29 | ;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 30 | ;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 31 | 32 | -------------------------------------------------------------------------------- /src/utils/test/file_system_test.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | 21 | namespace dsn { 22 | namespace utils { 23 | namespace filesystem { 24 | 25 | TEST(verify_file, verify_file_test) 26 | { 27 | const std::string &fname = "test_file"; 28 | std::string expected_md5; 29 | int64_t expected_fsize; 30 | create_file(fname); 31 | md5sum(fname, expected_md5); 32 | file_size(fname, expected_fsize); 33 | 34 | ASSERT_TRUE(verify_file(fname, expected_md5, expected_fsize)); 35 | ASSERT_FALSE(verify_file(fname, "wrong_md5", 10086)); 36 | ASSERT_FALSE(verify_file("file_not_exists", "wrong_md5", 10086)); 37 | 38 | remove_path(fname); 39 | } 40 | 41 | } // namespace filesystem 42 | } // namespace utils 43 | } // namespace dsn 44 | -------------------------------------------------------------------------------- /src/utils/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | extern void command_manager_module_init(); 24 | 25 | GTEST_API_ int main(int argc, char **argv) 26 | { 27 | testing::InitGoogleTest(&argc, argv); 28 | 29 | command_manager_module_init(); 30 | // init logging 31 | dsn_log_init("dsn::tools::simple_logger", "./", nullptr); 32 | 33 | dsn::flags_initialize(); 34 | 35 | return RUN_ALL_TESTS(); 36 | } 37 | -------------------------------------------------------------------------------- /src/utils/test/memutil_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Abseil Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Unit test for memutil.cc 16 | 17 | #include "utils/memutil.h" 18 | 19 | #include 20 | 21 | TEST(MemUtilTest, memmatch) 22 | { 23 | const char kHaystack[] = "0123456789"; 24 | EXPECT_EQ(dsn::strings_internal::memmatch(kHaystack, 0, "", 0), kHaystack); 25 | EXPECT_EQ(dsn::strings_internal::memmatch(kHaystack, 10, "012", 3), kHaystack); 26 | EXPECT_EQ(dsn::strings_internal::memmatch(kHaystack, 10, "0xx", 1), kHaystack); 27 | EXPECT_EQ(dsn::strings_internal::memmatch(kHaystack, 10, "789", 3), kHaystack + 7); 28 | EXPECT_EQ(dsn::strings_internal::memmatch(kHaystack, 10, "9xx", 1), kHaystack + 9); 29 | EXPECT_TRUE(dsn::strings_internal::memmatch(kHaystack, 10, "9xx", 3) == nullptr); 30 | EXPECT_TRUE(dsn::strings_internal::memmatch(kHaystack, 10, "xxx", 1) == nullptr); 31 | } 32 | -------------------------------------------------------------------------------- /src/utils/test/nth_element_bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | set(MY_PROJ_NAME nth_element_bench) 19 | project(${MY_PROJ_NAME} C CXX) 20 | 21 | # Source files under CURRENT project directory will be automatically included. 22 | # You can manually set MY_PROJ_SRC to include source files under other directories. 23 | set(MY_PROJ_SRC "") 24 | 25 | # Search mode for source files under CURRENT project directory? 26 | # "GLOB_RECURSE" for recursive search 27 | # "GLOB" for non-recursive search 28 | set(MY_SRC_SEARCH_MODE "GLOB") 29 | 30 | set(MY_PROJ_LIBS dsn_runtime dsn_utils) 31 | 32 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 33 | 34 | # Extra files that will be installed 35 | set(MY_BINPLACES "") 36 | 37 | dsn_add_executable() 38 | 39 | dsn_install_executable() 40 | -------------------------------------------------------------------------------- /src/utils/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | if [ -z "${REPORT_DIR}" ]; then 28 | REPORT_DIR="." 29 | fi 30 | 31 | ./clear.sh 32 | output_xml="${REPORT_DIR}/dsn_utils_tests.xml" 33 | GTEST_OUTPUT="xml:${output_xml}" ./dsn_utils_tests 34 | -------------------------------------------------------------------------------- /src/utils/time_utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #if FMT_VERSION < 60000 23 | #include // time.h was removed from fmtlib >=6.x 24 | #endif 25 | #include 26 | 27 | namespace dsn { 28 | namespace utils { 29 | 30 | /*extern*/ void time_ms_to_string(uint64_t ts_ms, char *str) 31 | { 32 | struct tm tmp; 33 | auto ret = get_localtime(ts_ms, &tmp); 34 | fmt::format_to(str, "{:%Y-%m-%d %H:%M:%S}.{}", *ret, static_cast(ts_ms % 1000)); 35 | } 36 | 37 | /*extern*/ void time_ms_to_string(uint64_t ts_ms, std::string &str) 38 | { 39 | str.clear(); 40 | struct tm tmp; 41 | auto ret = get_localtime(ts_ms, &tmp); 42 | fmt::format_to(std::back_inserter(str), 43 | "{:%Y-%m-%d %H:%M:%S}.{}", 44 | *ret, 45 | static_cast(ts_ms % 1000)); 46 | } 47 | 48 | } // namespace utils 49 | } // namespace dsn 50 | -------------------------------------------------------------------------------- /src/utils/token_buckets.cpp: -------------------------------------------------------------------------------- 1 | // Licensed to the Apache Software Foundation (ASF) under one 2 | // or more contributor license agreements. See the NOTICE file 3 | // distributed with this work for additional information 4 | // regarding copyright ownership. The ASF licenses this file 5 | // to you under the Apache License, Version 2.0 (the 6 | // "License"); you may not use this file except in compliance 7 | // with the License. You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | #include "dsn/utils/token_buckets.h" 19 | 20 | namespace dsn { 21 | namespace utils { 22 | 23 | std::shared_ptr token_buckets::get_token_bucket(const std::string &name) 24 | { 25 | { 26 | utils::auto_read_lock l(_buckets_lock); 27 | auto iter = _token_buckets.find(name); 28 | if (iter != _token_buckets.end()) { 29 | return iter->second; 30 | } 31 | } 32 | 33 | utils::auto_write_lock l(_buckets_lock); 34 | auto iter = _token_buckets.find(name); 35 | if (iter != _token_buckets.end()) { 36 | return iter->second; 37 | } 38 | 39 | auto token = std::make_shared(); 40 | _token_buckets.emplace(name, token); 41 | return token; 42 | } 43 | } // namespace utils 44 | } // namespace dsn 45 | -------------------------------------------------------------------------------- /src/zookeeper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.replication.zookeeper_provider) 2 | 3 | 4 | # Source files under CURRENT project directory will be automatically included. 5 | # You can manually set MY_PROJ_SRC to include source files under other directories. 6 | set(MY_PROJ_SRC "") 7 | 8 | # Search mode for source files under CURRENT project directory? 9 | # "GLOB_RECURSE" for recursive search 10 | # "GLOB" for non-recursive search 11 | set(MY_SRC_SEARCH_MODE "GLOB") 12 | 13 | set(MY_PROJ_LIBS zookeeper hashtable ssl crypto) 14 | 15 | # Extra files that will be installed 16 | set(MY_BINPLACES "") 17 | 18 | dsn_add_static_library() 19 | 20 | add_definitions(-DHAVE_CYRUS_SASL_H) 21 | 22 | add_subdirectory(test) 23 | -------------------------------------------------------------------------------- /src/zookeeper/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(MY_PROJ_NAME dsn.zookeeper.tests) 2 | 3 | # Source files under CURRENT project directory will be automatically included. 4 | # You can manually set MY_PROJ_SRC to include source files under other directories. 5 | set(MY_PROJ_SRC "") 6 | 7 | # Search mode for source files under CURRENT project directory? 8 | # "GLOB_RECURSE" for recursive search 9 | # "GLOB" for non-recursive search 10 | set(MY_SRC_SEARCH_MODE "GLOB") 11 | 12 | set(MY_PROJ_LIBS 13 | dsn.replication.zookeeper_provider 14 | dsn_runtime 15 | zookeeper 16 | hashtable 17 | gtest 18 | ssl 19 | crypto 20 | ) 21 | 22 | set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) 23 | 24 | # Extra files that will be installed 25 | set(MY_BINPLACES 26 | "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" 27 | "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh" 28 | "${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini" 29 | ) 30 | 31 | dsn_add_test() 32 | -------------------------------------------------------------------------------- /src/zookeeper/test/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2015 Microsoft Corporation 5 | # 6 | # -=- Robust Distributed System Nucleus (rDSN) -=- 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | 27 | rm -rf core* log.* *.log data 28 | -------------------------------------------------------------------------------- /src/zookeeper/zookeeper_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Microsoft Corporation 5 | * 6 | * -=- Robust Distributed System Nucleus (rDSN) -=- 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | * Description: 29 | * transform zookeeper error code to dsn error code, header 30 | * 31 | * Revision history: 32 | * 2015-12-04, @shengofsun (sunweijie@xiaomi.com) 33 | */ 34 | #pragma once 35 | 36 | #include 37 | 38 | namespace dsn { 39 | namespace dist { 40 | 41 | error_code from_zerror(int zerr); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /thirdparty/fix_fds_for_macos.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index d2d5f09..6de3158 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -11,6 +11,9 @@ add_library(galaxy-fds-sdk-cpp ${DIR_SRCS}) 6 | target_include_directories(galaxy-fds-sdk-cpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) 7 | 8 | include_directories(${POCO_INCLUDE}) 9 | +if (APPLE) 10 | + include_directories(${MACOS_OPENSSL_INCLUDE_DIR}) 11 | +endif() 12 | link_directories(${POCO_LIB}) 13 | 14 | option(WITH_TEST "enable building test" OFF) 15 | -------------------------------------------------------------------------------- /thirdparty/fix_s2_for_aarch64.patch: -------------------------------------------------------------------------------- 1 | --- CMakeLists.txt 2022-04-24 06:33:29.829438987 +0000 2 | +++ CMakeLists.aarch64.txt 2022-04-24 06:34:09.079226044 +0000 3 | @@ -355,6 +355,7 @@ install(FILES src/s2/third_party/absl/ba 4 | src/s2/third_party/absl/base/port.h 5 | src/s2/third_party/absl/base/thread_annotations.h 6 | DESTINATION include/s2/third_party/absl/base) 7 | +execute_process(COMMAND sed -i "/attributes\.h/a\#include \"s2\/base\/integral_types\.h\"" ${PROJECT_SOURCE_DIR}/src/s2/third_party/absl/base/internal/unaligned_access.h) 8 | install(FILES src/s2/third_party/absl/base/internal/identity.h 9 | src/s2/third_party/absl/base/internal/inline_variable.h 10 | src/s2/third_party/absl/base/internal/invoke.h 11 | --------------------------------------------------------------------------------