diff --git a/compile_thrift.py b/compile_thrift.py index a0a2756bbb..9b0c037edc 100755 --- a/compile_thrift.py +++ b/compile_thrift.py @@ -79,7 +79,7 @@ }, { "name": "simple_kv", - "path": "src/apps/skv" + "path": "src/dist/replication/storage_engine/simple_kv" }, { "name": "cli", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 194779059b..2db60e1920 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,5 +3,4 @@ if(UNIX) endif() add_subdirectory(core) add_subdirectory(dist) -add_subdirectory(apps) add_subdirectory(tests) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt deleted file mode 100644 index 5bf81603b0..0000000000 --- a/src/apps/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(skv) diff --git a/src/apps/skv/multi-meta.sh b/src/apps/skv/multi-meta.sh deleted file mode 100755 index 797c383d56..0000000000 --- a/src/apps/skv/multi-meta.sh +++ /dev/null @@ -1,166 +0,0 @@ -#!/bin/bash - -exe=dsn.replication.simple_kv -cfg=config-zk.ini -start_dir=run -meta_count=1 -replica_count=3 - -function run_app() -{ - cd $start_dir - local app_dir=$1$2 - if [ ! -d $app_dir ]; then - mkdir $app_dir - fi - - cd $app_dir - if [ ! -f $exe ]; then - cp ../$exe ../$cfg ./ - fi - ./$exe $cfg -app_list $1@$2 > output.log 2>&1 & - cd ../.. -} - -function kill_app() -{ - ps aux | grep $exe | grep $cfg | grep $1@$2 | awk '{print $2}' | xargs kill -9 -} - -function start_all_apps() -{ - for ((i=1; i<=$meta_count; ++i)); do - run_app meta $i - done - for ((i=1; i<=$replica_count; ++i)); do - run_app replica $i - done -} - -function stop_all_apps() -{ - ps aux | grep $exe | grep $cfg | awk '{print $2}' | xargs kill -9 -} - -function count_core_file() -{ - local target_dir=$start_dir/$1$2 - if [ -d $target_dir ]; then - echo `ls $target_dir | grep core | wc -l` - else - echo "0" - fi -} - -function core_file_detect() -{ - for ((i=1; i<=$meta_count; ++i)); do - if [ `count_core_file meta $i` -ne "0" ]; then - echo meta$i - return - fi - done - for ((i=1; i<=$replica_count; ++i)); do - if [ `count_core_file replica $i` -ne "0" ]; then - echo replica$i - return - fi - done - echo 0 -} - -function round_kill_meta() -{ - local i=0 - local meta_id - while [ `core_file_detect` == 0 ]; do - meta_id=$[ $i+1 ] - echo "kill meta $meta_id" - kill_app meta $meta_id - sleep 30 - echo "start meta $meta_id" - run_app meta $meta_id - i=$[ ($i+1)%$meta_count ] - sleep 60 - done - echo "core file detected, exit" -} - -function random_kill_replica() -{ - local random_replica_id - local core_result=0 - - while [ $core_result == 0 ]; do - sleep 30 - random_replica_id=$[ $RANDOM%$replica_count+1 ] - echo "kill replica $reandom_replica_id" - kill_app replica $random_replica_id - sleep 10 - echo "restart replica $random_replica_id" - run_app replica $random_replica_id - core_result=`core_file_detect` - done - - echo "core file detect in dir $core_result" - sleep 2 - stop_all_apps -} - -function poll_core() -{ - local core_result=0 - while [ $core_result == 0 ]; do - sleep 1 - core_result=`core_file_detect` - done - echo "core file detect in dir: $core_result" - sleep 2 - stop_all_apps -} - -if [ ! -d $start_dir ]; then - mkdir $start_dir -fi - -if [ ! -f $start_dir/$exe ]; then - cp $exe $cfg $start_dir -fi - -case $1 in - start) - start_all_apps ;; - stop) - stop_all_apps ;; - clear) - rm -rf run ;; - meta_test) - round_kill_meta ;; - replica_test) - random_kill_replica ;; - start_svc) - apps_count=$meta_count - if [ $2 == "replica" ]; then - apps_count=$replica_count - fi - - if [ $# -eq 2 ]; then - for ((index=1; index<=$apps_count; ++index)); do - run_app $2 $index - done - elif [ $# -eq 3 ]; then - run_app $2 $3 - fi - ;; - check_svc) - poll_core ;; - kill_svc) - if [ $# -eq 2 ]; then - ps aux | grep $exe | grep $cfg | grep $2 | awk '{print $2}' | xargs kill -9 - elif [ $# -eq 3 ]; then - kill_app $2 $3 - fi - ;; - list) - ps aux | grep $exe | grep $cfg -esac diff --git a/src/apps/skv/simple_kv.thrift.annotations b/src/apps/skv/simple_kv.thrift.annotations deleted file mode 100644 index e06a3c06bb..0000000000 --- a/src/apps/skv/simple_kv.thrift.annotations +++ /dev/null @@ -1,14 +0,0 @@ -; annotation format -;[type.name[[.subname]...]] -;key = vlaue - -[service.simple_kv] -stateful = true ; simple_kv is a stateful service - -[function.simple_kv.write] -write = true ; simple_kv.write is a write function - -[function.simple_kv.append] -write = true - - diff --git a/src/apps/skv/test-n.cmd b/src/apps/skv/test-n.cmd deleted file mode 100644 index dd5f57b4fd..0000000000 --- a/src/apps/skv/test-n.cmd +++ /dev/null @@ -1,8 +0,0 @@ -echo OFF -for /l %%x in (11, 1, 20) do ( - echo start test instance %%x - mkdir test-%%x - cd test-%%x - start ..\dsn.replication.simple_kv.exe ..\config-n.ini - cd .. -) diff --git a/src/apps/skv/test.cmd b/src/apps/skv/test.cmd deleted file mode 100644 index dece6b8163..0000000000 --- a/src/apps/skv/test.cmd +++ /dev/null @@ -1,15 +0,0 @@ -@echo OFF -mkdir test -copy /Y *.ini .\test -copy /Y *.exe .\test -copy /Y *.pdb .\test -copy /Y *.cmd .\test -copy /Y ..\..\Debug\*.dll .\test - -for /l %%x in (1, 1, 42) do ( - echo start test instance %%x - mkdir test-%%x - cd test-%%x - start "test-%%x" /LOW ../test/dsn.replication.simple_kv.exe ../test/config.ini - cd .. -) diff --git a/src/apps/skv/vconfig.ini b/src/apps/skv/vconfig.ini deleted file mode 100644 index 9c9cebd34c..0000000000 --- a/src/apps/skv/vconfig.ini +++ /dev/null @@ -1,165 +0,0 @@ -[apps..default] -run = true -count = 1 -;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 -;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 -;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536 -;network.server.0.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536 - -[apps.meta] -type = meta -arguments = -ports = %meta_port% -run = true -count = 1 -pools = THREAD_POOL_DEFAULT,THREAD_POOL_META_SERVER,THREAD_POOL_FD,THREAD_POOL_META_STATE - -[apps.replica] -type = replica -arguments = -ports = %replica_port% -run = true -count = 3 -pools = THREAD_POOL_DEFAULT,THREAD_POOL_REPLICATION_LONG,THREAD_POOL_REPLICATION,THREAD_POOL_FD,THREAD_POOL_LOCAL_APP - -[apps.client] -type = client -arguments = dsn://mycluster/simple_kv.instance0 -run = true -count = 1 -pools = THREAD_POOL_DEFAULT - -[apps.client.perf.test] -type = client.perf.test -arguments = dsn://mycluster/simple_kv.instance0 -run = true -count = 1 -pools = THREAD_POOL_DEFAULT - - -[core] - - -;tool = simulator -tool = nativerun -;toollets = tracer -;toollets = fault_injector -;toollets = tracer, fault_injector -toollets = tracer, profiler, fault_injector -;toollets = profiler, fault_injector -pause_on_start = false - -;logging_start_level = LOG_LEVEL_WARNING -;logging_factory_name = dsn::tools::screen_logger -;aio_factory_name = dsn::tools::empty_aio_provider - -[tools.simulator] -random_seed = 0 -;min_message_delay_microseconds = 0 -;max_message_delay_microseconds = 0 - -[network] -; how many network threads for network library(used by asio) -io_service_worker_count = 2 - -; specification for each thread pool - -[threadpool..default] -worker_count = 2 -worker_priority = THREAD_xPRIORITY_LOWEST - -[threadpool.THREAD_POOL_DEFAULT] -partitioned = false -worker_priority = THREAD_xPRIORITY_LOWEST - -[threadpool.THREAD_POOL_REPLICATION] -partitioned = true -worker_priority = THREAD_xPRIORITY_LOWEST - -[threadpool.THREAD_POOL_META_STATE] -worker_count = 1 - -[task..default] -is_trace = true -is_profile = true -allow_inline = false -rpc_call_channel = RPC_CHANNEL_TCP -rpc_message_header_format = dsn -rpc_timeout_milliseconds = 5000 - -disk_write_fail_ratio = 0.0 -disk_read_fail_ratio = 0.00001 - - -[task.LPC_CHECKPOINT_REPLICA] -execution_extra_delay_us_max = 10000000 - -[task.LPC_LEARN_REMOTE_DELTA_FILES] -execution_extra_delay_us_max = 10000000 - -[task.LPC_AIO_IMMEDIATE_CALLBACK] -is_trace = false -allow_inline = false -disk_write_fail_ratio = 0.0 - -[task.RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX] -is_trace = false - -[task.LPC_RPC_TIMEOUT] -is_trace = false - -[task.RPC_FD_FAILURE_DETECTOR_PING] -is_trace = false -rpc_call_channel = RPC_CHANNEL_UDP -rpc_message_crc_required = true - -[task.RPC_FD_FAILURE_DETECTOR_PING_ACK] -is_trace = false -rpc_call_channel = RPC_CHANNEL_UDP -rpc_message_crc_required = true - -[task.LPC_BEACON_CHECK] -is_trace = false - -[uri-resolver.dsn://mycluster] -factory = partition_resolver_simple -arguments = localhost:%meta_port% - -[meta_server] -server_list = localhost:%meta_port% - -[replication.app] -app_name = simple_kv.instance0 -app_type = simple_kv -partition_count = 1 -max_replica_count = 3 - -[replication] - -prepare_timeout_ms_for_secondaries = 10000 -log_enable_shared_prepare = true - -learn_timeout_ms = 30000 -staleness_for_commit = 20 -staleness_for_start_prepare_for_potential_secondary = 110 -mutation_max_size_mb = 15 -mutation_max_pending_time_ms = 20 -mutation_2pc_min_replica_count = 2 - -prepare_list_max_size_mb = 250 -request_batch_disabled = false -group_check_internal_ms = 100000 -group_check_disabled = false -fd_disabled = false -fd_check_interval_seconds = 5 -fd_beacon_interval_seconds = 3 -fd_lease_seconds = 14 -fd_grace_seconds = 15 -working_dir = . -log_buffer_size_mb = 1 -log_pending_max_ms = 100 -log_file_size_mb = 32 -log_batch_write = true - -config_sync_interval_ms = 60000 - diff --git a/src/apps/skv/vtest.cmd b/src/apps/skv/vtest.cmd deleted file mode 100644 index a7f5aeca47..0000000000 --- a/src/apps/skv/vtest.cmd +++ /dev/null @@ -1,29 +0,0 @@ -@echo OFF -mkdir test -copy /Y *.ini .\test -copy /Y *.exe .\test -copy /Y *.pdb .\test -copy /Y *.cmd .\test -copy /Y *.dll .\test - -set replica_port=34801 -set meta_port=34601 - -SETLOCAL ENABLEDELAYEDEXPANSION - -for /l %%x in (1, 1, 20) do call :test %%x -goto :eof - -:test - set x=%~n1 - echo start test instance %x% - @mkdir test-%x% - cd test-%x% - set /a replica_port=!replica_port!+3 - set /a meta_port=!meta_port!+3 - set lcmd=../test/dsn.replication.simple_kv.exe ../test/vconfig.ini -cargs meta_port=!meta_port!;replica_port=!replica_port! - echo %lcmd% - start "test-%x%" /LOW %lcmd% - cd .. - -:eof diff --git a/src/apps/skv/vtest.sh b/src/apps/skv/vtest.sh deleted file mode 100755 index 8f9a8b178d..0000000000 --- a/src/apps/skv/vtest.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -exe=dsn.replication.simple_kv -cfg=vconfig.ini -test_dir=test -test_count=5 - -function count_core_file() -{ - local target_dir=$test_dir/test-$1 - if [ -d $target_dir ]; then - echo `ls $target_dir | grep core | wc -l` - else - echo "0" - fi -} - -function core_file_detect() -{ - for ((i=1; i<=$test_count; ++i)); do - if [ `count_core_file $i` -ne "0" ]; then - echo $i - return - fi - done - echo 0 -} - -function run_test() -{ - mkdir $test_dir - replica_port=34801 - meta_port=34601 - - cd $test_dir - for ((i=1; i<=$test_count; ++i)); do - echo start test instance $i - mkdir test-$i - cp ../$exe ../$cfg test-$i - cd test-$i - replica_port=$[ $replica_port+3 ] - meta_port=$[ $meta_port+3 ] - command="./dsn.replication.simple_kv vconfig.ini -cargs meta_port=$meta_port,replica_port=$replica_port" - echo $command - ulimit -c unlimited - $command > output.log 2>&1 & - cd .. - done - cd .. -} - -function stop_all() -{ - ps aux | grep $exe | grep $cfg | awk '{print $2}' | xargs kill -9 -} - -function check_core() -{ - local check_result - while [ 0 -lt 1 ]; do - check_result=`core_file_detect` - if [ $check_result -ne "0" ]; then - echo "core file detect in $check_result" - fi - sleep 5 - done -} - -case $1 in - start) - run_test ;; - stop) - stop_all ;; - check) - check_core ;; -esac diff --git a/src/dist/replication/CMakeLists.txt b/src/dist/replication/CMakeLists.txt index 85c0e29a25..10ee12af9c 100644 --- a/src/dist/replication/CMakeLists.txt +++ b/src/dist/replication/CMakeLists.txt @@ -6,3 +6,4 @@ add_subdirectory(lib) add_subdirectory(global_checker) add_subdirectory(zookeeper) add_subdirectory(test) +add_subdirectory(storage_engine) diff --git a/src/dist/replication/storage_engine/CMakeLists.txt b/src/dist/replication/storage_engine/CMakeLists.txt new file mode 100644 index 0000000000..ddbac4f45d --- /dev/null +++ b/src/dist/replication/storage_engine/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(simple_kv) diff --git a/src/apps/skv/CMakeLists.txt b/src/dist/replication/storage_engine/simple_kv/CMakeLists.txt similarity index 95% rename from src/apps/skv/CMakeLists.txt rename to src/dist/replication/storage_engine/simple_kv/CMakeLists.txt index 802402d5ad..d25d454f9c 100644 --- a/src/apps/skv/CMakeLists.txt +++ b/src/dist/replication/storage_engine/simple_kv/CMakeLists.txt @@ -22,7 +22,6 @@ file(GLOB RES_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.ini" "${CMAKE_CURRENT_SOURCE_DIR}/*.sh" - "${CMAKE_CURRENT_SOURCE_DIR}/*.cmd" ) # Extra files that will be installed diff --git a/src/apps/skv/clear.sh b/src/dist/replication/storage_engine/simple_kv/clear.sh similarity index 100% rename from src/apps/skv/clear.sh rename to src/dist/replication/storage_engine/simple_kv/clear.sh diff --git a/src/apps/skv/config.ini b/src/dist/replication/storage_engine/simple_kv/config.ini similarity index 100% rename from src/apps/skv/config.ini rename to src/dist/replication/storage_engine/simple_kv/config.ini diff --git a/src/apps/skv/run.sh b/src/dist/replication/storage_engine/simple_kv/run.sh similarity index 100% rename from src/apps/skv/run.sh rename to src/dist/replication/storage_engine/simple_kv/run.sh diff --git a/src/apps/skv/simple_kv.app.example.h b/src/dist/replication/storage_engine/simple_kv/simple_kv.app.example.h similarity index 96% rename from src/apps/skv/simple_kv.app.example.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv.app.example.h index dfb0379c90..969521ebe0 100644 --- a/src/apps/skv/simple_kv.app.example.h +++ b/src/dist/replication/storage_engine/simple_kv/simple_kv.app.example.h @@ -34,7 +34,7 @@ */ #pragma once -#include "simple_kv.client.2.h" +#include "simple_kv.client.h" #include "simple_kv.server.h" #define TRANSPARENT_LAYER2_CLIENT @@ -57,7 +57,7 @@ class simple_kv_client_app : public ::dsn::service_app // argv[1]: e.g., dsn://mycluster/simple-kv.instance0 _server.assign_uri(args[1].c_str()); - _simple_kv_client.reset(new simple_kv_client2(_server)); + _simple_kv_client.reset(new simple_kv_client(_server)); _timer = ::dsn::tasking::enqueue_timer(LPC_SIMPLE_KV_TEST_TIMER, &_tracker, @@ -123,7 +123,7 @@ class simple_kv_client_app : public ::dsn::service_app private: ::dsn::task_ptr _timer; ::dsn::rpc_address _server; - std::unique_ptr _simple_kv_client; + std::unique_ptr _simple_kv_client; dsn::task_tracker _tracker; }; } diff --git a/src/apps/skv/simple_kv.client.2.h b/src/dist/replication/storage_engine/simple_kv/simple_kv.client.h similarity index 97% rename from src/apps/skv/simple_kv.client.2.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv.client.h index 2c90b9a95f..41e57ac14c 100644 --- a/src/apps/skv/simple_kv.client.2.h +++ b/src/dist/replication/storage_engine/simple_kv/simple_kv.client.h @@ -8,14 +8,14 @@ namespace dsn { namespace replication { namespace application { -class simple_kv_client2 +class simple_kv_client { public: - simple_kv_client2(::dsn::rpc_address server) { _server = server; } + simple_kv_client(::dsn::rpc_address server) { _server = server; } - simple_kv_client2() {} + simple_kv_client() {} - virtual ~simple_kv_client2() {} + virtual ~simple_kv_client() {} // ---------- call RPC_SIMPLE_KV_SIMPLE_KV_READ ------------ // - synchronous diff --git a/src/apps/skv/simple_kv.code.definition.h b/src/dist/replication/storage_engine/simple_kv/simple_kv.code.definition.h similarity index 100% rename from src/apps/skv/simple_kv.code.definition.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv.code.definition.h diff --git a/src/apps/skv/simple_kv.main.cpp b/src/dist/replication/storage_engine/simple_kv/simple_kv.main.cpp similarity index 100% rename from src/apps/skv/simple_kv.main.cpp rename to src/dist/replication/storage_engine/simple_kv/simple_kv.main.cpp diff --git a/src/apps/skv/simple_kv.server.h b/src/dist/replication/storage_engine/simple_kv/simple_kv.server.h similarity index 100% rename from src/apps/skv/simple_kv.server.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv.server.h diff --git a/src/apps/skv/simple_kv.server.impl.cpp b/src/dist/replication/storage_engine/simple_kv/simple_kv.server.impl.cpp similarity index 100% rename from src/apps/skv/simple_kv.server.impl.cpp rename to src/dist/replication/storage_engine/simple_kv/simple_kv.server.impl.cpp diff --git a/src/apps/skv/simple_kv.server.impl.h b/src/dist/replication/storage_engine/simple_kv/simple_kv.server.impl.h similarity index 100% rename from src/apps/skv/simple_kv.server.impl.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv.server.impl.h diff --git a/src/apps/skv/simple_kv.thrift b/src/dist/replication/storage_engine/simple_kv/simple_kv.thrift similarity index 100% rename from src/apps/skv/simple_kv.thrift rename to src/dist/replication/storage_engine/simple_kv/simple_kv.thrift diff --git a/src/apps/skv/simple_kv_types.cpp b/src/dist/replication/storage_engine/simple_kv/simple_kv_types.cpp similarity index 100% rename from src/apps/skv/simple_kv_types.cpp rename to src/dist/replication/storage_engine/simple_kv/simple_kv_types.cpp diff --git a/src/apps/skv/simple_kv_types.h b/src/dist/replication/storage_engine/simple_kv/simple_kv_types.h similarity index 100% rename from src/apps/skv/simple_kv_types.h rename to src/dist/replication/storage_engine/simple_kv/simple_kv_types.h