22 #ifndef Hyperspace_Event_h
23 #define Hyperspace_Event_h
36 #include <condition_variable>
44 #define HT_BDBTXN_EVT_BEGIN(parent_txn) \
47 ms_bdb_fs->start_transaction(txn); \
50 #define HT_BDBTXN_EVT_END_CB(_cb_) \
51 catch (Exception &e) { \
52 if (e.code() != Error::HYPERSPACE_BERKELEYDB_DEADLOCK) { \
53 if (e.code() == Error::HYPERSPACE_BERKELEYDB_ERROR) \
54 HT_ERROR_OUT << e << HT_END; \
56 HT_WARNF("%s - %s", Error::get_text(e.code()), e.what()); \
58 _cb_->error(e.code(), e.what()); \
61 HT_WARN_OUT << "Berkeley DB deadlock encountered in txn "<< txn << HT_END; \
63 std::this_thread::sleep_for(Random::duration_millis(3000)); \
69 #define HT_BDBTXN_EVT_END(...) \
70 catch (Exception &e) { \
71 if (e.code() != Error::HYPERSPACE_BERKELEYDB_DEADLOCK) { \
72 if (e.code() == Error::HYPERSPACE_BERKELEYDB_ERROR) \
73 HT_ERROR_OUT << e << HT_END; \
75 HT_WARNF("%s - %s", Error::get_text(e.code()), e.what()); \
79 HT_WARN_OUT << "Berkeley DB deadlock encountered in txn "<< txn << HT_END; \
81 std::this_thread::sleep_for(Random::duration_millis(3000)); \
98 Event(uint64_t
id, uint32_t mask) : m_id(id), m_mask(mask) { }
106 std::lock_guard<std::mutex> lock(m_mutex);
107 m_notification_count++;
111 std::lock_guard<std::mutex> lock(m_mutex);
112 m_notification_count--;
113 if (m_notification_count == 0) {
116 ms_bdb_fs->delete_event(txn, m_id);
125 std::unique_lock<std::mutex> lock(m_mutex);
126 m_cond.wait(lock, [
this](){
return m_notification_count == 0;});
129 virtual uint32_t encoded_length() = 0;
142 uint32_t m_notification_count {};
153 EventNamed(uint64_t
id, uint32_t mask,
const std::string &name)
227 #endif // Hyperspace_Event_h
Retrieves system information (hardware, installation directory, etc)
virtual void encode(Hypertable::CommBuf *cbuf)
static BerkeleyDbFilesystem * ms_bdb_fs
EventLockGranted(uint64_t id, uint32_t mode, uint64_t generation)
Network communication event.
void decrement_notification_count()
Event(uint64_t id, uint32_t mask)
static void set_bdb_fs(BerkeleyDbFilesystem *bdb_fs)
Declarations for BerkeleyDbFilesystem.
std::shared_ptr< Event > HyperspaceEventPtr
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
void wait_for_notifications()
void append_vstr(const char *str)
Appends a c-style string to the primary buffer.
virtual uint32_t encoded_length()
#define HT_BDBTXN_EVT_END(...)
EventLockReleased(uint64_t id)
Compatibility Macros for C/C++.
#define HT_BDBTXN_EVT_BEGIN(parent_txn)
void append_i32(uint32_t ival)
Appends a 32-bit integer to the primary buffer.
Functions to serialize/deserialize primitives to/from a memory buffer.
EventNamed(uint64_t id, uint32_t mask, const std::string &name)
virtual uint32_t encoded_length()
EventLockAcquired(uint64_t id, uint32_t mode)
virtual void encode(Hypertable::CommBuf *cbuf)
virtual uint32_t encoded_length()
Hyperspace filesystem implementation on top of BerkeleyDB.
void append_i64(uint64_t lval)
Appends a 64-bit integer to the primary buffer.
Declarations for CommBuf.
Random number generator for int32, int64, double and ascii arrays.
Message buffer for holding data to be transmitted over a network.
virtual uint32_t encoded_length()
virtual void encode(Hypertable::CommBuf *cbuf)
std::condition_variable m_cond
virtual void encode(Hypertable::CommBuf *cbuf)
void increment_notification_count()