cluck 1.0.1
The cluster lock service.
Public Types | Public Member Functions | Private Attributes | List of all members
cluck_daemon::messenger Class Reference

Handle messages from the communicatord. More...

#include <messenger.h>

Inheritance diagram for cluck_daemon::messenger:
Inheritance graph
[legend]
Collaboration diagram for cluck_daemon::messenger:
Collaboration graph
[legend]

Public Types

typedef std::shared_ptr< messengerpointer_t
 

Public Member Functions

 messenger (cluckd *c, advgetopt::getopt &opts)
 The messenger initialization.
 
 messenger (messenger const &)=delete
 
virtual ~messenger () override
 
void finish_parsing ()
 Finish handling command line options.
 
virtual void fluid_settings_changed (fluid_settings::fluid_settings_status_t status, std::string const &name, std::string const &value) override
 Send the CLUSTER_STATUS to communicatord once ready.
 
messengeroperator= (messenger const &)=delete
 
virtual void ready (ed::message &msg)
 Messenger received the READY message.
 
virtual void stop (bool quitting)
 Let the server know STOP or QUITTING was sent to us.
 

Private Attributes

cluckdf_cluckd = nullptr
 

Detailed Description

This class is an implementation of the TCP client message connection so we can handle incoming messages. We actually use the fluid-settings which itself uses the communicatord connection. All of the basic communication messages used by the communicatord and fluid settings are handled automatically.

This class handles the lock messages.

Definition at line 34 of file messenger.h.

Member Typedef Documentation

◆ pointer_t

Definition at line 38 of file messenger.h.

Constructor & Destructor Documentation

◆ messenger() [1/2]

cluck_daemon::messenger::messenger ( cluckd c,
advgetopt::getopt &  opts 
)

◆ messenger() [2/2]

cluck_daemon::messenger::messenger ( messenger const &  )
delete

◆ ~messenger()

cluck_daemon::messenger::~messenger ( )
overridevirtual

Definition at line 204 of file messenger.cpp.

Member Function Documentation

◆ finish_parsing()

void cluck_daemon::messenger::finish_parsing ( )

This function makes sure the fluid settings and communicator daemon have a chance to check the command line options and act on it.

Definition at line 214 of file messenger.cpp.

◆ fluid_settings_changed()

void cluck_daemon::messenger::fluid_settings_changed ( fluid_settings::fluid_settings_status_t  status,
std::string const &  name,
std::string const &  value 
)
overridevirtual

This function builds a message and sends it to communicatord.

The CLUSTER_UP and CLUSTER_DOWN messages are sent only when that specific event happen and until then we do not know what the state really is (although we assume the worst and use CLUSTER_DOWN until we get a reply).

Parameters
[in]statusThe status of the fluid settings object.
[in]nameThe name of the changing parameter.
[in]valueThe value of the parameter.

Definition at line 278 of file messenger.cpp.

◆ operator=()

messenger & cluck_daemon::messenger::operator= ( messenger const &  )
delete

◆ ready()

void cluck_daemon::messenger::ready ( ed::message &  msg)
virtual

Whenever we receive the READY message, we also receive our IP address as the "my_address" parameter. This gets copied in the cluckd object.

The function tells the fluid settings connection that the daemon is ready.

The cluck daemon uses the wall clock to synchronize the locks between servers so it requests the clock status from the communicator daemon. Once known to be stable, it's ready to start accepting locks.

Parameters
[in,out]msgThe READY message.

Definition at line 235 of file messenger.cpp.

References f_cluckd, and cluck_daemon::cluckd::set_my_ip_address().

◆ stop()

void cluck_daemon::messenger::stop ( bool  quitting)
virtual

This STOP and QUITTING messages are currently managed through this overridden virtual function.

Parameters
[in]quittingWhether STOP (false) or QUITTING (true) was received.

Definition at line 260 of file messenger.cpp.

References f_cluckd, and cluck_daemon::cluckd::stop().

Member Data Documentation

◆ f_cluckd

cluckd* cluck_daemon::messenger::f_cluckd = nullptr
private

Definition at line 59 of file messenger.h.

Referenced by ready(), and stop().


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

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.