32#include <fluid-settings/fluid_settings_connection.h>
42 :
public std::enable_shared_from_this<ticket>
58 , std::string
const & lock_name
59 , ed::dispatcher_match::tag_t tag
60 , std::string
const & entering_key
63 , std::string
const & server_name
64 , std::string
const & service_name);
85 void set_owner(std::string
const & owner);
104 ed::dispatcher_match::tag_t
get_tag()
const;
129 ed::dispatcher_match::tag_t
f_tag = ed::dispatcher_match::DISPATCHER_MATCH_NO_TAG;
Class handling intercomputer locking.
Handle messages from the communicatord.
std::shared_ptr< messenger > pointer_t
Handle the ticket messages.
void ticket_added(key_map_t const &entering)
Called whenever a TICKET_ADDED is received.
ticket & operator=(ticket const &)=delete
cluck::timeout_t f_unlock_duration
key_map_t f_still_entering
void set_owner(std::string const &owner)
Define whether this ticket is the owner of that lock.
void set_serial(serial_t owner)
Give the lock a serial number for some form of unicity.
std::string const & get_object_name() const
Retrieve the object name of this ticket.
void entering()
Enter the mode that lets us retrieve our ticket number.
cluck::timeout_t get_unlock_duration() const
Get unlock duration.
void set_alive_timeout(cluck::timeout_t timeout)
Define a time when the ticket times out while waiting.
ticket(ticket const &)=delete
std::string const & get_service_name() const
Retrieve the service name of this ticket.
cluck::timeout_t f_lock_timeout_date
static serial_t const NO_SERIAL
bool timed_out() const
Check whether this ticket timed out.
cluck::timeout_t get_lock_timeout_date() const
Get the lock timeout date.
cluck::timeout_t f_obtention_timeout
std::string const & get_owner() const
Return the name of this ticket's owner.
void entered()
Tell this entering that we received a LOCKENTERED message.
std::string const & get_entering_key() const
Retrieve a reference to the entering key of this ticket.
cluck::timeout_t get_obtention_timeout() const
Get the obtention timeout date.
static ticket_id_t const NO_TICKET
messenger::pointer_t f_messenger
cluck::timeout_t f_lock_duration
std::string serialize() const
Serialize a ticket to send it over to another leader.
ticket_id_t get_ticket_number() const
Return the ticket number of this ticket.
ed::dispatcher_match::tag_t get_tag() const
Retrieve the tag of this ticket.
void set_unlock_duration(cluck::timeout_t duration)
Change the unlock duration to the specified value.
bool f_added_ticket_quorum
void activate_lock()
Check whether this ticket can be activated and do so if so.
std::string f_object_name
cluck::timeout_t f_unlocked_timeout_date
ed::dispatcher_match::tag_t f_tag
std::string f_server_name
std::string const & get_server_name() const
Retrieve the server name of this ticket.
pid_t get_client_pid() const
Retrieve the client process identifier.
std::map< std::string, key_map_t > object_map_t
lock_failure_t f_lock_failed
std::uint32_t ticket_id_t
bool send_message_to_leaders(ed::message &msg)
Send a message to the other two leaders.
void drop_ticket()
We are done with the ticket.
bool is_locked() const
Check whether this ticket is locked or not.
serial_t get_serial() const
Return the serial number of this ticket.
void unserialize(std::string const &data)
Unserialize a ticket string back to a ticket object.
void lock_failed(std::string const &reason)
Let the service that wanted this lock know that it failed.
void lock_activated()
Check whether this ticket can be activated and do so if so.
cluck::timeout_t get_current_timeout_date() const
Get the current lock timeout date.
std::string const & get_ticket_key() const
Retrieve a reference to the ticket key.
std::string f_service_name
void max_ticket(ticket_id_t new_max_ticket)
Called whenever a MAX_TICKET is received.
std::vector< pointer_t > vector_t
void set_ticket_number(ticket_id_t number)
Set the ticket number.
std::shared_ptr< ticket > pointer_t
void remove_entering(std::string const &key)
Call any time time an entering flag is reset.
void add_ticket()
Send the ADD_TICKET message.
void set_ready()
Mark the ticket as being ready.
bool one_leader() const
Check whether the system only has one leader.
cluck::timeout_t f_alive_timeout
std::map< std::string, pointer_t > key_map_t
cluck::timeout_t get_lock_duration() const
Retrieve the lock duration.
std::string f_entering_key
snapdev::timespec_ex timeout_t
A timeout delay.