Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply clang format #62

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/lib/homeobject_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class HomeObjectImpl : public HomeObject,
virtual BlobManager::NullResult _del_blob(ShardInfo const&, blob_id) = 0;
///
folly::Future< ShardManager::Result< Shard > > _get_shard(shard_id id) const;
auto _defer() const { return folly::makeSemiFuture().via(folly::getGlobalCPUExecutor());}
auto _defer() const { return folly::makeSemiFuture().via(folly::getGlobalCPUExecutor()); }

protected:
std::mutex _repl_lock;
std::shared_ptr< home_replication::ReplicationService > _repl_svc;
//std::shared_ptr<homestore::ReplicationService> _repl_svc;
// std::shared_ptr<homestore::ReplicationService> _repl_svc;
peer_id _our_id;

/// Our SvcId retrieval and SvcId->IP mapping
Expand All @@ -67,6 +67,7 @@ class HomeObjectImpl : public HomeObject,
std::map< shard_id, ShardIterator > _shard_map;
///
PGManager::Result< PG > _get_pg(pg_id pg);

public:
explicit HomeObjectImpl(std::weak_ptr< HomeObjectApplication >&& application) :
_application(std::move(application)) {}
Expand All @@ -80,7 +81,7 @@ class HomeObjectImpl : public HomeObject,
// This is public but not exposed in the API above
void init_repl_svc();

std::shared_ptr< home_replication::ReplicationService > get_repl_svc() { return _repl_svc;}
std::shared_ptr< home_replication::ReplicationService > get_repl_svc() { return _repl_svc; }

std::shared_ptr< BlobManager > blob_manager() final;
std::shared_ptr< PGManager > pg_manager() final;
Expand Down
25 changes: 12 additions & 13 deletions src/lib/homestore/homeobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ void HSHomeObject::init_homestore() {

bool need_format = HomeStore::instance()->start(
hs_input_params{.devices = device_info, .app_mem_size = app_mem_size, .services = services},
[this]() {
register_homestore_metablk_callback();
});
[this]() { register_homestore_metablk_callback(); });

/// TODO how should this work?
LOGWARN("Persistence Looks Vacant, Formatting!!");
Expand All @@ -62,14 +60,14 @@ void HSHomeObject::init_homestore() {
}

void HSHomeObject::register_homestore_metablk_callback() {
//register some callbacks for metadata recovery;
// register some callbacks for metadata recovery;
using namespace homestore;
HomeStore::instance()->meta_service().register_handler(HSHomeObject::s_shard_info_sub_type,
[this](homestore::meta_blk* mblk, sisl::byte_view buf, size_t size) {
on_shard_meta_blk_found(mblk, buf, size);
},
nullptr,
true);
HomeStore::instance()->meta_service().register_handler(
HSHomeObject::s_shard_info_sub_type,
[this](homestore::meta_blk* mblk, sisl::byte_view buf, size_t size) {
on_shard_meta_blk_found(mblk, buf, size);
},
nullptr, true);
}

void HomeObjectImpl::init_repl_svc() {
Expand All @@ -91,13 +89,14 @@ HSHomeObject::~HSHomeObject() {

void HSHomeObject::on_shard_meta_blk_found(homestore::meta_blk* mblk, sisl::byte_view buf, size_t size) {
std::string shard_info_str;
shard_info_str.append(r_cast<const char*>(buf.bytes()), size);
shard_info_str.append(r_cast< const char* >(buf.bytes()), size);

auto shard = deserialize_shard(shard_info_str);
shard.metablk_cookie = mblk;

//As shard info in the homestore metablk is always the latest state(OPEN or SEALED),
//we can always create a shard from this shard info and once shard is deleted, the associated metablk will be deleted too.
// As shard info in the homestore metablk is always the latest state(OPEN or SEALED),
// we can always create a shard from this shard info and once shard is deleted, the associated metablk will be
// deleted too.
do_commit_new_shard(shard);
}

Expand Down
16 changes: 7 additions & 9 deletions src/lib/homestore/homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HSHomeObject : public HomeObjectImpl {
///
mutable std::shared_mutex _flying_shard_lock;
std::map< int64_t, Shard > _flying_shards;

private:
shard_id generate_new_shard_id(pg_id pg);
shard_id make_new_shard_id(pg_id pg, uint64_t sequence_num) const;
Expand All @@ -34,24 +35,21 @@ class HSHomeObject : public HomeObjectImpl {
void do_commit_seal_shard(const Shard& shard);
void register_homestore_metablk_callback();
void* get_shard_metablk(shard_id id);

public:
using HomeObjectImpl::HomeObjectImpl;
~HSHomeObject();

void init_homestore();

static const std::string s_shard_info_sub_type;
static const std::string s_shard_info_sub_type;
void on_shard_meta_blk_found(homestore::meta_blk* mblk, sisl::byte_view buf, size_t size);

bool precheck_and_decode_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key,
std::string* msg);
bool precheck_and_decode_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key, std::string* msg);

void on_pre_commit_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key,
void* user_ctx);
void on_rollback_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key,
void* user_ctx);
void on_shard_message_commit(int64_t lsn, sisl::blob const& header, sisl::blob const& key,
void* user_ctx);
void on_pre_commit_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key, void* user_ctx);
void on_rollback_shard_msg(int64_t lsn, sisl::blob const& header, sisl::blob const& key, void* user_ctx);
void on_shard_message_commit(int64_t lsn, sisl::blob const& header, sisl::blob const& key, void* user_ctx);
};

} // namespace homeobject
4 changes: 2 additions & 2 deletions src/lib/homestore/replication_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ struct ReplicationMessageHeader {
uint8_t reserved_pad[6]{};
uint32_t header_crc;
uint32_t calculate_crc() const {
return crc32_ieee(init_crc32, r_cast<const unsigned char*>(this), sizeof(*this) - sizeof(header_crc));
return crc32_ieee(init_crc32, r_cast< const unsigned char* >(this), sizeof(*this) - sizeof(header_crc));
}
};

#pragma pack()

}
} // namespace homeobject
14 changes: 7 additions & 7 deletions src/lib/homestore/replication_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace homeobject {
void ReplicationStateMachine::on_commit(int64_t lsn, const sisl::blob& header, const sisl::blob& key,
const home_replication::pba_list_t& pbas, void* ctx) {
LOGINFO("applying raft log commit with lsn:{}", lsn);
const ReplicationMessageHeader* msg_header = r_cast<const ReplicationMessageHeader*>(header.bytes);
const ReplicationMessageHeader* msg_header = r_cast< const ReplicationMessageHeader* >(header.bytes);

switch (msg_header->message_type) {
case ReplicationMessageType::SHARD_MESSAGE: {
_home_object->on_shard_message_commit(lsn, header, key,ctx);
_home_object->on_shard_message_commit(lsn, header, key, ctx);
break;
}
case ReplicationMessageType::PG_MESSAGE:
Expand All @@ -23,11 +23,11 @@ void ReplicationStateMachine::on_commit(int64_t lsn, const sisl::blob& header, c

void ReplicationStateMachine::on_pre_commit(int64_t lsn, sisl::blob const& header, sisl::blob const& key, void* ctx) {
LOGINFO("on_pre_commit with lsn:{}", lsn);
const ReplicationMessageHeader* msg_header = r_cast<const ReplicationMessageHeader*>(header.bytes);
const ReplicationMessageHeader* msg_header = r_cast< const ReplicationMessageHeader* >(header.bytes);

switch (msg_header->message_type) {
case ReplicationMessageType::SHARD_MESSAGE: {
_home_object->on_pre_commit_shard_msg(lsn, header, key,ctx);
_home_object->on_pre_commit_shard_msg(lsn, header, key, ctx);
break;
}
case ReplicationMessageType::PG_MESSAGE:
Expand All @@ -40,11 +40,11 @@ void ReplicationStateMachine::on_pre_commit(int64_t lsn, sisl::blob const& heade

void ReplicationStateMachine::on_rollback(int64_t lsn, sisl::blob const& header, sisl::blob const& key, void* ctx) {
LOGINFO("rollback with lsn:{}", lsn);
const ReplicationMessageHeader* msg_header = r_cast<const ReplicationMessageHeader*>(header.bytes);
const ReplicationMessageHeader* msg_header = r_cast< const ReplicationMessageHeader* >(header.bytes);

switch (msg_header->message_type) {
case ReplicationMessageType::SHARD_MESSAGE: {
_home_object->on_rollback_shard_msg(lsn, header, key,ctx);
_home_object->on_rollback_shard_msg(lsn, header, key, ctx);
break;
}
case ReplicationMessageType::PG_MESSAGE:
Expand All @@ -57,4 +57,4 @@ void ReplicationStateMachine::on_rollback(int64_t lsn, sisl::blob const& header,

void ReplicationStateMachine::on_replica_stop() {}

}
} // namespace homeobject
4 changes: 2 additions & 2 deletions src/lib/homestore/replication_state_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HomeObjectImpl;
class ReplicationStateMachine : public home_replication::ReplicaSetListener {
public:
explicit ReplicationStateMachine(HSHomeObject* home_object) : _home_object(home_object) {}

~ReplicationStateMachine() = default;
/// @brief Called when the log entry has been committed in the replica set.
///
Expand Down Expand Up @@ -68,4 +68,4 @@ class ReplicationStateMachine : public home_replication::ReplicaSetListener {
HSHomeObject* _home_object;
};

}
} // namespace homeobject
Loading