Skip to content

Commit

Permalink
Integration with hs replication service and renamed certain path for …
Browse files Browse the repository at this point in the history
…in-mem and homestore backends
  • Loading branch information
hkadayam committed Sep 28, 2023
1 parent b001c94 commit e3dd476
Show file tree
Hide file tree
Showing 37 changed files with 650 additions and 416 deletions.
2 changes: 1 addition & 1 deletion .jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pipeline {
CONAN_USER = 'oss'
TARGET_BRANCH = 'main'
STABLE_BRANCH = 'stable/v*'
DISABLE_DEP_TESTS = '-o sisl:testing=False -o iomgr:testing=off -o homestore:testing=off -o nuraft_mesg:testing=False'
DISABLE_DEP_TESTS = '-o sisl:testing=False -o iomgr:testing=off -o homestore:testing=off'
}

stages {
Expand Down
4 changes: 1 addition & 3 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeObjectConan(ConanFile):
name = "homeobject"
version = "0.10.2"
version = "0.10.3"
homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
topics = ("ebay")
Expand Down Expand Up @@ -42,8 +42,6 @@ def build_requirements(self):
def requirements(self):
self.requires("homestore/[~=4, include_prerelease=True]@oss/master")
self.requires("sisl/[~=10, include_prerelease=True]@oss/master")
# Remove when HomeStore Replication Service is mature
self.requires("nuraft_mesg/[~=1, include_prerelease=True]@oss/main")
self.requires("lz4/1.9.4", override=True)

def validate(self):
Expand Down
6 changes: 1 addition & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ cmake_minimum_required (VERSION 3.11)
find_package(Threads QUIET REQUIRED)
find_package(sisl QUIET REQUIRED)
find_package(homestore QUIET REQUIRED)
find_package(nuraft_mesg QUIET REQUIRED)

find_package(GTest QUIET REQUIRED)

link_directories(${spdk_LIB_DIRS} ${dpdk_LIB_DIRS})

set (COMMON_DEPS
homestore::homestore
nuraft_mesg::nuraft_mesg
sisl::sisl
)

set(COMMON_TEST_DEPS
home_replication_mock
${COMMON_DEPS}
GTest::gmock
${spdk_LIBRARY_LIST}
Expand All @@ -30,4 +26,4 @@ include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/lib)

add_subdirectory(lib)
add_subdirectory(mocks)
#add_subdirectory(mocks)
9 changes: 5 additions & 4 deletions src/include/homeobject/blob_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ struct Blob {
sisl::io_blob_safe body;
std::string user_key;
uint64_t object_off;
std::optional< peer_id > current_leader{std::nullopt};
std::optional< peer_id_t > current_leader{std::nullopt};
};

class BlobManager : public Manager< BlobError > {
public:
virtual AsyncResult< blob_id > put(shard_id shard, Blob&&) = 0;
virtual AsyncResult< Blob > get(shard_id shard, blob_id const& blob, uint64_t off = 0, uint64_t len = 0) const = 0;
virtual NullAsyncResult del(shard_id shard, blob_id const& blob) = 0;
virtual AsyncResult< blob_id_t > put(shard_id_t shard, Blob&&) = 0;
virtual AsyncResult< Blob > get(shard_id_t shard, blob_id_t const& blob, uint64_t off = 0,
uint64_t len = 0) const = 0;
virtual NullAsyncResult del(shard_id_t shard, blob_id_t const& blob) = 0;
};

} // namespace homeobject
25 changes: 20 additions & 5 deletions src/include/homeobject/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

SISL_LOGGING_DECL(homeobject);

#define HOMEOBJECT_LOG_MODS grpc_server, HOMESTORE_LOG_MODS, nuraft_mesg, nuraft, home_replication, homeobject
#define HOMEOBJECT_LOG_MODS grpc_server, HOMESTORE_LOG_MODS, homeobject

#ifndef Ki
constexpr uint64_t Ki = 1024ul;
Expand All @@ -25,11 +25,26 @@ constexpr uint64_t Gi = Ki * Mi;

namespace homeobject {

using blob_id = uint64_t;
using blob_id_t = uint64_t;

using peer_id = boost::uuids::uuid;
using pg_id = uint16_t;
using shard_id = uint64_t;
using peer_id_t = boost::uuids::uuid;
using pg_id_t = uint16_t;
using shard_id_t = uint64_t;

template < typename T >
using shared = std::shared_ptr< T >;

template < typename T >
using cshared = const std::shared_ptr< T >;

template < typename T >
using unique = std::unique_ptr< T >;

template < typename T >
using intrusive = boost::intrusive_ptr< T >;

template < typename T >
using cintrusive = const boost::intrusive_ptr< T >;

template < class E >
class Manager {
Expand Down
6 changes: 3 additions & 3 deletions src/include/homeobject/homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class HomeObjectApplication {
virtual std::list< std::filesystem::path > devices() const = 0;

// Callback made after determining if a SvcId exists or not during initialization, will consume response
virtual peer_id discover_svcid(std::optional< peer_id > const& found) const = 0;
virtual peer_id_t discover_svcid(std::optional< peer_id_t > const& found) const = 0;

// When RAFT operations take place, we must map the SvcId to a gethostbyaddr() value (IP)
virtual std::string lookup_peer(peer_id const&) const = 0;
virtual std::string lookup_peer(peer_id_t const&) const = 0;
};

class HomeObject {
public:
virtual ~HomeObject() = default;
virtual peer_id our_uuid() const = 0;
virtual peer_id_t our_uuid() const = 0;
virtual std::shared_ptr< BlobManager > blob_manager() = 0;
virtual std::shared_ptr< PGManager > pg_manager() = 0;
virtual std::shared_ptr< ShardManager > shard_manager() = 0;
Expand Down
17 changes: 9 additions & 8 deletions src/include/homeobject/pg_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

namespace homeobject {

ENUM(PGError, uint16_t, UNKNOWN = 1, INVALID_ARG, TIMEOUT, UNKNOWN_PG, UNKNOWN_PEER);
ENUM(PGError, uint16_t, UNKNOWN = 1, INVALID_ARG, TIMEOUT, UNKNOWN_PG, UNKNOWN_PEER, UNSUPPORTED_OP);

struct PGMember {
explicit PGMember(peer_id _id) : id(_id) {}
PGMember(peer_id _id, std::string const& _name) : id(_id), name(_name) {}
PGMember(peer_id _id, std::string const& _name, int32_t _priority) : id(_id), name(_name), priority(_priority) {}
peer_id id;
explicit PGMember(peer_id_t _id) : id(_id) {}
PGMember(peer_id_t _id, std::string const& _name) : id(_id), name(_name) {}
PGMember(peer_id_t _id, std::string const& _name, int32_t _priority) : id(_id), name(_name), priority(_priority) {}
peer_id_t id;
std::string name;
int32_t priority{0}; // <0 (Arbiter), ==0 (Follower), >0 (F|Leader)

Expand All @@ -28,9 +28,10 @@ struct PGMember {
using MemberSet = std::set< PGMember >;

struct PGInfo {
explicit PGInfo(pg_id _id) : id(_id) {}
pg_id id;
explicit PGInfo(pg_id_t _id) : id(_id) {}
pg_id_t id;
mutable MemberSet members;
peer_id_t replica_set_uuid;

auto operator<=>(PGInfo const& rhs) const { return id <=> rhs.id; }
auto operator==(PGInfo const& rhs) const { return id == rhs.id; }
Expand All @@ -39,7 +40,7 @@ struct PGInfo {
class PGManager : public Manager< PGError > {
public:
virtual NullAsyncResult create_pg(PGInfo&& pg_info) = 0;
virtual NullAsyncResult replace_member(pg_id id, peer_id const& old_member, PGMember const& new_member) = 0;
virtual NullAsyncResult replace_member(pg_id_t id, peer_id_t const& old_member, PGMember const& new_member) = 0;
};

} // namespace homeobject
23 changes: 12 additions & 11 deletions src/include/homeobject/shard_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@

namespace homeobject {

ENUM(ShardError, uint16_t, UNKNOWN = 1, TIMEOUT, INVALID_ARG, NOT_LEADER, UNKNOWN_PG, UNKNOWN_SHARD);
ENUM(ShardError, uint16_t, UNKNOWN = 1, TIMEOUT, INVALID_ARG, NOT_LEADER, UNKNOWN_PG, UNKNOWN_SHARD, PG_NOT_READY);

struct ShardInfo {
enum class State {
enum class State : uint8_t {
OPEN = 0,
SEALED,
DELETED,
SEALED = 1,
DELETED = 2,
};

shard_id id;
pg_id placement_group;
shard_id_t id;
pg_id_t placement_group;
State state;
uint64_t created_time;
uint64_t last_modified_time;
uint64_t available_capacity_bytes;
uint64_t total_capacity_bytes;
uint64_t deleted_capacity_bytes;
std::optional< peer_id > current_leader{std::nullopt};
std::optional< peer_id_t > current_leader{std::nullopt};

auto operator<=>(ShardInfo const& rhs) const { return id <=> rhs.id; }
auto operator==(ShardInfo const& rhs) const { return id == rhs.id; }
std::optional< peer_id_t > current_leader{std::nullopt};
};

using InfoList = std::list< ShardInfo >;
Expand All @@ -39,10 +40,10 @@ class ShardManager : public Manager< ShardError > {
static uint64_t max_shard_size(); // Static function forces runtime evaluation.
static uint64_t max_shard_num_in_pg();

virtual AsyncResult< ShardInfo > get_shard(shard_id id) const = 0;
virtual AsyncResult< InfoList > list_shards(pg_id id) const = 0;
virtual AsyncResult< ShardInfo > create_shard(pg_id pg_owner, uint64_t size_bytes) = 0;
virtual AsyncResult< ShardInfo > seal_shard(shard_id id) = 0;
virtual AsyncResult< ShardInfo > get_shard(shard_id_t id) const = 0;
virtual AsyncResult< InfoList > list_shards(pg_id_t id) const = 0;
virtual AsyncResult< ShardInfo > create_shard(pg_id_t pg_owner, uint64_t size_bytes) = 0;
virtual AsyncResult< ShardInfo > seal_shard(shard_id_t id) = 0;
};

} // namespace homeobject
4 changes: 2 additions & 2 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()

add_subdirectory(homestore)
add_subdirectory(memory)
add_subdirectory(homestore_backend)
add_subdirectory(memory_backend)
13 changes: 5 additions & 8 deletions src/lib/blob_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@

namespace homeobject {

std::shared_ptr< BlobManager > HomeObjectImpl::blob_manager() {
init_repl_svc();
return shared_from_this();
}
std::shared_ptr< BlobManager > HomeObjectImpl::blob_manager() { return shared_from_this(); }

BlobManager::AsyncResult< Blob > HomeObjectImpl::get(shard_id shard, blob_id const& blob, uint64_t off,
BlobManager::AsyncResult< Blob > HomeObjectImpl::get(shard_id_t shard, blob_id_t const& blob, uint64_t off,
uint64_t len) const {
return _get_shard(shard).thenValue([this, blob](auto const e) -> BlobManager::Result< Blob > {
if (!e) return folly::makeUnexpected(BlobError::UNKNOWN_SHARD);
return _get_blob(e.value().info, blob);
});
}

BlobManager::AsyncResult< blob_id > HomeObjectImpl::put(shard_id shard, Blob&& blob) {
BlobManager::AsyncResult< blob_id_t > HomeObjectImpl::put(shard_id_t shard, Blob&& blob) {
return _get_shard(shard).thenValue(
[this, blob = std::move(blob)](auto const e) mutable -> BlobManager::Result< blob_id > {
[this, blob = std::move(blob)](auto const e) mutable -> BlobManager::Result< blob_id_t > {
if (!e) return folly::makeUnexpected(BlobError::UNKNOWN_SHARD);
if (ShardInfo::State::SEALED == e.value().info.state) return folly::makeUnexpected(BlobError::INVALID_ARG);
return _put_blob(e.value().info, std::move(blob));
});
}

BlobManager::NullAsyncResult HomeObjectImpl::del(shard_id shard, blob_id const& blob) {
BlobManager::NullAsyncResult HomeObjectImpl::del(shard_id_t shard, blob_id_t const& blob) {
return _get_shard(shard).thenValue([this, blob](auto const e) mutable -> BlobManager::NullResult {
if (!e) return folly::makeUnexpected(BlobError::UNKNOWN_SHARD);
return _del_blob(e.value().info, blob);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/blob_route.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace homeobject {
// A Key used in the IndexService (BTree). The inclusion of Shard allows BlobRoutes
// to appear in a different Index should the Blob (Shard) be moved between Pgs.
struct BlobRoute {
shard_id shard;
blob_id blob;
shard_id_t shard;
blob_id_t blob;
auto operator<=>(BlobRoute const&) const = default;
};

Expand All @@ -37,6 +37,6 @@ struct formatter< homeobject::BlobRoute > {
template <>
struct std::hash< homeobject::BlobRoute > {
std::size_t operator()(homeobject::BlobRoute const& r) const noexcept {
return boost::hash_value< homeobject::blob_id >(std::make_pair(r.shard, r.blob));
return boost::hash_value< homeobject::blob_id_t >(std::make_pair(r.shard, r.blob));
}
};
Loading

0 comments on commit e3dd476

Please sign in to comment.