Skip to content

Commit

Permalink
config: add configuration duplication_disabled (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored and qinzuoyan committed Mar 11, 2019
1 parent b464267 commit a493678
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
31 changes: 19 additions & 12 deletions src/dist/replication/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@
* THE SOFTWARE.
*/

/*
* Description:
* What is this file about?
*
* Revision history:
* xxxx-xx-xx, author, first version
* xxxx-xx-xx, author, fix bug about xxx
*/

#include "replication_common.h"
#include <dsn/utility/filesystem.h>
#include <fstream>

namespace dsn {
namespace replication {

/*extern*/ const char *partition_status_to_string(partition_status::type status)
{
auto it = _partition_status_VALUES_TO_NAMES.find(status);
dassert(it != _partition_status_VALUES_TO_NAMES.end(),
"unexpected type of partition_status: %d",
status);
return it->second;
}

replication_options::replication_options()
{
deny_client_on_start = false;
Expand All @@ -48,6 +48,7 @@ replication_options::replication_options()
delay_for_fd_timeout_on_start = false;
empty_write_disabled = false;
allow_non_idempotent_write = false;
duplication_disabled = false;

prepare_timeout_ms_for_secondaries = 1000;
prepare_timeout_ms_for_potential_secondaries = 3000;
Expand Down Expand Up @@ -265,6 +266,12 @@ void replication_options::initialize()
allow_non_idempotent_write,
"whether to allow non-idempotent write, default is false");

duplication_disabled = dsn_config_get_value_bool(
"replication", "duplication_disabled", false, "is duplication disabled");
if (allow_non_idempotent_write && !duplication_disabled) {
dfatal("duplication and idempotent write cannot be enabled together");
}

prepare_timeout_ms_for_secondaries = (int)dsn_config_get_value_uint64(
"replication",
"prepare_timeout_ms_for_secondaries",
Expand Down Expand Up @@ -691,6 +698,6 @@ std::string get_remote_chkpt_meta_file(const std::string &root,
return ss.str();
}

} // end cold_backup namespace
}
} // end namespace
} // namespace cold_backup
} // namespace replication
} // namespace dsn
18 changes: 6 additions & 12 deletions src/dist/replication/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
* THE SOFTWARE.
*/

/*
* Description:
* What is this file about?
*
* Revision history:
* xxxx-xx-xx, author, first version
* xxxx-xx-xx, author, fix bug about xxx
*/

#pragma once

#include <dsn/dist/replication.h>
Expand Down Expand Up @@ -61,6 +52,7 @@ class replication_options
bool delay_for_fd_timeout_on_start;
bool empty_write_disabled;
bool allow_non_idempotent_write;
bool duplication_disabled;

int32_t prepare_timeout_ms_for_secondaries;
int32_t prepare_timeout_ms_for_potential_secondaries;
Expand Down Expand Up @@ -127,6 +119,8 @@ class replication_options
void sanity_check();
};

extern const char *partition_status_to_string(partition_status::type status);

class cold_backup_constant
{
public:
Expand Down Expand Up @@ -310,6 +304,6 @@ std::string get_remote_chkpt_meta_file(const std::string &root,
const std::string &app_name,
gpid pid,
int64_t backup_id);
} // end cold_backup namespace
}
} // namespace
} // namespace cold_backup
} // namespace replication
} // namespace dsn

0 comments on commit a493678

Please sign in to comment.