-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into HeapChunkSelector
- Loading branch information
Showing
24 changed files
with
1,147 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "homeobject/common.hpp" | ||
|
||
#include <sisl/utility/enum.hpp> | ||
#include <isa-l/crc.h> | ||
|
||
namespace homeobject { | ||
|
||
ENUM(ReplicationMessageType, uint16_t, PG_MESSAGE = 0, SHARD_MESSAGE, BLOB_MESSAGE, UNKNOWN_MESSAGE); | ||
|
||
// magic num comes from the first 8 bytes of 'echo homeobject_replication | md5sum' | ||
static constexpr uint64_t HOMEOBJECT_REPLICATION_MAGIC = 0x11153ca24efc8d34; | ||
static constexpr uint32_t HOMEOBJECT_REPLICATION_PROTOCOL_VERSION_V1 = 0x01; | ||
static constexpr uint32_t init_crc32 = 0; | ||
|
||
#pragma pack(1) | ||
struct ReplicationMessageHeader { | ||
uint64_t magic_num{HOMEOBJECT_REPLICATION_MAGIC}; | ||
uint32_t protocol_version{HOMEOBJECT_REPLICATION_PROTOCOL_VERSION_V1}; | ||
ReplicationMessageType message_type; | ||
uint32_t payload_size; | ||
uint32_t payload_crc; | ||
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)); | ||
} | ||
}; | ||
|
||
#pragma pack() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "replication_message.hpp" | ||
#include "replication_state_machine.hpp" | ||
|
||
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); | ||
|
||
switch (msg_header->message_type) { | ||
case ReplicationMessageType::SHARD_MESSAGE: { | ||
_home_object->on_shard_message_commit(lsn, header, key,ctx); | ||
break; | ||
} | ||
case ReplicationMessageType::PG_MESSAGE: | ||
case ReplicationMessageType::BLOB_MESSAGE: | ||
default: { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
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); | ||
|
||
switch (msg_header->message_type) { | ||
case ReplicationMessageType::SHARD_MESSAGE: { | ||
_home_object->on_pre_commit_shard_msg(lsn, header, key,ctx); | ||
break; | ||
} | ||
case ReplicationMessageType::PG_MESSAGE: | ||
case ReplicationMessageType::BLOB_MESSAGE: | ||
default: { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
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); | ||
|
||
switch (msg_header->message_type) { | ||
case ReplicationMessageType::SHARD_MESSAGE: { | ||
_home_object->on_rollback_shard_msg(lsn, header, key,ctx); | ||
break; | ||
} | ||
case ReplicationMessageType::PG_MESSAGE: | ||
case ReplicationMessageType::BLOB_MESSAGE: | ||
default: { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void ReplicationStateMachine::on_replica_stop() {} | ||
|
||
} |
Oops, something went wrong.