Hyperspace session. More...
#include <Session.h>
Public Types | |
enum | State { STATE_EXPIRED, STATE_JEOPARDY, STATE_SAFE, STATE_DISCONNECTED } |
Session state values More... | |
enum | Locate { LOCATE_MASTER =1, LOCATE_REPLICAS } |
Public Member Functions | |
Session (Comm *comm, PropertiesPtr &props) | |
Constructor. More... | |
virtual | ~Session () |
void | add_callback (SessionCallback *cb) |
Register a new session callback. More... | |
bool | remove_callback (SessionCallback *cb) |
De-register session callback. More... | |
uint64_t | open (const std::string &name, uint32_t flags, HandleCallbackPtr &callback, Timer *timer=0) |
Opens a file. More... | |
uint64_t | open (const std::string &name, uint32_t flags, Timer *timer=0) |
Opens a file. More... | |
uint64_t | create (const std::string &name, uint32_t flags, HandleCallbackPtr &callback, const std::vector< Attribute > &init_attrs, Timer *timer=0) |
Creates a file. More... | |
void | close (uint64_t handle, Timer *timer=0) |
Closes a file handle. More... | |
void | close_nowait (uint64_t handle) |
Attempts close a file handle, but doesn't block. More... | |
void | mkdir (const std::string &name, Timer *timer=0) |
Creates a directory. More... | |
void | mkdir (const std::string &name, const std::vector< Attribute > &init_attrs, Timer *timer=0) |
Creates a directory. More... | |
void | mkdirs (const std::string &name, Timer *timer=0) |
Creates a directory, including all intermediate paths. More... | |
void | mkdirs (const std::string &name, const std::vector< Attribute > &init_attrs, Timer *timer=0) |
Creates a directory, including all intermediate paths. More... | |
void | attr_set (uint64_t handle, const std::string &attr, const void *value, size_t value_len, Timer *timer=0) |
Sets an extended attribute of a file. More... | |
void | attr_set (uint64_t handle, const std::vector< Attribute > &attrs, Timer *timer=0) |
Sets an extended attribute of a file. More... | |
void | attr_set (const std::string &name, const std::string &attr, const void *value, size_t value_len, Timer *timer=0) |
Sets an extended attribute of a file. More... | |
void | attr_set (const std::string &name, uint32_t oflags, const std::string &attr, const void *value, size_t value_len, Timer *timer=0) |
Sets an extended attribute of a file. More... | |
void | attr_set (const std::string &name, uint32_t oflags, const std::vector< Attribute > &attrs, Timer *timer=0) |
Sets extended attributes of a file. More... | |
uint64_t | attr_incr (uint64_t handle, const std::string &attr, Timer *timer=0) |
Atomically increments the attribute and returns pre-incremented value Attribute is assumed to be a uint64_t. More... | |
uint64_t | attr_incr (const std::string &name, const std::string &attr, Timer *timer=0) |
Atomically increments the attribute and returns pre-incremented value Attribute is assumed to be a uint64_t. More... | |
void | attr_list (uint64_t handle, vector< String > &anames, Timer *timer=0) |
Lists all extended attributes of a file. More... | |
bool | attr_exists (uint64_t handle, const std::string &attr, Timer *timer=0) |
bool | attr_exists (const std::string &name, const std::string &attr, Timer *timer=0) |
void | attr_get (uint64_t handle, const std::string &attr, DynamicBuffer &value, Timer *timer=0) |
Gets an extended attribute of a file. More... | |
void | attr_get (const std::string &name, const std::string &attr, DynamicBuffer &value, Timer *timer=0) |
Gets an extended attribute of a file. More... | |
void | attr_get (const std::string &name, const std::string &attr, bool &attr_exists, DynamicBuffer &value, Timer *timer=0) |
Gets an extended attribute of a file. More... | |
void | attrs_get (uint64_t handle, const std::vector< std::string > &attrs, std::vector< DynamicBufferPtr > &values, Timer *timer=0) |
Gets extended attributes of a file. More... | |
void | attrs_get (const std::string &name, const std::vector< std::string > &attrs, std::vector< DynamicBufferPtr > &values, Timer *timer=0) |
Gets extended attributes of a file. More... | |
void | attr_del (uint64_t handle, const std::string &name, Timer *timer=0) |
Deletes an extended attribute of a file. More... | |
bool | exists (const std::string &name, Timer *timer=0) |
Checks for the existence of a file. More... | |
void | unlink (const std::string &name, Timer *timer=0) |
Removes a file or directory. More... | |
void | readdir (uint64_t handle, std::vector< DirEntry > &listing, Timer *timer=0) |
Gets a directory listing. More... | |
void | readdir_attr (uint64_t handle, const std::string &attr, bool include_sub_entries, std::vector< DirEntryAttr > &listing, Timer *timer=0) |
Gets a listing of all entries in a directory which have a certain attribute . More... | |
void | readdir_attr (const std::string &name, const std::string &attr, bool include_sub_entries, std::vector< DirEntryAttr > &listing, Timer *timer=0) |
Gets a listing of all entries in a directory which have a certain attribute . More... | |
void | readpath_attr (uint64_t handle, const std::string &attr, std::vector< DirEntryAttr > &listing, Timer *timer=0) |
Gets a listing of the value of a specified atribute for each path components of the file/dir name. More... | |
void | readpath_attr (const std::string &name, const std::string &attr, std::vector< DirEntryAttr > &listing, Timer *timer=0) |
Gets a listing of the value of a specified atribute for each path components of the file/dir name. More... | |
void | lock (uint64_t handle, LockMode mode, LockSequencer *sequencerp, Timer *timer=0) |
Locks a file. More... | |
void | try_lock (uint64_t handle, LockMode mode, LockStatus *statusp, LockSequencer *sequencerp, Timer *timer=0) |
Attempts to lock a file. More... | |
void | release (uint64_t handle, Timer *timer=0) |
Releases any file handle locks. More... | |
void | get_sequencer (uint64_t handle, LockSequencer *sequencerp, Timer *timer=0) |
Gets the lock sequencer of a locked file or directory handle. More... | |
void | check_sequencer (LockSequencer &sequencer, Timer *timer=0) |
Checks to see if a lock sequencer is valid. More... | |
String | locate (int type) |
Returns location of Hyperspace Master/Replicas. More... | |
int | status (Status &status, Timer *timer=0) |
Check the status of the Hyperspace master server. More... | |
bool | wait_for_connection (uint32_t max_wait_ms) |
Waits for session state to change to STATE_SAFE. More... | |
bool | wait_for_connection (Timer &timer) |
Waits for session state to change to STATE_SAFE. More... | |
void | set_verbose_flag (bool verbose) |
Sets verbose flag. More... | |
int | state_transition (int state) |
Transions state (internal method) More... | |
int | get_state () |
Returns current state (internal method) More... | |
bool | expired () |
Checks for session expiration (internal method) More... | |
HsCommandInterpreterPtr | create_hs_interpreter () |
Creates a new Hyperspace command interpreter. More... | |
void | advance_expire_time (std::chrono::steady_clock::time_point now) |
void | update_master_addr (const String &host) |
void | handle_sleep () |
Handle sleep event (e.g. More... | |
void | handle_wakeup () |
Handle wakeup event (e.g. More... | |
void | shutdown (Timer *timer=0) |
Attempts to shutdown the Hyperspace server and destroys this session. More... | |
Private Types | |
typedef std::unordered_map < uint64_t, SessionCallback * > | CallbackMap |
Private Member Functions | |
void | mkdir (const std::string &name, bool create_intermediate, const std::vector< Attribute > *init_attrs, Timer *timer) |
void | decode_listing (Hypertable::EventPtr &event_ptr, std::vector< DirEntryAttr > &listing) |
void | decode_value (Hypertable::EventPtr &event_ptr, DynamicBuffer &value) |
void | decode_values (Hypertable::EventPtr &event_ptr, std::vector< DynamicBufferPtr > &values) |
bool | wait_for_safe () |
int | send_message (CommBufPtr &, DispatchHandler *, Timer *timer) |
void | normalize_name (const std::string &name, std::string &normal) |
uint64_t | open (ClientHandleStatePtr &, CommBufPtr &, Timer *timer) |
Private Attributes | |
std::mutex | m_mutex |
std::condition_variable | m_cond |
Comm * | m_comm |
PropertiesPtr | m_cfg |
bool | m_verbose |
bool | m_silent |
bool | m_reconnect |
uint16_t | m_hyperspace_port |
int | m_state |
uint32_t | m_grace_period |
uint32_t | m_lease_interval |
uint32_t | m_timeout_ms |
std::chrono::steady_clock::time_point | m_expire_time |
InetAddr | m_master_addr |
ClientKeepaliveHandlerPtr | m_keepalive_handler_ptr |
CallbackMap | m_callbacks |
uint64_t | m_last_callback_id |
std::mutex | m_callback_mutex |
vector< String > | m_hyperspace_replicas |
String | m_hyperspace_master |
SleepWakeNotifier * | m_sleep_wake_notifier |
Delivers suspend/resume notifications (e.g. laptop close/open). More... | |
Hyperspace session.
Provides the API for Hyperspace, a namespace and lock service. This service is modeled after Chubby. Presently it is implemented as just a single server, but ultimately it will get re-written using a distributed consensus protocol for high availablility. For now, it provides the same functionality (albeit less available) and the same API. This allows us to get the system up and running and since the API is the same as the API for the highly-available version, minimal code changes will be needed when we swap out this one for the highly available one.
Session establishes a session with the master which includes a TCP connection and the initiation of regular heartbeat UDP messages. As soon as the master receives the first heartbeat message from the client Session object, it creates the session and grants a lease. Each heartbeat that the master receives from the client causes the master to extend the lease. In this mode of operation, the session is in the SAFE state. If the master does not receive a heartbeat message before the lease expiration time, then the session transitions to the EXPIRED state and the master drops the session.
Whenever the client receives a heartbeat UDP response message, it advances its conservative estimate of what it thinks the lease expiration time is. If the lease expires, then the client will put the session in the JEOPARDY state and will continue sending heartbeats for a period of time known as the 'grace period'. During the JEOPARDY state, all Hyperspace commands are suspended. If a heartbeat response message is received during the grace period, then it will switch back to SAFE mode and allow pending commands to proceed. Otherwise, the session expires.
The following set of properties are available to configure the protocol (default values are shown):
Hyperspace.Lease.Interval=2000 Hyperspace.KeepAlive.Interval=1000 Hyperspace.GracePeriod=6000
|
private |
Session::Session | ( | Comm * | comm, |
PropertiesPtr & | props | ||
) |
Constructor.
Establishes a connection to Hyperspace master and initiates keepalive pings. The location of the master is determined by contacting one of the replicas (Hyperspace.Replica) at the port specified by Hyperspace.port The session callback is used to notify the application of session state changes.
comm | pointer to the Comm object |
props | reference to config properties |
Definition at line 54 of file Session.cc.
|
virtual |
Definition at line 86 of file Session.cc.
void Session::add_callback | ( | SessionCallback * | cb | ) |
Register a new session callback.
Definition at line 141 of file Session.cc.
|
inline |
void Session::attr_del | ( | uint64_t | handle, |
const std::string & | name, | ||
Timer * | timer = 0 |
||
) |
Deletes an extended attribute of a file.
handle | file handle |
name | name of extended attribute |
timer | maximum wait timer |
Definition at line 747 of file Session.cc.
bool Session::attr_exists | ( | uint64_t | handle, |
const std::string & | attr, | ||
Timer * | timer = 0 |
||
) |
Definition at line 685 of file Session.cc.
bool Session::attr_exists | ( | const std::string & | name, |
const std::string & | attr, | ||
Timer * | timer = 0 |
||
) |
Definition at line 715 of file Session.cc.
void Session::attr_get | ( | uint64_t | handle, |
const std::string & | attr, | ||
DynamicBuffer & | value, | ||
Timer * | timer = 0 |
||
) |
Gets an extended attribute of a file.
A '\0' character is written just past the end of the value, but not included in the value size. If the value is a character string, it can be accessed easily by simply casting the base pointer: (const char *)value.base
handle | file handle |
attr | name of extended attribute |
value | reference to DynamicBuffer to hold returned value |
timer | maximum wait timer |
Definition at line 554 of file Session.cc.
void Session::attr_get | ( | const std::string & | name, |
const std::string & | attr, | ||
DynamicBuffer & | value, | ||
Timer * | timer = 0 |
||
) |
Gets an extended attribute of a file.
A '\0' character is written just past the end of the value, but not included in the value size. If the value is a character string, it can be accessed easily by simply casting the base pointer: (const char *)value.base
name | absolute path name of the file/directory |
attr | name of extended attribute |
value | reference to DynamicBuffer to hold returned value |
timer | maximum wait timer |
Definition at line 585 of file Session.cc.
void Session::attr_get | ( | const std::string & | name, |
const std::string & | attr, | ||
bool & | attr_exists, | ||
DynamicBuffer & | value, | ||
Timer * | timer = 0 |
||
) |
Gets an extended attribute of a file.
A '\0' character is written just past the end of the value, but not included in the value size. If the value is a character string, it can be accessed easily by simply casting the base pointer: (const char *)value.base
name | absolute path name of the file/directory |
attr | name of extended attribute |
attr_exists | flag indicating if the attribute exists or not |
value | reference to DynamicBuffer to hold returned value |
timer | maximum wait timer |
Definition at line 612 of file Session.cc.
uint64_t Session::attr_incr | ( | uint64_t | handle, |
const std::string & | attr, | ||
Timer * | timer = 0 |
||
) |
Atomically increments the attribute and returns pre-incremented value Attribute is assumed to be a uint64_t.
handle | file handle |
attr | name of extended attribute |
timer | maximum wait timer |
Definition at line 485 of file Session.cc.
uint64_t Session::attr_incr | ( | const std::string & | name, |
const std::string & | attr, | ||
Timer * | timer = 0 |
||
) |
Atomically increments the attribute and returns pre-incremented value Attribute is assumed to be a uint64_t.
name | absolute path name of the file/directory |
attr | name of extended attribute |
timer | maximum wait timer |
Definition at line 522 of file Session.cc.
Lists all extended attributes of a file.
handle | file handle |
anames | vector of atribute names |
timer | maximum wait timer |
Definition at line 775 of file Session.cc.
void Session::attr_set | ( | uint64_t | handle, |
const std::string & | attr, | ||
const void * | value, | ||
size_t | value_len, | ||
Timer * | timer = 0 |
||
) |
Sets an extended attribute of a file.
handle | file handle |
attr | name of extended attribute |
value | pointer to new value |
value_len | length of new value |
timer | maximum wait timer |
Definition at line 369 of file Session.cc.
void Session::attr_set | ( | uint64_t | handle, |
const std::vector< Attribute > & | attrs, | ||
Timer * | timer = 0 |
||
) |
Sets an extended attribute of a file.
handle | file handle |
attrs | vector of attributes to be atomically set |
timer | maximum wait timer |
Definition at line 400 of file Session.cc.
void Session::attr_set | ( | const std::string & | name, |
const std::string & | attr, | ||
const void * | value, | ||
size_t | value_len, | ||
Timer * | timer = 0 |
||
) |
Sets an extended attribute of a file.
name | absolute path name of the file/directory |
attr | name of extended attribute |
value | pointer to new value |
value_len | length of new value |
timer | maximum wait timer |
Definition at line 429 of file Session.cc.
void Session::attr_set | ( | const std::string & | name, |
uint32_t | oflags, | ||
const std::string & | attr, | ||
const void * | value, | ||
size_t | value_len, | ||
Timer * | timer = 0 |
||
) |
Sets an extended attribute of a file.
name | absolute path name of the file/directory |
oflags | OR'ed together set of open flags (see OpenFlags) |
attr | name of extended attribute |
value | pointer to new value |
value_len | length of new value |
timer | maximum wait timer |
Definition at line 434 of file Session.cc.
void Session::attr_set | ( | const std::string & | name, |
uint32_t | oflags, | ||
const std::vector< Attribute > & | attrs, | ||
Timer * | timer = 0 |
||
) |
Sets extended attributes of a file.
name | absolute path name of the file/directory |
oflags | OR'ed together set of open flags (see OpenFlags) |
attrs | vector of attributes to be atomically set |
timer | maximum wait timer |
Definition at line 459 of file Session.cc.
void Session::attrs_get | ( | uint64_t | handle, |
const std::vector< std::string > & | attrs, | ||
std::vector< DynamicBufferPtr > & | values, | ||
Timer * | timer = 0 |
||
) |
Gets extended attributes of a file.
A '\0' character is written just past the end of the values, but not included in the value size. If the value is a character string, it can be accessed easily by simply casting the base pointer: (const char *)value.base
handle | file handle |
attrs | names of extended attribute |
values | reference to DynamicBuffer to hold returned value |
timer | maximum wait timer |
Definition at line 627 of file Session.cc.
void Session::attrs_get | ( | const std::string & | name, |
const std::vector< std::string > & | attrs, | ||
std::vector< DynamicBufferPtr > & | values, | ||
Timer * | timer = 0 |
||
) |
Gets extended attributes of a file.
A '\0' character is written just past the end of the value, but not included in the value size. If the value is a character string, it can be accessed easily by simply casting the base pointer: (const char *)value.base
name | absolute path name of the file/directory |
attrs | names of extended attributes |
values | reference to DynamicBuffer to hold returned value |
timer | maximum wait timer |
Definition at line 658 of file Session.cc.
void Session::check_sequencer | ( | LockSequencer & | sequencer, |
Timer * | timer = 0 |
||
) |
Checks to see if a lock sequencer is valid.
NOTE: This method is not yet implemented and always returns Error::OK
sequencer | lock sequencer to validate |
timer | maximum wait timer |
Definition at line 1139 of file Session.cc.
void Session::close | ( | uint64_t | handle, |
Timer * | timer = 0 |
||
) |
Closes a file handle.
handle | file handle to close |
timer | maximum wait timer |
Definition at line 255 of file Session.cc.
void Session::close_nowait | ( | uint64_t | handle | ) |
Attempts close a file handle, but doesn't block.
Handle may not get closed.
handle | file handle to close |
Definition at line 277 of file Session.cc.
uint64_t Session::create | ( | const std::string & | name, |
uint32_t | flags, | ||
HandleCallbackPtr & | callback, | ||
const std::vector< Attribute > & | init_attrs, | ||
Timer * | timer = 0 |
||
) |
Creates a file.
This method is basically the same as the open method except that it implicitly sets the OPEN_FLAG_CREATE and OPEN_FLAG_EXCL open flags and supplies a set of initial attributes to be set when the file is created. The flags argument controls other open modes and the callback argument is registered as the callback for this handle. The events that should be reported on this handle are determined by the event mask inside callback (see HandleCallback::get_event_mask).
name | pathname of file to create |
flags | OR'ed together set of open flags (see OpenFlags) |
callback | smart pointer to handle callback |
init_attrs | vector of attributes to be atomically set when the file is created |
timer | maximum wait timer |
Definition at line 235 of file Session.cc.
HsCommandInterpreterPtr Session::create_hs_interpreter | ( | ) |
Creates a new Hyperspace command interpreter.
Definition at line 1390 of file Session.cc.
|
private |
Definition at line 1320 of file Session.cc.
|
private |
Definition at line 1276 of file Session.cc.
|
private |
Definition at line 1294 of file Session.cc.
bool Session::exists | ( | const std::string & | name, |
Timer * | timer = 0 |
||
) |
Checks for the existence of a file.
name | absolute name of file or directory to check for |
timer | maximum wait timer |
Definition at line 335 of file Session.cc.
bool Session::expired | ( | ) |
Checks for session expiration (internal method)
Definition at line 1229 of file Session.cc.
void Session::get_sequencer | ( | uint64_t | handle, |
LockSequencer * | sequencerp, | ||
Timer * | timer = 0 |
||
) |
Gets the lock sequencer of a locked file or directory handle.
handle | locked file or directory handle |
sequencerp | address of LockSequencer return structure |
timer | maximum wait timer |
Definition at line 1120 of file Session.cc.
int Session::get_state | ( | ) |
Returns current state (internal method)
Definition at line 1223 of file Session.cc.
void Session::handle_sleep | ( | ) |
Handle sleep event (e.g.
laptop close). This method handles a suspend event (e.g. laptop close) by setting m_expire_time to the current time plus the grace period.
Definition at line 100 of file Session.cc.
void Session::handle_wakeup | ( | ) |
Handle wakeup event (e.g.
laptop open). This method handles a resume event (e.g. laptop open) by setting m_expire_time to the current time plus the grace period. It also transitions back to STATE_SAFE if current state is STATE_JEOPARDY.
Definition at line 106 of file Session.cc.
String Session::locate | ( | int | type | ) |
Returns location of Hyperspace Master/Replicas.
Definition at line 1145 of file Session.cc.
void Session::lock | ( | uint64_t | handle, |
LockMode | mode, | ||
LockSequencer * | sequencerp, | ||
Timer * | timer = 0 |
||
) |
Locks a file.
The mode argument indicates the type of lock to be acquired and takes a value of either LOCK_MODE_SHARED or LOCK_MODE_EXCLUSIVE (see LockMode). Upon success, the structure pointed to by sequencerp will get filled in with information about the lock, including a generation number. Some services operate on resources on behalf of clients, but require that the client have the resource locked. The LockSequencer object can be passed by the client to the service in each request so that the service can call check_sequencer (not yet implemented) to verify that the client indeed has the current up-to-date lock.
handle | handle of file or directory to lock |
mode | lock mode (see LockMode) |
sequencerp | address of LockSequencer return structure |
timer | maximum wait timer |
Definition at line 968 of file Session.cc.
void Session::mkdir | ( | const std::string & | name, |
Timer * | timer = 0 |
||
) |
Creates a directory.
The name argument should be the absolute path to the file. All of the directories up to, but not including, the last path component must be valid. Otherwise, Error::HYPERSPACE_BAD_PATHNAME will be returned.
name | absolute pathname of directory to create |
timer | maximum wait timer |
Definition at line 295 of file Session.cc.
void Session::mkdir | ( | const std::string & | name, |
const std::vector< Attribute > & | init_attrs, | ||
Timer * | timer = 0 |
||
) |
Creates a directory.
The name argument should be the absolute path to the file. All of the directories up to, but not including, the last path component must be valid. Otherwise, Error::HYPERSPACE_BAD_PATHNAME will be returned.
name | absolute pathname of directory to create |
init_attrs | vector of attributes to be atomically set when the directory is created |
timer | maximum wait timer |
Definition at line 291 of file Session.cc.
|
private |
Definition at line 1251 of file Session.cc.
void Session::mkdirs | ( | const std::string & | name, |
Timer * | timer = 0 |
||
) |
Creates a directory, including all intermediate paths.
The name argument should be the absolute path to the file.
name | absolute pathname of directory to create |
timer | maximum wait timer |
Definition at line 299 of file Session.cc.
void Session::mkdirs | ( | const std::string & | name, |
const std::vector< Attribute > & | init_attrs, | ||
Timer * | timer = 0 |
||
) |
Creates a directory, including all intermediate paths.
The name argument should be the absolute path to the file.
name | absolute pathname of directory to create |
init_attrs | vector of attributes to be atomically set when the directory is created (applies not to the intermediates) |
timer | maximum wait timer |
Definition at line 303 of file Session.cc.
|
private |
Definition at line 1373 of file Session.cc.
uint64_t Session::open | ( | const std::string & | name, |
uint32_t | flags, | ||
HandleCallbackPtr & | callback, | ||
Timer * | timer = 0 |
||
) |
Opens a file.
The open mode is determined by the bits in the flags argument and the callback argument is registered as the callback for this handle. The events that should be reported on this handle are determined by the event mask inside callback (see HandleCallback::get_event_mask).
name | pathname of file to open |
flags | OR'ed together set of open flags (see OpenFlags) |
callback | smart pointer to handle callback |
timer | maximum wait timer |
Definition at line 210 of file Session.cc.
uint64_t Session::open | ( | const std::string & | name, |
uint32_t | flags, | ||
Timer * | timer = 0 |
||
) |
Opens a file.
The open mode is determined by the bits in the flags argument. No callback is registered for this handle and no events are reported on this handle.
name | pathname of file to open |
flags | OR'ed together set of open flags (see OpenFlags) |
timer | maximum wait timer |
Definition at line 228 of file Session.cc.
|
private |
if (createdp) *createdp = cbyte ? true : false;
Definition at line 156 of file Session.cc.
Gets a directory listing.
The listing comes back as a vector of DireEntry which contains a name and boolean flag indicating if the entry is an element or not.
handle | handle of directory to scan |
listing | reference to vector of DirEntry structures to hold result |
timer | maximum wait timer |
Definition at line 817 of file Session.cc.
void Session::readdir_attr | ( | uint64_t | handle, |
const std::string & | attr, | ||
bool | include_sub_entries, | ||
std::vector< DirEntryAttr > & | listing, | ||
Timer * | timer = 0 |
||
) |
Gets a listing of all entries in a directory which have a certain attribute .
The listing comes back as a vector of DirEntryAttr which contains a name, attr and boolean flag indicating if the entry is a directory or not.
handle | handle of directory to scan |
attr | attribute name |
include_sub_entries | include or not include all sub entries |
listing | reference to vector of DirEntry structures to hold result |
timer | maximum wait timer |
Definition at line 864 of file Session.cc.
void Session::readdir_attr | ( | const std::string & | name, |
const std::string & | attr, | ||
bool | include_sub_entries, | ||
std::vector< DirEntryAttr > & | listing, | ||
Timer * | timer = 0 |
||
) |
Gets a listing of all entries in a directory which have a certain attribute .
The listing comes back as a vector of DirEntryAttr which contains a name, attr and boolean flag indicating if the entry is a directory or not.
name | absolute path name of directory to scan |
attr | attribute name |
include_sub_entries | include or not include all sub entries |
listing | reference to vector of DirEntry structures to hold result |
timer | maximum wait timer |
Definition at line 890 of file Session.cc.
void Session::readpath_attr | ( | uint64_t | handle, |
const std::string & | attr, | ||
std::vector< DirEntryAttr > & | listing, | ||
Timer * | timer = 0 |
||
) |
Gets a listing of the value of a specified atribute for each path components of the file/dir name.
The listing comes back as a vector of DirEntryAttr which contains a name, attr and boolean flag indicating if the entry is a directory or not.
handle | handle of the file/directory to scan |
attr | attribute name |
listing | reference to vector of DirEntry structures to hold result |
timer | maximum wait timer |
Definition at line 916 of file Session.cc.
void Session::readpath_attr | ( | const std::string & | name, |
const std::string & | attr, | ||
std::vector< DirEntryAttr > & | listing, | ||
Timer * | timer = 0 |
||
) |
Gets a listing of the value of a specified atribute for each path components of the file/dir name.
The listing comes back as a vector of DirEntryAttr which contains a name, attr and boolean flag indicating if the entry is a directory or not.
name | absolute path name of the file/directory to scan |
attr | attribute name |
listing | reference to vector of DirEntry structures to hold result |
timer | maximum wait timer |
Definition at line 942 of file Session.cc.
void Session::release | ( | uint64_t | handle, |
Timer * | timer = 0 |
||
) |
Releases any file handle locks.
handle | locked file or directory handle |
timer | maximum wait timer |
Definition at line 1088 of file Session.cc.
bool Session::remove_callback | ( | SessionCallback * | cb | ) |
De-register session callback.
Definition at line 149 of file Session.cc.
|
private |
Definition at line 1356 of file Session.cc.
|
inline |
void Session::shutdown | ( | Timer * | timer = 0 | ) |
Attempts to shutdown the Hyperspace server and destroys this session.
timer | maximum wait timer |
Definition at line 117 of file Session.cc.
int Session::state_transition | ( | int | state | ) |
Transions state (internal method)
state | new state (see SessionState) |
Definition at line 1181 of file Session.cc.
Check the status of the Hyperspace master server.
status | Reference to status object |
timer | maximum wait timer |
Definition at line 1162 of file Session.cc.
void Session::try_lock | ( | uint64_t | handle, |
LockMode | mode, | ||
LockStatus * | statusp, | ||
LockSequencer * | sequencerp, | ||
Timer * | timer = 0 |
||
) |
Attempts to lock a file.
The mode argument indicates the type of lock to be acquired and takes a value of either LOCK_MODE_SHARED or LOCK_MODE_EXCLUSIVE (see LockMode). The result of the attempt will get returned in the statusp argument and will contain either LOCK_STATUS_BUSY or LOCK_STATUS_GRANTED. Upon success, the structure pointed to by sequencerp will get filled in with information about the lock, including a generation number. Some services operate on resources on behalf of clients, but require that the client have the resource locked. The LockSequencer object can be passed by the client to the service in each request so that the service can call check_sequencer (not yet implemented) to verify that the client indeed has the current up-to-date lock.
handle | handle of file or directory to lock |
mode | lock mode (see LockMode) |
statusp | address of variable to hold the status of the attempt (see LockStatus) |
sequencerp | address of LockSequencer return structure |
timer | maximum wait timer |
Definition at line 1035 of file Session.cc.
void Session::unlink | ( | const std::string & | name, |
Timer * | timer = 0 |
||
) |
Removes a file or directory.
Directory must be empty, otherwise Error::HYPERSPACE_IO_ERROR will be returned.
name | absolute path name of file or directory to delete |
timer | maximum wait timer |
Definition at line 308 of file Session.cc.
void Session::update_master_addr | ( | const String & | host | ) |
Definition at line 92 of file Session.cc.
bool Session::wait_for_connection | ( | uint32_t | max_wait_ms | ) |
Waits for session state to change to STATE_SAFE.
max_wait_ms | maximum milliseconds to wait for connection |
Definition at line 1235 of file Session.cc.
bool Session::wait_for_connection | ( | Timer & | timer | ) |
Waits for session state to change to STATE_SAFE.
timer | maximum wait timer |
Definition at line 1243 of file Session.cc.
|
private |
Definition at line 1345 of file Session.cc.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |