0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Hyperspace::Session Class Reference

Hyperspace session. More...

#include <Session.h>

Collaboration diagram for Hyperspace::Session:
Collaboration graph
[legend]

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
 
Commm_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< Stringm_hyperspace_replicas
 
String m_hyperspace_master
 
SleepWakeNotifierm_sleep_wake_notifier
 Delivers suspend/resume notifications (e.g. laptop close/open). More...
 

Detailed Description

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

Definition at line 148 of file Session.h.

Member Typedef Documentation

typedef std::unordered_map<uint64_t, SessionCallback *> Hyperspace::Session::CallbackMap
private

Definition at line 698 of file Session.h.

Constructor & Destructor Documentation

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.

Parameters
commpointer to the Comm object
propsreference to config properties

Definition at line 54 of file Session.cc.

Session::~Session ( )
virtual

Definition at line 86 of file Session.cc.

Member Function Documentation

void Session::add_callback ( SessionCallback cb)

Register a new session callback.

Definition at line 141 of file Session.cc.

void Hyperspace::Session::advance_expire_time ( std::chrono::steady_clock::time_point  now)
inline

Definition at line 672 of file Session.h.

void Session::attr_del ( uint64_t  handle,
const std::string &  name,
Timer timer = 0 
)

Deletes an extended attribute of a file.

Parameters
handlefile handle
namename of extended attribute
timermaximum 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

Parameters
handlefile handle
attrname of extended attribute
valuereference to DynamicBuffer to hold returned value
timermaximum 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

Parameters
nameabsolute path name of the file/directory
attrname of extended attribute
valuereference to DynamicBuffer to hold returned value
timermaximum 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

Parameters
nameabsolute path name of the file/directory
attrname of extended attribute
attr_existsflag indicating if the attribute exists or not
valuereference to DynamicBuffer to hold returned value
timermaximum 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.

Parameters
handlefile handle
attrname of extended attribute
timermaximum 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.

Parameters
nameabsolute path name of the file/directory
attrname of extended attribute
timermaximum wait timer

Definition at line 522 of file Session.cc.

void Session::attr_list ( uint64_t  handle,
vector< String > &  anames,
Timer timer = 0 
)

Lists all extended attributes of a file.

Parameters
handlefile handle
anamesvector of atribute names
timermaximum 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.

Parameters
handlefile handle
attrname of extended attribute
valuepointer to new value
value_lenlength of new value
timermaximum 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.

Parameters
handlefile handle
attrsvector of attributes to be atomically set
timermaximum 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.

Parameters
nameabsolute path name of the file/directory
attrname of extended attribute
valuepointer to new value
value_lenlength of new value
timermaximum 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.

Parameters
nameabsolute path name of the file/directory
oflagsOR'ed together set of open flags (see OpenFlags)
attrname of extended attribute
valuepointer to new value
value_lenlength of new value
timermaximum 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.

Parameters
nameabsolute path name of the file/directory
oflagsOR'ed together set of open flags (see OpenFlags)
attrsvector of attributes to be atomically set
timermaximum 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

Parameters
handlefile handle
attrsnames of extended attribute
valuesreference to DynamicBuffer to hold returned value
timermaximum 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

Parameters
nameabsolute path name of the file/directory
attrsnames of extended attributes
valuesreference to DynamicBuffer to hold returned value
timermaximum 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

Parameters
sequencerlock sequencer to validate
timermaximum wait timer

Definition at line 1139 of file Session.cc.

void Session::close ( uint64_t  handle,
Timer timer = 0 
)

Closes a file handle.

Parameters
handlefile handle to close
timermaximum 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.

Parameters
handlefile 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).

Parameters
namepathname of file to create
flagsOR'ed together set of open flags (see OpenFlags)
callbacksmart pointer to handle callback
init_attrsvector of attributes to be atomically set when the file is created
timermaximum wait timer
Returns
Error::OK on success or error code on failure

Definition at line 235 of file Session.cc.

