Skip to content

Commit

Permalink
Merge pull request #128 from sduzh/master
Browse files Browse the repository at this point in the history
Fix code style
  • Loading branch information
PFZheng committed Apr 25, 2019
2 parents 20ae73b + 681367a commit 8348a50
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
9 changes: 4 additions & 5 deletions src/braft/node.cpp
Expand Up @@ -2237,12 +2237,11 @@ void NodeImpl::after_shutdown() {
}
}

void NodeImpl::handle_install_snapshot_request(brpc::Controller* controller,
void NodeImpl::handle_install_snapshot_request(brpc::Controller* cntl,
const InstallSnapshotRequest* request,
InstallSnapshotResponse* response,
google::protobuf::Closure* done) {
brpc::ClosureGuard done_guard(done);
brpc::Controller* cntl = (brpc::Controller*)controller;

if (_snapshot_executor == NULL) {
cntl->SetFailed(EINVAL, "Not support snapshot");
Expand Down Expand Up @@ -2271,7 +2270,7 @@ void NodeImpl::handle_install_snapshot_request(brpc::Controller* controller,
// check stale term
if (request->term() < _current_term) {
LOG(WARNING) << "node " << _group_id << ":" << _server_id
<< " ignore stale AppendEntries from " << request->server_id()
<< " ignore stale InstallSnapshot from " << request->server_id()
<< " in term " << request->term()
<< " current_term " << _current_term;
response->set_term(_current_term);
Expand Down Expand Up @@ -2324,11 +2323,11 @@ butil::Status NodeImpl::read_committed_user_log(const int64_t index, UserLog* us
}
int64_t cur_index = index;
LogEntry* entry = _log_manager->get_entry(cur_index);
if (entry == NULL){
if (entry == NULL) {
return butil::Status(ELOGDELETED, "user log is deleted at index:%" PRId64, index);
}
do {
if (entry->type == ENTRY_TYPE_DATA){
if (entry->type == ENTRY_TYPE_DATA) {
user_log->set_log_index(cur_index);
user_log->set_log_data(entry->data);
entry->Release();
Expand Down
9 changes: 5 additions & 4 deletions src/braft/replicator.cpp
Expand Up @@ -326,9 +326,10 @@ void Replicator::_on_heartbeat_returned(
node_impl->Release();
return;
}

bool readonly = response->has_readonly() && response->readonly();
BRAFT_VLOG << ss.str() << " readonly " << readonly;
if (rpc_send_time > r->_last_rpc_send_timestamp){
if (rpc_send_time > r->_last_rpc_send_timestamp) {
r->_last_rpc_send_timestamp = rpc_send_time;
}
r->_start_heartbeat_timer(start_time_us);
Expand Down Expand Up @@ -775,10 +776,10 @@ void Replicator::_install_snapshot() {
_st.st = INSTALLING_SNAPSHOT;

_reader = _options.snapshot_storage->open();
if (!_reader){
if (!_reader) {
if (_options.snapshot_throttle) {
_options.snapshot_throttle->finish_one_task(true);
}
}
NodeImpl *node_impl = _options.node;
node_impl->AddRef();
CHECK_EQ(0, bthread_id_unlock(_id)) << "Fail to unlock " << _id;
Expand All @@ -802,7 +803,7 @@ void Replicator::_install_snapshot() {
}
SnapshotMeta meta;
// report error on failure
if (_reader->load_meta(&meta) != 0){
if (_reader->load_meta(&meta) != 0) {
std::string snapshot_path = _reader->get_path();
NodeImpl *node_impl = _options.node;
node_impl->AddRef();
Expand Down
8 changes: 4 additions & 4 deletions src/braft/snapshot_executor.cpp
Expand Up @@ -393,7 +393,7 @@ void SnapshotExecutor::install_snapshot(brpc::Controller* cntl,
SnapshotMeta meta = request->meta();

// check if install_snapshot tasks num exceeds threshold
if (_snapshot_throttle && !_snapshot_throttle->add_one_more_task(false)){
if (_snapshot_throttle && !_snapshot_throttle->add_one_more_task(false)) {
LOG(WARNING) << "Fail to install snapshot";
cntl->SetFailed(EBUSY, "Fail to add install_snapshot tasks now");
return;
Expand Down Expand Up @@ -425,7 +425,7 @@ void SnapshotExecutor::install_snapshot(brpc::Controller* cntl,
done_guard.release();
CHECK(_cur_copier);
_cur_copier->join();
// when coping finished or canceled, more install_snapshot tasks are allowed
// when copying finished or canceled, more install_snapshot tasks are allowed
if (_snapshot_throttle) {
_snapshot_throttle->finish_one_task(false);
}
Expand Down Expand Up @@ -549,12 +549,12 @@ int SnapshotExecutor::register_downloading_snapshot(DownloadingSnapshot* ds) {
rc = 1;
} else if (m->request->meta().last_included_index()
> ds->request->meta().last_included_index()) {
// |is| is older
// |ds| is older
LOG(WARNING) << "Register failed: is installing a newer one.";
ds->cntl->SetFailed(EINVAL, "A newer snapshot is under installing");
return -1;
} else {
// |is| is newer
// |ds| is newer
if (_loading_snapshot) {
// We can't interrupt the loading one
LOG(WARNING) << "Register failed: is loading an older snapshot.";
Expand Down
4 changes: 2 additions & 2 deletions test/memory_file_system_adaptor.h
Expand Up @@ -276,7 +276,7 @@ class MemoryFileSystemAdaptor : public braft::FileSystemAdaptor {
continue;
} else if (sub_path.BaseName().value() == "..") {
++ignore;
} else if (ignore > 0){
} else if (ignore > 0) {
--ignore;
} else {
subpaths.push_back(sub_path.BaseName());
Expand Down Expand Up @@ -358,7 +358,7 @@ class MemoryFileSystemAdaptor : public braft::FileSystemAdaptor {
continue;
} else if (sub_path.BaseName().value() == "..") {
++ignore;
} else if (ignore > 0){
} else if (ignore > 0) {
--ignore;
} else {
subpaths.push_back(sub_path.BaseName());
Expand Down

0 comments on commit 8348a50

Please sign in to comment.