14 std::map<
subgroup_id_t, std::reference_wrapper<ReplicatedObject>>& objects_map,
16 : thread_shutdown(false),
17 persistence_callback(_persistence_callback),
18 objects_by_subgroup_id(objects_map) {
21 throw derecho_exception(
"Cannot initialize persistent_request_sem:errno=" + std::to_string(errno));
42 pthread_setname_np(pthread_self(),
"persist");
46 while(
prq_lock.test_and_set(std::memory_order_acquire))
49 prq_lock.clear(std::memory_order_release);
59 prq_lock.clear(std::memory_order_release);
65 search->second.get().persist(version);
72 Vc.
gmsSST->persisted_num[Vc.
gmsSST->get_local_index()][subgroup_id] = version;
74 (
char*)std::addressof(Vc.
gmsSST->persisted_num[0][subgroup_id]) - Vc.
gmsSST->getBaseAddress(),
75 sizeof(
long long int));
76 }
catch(uint64_t exp) {
77 dbg_default_debug(
"exception on persist():subgroup={},ver={},exp={}.", subgroup_id, version, exp);
78 std::cout <<
"exception on persistent:subgroup=" << subgroup_id <<
",ver=" << version <<
"exception=0x" << std::hex << exp << std::endl;
87 while(
prq_lock.test_and_set(std::memory_order_acquire))
90 prq_lock.clear(std::memory_order_release);
93 prq_lock.clear(std::memory_order_release);
102 while(
prq_lock.test_and_set(std::memory_order_acquire))
105 prq_lock.clear(std::memory_order_release);
115 search->second.get().make_version(version, mhlc);
137 return std::make_tuple(
uint32_t subgroup_id_t
Type alias for the internal Subgroup IDs generated by ViewManager.
std::atomic< bool > thread_shutdown
A flag to singal the persistent thread to shutdown; set to true when the group is destroyed...
PersistenceManager(std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject >> &objects_map, const persistence_callback_t &_persistence_callback)
Constructor.
void shutdown(bool wait)
shutdown the thread - wait till the thread finished or not.
std::queue< persistence_request_t > persistence_request_queue
a queue for the requests
persistence_manager_callbacks_t get_callbacks()
get the persistence callbacks.
std::unique_ptr< MulticastGroup > multicast_group
RDMC manager object used for sending multicasts.
void post_persist_request(const subgroup_id_t &subgroup_id, const persistent::version_t &version)
post a persistence request
virtual ~PersistenceManager()
default Destructor
#define dbg_default_debug(...)
void start()
Start the persistent thread.
std::shared_ptr< DerechoSST > gmsSST
Pointer to the SST instance used by the GMS in this View.
void make_version(const subgroup_id_t &subgroup_id, const persistent::version_t &version, const HLC &mhlc)
make a version
void set_view_manager(ViewManager &view_manager)
std::function< void(subgroup_id_t, persistent::version_t)> persistence_callback_t
std::map< subgroup_id_t, std::reference_wrapper< ReplicatedObject > > & objects_by_subgroup_id
Replicated Objects handle: TODO:make it safer.
ViewManager * view_manager
View Manager pointer.
std::shared_timed_mutex view_mutex
Controls access to curr_view.
sem_t persistence_request_sem
The semaphore for persistence request the persistent thread.
persistence_callback_t persistence_callback
persistence callback
std::atomic_flag prq_lock
lock for persistence request queue
std::tuple< persistence_manager_make_version_func_t, persistence_manager_post_persist_func_t > persistence_manager_callbacks_t
std::unique_ptr< View > curr_view
The current View, containing the state of the managed group.
Base exception class for all exceptions raised by Derecho.
std::thread persist_thread
Thread handle.