MXS-2273 Move constants to more appropriate locations
Constants now used in the context of MXS_MONITORED_SERVER or Monitor are now moved from SERVER to MXS_MONITORED_SERVER or Monitor, respectively.
This commit is contained in:
@ -1588,20 +1588,21 @@ void monitor_check_maintenance_requests(Monitor* monitor)
|
||||
{
|
||||
/* In theory, the admin may be modifying the server maintenance status during this function. The overall
|
||||
* maintenance flag should be read-written atomically to prevent missing a value. */
|
||||
int flags_changed = atomic_exchange_int(&monitor->m_check_maintenance_flag,
|
||||
SERVER::MAINTENANCE_FLAG_NOCHECK);
|
||||
if (flags_changed != SERVER::MAINTENANCE_FLAG_NOCHECK)
|
||||
int flags_changed = atomic_exchange_int(&monitor->check_maintenance_flag,
|
||||
Monitor::MAINTENANCE_FLAG_NOCHECK);
|
||||
if (flags_changed != Monitor::MAINTENANCE_FLAG_NOCHECK)
|
||||
{
|
||||
for (auto ptr : monitor->m_servers)
|
||||
{
|
||||
// The only server status bit the admin may change is the [Maintenance] bit.
|
||||
int admin_msg = atomic_exchange_int(&ptr->maint_request, SERVER::MAINTENANCE_NO_CHANGE);
|
||||
if (admin_msg == SERVER::MAINTENANCE_ON)
|
||||
int admin_msg = atomic_exchange_int(&ptr->maint_request,
|
||||
MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE);
|
||||
if (admin_msg == MXS_MONITORED_SERVER::MAINTENANCE_ON)
|
||||
{
|
||||
// TODO: Change to writing MONITORED_SERVER->pending status instead once cleanup done.
|
||||
ptr->server->set_status(SERVER_MAINT);
|
||||
}
|
||||
else if (admin_msg == SERVER::MAINTENANCE_OFF)
|
||||
else if (admin_msg == MXS_MONITORED_SERVER::MAINTENANCE_OFF)
|
||||
{
|
||||
ptr->server->clear_status(SERVER_MAINT);
|
||||
}
|
||||
@ -2386,15 +2387,16 @@ bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
{
|
||||
/* Maintenance is set/cleared using a special variable which the monitor reads when
|
||||
* starting the next update cycle. */
|
||||
int previous_request = atomic_exchange_int(&msrv->maint_request, SERVER::MAINTENANCE_ON);
|
||||
int previous_request = atomic_exchange_int(&msrv->maint_request,
|
||||
MXS_MONITORED_SERVER::MAINTENANCE_ON);
|
||||
written = true;
|
||||
// Warn if the previous request hasn't been read.
|
||||
if (previous_request != SERVER::MAINTENANCE_NO_CHANGE)
|
||||
if (previous_request != MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE)
|
||||
{
|
||||
MXS_WARNING(WRN_REQUEST_OVERWRITTEN);
|
||||
}
|
||||
// Also set a flag so the next loop happens sooner.
|
||||
atomic_store_int(&this->check_maintenance_flag, SERVER::MAINTENANCE_FLAG_CHECK);
|
||||
atomic_store_int(&this->check_maintenance_flag, Monitor::MAINTENANCE_FLAG_CHECK);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2440,13 +2442,14 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
else if (bit & SERVER_MAINT)
|
||||
{
|
||||
// Warn if the previous request hasn't been read.
|
||||
int previous_request = atomic_exchange_int(&msrv->maint_request, SERVER::MAINTENANCE_OFF);
|
||||
int previous_request = atomic_exchange_int(&msrv->maint_request,
|
||||
MXS_MONITORED_SERVER::MAINTENANCE_OFF);
|
||||
written = true;
|
||||
if (previous_request != SERVER::MAINTENANCE_NO_CHANGE)
|
||||
if (previous_request != MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE)
|
||||
{
|
||||
MXS_WARNING(WRN_REQUEST_OVERWRITTEN);
|
||||
}
|
||||
atomic_store_int(&this->check_maintenance_flag, SERVER::MAINTENANCE_FLAG_CHECK);
|
||||
atomic_store_int(&this->check_maintenance_flag, Monitor::MAINTENANCE_FLAG_CHECK);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2917,7 +2920,7 @@ bool MonitorWorker::call_run_one_tick(Worker::Call::action_t action)
|
||||
// Enough time has passed,
|
||||
if ((now - m_loop_called > m_settings.interval)
|
||||
// or maintenance flag is set,
|
||||
|| atomic_load_int(&m_check_maintenance_flag) == SERVER::MAINTENANCE_FLAG_CHECK
|
||||
|| atomic_load_int(&this->check_maintenance_flag) == Monitor::MAINTENANCE_FLAG_CHECK
|
||||
// or a monitor-specific condition is met.
|
||||
|| immediate_tick_required())
|
||||
{
|
||||
|
Reference in New Issue
Block a user