22 #ifndef Hyperspace_Session_h
23 #define Hyperspace_Session_h
45 #include <condition_variable>
48 #include <unordered_map>
98 virtual void safe() = 0;
99 virtual void expired() = 0;
100 virtual void jeopardy() = 0;
101 virtual void disconnected() = 0;
102 virtual void reconnected() = 0;
207 uint64_t open(
const std::string &name, uint32_t flags,
219 uint64_t open(
const std::string &name, uint32_t flags,
Timer *timer = 0);
237 uint64_t create(
const std::string &name, uint32_t flags,
239 const std::vector<Attribute> &init_attrs,
Timer *timer=0);
251 void close(uint64_t handle,
Timer *timer=0);
258 void close_nowait(uint64_t handle);
269 void mkdir(
const std::string &name,
Timer *timer=0);
282 void mkdir(
const std::string &name,
const std::vector<Attribute> &init_attrs,
Timer *timer=0);
291 void mkdirs(
const std::string &name,
Timer *timer=0);
302 void mkdirs(
const std::string &name,
const std::vector<Attribute> &init_attrs,
Timer *timer=0);
312 void attr_set(uint64_t handle,
const std::string &attr,
313 const void *value,
size_t value_len,
Timer *timer=0);
321 void attr_set(uint64_t handle,
const std::vector<Attribute> &attrs,
332 void attr_set(
const std::string &name,
const std::string &attr,
333 const void *value,
size_t value_len,
Timer *timer=0);
344 void attr_set(
const std::string &name, uint32_t oflags,
const std::string &attr,
345 const void *value,
size_t value_len,
Timer *timer=0);
354 void attr_set(
const std::string &name, uint32_t oflags,
355 const std::vector<Attribute> &attrs,
Timer *timer=0);
364 uint64_t attr_incr(uint64_t handle,
const std::string &attr,
Timer *timer=0);
373 uint64_t attr_incr(
const std::string &name,
const std::string &attr,
Timer *timer=0);
381 void attr_list(uint64_t handle, vector<String> &anames,
Timer *timer=0);
383 bool attr_exists(uint64_t handle,
const std::string& attr,
Timer *timer=0);
384 bool attr_exists(
const std::string &name,
const std::string& attr,
Timer *timer=0);
396 void attr_get(uint64_t handle,
const std::string &attr,
409 void attr_get(
const std::string &name,
const std::string &attr,
423 void attr_get(
const std::string &name,
const std::string &attr,
436 void attrs_get(uint64_t handle,
const std::vector<std::string> &attrs,
437 std::vector<DynamicBufferPtr> &values,
Timer *timer=0);
449 void attrs_get(
const std::string &name,
const std::vector<std::string> &attrs,
450 std::vector<DynamicBufferPtr> &values,
Timer *timer=0);
458 void attr_del(uint64_t handle,
const std::string &name,
Timer *timer=0);
466 bool exists(
const std::string &name,
Timer *timer=0);
474 void unlink(
const std::string &name,
Timer *timer=0);
484 void readdir(uint64_t handle, std::vector<DirEntry> &listing,
498 void readdir_attr(uint64_t handle,
const std::string &attr,
bool include_sub_entries,
499 std::vector<DirEntryAttr> &listing,
Timer *timer=0);
512 void readdir_attr(
const std::string &name,
const std::string &attr,
bool include_sub_entries,
513 std::vector<DirEntryAttr> &listing,
Timer *timer=0);
526 void readpath_attr(uint64_t handle,
const std::string &attr,
527 std::vector<DirEntryAttr> &listing,
Timer *timer=0);
540 void readpath_attr(
const std::string &name,
const std::string &attr,
541 std::vector<DirEntryAttr> &listing,
Timer *timer=0);
559 void lock(uint64_t handle,
LockMode mode,
590 void release(uint64_t handle,
Timer *timer=0);
598 void get_sequencer(uint64_t handle,
LockSequencer *sequencerp,
630 bool wait_for_connection(uint32_t max_wait_ms);
637 bool wait_for_connection(
Timer &timer);
650 int state_transition(
int state);
673 std::lock_guard<std::mutex> lock(m_mutex);
674 m_expire_time = now + std::chrono::milliseconds(m_lease_interval);
677 void update_master_addr(
const String &host);
688 void handle_wakeup();
694 void shutdown(
Timer *timer=0);
698 typedef std::unordered_map<uint64_t, SessionCallback *>
CallbackMap;
700 void mkdir(
const std::string &name,
bool create_intermediate,
const std::vector<Attribute> *init_attrs,
Timer *timer);
704 bool wait_for_safe();
706 void normalize_name(
const std::string &name, std::string &normal);
736 void close_handle(SessionPtr hyperspace, uint64_t handle);
743 #endif // Hyperspace_Session_h
uint16_t m_hyperspace_port
std::shared_ptr< HsCommandInterpreter > HsCommandInterpreterPtr
A callback object derived from this class gets passed into the constructor of Hyperspace.
Holds Nagios-style program status information.
Delivers sleep and wakeup notifications.
std::shared_ptr< ClientKeepaliveHandler > ClientKeepaliveHandlerPtr
std::string String
A String is simply a typedef to std::string.
void set_verbose_flag(bool verbose)
Sets verbose flag.
Declarations for Protocol.
Abstract base class for application dispatch handlers registered with AsyncComm.
Error if create and file exists.
void advance_expire_time(std::chrono::steady_clock::time_point now)
Program options handling.
SleepWakeNotifier * m_sleep_wake_notifier
Delivers suspend/resume notifications (e.g. laptop close/open).
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
std::unordered_map< uint64_t, SessionCallback * > CallbackMap
Atomically open and lock file shared, fail if can't.
A dynamic, resizable and reference counted memory buffer.
uint64_t m_last_callback_id
State
Session state values
uint32_t m_lease_interval
vector< String > m_hyperspace_replicas
Declarations for DispatchHandler.
A dynamic, resizable memory buffer.
std::shared_ptr< Session > SessionPtr
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Encapsulate an internet address.
std::shared_ptr< CommBuf > CommBufPtr
Smart pointer to CommBuf.
std::shared_ptr< Properties > PropertiesPtr
A timer class to keep timeout states across AsyncComm related calls.
void close_handle_ptr(SessionPtr hyperspace, uint64_t *handlep)
std::chrono::steady_clock::time_point m_expire_time
void close_handle(SessionPtr hyperspace, uint64_t handle)
ClientKeepaliveHandlerPtr m_keepalive_handler_ptr
std::shared_ptr< HandleCallback > HandleCallbackPtr
std::mutex m_callback_mutex
Entry point to AsyncComm service.
String m_hyperspace_master
Declarations for CommBuf.
Declarations for ConnectionManager.
atomically open and lock file exclusive, fail if can't
A timer class to keep timeout states across AsyncComm related calls.
A String class based on std::string.
Used in conjunction with CREATE to create an ephemeral file.
std::shared_ptr< ClientHandleState > ClientHandleStatePtr
Create file if it does not exist.
virtual ~SessionCallback()
std::condition_variable m_cond