diff --git a/include/dsn/cpp/message_utils.h b/include/dsn/cpp/message_utils.h index a80b042621..9e65352a8e 100644 --- a/include/dsn/cpp/message_utils.h +++ b/include/dsn/cpp/message_utils.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace dsn { diff --git a/include/dsn/cpp/serialization.h b/include/dsn/cpp/serialization.h index 807f026743..7aaa04322e 100644 --- a/include/dsn/cpp/serialization.h +++ b/include/dsn/cpp/serialization.h @@ -50,61 +50,36 @@ std::string no_registered_function_error_notice(const T &t, dsn_msg_serialize_fo } // namespace serialization -#define THRIFT_MARSHALLER \ - case DSF_THRIFT_BINARY: \ - marshall_thrift_binary(writer, value); \ - break; \ - case DSF_THRIFT_JSON: \ - marshall_thrift_json(writer, value); \ - break; - -#define THRIFT_UNMARSHALLER \ - case DSF_THRIFT_BINARY: \ - unmarshall_thrift_binary(reader, value); \ - break; \ - case DSF_THRIFT_JSON: \ - unmarshall_thrift_json(reader, value); \ - break; - -// the following 2 functions is for thrift basic type serialization -template -inline void marshall(binary_writer &writer, const T &value, dsn_msg_serialize_format fmt) +template +inline void marshall(binary_writer &writer, const ThriftType &value, dsn_msg_serialize_format fmt) { switch (fmt) { - THRIFT_MARSHALLER + case DSF_THRIFT_BINARY: + marshall_thrift_binary(writer, value); + break; + case DSF_THRIFT_JSON: + marshall_thrift_json(writer, value); + break; default: dassert(false, serialization::no_registered_function_error_notice(value, fmt).c_str()); } } -template -inline void unmarshall(binary_reader &reader, T &value, dsn_msg_serialize_format fmt) +template +inline void unmarshall(binary_reader &reader, ThriftType &value, dsn_msg_serialize_format fmt) { switch (fmt) { - THRIFT_UNMARSHALLER + case DSF_THRIFT_BINARY: + unmarshall_thrift_binary(reader, value); + break; + case DSF_THRIFT_JSON: + unmarshall_thrift_json(reader, value); + break; default: dassert(false, serialization::no_registered_function_error_notice(value, fmt).c_str()); } } -#define GENERATED_TYPE_SERIALIZATION(GType, SerializationType) \ - inline void marshall(binary_writer &writer, const GType &value, dsn_msg_serialize_format fmt) \ - { \ - switch (fmt) { \ - SerializationType##_MARSHALLER default \ - : dassert(false, \ - serialization::no_registered_function_error_notice(value, fmt).c_str()); \ - } \ - } \ - inline void unmarshall(binary_reader &reader, GType &value, dsn_msg_serialize_format fmt) \ - { \ - switch (fmt) { \ - SerializationType##_UNMARSHALLER default \ - : dassert(false, \ - serialization::no_registered_function_error_notice(value, fmt).c_str()); \ - } \ - } - template inline void marshall(dsn::message_ex *msg, const T &val) { diff --git a/include/dsn/cpp/serialization_helper/dsn.layer2.types.h b/include/dsn/cpp/serialization_helper/dsn.layer2.types.h deleted file mode 100644 index f8cfb7da72..0000000000 --- a/include/dsn/cpp/serialization_helper/dsn.layer2.types.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include -#include - - - - -namespace dsn { - GENERATED_TYPE_SERIALIZATION(partition_configuration, THRIFT) - GENERATED_TYPE_SERIALIZATION(configuration_query_by_index_request, THRIFT) - GENERATED_TYPE_SERIALIZATION(configuration_query_by_index_response, THRIFT) - GENERATED_TYPE_SERIALIZATION(app_info, THRIFT) - -} \ No newline at end of file diff --git a/include/dsn/dist/cli/cli.client.h b/include/dsn/dist/cli/cli.client.h index bfbb0cce70..73e2b58b39 100644 --- a/include/dsn/dist/cli/cli.client.h +++ b/include/dsn/dist/cli/cli.client.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include namespace dsn { diff --git a/include/dsn/dist/cli/cli.server.h b/include/dsn/dist/cli/cli.server.h index 5c026b5948..819265acfb 100644 --- a/include/dsn/dist/cli/cli.server.h +++ b/include/dsn/dist/cli/cli.server.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace dsn { class cli_service : public ::dsn::serverlet diff --git a/include/dsn/dist/cli/cli.types.h b/include/dsn/dist/cli/cli.types.h deleted file mode 100644 index 717880883f..0000000000 --- a/include/dsn/dist/cli/cli.types.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include -#include - - - - -namespace dsn { - GENERATED_TYPE_SERIALIZATION(command, THRIFT) - -} diff --git a/include/dsn/dist/failure_detector/fd.code.definition.h b/include/dsn/dist/failure_detector/fd.code.definition.h index 982a9ccca8..320d753196 100644 --- a/include/dsn/dist/failure_detector/fd.code.definition.h +++ b/include/dsn/dist/failure_detector/fd.code.definition.h @@ -34,7 +34,9 @@ */ #pragma once -#include + +#include +#include namespace dsn { namespace fd { diff --git a/include/dsn/dist/failure_detector/fd.types.h b/include/dsn/dist/failure_detector/fd.types.h deleted file mode 100644 index 75b8aec993..0000000000 --- a/include/dsn/dist/failure_detector/fd.types.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include -#include - - - - -namespace dsn { namespace fd { - GENERATED_TYPE_SERIALIZATION(beacon_msg, THRIFT) - GENERATED_TYPE_SERIALIZATION(beacon_ack, THRIFT) - GENERATED_TYPE_SERIALIZATION(config_master_message, THRIFT) - -} } \ No newline at end of file diff --git a/include/dsn/dist/replication.h b/include/dsn/dist/replication.h index a5bb932886..069a6bb532 100644 --- a/include/dsn/dist/replication.h +++ b/include/dsn/dist/replication.h @@ -36,6 +36,5 @@ #pragma once #include -#include #include #include diff --git a/include/dsn/dist/replication/duplication_common.h b/include/dsn/dist/replication/duplication_common.h index acebd8426b..d109b2c758 100644 --- a/include/dsn/dist/replication/duplication_common.h +++ b/include/dsn/dist/replication/duplication_common.h @@ -26,7 +26,6 @@ #pragma once -#include #include #include #include diff --git a/include/dsn/dist/replication/replication.types.h b/include/dsn/dist/replication/replication.types.h deleted file mode 100644 index a457b56572..0000000000 --- a/include/dsn/dist/replication/replication.types.h +++ /dev/null @@ -1,90 +0,0 @@ -#pragma once -#include -#include -#include - -namespace dsn { -namespace replication { -GENERATED_TYPE_SERIALIZATION(mutation_header, THRIFT) -GENERATED_TYPE_SERIALIZATION(mutation_update, THRIFT) -GENERATED_TYPE_SERIALIZATION(mutation_data, THRIFT) -GENERATED_TYPE_SERIALIZATION(replica_configuration, THRIFT) -GENERATED_TYPE_SERIALIZATION(prepare_msg, THRIFT) -GENERATED_TYPE_SERIALIZATION(read_request_header, THRIFT) -GENERATED_TYPE_SERIALIZATION(write_request_header, THRIFT) -GENERATED_TYPE_SERIALIZATION(rw_response_header, THRIFT) -GENERATED_TYPE_SERIALIZATION(prepare_ack, THRIFT) -GENERATED_TYPE_SERIALIZATION(learn_state, THRIFT) -GENERATED_TYPE_SERIALIZATION(learn_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(learn_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(learn_notify_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(group_check_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(group_check_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(node_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_update_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_update_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(replica_server_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_by_node_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_by_node_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(create_app_options, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_create_app_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(drop_app_options, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_drop_app_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_list_apps_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_list_nodes_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_cluster_info_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_recall_app_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_create_app_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_meta_control_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_meta_control_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_proposal_action, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_balancer_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_balancer_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_drop_app_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_list_apps_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_list_nodes_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_cluster_info_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_recall_app_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_replica_decree_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_replica_decree_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(replica_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_replica_info_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_replica_info_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_app_info_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(query_app_info_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_recovery_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_recovery_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(policy_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_restore_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(backup_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(backup_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_modify_backup_policy_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_modify_backup_policy_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_add_backup_policy_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_add_backup_policy_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(policy_entry, THRIFT) -GENERATED_TYPE_SERIALIZATION(backup_entry, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_backup_policy_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_backup_policy_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_report_restore_status_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_report_restore_status_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_restore_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_query_restore_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_update_app_env_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(configuration_update_app_env_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_add_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_add_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_status_change_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_status_change_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_entry, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_query_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_query_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_confirm_entry, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_sync_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(duplication_sync_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(ddd_diagnose_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(ddd_node_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(ddd_partition_info, THRIFT) -GENERATED_TYPE_SERIALIZATION(ddd_diagnose_response, THRIFT) -} -} diff --git a/include/dsn/dist/replication/replication_app_base.h b/include/dsn/dist/replication/replication_app_base.h index bfb92968b4..968a5856f7 100644 --- a/include/dsn/dist/replication/replication_app_base.h +++ b/include/dsn/dist/replication/replication_app_base.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/dsn/dist/replication/replication_other_types.h b/include/dsn/dist/replication/replication_other_types.h index 590ecd5501..efc9bfafcd 100644 --- a/include/dsn/dist/replication/replication_other_types.h +++ b/include/dsn/dist/replication/replication_other_types.h @@ -36,7 +36,7 @@ #define replication_OTHER_TYPES_H #include -#include +#include #include namespace dsn { diff --git a/include/dsn/service_api_cpp.h b/include/dsn/service_api_cpp.h index 3b075171f1..61229763e7 100644 --- a/include/dsn/service_api_cpp.h +++ b/include/dsn/service_api_cpp.h @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/src/apps/echo/echo.code.definition.h b/src/apps/echo/echo.code.definition.h index 33c70a14dc..ad3b4c35ed 100644 --- a/src/apps/echo/echo.code.definition.h +++ b/src/apps/echo/echo.code.definition.h @@ -34,7 +34,6 @@ */ #pragma once #include -#include "echo.types.h" namespace dsn { namespace example { diff --git a/src/apps/echo/echo.types.h b/src/apps/echo/echo.types.h deleted file mode 100644 index b81b391dee..0000000000 --- a/src/apps/echo/echo.types.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include -#include - - -#include "echo_types.h" - - -namespace dsn { namespace example { - -} } \ No newline at end of file diff --git a/src/apps/skv/simple_kv.client.2.h b/src/apps/skv/simple_kv.client.2.h index 88786c5156..2c90b9a95f 100644 --- a/src/apps/skv/simple_kv.client.2.h +++ b/src/apps/skv/simple_kv.client.2.h @@ -1,6 +1,6 @@ #pragma once #include "simple_kv.code.definition.h" -#include "simple_kv.types.h" +#include "simple_kv_types.h" #include #include #include diff --git a/src/apps/skv/simple_kv.server.h b/src/apps/skv/simple_kv.server.h index fcf2ee5927..40d328603d 100644 --- a/src/apps/skv/simple_kv.server.h +++ b/src/apps/skv/simple_kv.server.h @@ -40,7 +40,7 @@ #include #include "simple_kv.code.definition.h" -#include "simple_kv.types.h" +#include "simple_kv_types.h" namespace dsn { namespace replication { @@ -51,7 +51,7 @@ class simple_kv_service : public replication_app_base, public storage_serverlet< simple_kv_service(replica *r) : replication_app_base(r) {} virtual ~simple_kv_service() {} - virtual int on_request(dsn::message_ex* request) override { return handle_request(request); } + virtual int on_request(dsn::message_ex *request) override { return handle_request(request); } protected: // all service handlers to be implemented further // RPC_SIMPLE_KV_SIMPLE_KV_READ diff --git a/src/apps/skv/simple_kv.types.h b/src/apps/skv/simple_kv.types.h deleted file mode 100644 index ae148458e0..0000000000 --- a/src/apps/skv/simple_kv.types.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include - - -#include "simple_kv_types.h" - - -namespace dsn { namespace replication { namespace application { - GENERATED_TYPE_SERIALIZATION(kv_pair, THRIFT) - -} } } \ No newline at end of file diff --git a/src/core/core/common_providers.cpp b/src/core/core/common_providers.cpp index a15a556393..23e38f4cb7 100644 --- a/src/core/core/common_providers.cpp +++ b/src/core/core/common_providers.cpp @@ -35,8 +35,6 @@ #include "partition_resolver_simple.h" #include -#include - namespace dsn { namespace dist { static bool register_component_provider(const char *name, diff --git a/src/core/core/partition_resolver_simple.h b/src/core/core/partition_resolver_simple.h index d830f534fb..d03836e4eb 100644 --- a/src/core/core/partition_resolver_simple.h +++ b/src/core/core/partition_resolver_simple.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include namespace dsn { namespace dist { diff --git a/src/dist/nfs/nfs.types.h b/src/dist/nfs/nfs.types.h deleted file mode 100644 index 9c2a263e96..0000000000 --- a/src/dist/nfs/nfs.types.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include - -#include "nfs_types.h" - -namespace dsn { -namespace service { -GENERATED_TYPE_SERIALIZATION(copy_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(copy_response, THRIFT) -GENERATED_TYPE_SERIALIZATION(get_file_size_request, THRIFT) -GENERATED_TYPE_SERIALIZATION(get_file_size_response, THRIFT) -} -} \ No newline at end of file diff --git a/src/dist/nfs/nfs_client.h b/src/dist/nfs/nfs_client.h index 7f0f3737c5..7d59847c1e 100644 --- a/src/dist/nfs/nfs_client.h +++ b/src/dist/nfs/nfs_client.h @@ -29,7 +29,7 @@ #include #include -#include "nfs.types.h" +#include "nfs_types.h" #include "nfs_code_definition.h" namespace dsn { diff --git a/src/dist/nfs/nfs_client_impl.h b/src/dist/nfs/nfs_client_impl.h index 17eb2e2c72..d93eb8672a 100644 --- a/src/dist/nfs/nfs_client_impl.h +++ b/src/dist/nfs/nfs_client_impl.h @@ -39,7 +39,6 @@ #include #include -#include "nfs.types.h" #include "nfs_client.h" namespace dsn { diff --git a/src/dist/nfs/nfs_code_definition.h b/src/dist/nfs/nfs_code_definition.h index 5a6fecfa2a..6cd1c08814 100644 --- a/src/dist/nfs/nfs_code_definition.h +++ b/src/dist/nfs/nfs_code_definition.h @@ -33,7 +33,6 @@ * xxxx-xx-xx, author, fix bug about xxx */ #pragma once -#include "nfs.types.h" namespace dsn { namespace service { diff --git a/src/dist/nfs/nfs_server.h b/src/dist/nfs/nfs_server.h index 499acbcbc5..086e3e1c49 100644 --- a/src/dist/nfs/nfs_server.h +++ b/src/dist/nfs/nfs_server.h @@ -28,7 +28,7 @@ #include #include #include "nfs_code_definition.h" -#include "nfs.types.h" +#include "nfs_types.h" namespace dsn { namespace service { diff --git a/src/dist/replication/meta_server/meta_options.h b/src/dist/replication/meta_server/meta_options.h index e5b8edb7d9..aaaec9c6c5 100644 --- a/src/dist/replication/meta_server/meta_options.h +++ b/src/dist/replication/meta_server/meta_options.h @@ -36,7 +36,6 @@ #include #include -#include namespace dsn { namespace replication { diff --git a/src/dist/replication/test/meta_test/misc/misc.cpp b/src/dist/replication/test/meta_test/misc/misc.cpp index 3c2773d9ce..2c3917617b 100644 --- a/src/dist/replication/test/meta_test/misc/misc.cpp +++ b/src/dist/replication/test/meta_test/misc/misc.cpp @@ -1,8 +1,6 @@ #include #include #include - -#include #include #include "dist/replication/common/replication_common.h" diff --git a/src/dist/replication/test/meta_test/misc/misc.h b/src/dist/replication/test/meta_test/misc/misc.h index 4019072516..39f45f4277 100644 --- a/src/dist/replication/test/meta_test/misc/misc.h +++ b/src/dist/replication/test/meta_test/misc/misc.h @@ -4,7 +4,6 @@ #include #include #include -#include #include "dist/replication/meta_server/meta_data.h" #include "dist/replication/common/fs_manager.h" diff --git a/src/dist/replication/test/simple_kv/simple_kv.client.h b/src/dist/replication/test/simple_kv/simple_kv.client.h index 3b0c48e881..7a8c42119d 100644 --- a/src/dist/replication/test/simple_kv/simple_kv.client.h +++ b/src/dist/replication/test/simple_kv/simple_kv.client.h @@ -30,7 +30,7 @@ #include #include "simple_kv.code.definition.h" -#include "simple_kv.types.h" +#include "simple_kv_types.h" #include "case.h" namespace dsn { diff --git a/src/dist/replication/test/simple_kv/simple_kv.server.h b/src/dist/replication/test/simple_kv/simple_kv.server.h index efc27fdc4e..1f3251faa8 100644 --- a/src/dist/replication/test/simple_kv/simple_kv.server.h +++ b/src/dist/replication/test/simple_kv/simple_kv.server.h @@ -40,7 +40,7 @@ #include #include "simple_kv.code.definition.h" -#include "simple_kv.types.h" +#include "simple_kv_types.h" namespace dsn { namespace replication { @@ -51,7 +51,7 @@ class simple_kv_service : public replication_app_base, public storage_serverlet< simple_kv_service(replica *r) : replication_app_base(r) {} virtual ~simple_kv_service() {} - virtual int on_request(dsn::message_ex* request) override { return handle_request(request); } + virtual int on_request(dsn::message_ex *request) override { return handle_request(request); } protected: // all service handlers to be implemented further // RPC_SIMPLE_KV_SIMPLE_KV_READ