HsCommandInterpreterPtr Session::create_hs_interpreter ( )

Creates a new Hyperspace command interpreter.

Returns
HsCommandInterpreter ptr to created Hperspace interpreter object

Definition at line 1390 of file Session.cc.

void Session::decode_listing ( Hypertable::EventPtr event_ptr,
std::vector< DirEntryAttr > &  listing 
)
private

Definition at line 1320 of file Session.cc.

void Session::decode_value ( Hypertable::EventPtr event_ptr,
DynamicBuffer value 
)
private

Definition at line 1276 of file Session.cc.

void Session::decode_values ( Hypertable::EventPtr event_ptr,
std::vector< DynamicBufferPtr > &  values 
)
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.

Parameters
nameabsolute name of file or directory to check for
timermaximum wait timer
Returns
true if exists, false otherwise

Definition at line 335 of file Session.cc.

bool Session::expired ( )

Checks for session expiration (internal method)

Returns
true if expired, false otherwise

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.

Parameters
handlelocked file or directory handle
sequencerpaddress of LockSequencer return structure
timermaximum wait timer

Definition at line 1120 of file Session.cc.

int Session::get_state ( )

Returns current state (internal method)

Returns
current state (see SessionState)

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.

Parameters
handlehandle of file or directory to lock
modelock mode (see LockMode)
sequencerpaddress of LockSequencer return structure
timermaximum 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.

Parameters
nameabsolute pathname of directory to create
timermaximum 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.

Parameters
nameabsolute pathname of directory to create
init_attrsvector of attributes to be atomically set when the directory is created
timermaximum wait timer

Definition at line 291 of file Session.cc.

void Session::mkdir ( const std::string &  name,
bool  create_intermediate,
const std::vector< Attribute > *  init_attrs,
Timer timer 
)
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.

Parameters
nameabsolute pathname of directory to create
timermaximum 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.

Parameters
nameabsolute pathname of directory to create
init_attrsvector of attributes to be atomically set when the directory is created (applies not to the intermediates)
timermaximum wait timer

Definition at line 303 of file Session.cc.

void Session::normalize_name ( const std::string &  name,
std::string &  normal 
)
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).

Parameters
namepathname of file to open
flagsOR'ed together set of open flags (see OpenFlags)
callbacksmart pointer to handle callback
timermaximum wait timer
Returns
opened file handle

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.

Parameters
namepathname of file to open
flagsOR'ed together set of open flags (see OpenFlags)
timermaximum wait timer
Returns
opened file handle

Definition at line 228 of file Session.cc.

uint64_t Session::open ( ClientHandleStatePtr handle_state,
CommBufPtr cbuf_ptr,
Timer timer 
)
private

if (createdp) *createdp = cbyte ? true : false;

Definition at line 156 of file Session.cc.

void Session::readdir ( uint64_t  handle,
std::vector< DirEntry > &  listing,
Timer timer = 0 
)

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.

Parameters
handlehandle of directory to scan
listingreference to vector of DirEntry structures to hold result
timermaximum 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.

Parameters
handlehandle of directory to scan
attrattribute name
include_sub_entriesinclude or not include all sub entries
listingreference to vector of DirEntry structures to hold result
timermaximum 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.

Parameters
nameabsolute path name of directory to scan
attrattribute name
include_sub_entriesinclude or not include all sub entries
listingreference to vector of DirEntry structures to hold result
timermaximum 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.

Parameters
handlehandle of the file/directory to scan
attrattribute name
listingreference to vector of DirEntry structures to hold result
timermaximum 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.

Parameters
nameabsolute path name of the file/directory to scan
attrattribute name
listingreference to vector of DirEntry structures to hold result
timermaximum wait timer

Definition at line 942 of file Session.cc.

void Session::release ( uint64_t  handle,
Timer timer = 0 
)

Releases any file handle locks.

Parameters
handlelocked file or directory handle
timermaximum 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.

int Session::send_message ( CommBufPtr cbuf_ptr,
DispatchHandler handler,
Timer timer 
)
private

