-
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.
SDSTOR-11601 add create_shard implementation (#34)
shard is a logic concept in nuobject2.0 and provides better allocation management and sequential grouping of related bucket writes from same S3 gateway. shard creation is one of the supported functionality of shard manager, which will create a new shard instance with replication enabled. after that, S3 gateway can put/get/delete blobs to the shard.
- Loading branch information
1 parent
291b070
commit 1cbf09d
Showing
18 changed files
with
1,043 additions
and
103 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
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.