Skip to content

Commit

Permalink
submodule: use new random APIs of rdsn (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored and qinzuoyan committed Sep 26, 2018
1 parent fc90a0d commit 31aaa1a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion rdsn
Submodule rdsn updated 47 files
+1 −26 bin/dsn.cmake
+0 −15 compile_thrift.py
+0 −11 include/dsn/c/api_layer1.h
+28 −76 include/dsn/cpp/serialization.h
+0 −143 include/dsn/cpp/serialization_helper/protobuf_helper.h
+0 −5 include/dsn/tool-api/env_provider.h
+2 −6 include/dsn/tool-api/gpid.h
+5 −4 include/dsn/tool-api/group_address.h
+8 −8 include/dsn/tool-api/rpc_address.h
+1 −5 include/dsn/tool-api/task_code.h
+4 −5 include/dsn/utility/blob.h
+4 −6 include/dsn/utility/error_code.h
+53 −0 include/dsn/utility/rand.h
+0 −6 scripts/linux/build.sh
+0 −1 src/CMakeLists.txt
+0 −24 src/core/core/env_provider.cpp
+2 −1 src/core/core/fail_point.cpp
+2 −1 src/core/core/partition_resolver_simple.cpp
+21 −0 src/core/core/rand.cpp
+3 −2 src/core/core/rpc_engine.cpp
+0 −5 src/core/core/service_api_c.cpp
+2 −1 src/core/core/task.cpp
+3 −2 src/core/tests/env.cpp
+69 −0 src/core/tests/rand_test.cpp
+2 −1 src/core/tests/service_api_c.cpp
+2 −1 src/core/tests/utils.cpp
+4 −2 src/core/tools/common/asio_net_provider.cpp
+16 −15 src/core/tools/common/fault_injector.cpp
+2 −1 src/core/tools/common/network.sim.cpp
+8 −5 src/core/tools/simulator/env.sim.cpp
+3 −2 src/core/tools/simulator/scheduler.cpp
+4 −3 src/core/tools/simulator/task_engine.sim.cpp
+2 −1 src/dist/failure_detector_multimaster/failure_detector_multimaster.cpp
+2 −1 src/dist/replication/lib/replica.cpp
+4 −3 src/dist/replication/lib/replica_stub.cpp
+4 −2 src/dist/replication/test/meta_test/misc/misc.cpp
+5 −4 src/tests/dsn/fds_service_test.cpp
+0 −6 src/tests/dsn/mutation_log.cpp
+0 −6 src/tests/dsn/mutation_log_learn.cpp
+0 −1 src/tools/CMakeLists.txt
+0 −35 src/tools/repli/CMakeLists.txt
+0 −72 src/tools/repli/config.ini
+0 −162 src/tools/repli/repli.app.cpp
+0 −60 src/tools/repli/repli.app.h
+0 −87 src/tools/repli/repli.main.cpp
+0 −17 thirdparty/build-thirdparty.sh
+0 −6 thirdparty/download-thirdparty.sh
11 changes: 6 additions & 5 deletions src/redis_protocol/proxy_ut/redis_proxy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <boost/asio.hpp>

#include <dsn/utility/string_conv.h>
#include <dsn/utility/rand.h>

#include <gtest/gtest.h>
#include <rrdb/rrdb.client.h>
Expand Down Expand Up @@ -197,17 +198,17 @@ class redis_test_parser : public redis_parser
// create several requests
for (entry_index = 0; entry_index < total_requests; ++entry_index) {
redis_request &ra = reserved_entry[entry_index]->request;
ra.length = dsn_random32(1, 20);
ra.length = dsn::rand::next_u32(1, 20);
ra.buffers.resize(ra.length);
for (unsigned int i = 0; i != ra.length; ++i) {
redis_bulk_string &bs = ra.buffers[i];
bs.length = dsn_random32(0, 8);
bs.length = dsn::rand::next_u32(0, 8);
if (bs.length == 0) {
bs.length = -1;
} else if (bs.length == 1) {
bs.length = 0;
} else {
bs.length = dsn_random32(1, 256);
bs.length = dsn::rand::next_u32(1, 256);
std::shared_ptr<char> raw_buf(new char[bs.length],
std::default_delete<char[]>());
memset(raw_buf.get(), 't', bs.length);
Expand Down Expand Up @@ -256,11 +257,11 @@ class redis_test_parser : public redis_parser
// let's split the messages into different pieces
{
entry_index = 0;
size_t slice_count = dsn_random32(total_requests, total_body_size);
size_t slice_count = dsn::rand::next_u32(total_requests, total_body_size);
std::vector<int> start_pos;
start_pos.push_back(0);
for (unsigned int i = 0; i < slice_count - 1; ++i) {
start_pos.push_back(dsn_random32(0, total_body_size - 1));
start_pos.push_back(dsn::rand::next_u32(0, total_body_size - 1));
}
start_pos.push_back(total_body_size);
std::sort(start_pos.begin(), start_pos.end());
Expand Down
3 changes: 2 additions & 1 deletion src/server/pegasus_scan_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <map>
#include <rocksdb/db.h>
#include <dsn/tool_api.h>
#include <dsn/utility/rand.h>
#include <rrdb/rrdb_types.h>

#include "base/pegasus_const.h"
Expand Down Expand Up @@ -76,7 +77,7 @@ class pegasus_context_cache
//
// however, currently the implementation is not 100% correct.
//
_counter = dsn_random64(0, 2L << 31);
_counter = dsn::rand::next_u64(0, 2L << 31);
_counter <<= 32;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ bool pegasus_server_impl::set_usage_scenario(const std::string &usage_scenario)
// write_buffer_size = random_nearby(db_opts.write_buffer_size)
//
uint64_t buffer_size =
dsn_random64(_db_opts.write_buffer_size, _db_opts.write_buffer_size * 2);
dsn::rand::next_u64(_db_opts.write_buffer_size, _db_opts.write_buffer_size * 2);
new_options["write_buffer_size"] = boost::lexical_cast<std::string>(buffer_size);

//
Expand Down
2 changes: 1 addition & 1 deletion src/server/pegasus_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class pegasus_server_impl : public ::dsn::apps::rrdb_service
uint64_t get_random_nearby(uint64_t base_value)
{
uint64_t gap = base_value / 4;
return dsn_random64(base_value - gap, base_value + gap);
return dsn::rand::next_u64(base_value - gap, base_value + gap);
}

// return true if expired
Expand Down
4 changes: 2 additions & 2 deletions src/server/test/pegasus_server_write_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class pegasus_server_write_test : public pegasus_server_test_base
req.key = key;
req.value.assign("value", 0, 5);

int put_rpc_cnt = dsn_random32(1, 10);
int remove_rpc_cnt = dsn_random32(1, 10);
int put_rpc_cnt = dsn::rand::next_u32(1, 10);
int remove_rpc_cnt = dsn::rand::next_u32(1, 10);
int total_rpc_cnt = put_rpc_cnt + remove_rpc_cnt;
auto writes = new dsn::message_ex *[total_rpc_cnt];
for (int i = 0; i < put_rpc_cnt; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/function_test/test_recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <dsn/service_api_c.h>
#include <dsn/dist/replication/replication_ddl_client.h>
#include <dsn/utility/rand.h>

#include <pegasus/client.h>
#include <gtest/gtest.h>
Expand Down Expand Up @@ -298,7 +299,7 @@ TEST_F(recovery_test, recovery)
{
prepare_recovery();
for (int i = 0; i < default_partitions; ++i) {
int replica_id = dsn_random32(1, 3);
int replica_id = dsn::rand::next_u32(1, 3);
delete_replica(replica_id, 2, i);
}

Expand Down
9 changes: 3 additions & 6 deletions src/test/pressure_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <dsn/c/api_utilities.h>
#include <dsn/c/api_layer1.h>
#include <dsn/utility/utils.h>
#include <dsn/utility/rand.h>
#include <dsn/tool-api/async_calls.h>

#include "pegasus/client.h"
Expand All @@ -19,9 +19,6 @@ using namespace ::pegasus;

DEFINE_TASK_CODE(LPC_DEFAUT_TASK, TASK_PRIORITY_COMMON, dsn::THREAD_POOL_DEFAULT)

//[min, max], min and max is unsigned
// dsn_random64(min, max); or dsn_random32(min, max)

static int32_t hashkey_len;
static int32_t sortkey_len;
static int32_t value_len;
Expand All @@ -45,7 +42,7 @@ std::string fill_string(const std::string &str, int len)

std::string get_hashkey()
{
std::string key = to_string(dsn_random64(0, hashkey_limit));
std::string key = to_string(dsn::rand::next_u64(0, hashkey_limit));
if (key.size() >= hashkey_len) {
return key;
} else {
Expand All @@ -55,7 +52,7 @@ std::string get_hashkey()

std::string get_sortkey()
{
std::string key = to_string(dsn_random64(0, sortkey_limit));
std::string key = to_string(dsn::rand::next_u64(0, sortkey_limit));
if (key.size() >= sortkey_len) {
return key;
} else {
Expand Down

0 comments on commit 31aaa1a

Please sign in to comment.