Definition at line 1356 of file Session.cc.

void Hyperspace::Session::set_verbose_flag ( bool  verbose)
inline

Sets verbose flag.

Turns on or off (default) verbose logging

Parameters
verbosevalue of verbose flag

Definition at line 643 of file Session.h.

void Session::shutdown ( Timer timer = 0)

Attempts to shutdown the Hyperspace server and destroys this session.

Parameters
timermaximum wait timer

Definition at line 117 of file Session.cc.

int Session::state_transition ( int  state)

Transions state (internal method)

Parameters
statenew state (see SessionState)
Returns
old state (see SessionState)

Definition at line 1181 of file Session.cc.

int Session::status ( Status status,
Timer timer = 0 
)

Check the status of the Hyperspace master server.

Parameters
statusReference to status object
timermaximum wait timer
Returns
Error::OK on if server is up and ok or error code on failure

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.

Parameters
handlehandle of file or directory to lock
modelock mode (see LockMode)
statuspaddress of variable to hold the status of the attempt (see LockStatus)
sequencerpaddress of LockSequencer return structure
timermaximum 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.

Parameters
nameabsolute path name of file or directory to delete
timermaximum 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.

Parameters
max_wait_msmaximum milliseconds to wait for connection
Returns
true if connected, false otherwise

Definition at line 1235 of file Session.cc.

bool Session::wait_for_connection ( Timer timer)

Waits for session state to change to STATE_SAFE.

Parameters
timermaximum wait timer
Returns
true if connected, false otherwise

Definition at line 1243 of file Session.cc.

bool Session::wait_for_safe ( )
private

Definition at line 1345 of file Session.cc.

Member Data Documentation

std::mutex Hyperspace::Session::m_callback_mutex
private

Definition at line 726 of file Session.h.

CallbackMap Hyperspace::Session::m_callbacks
private

Definition at line 724 of file Session.h.

PropertiesPtr Hyperspace::Session::m_cfg
private

Definition at line 712 of file Session.h.

Comm* Hyperspace::Session::m_comm
private

Definition at line 711 of file Session.h.

std::condition_variable Hyperspace::Session::m_cond
private

Definition at line 710 of file Session.h.

std::chrono::steady_clock::time_point Hyperspace::Session::m_expire_time
private

Definition at line 721 of file Session.h.

uint32_t Hyperspace::Session::m_grace_period
private

Definition at line 718 of file Session.h.

String Hyperspace::Session::m_hyperspace_master
private

Definition at line 728 of file Session.h.

uint16_t Hyperspace::Session::m_hyperspace_port
private

Definition at line 716 of file Session.h.

vector<String> Hyperspace::Session::m_hyperspace_replicas
private

Definition at line 727 of file Session.h.

ClientKeepaliveHandlerPtr Hyperspace::Session::m_keepalive_handler_ptr
private

Definition at line 723 of file Session.h.

uint64_t Hyperspace::Session::m_last_callback_id
private

Definition at line 725 of file Session.h.

uint32_t Hyperspace::Session::m_lease_interval
private

Definition at line 719 of file Session.h.

InetAddr Hyperspace::Session::m_master_addr
private

Definition at line 722 of file Session.h.

std::mutex Hyperspace::Session::m_mutex
private

Definition at line 709 of file Session.h.

bool Hyperspace::Session::m_reconnect
private

Definition at line 715 of file Session.h.

bool Hyperspace::Session::m_silent
private

Definition at line 714 of file Session.h.

SleepWakeNotifier* Hyperspace::Session::m_sleep_wake_notifier
private

Delivers suspend/resume notifications (e.g. laptop close/open).

Definition at line 731 of file Session.h.

int Hyperspace::Session::m_state
private

Definition at line 717 of file Session.h.

uint32_t Hyperspace::Session::m_timeout_ms
private

Definition at line 720 of file Session.h.

bool Hyperspace::Session::m_verbose
private

Definition at line 713 of file Session.h.


The documentation for this class was generated from the following files: