Skip to content

Commit

Permalink
issue: 226 Expose CP for external HomeStore client
Browse files Browse the repository at this point in the history
  • Loading branch information
yamingk committed Nov 14, 2023
1 parent e74e78f commit 898bf8f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 40 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "4.8.2"
version = "4.9.0"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
#include <mutex>

#include <sisl/logging/logging.h>
#include <iomgr/iomgr.hpp>
#include <sisl/utility/atomic_counter.hpp>
#include <folly/futures/SharedPromise.h>
#include "common/homestore_assert.hpp"

/*
* These are the design requirements of this class. If we don't follow these requirements then there can be serious
Expand Down Expand Up @@ -50,6 +49,7 @@ SISL_LOGGING_DECL(cp, replay)
HS_PERIODIC_DETAILED_LOG(level, cp, "cp_id", cp_id, , , msg, ##__VA_ARGS__)
#define CP_LOG(level, cp_id, msg, ...) HS_SUBMOD_LOG(level, cp, , "cp_id", cp_id, msg, ##__VA_ARGS__)

typedef int64_t cp_id_t;
ENUM(cp_status_t, uint8_t,
cp_unknown, // It is not inited yet.

Expand All @@ -66,6 +66,16 @@ ENUM(cp_status_t, uint8_t,
cp_cleaning);

class CPContext;
class CPManager;

VENUM(cp_consumer_t, uint8_t,
HS_CLIENT = 0, // Client of the homestore module
INDEX_SVC = 1, // Index service module
BLK_DATA_SVC = 2, // Block data service module
REPLICATION_SVC = 3, // Replication service module
SENTINEL = 4 // Should always be the last in this list
);

struct CP {
std::atomic< cp_status_t > m_cp_status{cp_status_t::cp_unknown};
sisl::atomic_counter< int64_t > m_enter_cnt;
Expand All @@ -89,23 +99,4 @@ struct CP {
return fmt::format("CP={}: status={}, enter_count={}", m_cp_id, enum_name(get_status()), m_enter_cnt.get());
}
};

class CPManager;
class CPWatchdog {
public:
CPWatchdog(CPManager* cp_mgr);
void set_cp(CP* cp);
void reset_cp();
void cp_watchdog_timer();
void stop();

private:
CP* m_cp;
CPManager* m_cp_mgr;
std::shared_mutex m_cp_mtx;
Clock::time_point m_last_state_ch_time;
uint64_t m_timer_sec{0};
iomgr::timer_handle_t m_timer_hdl;
uint32_t m_progress_pct{0};
};
} // namespace homestore
11 changes: 1 addition & 10 deletions src/include/homestore/checkpoint/cp_mgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include <sisl/utility/enum.hpp>

#include <homestore/superblk_handler.hpp>
#include <homestore/checkpoint/cp.hpp>

namespace homestore {
static constexpr size_t MAX_CP_COUNT{2};
typedef int64_t cp_id_t;

class CPMgrMetrics : public sisl::MetricsGroup {
public:
Expand All @@ -46,15 +46,6 @@ class CPMgrMetrics : public sisl::MetricsGroup {
~CPMgrMetrics() { deregister_me_from_farm(); }
};

VENUM(cp_consumer_t, uint8_t,
HS_CLIENT = 0, // Client of the homestore module
INDEX_SVC = 1, // Index service module
BLK_DATA_SVC = 2, // Block data service module
REPLICATION_SVC = 3, // Replication service module
SENTINEL = 4 // Should always be the last in this list
);

struct CP;
class CPContext {
protected:
CP* m_cp;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/blkalloc/append_blk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* *
* *********************************************************************************/
#include <homestore/checkpoint/cp_mgr.hpp>
#include <homestore/checkpoint/cp.hpp>
#include <homestore/meta_service.hpp>

#include "append_blk_allocator.h"
#include "checkpoint/cp.hpp"

namespace homestore {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/blkdata_svc/data_svc_cp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*********************************************************************************/
#pragma once
#include <homestore/checkpoint/cp_mgr.hpp>
#include <homestore/checkpoint/cp.hpp>
#include <homestore/homestore_decl.hpp>
#include "checkpoint/cp.hpp"

namespace homestore {

Expand Down
45 changes: 45 additions & 0 deletions src/lib/checkpoint/cp_internel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*********************************************************************************
* Modifications Copyright 2017-2019 eBay Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*********************************************************************************/
#pragma once
#include <atomic>
#include <array>
#include <memory>
#include <mutex>

#include <sisl/logging/logging.h>
#include <iomgr/iomgr.hpp>
#include <folly/futures/SharedPromise.h>

namespace homestore {
class CPManager;
class CPWatchdog {
public:
CPWatchdog(CPManager* cp_mgr);
void set_cp(CP* cp);
void reset_cp();
void cp_watchdog_timer();
void stop();

private:
CP* m_cp;
CPManager* m_cp_mgr;
std::shared_mutex m_cp_mtx;
Clock::time_point m_last_state_ch_time;
uint64_t m_timer_sec{0};
iomgr::timer_handle_t m_timer_hdl;
uint32_t m_progress_pct{0};
};
} // namespace homestore
2 changes: 1 addition & 1 deletion src/lib/checkpoint/cp_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "common/homestore_assert.hpp"
#include "common/homestore_config.hpp"
#include "common/resource_mgr.hpp"
#include "cp.hpp"
#include "cp_internel.hpp"

namespace homestore {
thread_local std::stack< CP* > CPGuard::t_cp_stack;
Expand Down
7 changes: 3 additions & 4 deletions src/lib/index/index_cp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <homestore/index/index_internal.hpp>
#include <homestore/index_service.hpp>
#include <homestore/checkpoint/cp_mgr.hpp>
#include <homestore/checkpoint/cp.hpp>

#include "checkpoint/cp.hpp"
#include "device/virtual_dev.hpp"

SISL_LOGGING_DECL(wbcache)
Expand All @@ -37,7 +37,6 @@ struct IndexCPContext : public VDevCPContext {
sisl::ConcurrentInsertVector< IndexBufferPtr >::iterator m_dirty_buf_it;

public:

IndexCPContext(CP* cp) : VDevCPContext(cp) {}
virtual ~IndexCPContext() = default;

Expand Down Expand Up @@ -97,7 +96,8 @@ struct IndexCPContext : public VDevCPContext {
// Use dfs to find if the graph is cycle
auto it = m_dirty_buf_list.begin();
while (it != m_dirty_buf_list.end()) {
IndexBufferPtr buf = *it;;
IndexBufferPtr buf = *it;
;
std::set< IndexBuffer* > visited;
check_cycle_recurse(buf, visited);
++it;
Expand Down Expand Up @@ -153,7 +153,6 @@ struct IndexCPContext : public VDevCPContext {
}
};


class IndexWBCache;
class IndexCPCallbacks : public CPCallbacks {
public:
Expand Down
1 change: 1 addition & 0 deletions src/lib/index/index_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "index/wb_cache.hpp"
#include "index/index_cp.hpp"
#include "common/homestore_utils.hpp"
#include "common/homestore_assert.hpp"
#include "device/virtual_dev.hpp"
#include "device/physical_dev.hpp"
#include "device/chunk.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_cp_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <homestore/homestore.hpp>
#include <homestore/meta_service.hpp>
#include <homestore/checkpoint/cp_mgr.hpp>
#include "checkpoint/cp.hpp"
#include <homestore/checkpoint/cp.hpp>
#include "test_common/homestore_test_common.hpp"

using namespace homestore;
Expand Down

0 comments on commit 898bf8f

Please sign in to comment.