本文整理汇总了C++中mutation_ptr::create_ts_ns方法的典型用法代码示例。如果您正苦于以下问题:C++ mutation_ptr::create_ts_ns方法的具体用法?C++ mutation_ptr::create_ts_ns怎么用?C++ mutation_ptr::create_ts_ns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutation_ptr
的用法示例。
在下文中一共展示了mutation_ptr::create_ts_ns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute_mutation
void replica::execute_mutation(mutation_ptr& mu)
{
dinfo("%s: execute mutation %s: request_count = %u",
name(),
mu->name(),
static_cast<int>(mu->client_requests.size())
);
error_code err = ERR_OK;
decree d = mu->data.header.decree;
switch (status())
{
case partition_status::PS_INACTIVE:
if (_app->last_committed_decree() + 1 == d)
{
err = _app->write_internal(mu);
}
else
{
ddebug(
"%s: mutation %s commit to %s skipped, app.last_committed_decree = %" PRId64,
name(), mu->name(),
enum_to_string(status()),
_app->last_committed_decree()
);
}
break;
case partition_status::PS_PRIMARY:
{
check_state_completeness();
dassert(_app->last_committed_decree() + 1 == d, "");
err = _app->write_internal(mu);
}
break;
case partition_status::PS_SECONDARY:
if (!_secondary_states.checkpoint_is_running)
{
check_state_completeness();
dassert (_app->last_committed_decree() + 1 == d, "");
err = _app->write_internal(mu);
}
else
{
ddebug(
"%s: mutation %s commit to %s skipped, app.last_committed_decree = %" PRId64,
name(), mu->name(),
enum_to_string(status()),
_app->last_committed_decree()
);
// make sure private log saves the state
// catch-up will be done later after checkpoint task is fininished
dassert(_private_log != nullptr, "");
}
break;
case partition_status::PS_POTENTIAL_SECONDARY:
if (_potential_secondary_states.learning_status == learner_status::LearningSucceeded ||
_potential_secondary_states.learning_status == learner_status::LearningWithPrepareTransient)
{
dassert(_app->last_committed_decree() + 1 == d, "");
err = _app->write_internal(mu);
}
else
{
// prepare also happens with learner_status::LearningWithPrepare, in this case
// make sure private log saves the state,
// catch-up will be done later after the checkpoint task is finished
ddebug(
"%s: mutation %s commit to %s skipped, app.last_committed_decree = %" PRId64,
name(), mu->name(),
enum_to_string(status()),
_app->last_committed_decree()
);
}
break;
case partition_status::PS_ERROR:
break;
}
ddebug("TwoPhaseCommit, %s: mutation %s committed, err = %s", name(), mu->name(), err.to_string());
_counter_commit_latency.set(dsn_now_ns() - mu->create_ts_ns());
if (err != ERR_OK)
{
handle_local_failure(err);
}
if (status() == partition_status::PS_PRIMARY)
{
mutation_ptr next = _primary_states.write_queue.check_possible_work(
static_cast<int>(_prepare_list->max_decree() - d)
);
if (next)
{
init_prepare(next);
//.........这里部分代码省略.........