MXS-2178 Reduce accessbility of workarounds
Some rearrangements to ensure that what should be private can be kept private. - WatchdogNotifier made a friend. - WatchdogWorkaround defined in RoutingWorker and made a friend. - mxs::WatchdogWorker defined with 'using'.
This commit is contained in:
@ -433,67 +433,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void set_watchdog_interval(uint64_t microseconds);
|
static void set_watchdog_interval(uint64_t microseconds);
|
||||||
|
|
||||||
/**
|
class WatchdogWorkaround;
|
||||||
* The internal watchdog interval.
|
friend WatchdogWorkaround;
|
||||||
*
|
|
||||||
* @return The interval in seconds, 0 if not enabled.
|
|
||||||
*/
|
|
||||||
static uint32_t get_internal_watchdog_interval()
|
|
||||||
{
|
|
||||||
return s_watchdog_interval.secs();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Public now ONLY so that it can be used in the workaround for the
|
|
||||||
// TODO "long max[admin|ctrl] operations may trigger the watchdog" problem.
|
|
||||||
void check_systemd_watchdog();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn on the watchdog workaround for this worker.
|
|
||||||
*
|
|
||||||
* @see mxs::WatchdogWorkaround
|
|
||||||
*/
|
|
||||||
void start_watchdog_workaround();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn off the watchdog workaround for this worker.
|
|
||||||
*
|
|
||||||
* @see mxs::WatchdogWorkaround
|
|
||||||
*/
|
|
||||||
void stop_watchdog_workaround();
|
|
||||||
|
|
||||||
private:
|
|
||||||
class WatchdogNotifier;
|
|
||||||
|
|
||||||
const int m_id; /*< The id of the worker. */
|
|
||||||
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
|
||||||
* should contain sessions exclusive to this
|
|
||||||
* worker and not e.g. listener sessions. For now,
|
|
||||||
* it's up to the protocol to decide whether a new
|
|
||||||
* session is added to the map. */
|
|
||||||
Zombies m_zombies; /*< DCBs to be deleted. */
|
|
||||||
LocalData m_local_data; /*< Data local to this worker */
|
|
||||||
DataDeleters m_data_deleters; /*< Delete functions for the local data */
|
|
||||||
|
|
||||||
RoutingWorker();
|
|
||||||
virtual ~RoutingWorker();
|
|
||||||
|
|
||||||
static RoutingWorker* create(int epoll_listener_fd);
|
|
||||||
|
|
||||||
bool pre_run(); // override
|
|
||||||
void post_run(); // override
|
|
||||||
void epoll_tick(); // override
|
|
||||||
|
|
||||||
void delete_zombies();
|
|
||||||
//void check_systemd_watchdog();
|
|
||||||
|
|
||||||
static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
|
||||||
uint32_t handle_epoll_events(uint32_t events);
|
|
||||||
|
|
||||||
static maxbase::Duration s_watchdog_interval; /*< Duration between notifications, if any. */
|
|
||||||
static maxbase::TimePoint s_watchdog_next_check; /*< Next time to notify systemd. */
|
|
||||||
std::atomic<bool> m_alive; /*< Set to true in epoll_tick(), false on notification. */
|
|
||||||
WatchdogNotifier* m_pWatchdog_notifier; /*< Watchdog notifier, if systemd enabled. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class WatchdogWorkaround
|
* @class WatchdogWorkaround
|
||||||
@ -544,6 +485,45 @@ private:
|
|||||||
RoutingWorker* m_pWorker;
|
RoutingWorker* m_pWorker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
class WatchdogNotifier;
|
||||||
|
friend WatchdogNotifier;
|
||||||
|
|
||||||
|
const int m_id; /*< The id of the worker. */
|
||||||
|
SessionsById m_sessions; /*< A mapping of session_id->MXS_SESSION. The map
|
||||||
|
* should contain sessions exclusive to this
|
||||||
|
* worker and not e.g. listener sessions. For now,
|
||||||
|
* it's up to the protocol to decide whether a new
|
||||||
|
* session is added to the map. */
|
||||||
|
Zombies m_zombies; /*< DCBs to be deleted. */
|
||||||
|
LocalData m_local_data; /*< Data local to this worker */
|
||||||
|
DataDeleters m_data_deleters; /*< Delete functions for the local data */
|
||||||
|
|
||||||
|
RoutingWorker();
|
||||||
|
virtual ~RoutingWorker();
|
||||||
|
|
||||||
|
static RoutingWorker* create(int epoll_listener_fd);
|
||||||
|
|
||||||
|
bool pre_run(); // override
|
||||||
|
void post_run(); // override
|
||||||
|
void epoll_tick(); // override
|
||||||
|
|
||||||
|
void delete_zombies();
|
||||||
|
void check_systemd_watchdog();
|
||||||
|
void start_watchdog_workaround();
|
||||||
|
void stop_watchdog_workaround();
|
||||||
|
|
||||||
|
static uint32_t epoll_instance_handler(MXB_POLL_DATA* data, MXB_WORKER* worker, uint32_t events);
|
||||||
|
uint32_t handle_epoll_events(uint32_t events);
|
||||||
|
|
||||||
|
static maxbase::Duration s_watchdog_interval; /*< Duration between notifications, if any. */
|
||||||
|
static maxbase::TimePoint s_watchdog_next_check; /*< Next time to notify systemd. */
|
||||||
|
std::atomic<bool> m_alive; /*< Set to true in epoll_tick(), false on notification. */
|
||||||
|
WatchdogNotifier* m_pWatchdog_notifier; /*< Watchdog notifier, if systemd enabled. */
|
||||||
|
};
|
||||||
|
|
||||||
|
using WatchdogWorkaround = RoutingWorker::WatchdogWorkaround;
|
||||||
|
|
||||||
// Data local to a routing worker
|
// Data local to a routing worker
|
||||||
template<class T>
|
template<class T>
|
||||||
class rworker_local
|
class rworker_local
|
||||||
|
@ -183,7 +183,7 @@ public:
|
|||||||
, m_terminate(false)
|
, m_terminate(false)
|
||||||
{
|
{
|
||||||
m_thread = std::thread([this] {
|
m_thread = std::thread([this] {
|
||||||
uint32_t interval = mxs::RoutingWorker::get_internal_watchdog_interval();
|
uint32_t interval = mxs::RoutingWorker::s_watchdog_interval.secs();
|
||||||
timespec timeout = { interval, 0 };
|
timespec timeout = { interval, 0 };
|
||||||
|
|
||||||
while (!mxb::atomic::load(&m_terminate, mxb::atomic::RELAXED))
|
while (!mxb::atomic::load(&m_terminate, mxb::atomic::RELAXED))
|
||||||
|
Reference in New Issue
Block a user