MXS-2220 Move most remaining functions inside class
Most of the ones still remaining outside are special cases. Also, removed locking from status manipulation functions as it has not been required for quite some time.
This commit is contained in:
parent
d5c78eb31f
commit
1c647f3753
@ -287,7 +287,6 @@ public:
|
||||
/**
|
||||
* @brief Check if a server points to a local MaxScale service
|
||||
*
|
||||
* @param server Server to check
|
||||
* @return True if the server points to a local MaxScale service
|
||||
*/
|
||||
bool is_mxs_service();
|
||||
@ -430,6 +429,44 @@ public:
|
||||
*/
|
||||
static int server_find_by_unique_names(char** server_names, int size, SERVER*** output);
|
||||
|
||||
/**
|
||||
* Convert the current server status flags to a string.
|
||||
*
|
||||
* @param server The server to return the status for
|
||||
* @return A string representation of the status
|
||||
*/
|
||||
std::string status_string() const;
|
||||
|
||||
/**
|
||||
* Convert a set of server status flags to a string.
|
||||
*
|
||||
* @param flags Status flags
|
||||
* @return A string representation of the status flags
|
||||
*/
|
||||
static std::string status_to_string(uint64_t flags);
|
||||
|
||||
/**
|
||||
* Convert a status string to a status bit. Only converts one status element.
|
||||
*
|
||||
* @param str String representation
|
||||
* @return bit value or 0 on error
|
||||
*/
|
||||
static uint64_t status_from_string(const char* str);
|
||||
|
||||
/**
|
||||
* Set a status bit in the server without locking
|
||||
*
|
||||
* @param bit The bit to set for the server
|
||||
*/
|
||||
void set_status(uint64_t bit);
|
||||
|
||||
/**
|
||||
* Clear a status bit in the server without locking
|
||||
*
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void clear_status(uint64_t bit);
|
||||
|
||||
protected:
|
||||
SERVER()
|
||||
{
|
||||
@ -448,21 +485,31 @@ private:
|
||||
*/
|
||||
void server_add_response_average(SERVER* server, double ave, int num_samples);
|
||||
|
||||
extern int server_free(SERVER* server);
|
||||
extern void server_clear_set_status_nolock(SERVER* server, uint64_t bits_to_clear, uint64_t bits_to_set);
|
||||
extern void server_set_status_nolock(SERVER* server, uint64_t bit);
|
||||
extern void server_clear_status_nolock(SERVER* server, uint64_t bit);
|
||||
extern void server_transfer_status(SERVER* dest_server, const SERVER* source_server);
|
||||
extern void server_update_address(SERVER* server, const char* address);
|
||||
extern uint64_t server_map_status(const char* str);
|
||||
|
||||
int server_response_time_num_samples(const SERVER* server);
|
||||
double server_response_time_average(const SERVER* server);
|
||||
|
||||
namespace maxscale
|
||||
{
|
||||
std::string server_status(uint64_t flags);
|
||||
std::string server_status(const SERVER*);
|
||||
bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
|
||||
/**
|
||||
* Set a status bit in the server. This should not be called from within a monitor. If the server is
|
||||
* monitored, only set the pending bit.
|
||||
*
|
||||
* @param bit The bit to set for the server
|
||||
* @param errmsg_out Error output
|
||||
*/
|
||||
bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
|
||||
/**
|
||||
* Clear a status bit in the server under a lock. This ensures synchronization
|
||||
* with the server monitor thread. Calling this inside the monitor will likely
|
||||
* cause a deadlock. If the server is monitored, only clear the pending bit.
|
||||
*
|
||||
* @param bit The bit to clear for the server
|
||||
* @param errmsg_out Error output
|
||||
*/
|
||||
bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||
|
||||
}
|
||||
|
@ -3760,7 +3760,7 @@ int create_new_server(CONFIG_CONTEXT* obj)
|
||||
const char* disk_space_threshold = config_get_value(obj->parameters, CN_DISK_SPACE_THRESHOLD);
|
||||
if (disk_space_threshold)
|
||||
{
|
||||
if (!server->server_set_disk_space_threshold(disk_space_threshold))
|
||||
if (!server->set_disk_space_threshold(disk_space_threshold))
|
||||
{
|
||||
MXS_ERROR("Invalid value for '%s' for server %s: %s",
|
||||
CN_DISK_SPACE_THRESHOLD,
|
||||
|
@ -1295,7 +1295,7 @@ void printDCB(DCB* dcb)
|
||||
}
|
||||
if (dcb->server)
|
||||
{
|
||||
string statusname = mxs::server_status(dcb->server);
|
||||
string statusname = dcb->server->status_string();
|
||||
if (!statusname.empty())
|
||||
{
|
||||
printf("\tServer status: %s\n", statusname.c_str());
|
||||
@ -1405,7 +1405,7 @@ void dprintOneDCB(DCB* pdcb, DCB* dcb)
|
||||
}
|
||||
if (dcb->server)
|
||||
{
|
||||
string statusname = mxs::server_status(dcb->server);
|
||||
string statusname = dcb->server->status_string();
|
||||
if (!statusname.empty())
|
||||
{
|
||||
dcb_printf(pdcb, "\tServer status: %s\n", statusname.c_str());
|
||||
@ -1568,7 +1568,7 @@ void dprintDCB(DCB* pdcb, DCB* dcb)
|
||||
}
|
||||
if (dcb->server)
|
||||
{
|
||||
string statusname = mxs::server_status(dcb->server);
|
||||
string statusname = dcb->server->status_string();
|
||||
if (!statusname.c_str())
|
||||
{
|
||||
dcb_printf(pdcb, "\tServer status: %s\n", statusname.c_str());
|
||||
|
@ -175,6 +175,14 @@ public:
|
||||
*/
|
||||
static Server* create_test_server();
|
||||
|
||||
/**
|
||||
* Deallocate the specified server
|
||||
*
|
||||
* @param server The server to deallocate
|
||||
* @return Returns true if the server was freed
|
||||
*/
|
||||
static void server_free(Server* server);
|
||||
|
||||
/**
|
||||
* @brief Find a server with the specified name
|
||||
*
|
||||
@ -289,7 +297,7 @@ public:
|
||||
*
|
||||
* @return True, if the provided string is valid and the threshold could be set.
|
||||
*/
|
||||
bool server_set_disk_space_threshold(const char* disk_space_threshold);
|
||||
bool set_disk_space_threshold(const char* disk_space_threshold);
|
||||
|
||||
/**
|
||||
* Print all servers
|
||||
@ -367,8 +375,6 @@ private:
|
||||
maxbase::EMAverage m_response_time; /**< Response time calculations for this server */
|
||||
};
|
||||
|
||||
void server_free(Server* server);
|
||||
|
||||
/**
|
||||
* @brief Convert a server to JSON format
|
||||
*
|
||||
|
@ -1541,8 +1541,8 @@ void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t
|
||||
|
||||
static void mon_log_state_change(MXS_MONITORED_SERVER* ptr)
|
||||
{
|
||||
string prev = mxs::server_status(ptr->mon_prev_status);
|
||||
string next = mxs::server_status(ptr->server);
|
||||
string prev = SERVER::status_to_string(ptr->mon_prev_status);
|
||||
string next = ptr->server->status_string();
|
||||
MXS_NOTICE("Server changed state: %s[%s:%u]: %s. [%s] -> [%s]",
|
||||
ptr->server->name(), ptr->server->address, ptr->server->port,
|
||||
mon_get_event_name(ptr),
|
||||
@ -1706,11 +1706,11 @@ void monitor_check_maintenance_requests(MXS_MONITOR* monitor)
|
||||
if (admin_msg == SERVER::MAINTENANCE_ON)
|
||||
{
|
||||
// TODO: Change to writing MONITORED_SERVER->pending status instead once cleanup done.
|
||||
server_set_status_nolock(ptr->server, SERVER_MAINT);
|
||||
ptr->server->set_status(SERVER_MAINT);
|
||||
}
|
||||
else if (admin_msg == SERVER::MAINTENANCE_OFF)
|
||||
{
|
||||
server_clear_status_nolock(ptr->server, SERVER_MAINT);
|
||||
ptr->server->clear_status(SERVER_MAINT);
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
@ -2104,7 +2104,7 @@ static const char* process_server(MXS_MONITOR* monitor, const char* data, const
|
||||
|
||||
uint64_t status = maxscale::get_byteN(sptr, MMB_LEN_SERVER_STATUS);
|
||||
db->mon_prev_status = status;
|
||||
server_set_status_nolock(db->server, status);
|
||||
db->server->set_status(status);
|
||||
monitor_set_pending_status(db, status);
|
||||
break;
|
||||
}
|
||||
@ -2852,7 +2852,7 @@ void MonitorInstanceSimple::tick()
|
||||
// The current status is still in pMs->pending_status.
|
||||
MXS_DEBUG("Backend server [%s]:%d state : %s",
|
||||
pMs->server->address, pMs->server->port,
|
||||
mxs::server_status(pMs->pending_status).c_str());
|
||||
SERVER::status_to_string(pMs->pending_status).c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -767,7 +767,7 @@ HttpResponse cb_delete_user(const HttpRequest& request)
|
||||
HttpResponse cb_set_server(const HttpRequest& request)
|
||||
{
|
||||
SERVER* server = Server::find_by_unique_name(request.uri_part(1));
|
||||
int opt = server_map_status(request.get_option(CN_STATE).c_str());
|
||||
int opt = SERVER::status_from_string(request.get_option(CN_STATE).c_str());
|
||||
|
||||
if (opt)
|
||||
{
|
||||
@ -791,7 +791,7 @@ HttpResponse cb_set_server(const HttpRequest& request)
|
||||
HttpResponse cb_clear_server(const HttpRequest& request)
|
||||
{
|
||||
SERVER* server = Server::find_by_unique_name(request.uri_part(1));
|
||||
int opt = server_map_status(request.get_option(CN_STATE).c_str());
|
||||
int opt = SERVER::status_from_string(request.get_option(CN_STATE).c_str());
|
||||
|
||||
if (opt)
|
||||
{
|
||||
|
@ -262,13 +262,7 @@ Server* Server::create_test_server()
|
||||
return new Server(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocate the specified server
|
||||
*
|
||||
* @param server The service to deallocate
|
||||
* @return Returns true if the server was freed
|
||||
*/
|
||||
void server_free(Server* server)
|
||||
void Server::server_free(Server* server)
|
||||
{
|
||||
mxb_assert(server);
|
||||
|
||||
@ -481,7 +475,7 @@ void Server::print_to_dcb(DCB* dcb) const
|
||||
|
||||
dcb_printf(dcb, "Server %p (%s)\n", server, server->name());
|
||||
dcb_printf(dcb, "\tServer: %s\n", server->address);
|
||||
string stat = mxs::server_status(server);
|
||||
string stat = status_string();
|
||||
dcb_printf(dcb, "\tStatus: %s\n", stat.c_str());
|
||||
dcb_printf(dcb, "\tProtocol: %s\n", server->m_settings.protocol.c_str());
|
||||
dcb_printf(dcb, "\tPort: %d\n", server->port);
|
||||
@ -603,7 +597,7 @@ void Server::dListServers(DCB* dcb)
|
||||
{
|
||||
if (server->is_active)
|
||||
{
|
||||
string stat = mxs::server_status(server);
|
||||
string stat = server->status_string();
|
||||
dcb_printf(dcb,
|
||||
"%-18s | %-15s | %5d | %11d | %s\n",
|
||||
server->name(),
|
||||
@ -618,13 +612,7 @@ void Server::dListServers(DCB* dcb)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a set of server status flags to a string.
|
||||
*
|
||||
* @param flags Status flags
|
||||
* @return A string representation of the status flags
|
||||
*/
|
||||
string mxs::server_status(uint64_t flags)
|
||||
string SERVER::status_to_string(uint64_t flags)
|
||||
{
|
||||
string result;
|
||||
string separator;
|
||||
@ -684,79 +672,25 @@ string mxs::server_status(uint64_t flags)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the current server status flags to a string.
|
||||
*
|
||||
* @param server The server to return the status for
|
||||
* @return A string representation of the status
|
||||
*/
|
||||
string mxs::server_status(const SERVER* server)
|
||||
string SERVER::status_string() const
|
||||
{
|
||||
mxb_assert(server);
|
||||
return mxs::server_status(server->status);
|
||||
return status_to_string(status);
|
||||
}
|
||||
/**
|
||||
* Set a status bit in the server without locking
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to set for the server
|
||||
*/
|
||||
void server_set_status_nolock(SERVER* server, uint64_t bit)
|
||||
|
||||
void SERVER::set_status(uint64_t bit)
|
||||
{
|
||||
server->status |= bit;
|
||||
status |= bit;
|
||||
|
||||
/** clear error logged flag before the next failure */
|
||||
if (server->is_master())
|
||||
if (is_master())
|
||||
{
|
||||
server->master_err_is_logged = false;
|
||||
master_err_is_logged = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears and sets specified bits.
|
||||
*
|
||||
* @attention This function does no locking
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bits_to_clear The bits to clear for the server.
|
||||
* @param bits_to_set The bits to set for the server.
|
||||
*/
|
||||
void server_clear_set_status_nolock(SERVER* server, uint64_t bits_to_clear, uint64_t bits_to_set)
|
||||
void SERVER::clear_status(uint64_t bit)
|
||||
{
|
||||
/** clear error logged flag before the next failure */
|
||||
if ((bits_to_set & SERVER_MASTER) && ((server->status & SERVER_MASTER) == 0))
|
||||
{
|
||||
server->master_err_is_logged = false;
|
||||
}
|
||||
|
||||
if ((server->status & bits_to_clear) != bits_to_set)
|
||||
{
|
||||
server->status = (server->status & ~bits_to_clear) | bits_to_set;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a status bit in the server without locking
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
void server_clear_status_nolock(SERVER* server, uint64_t bit)
|
||||
{
|
||||
server->status &= ~bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer status bitstring from one server to another
|
||||
*
|
||||
* @attention This function does no locking
|
||||
*
|
||||
* @param dest_server The server to be updated
|
||||
* @param source_server The server to provide the new bit string
|
||||
*/
|
||||
void server_transfer_status(SERVER* dest_server, const SERVER* source_server)
|
||||
{
|
||||
dest_server->status = source_server->status;
|
||||
status &= ~bit;
|
||||
}
|
||||
|
||||
bool Server::set_monitor_user(const string& username)
|
||||
@ -847,7 +781,7 @@ std::unique_ptr<ResultSet> serverGetList()
|
||||
{
|
||||
if (server->server_is_active())
|
||||
{
|
||||
string stat = mxs::server_status(server);
|
||||
string stat = server->status_string();
|
||||
set->add_row({server->name(), server->address, std::to_string(server->port),
|
||||
std::to_string(server->stats.n_current), stat});
|
||||
}
|
||||
@ -883,34 +817,26 @@ void SERVER::update_extra_port(int new_port)
|
||||
mxb::atomic::store(&extra_port, new_port, mxb::atomic::RELAXED);
|
||||
}
|
||||
|
||||
static struct
|
||||
uint64_t SERVER::status_from_string(const char* str)
|
||||
{
|
||||
const char* str;
|
||||
uint64_t bit;
|
||||
} ServerBits[] =
|
||||
{
|
||||
{"running", SERVER_RUNNING },
|
||||
{"master", SERVER_MASTER },
|
||||
{"slave", SERVER_SLAVE },
|
||||
{"synced", SERVER_JOINED },
|
||||
{"ndb", SERVER_NDB },
|
||||
{"maintenance", SERVER_MAINT },
|
||||
{"maint", SERVER_MAINT },
|
||||
{"stale", SERVER_WAS_MASTER},
|
||||
{NULL, 0 }
|
||||
};
|
||||
static struct
|
||||
{
|
||||
const char* str;
|
||||
uint64_t bit;
|
||||
} ServerBits[] =
|
||||
{
|
||||
{"running", SERVER_RUNNING },
|
||||
{"master", SERVER_MASTER },
|
||||
{"slave", SERVER_SLAVE },
|
||||
{"synced", SERVER_JOINED },
|
||||
{"ndb", SERVER_NDB },
|
||||
{"maintenance", SERVER_MAINT },
|
||||
{"maint", SERVER_MAINT },
|
||||
{"stale", SERVER_WAS_MASTER},
|
||||
{NULL, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
* Map the server status bit
|
||||
*
|
||||
* @param str String representation
|
||||
* @return bit value or 0 on error
|
||||
*/
|
||||
uint64_t server_map_status(const char* str)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; ServerBits[i].str; i++)
|
||||
for (int i = 0; ServerBits[i].str; i++)
|
||||
{
|
||||
if (!strcasecmp(str, ServerBits[i].str))
|
||||
{
|
||||
@ -1011,29 +937,17 @@ bool Server::serialize() const
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a status bit in the server under a lock. This ensures synchronization
|
||||
* with the server monitor thread. Calling this inside the monitor will likely
|
||||
* cause a deadlock. If the server is monitored, only set the pending bit.
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to set for the server
|
||||
*/
|
||||
bool mxs::server_set_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
{
|
||||
Server* server = static_cast<Server*>(srv);
|
||||
bool written = false;
|
||||
/* First check if the server is monitored. This isn't done under a lock
|
||||
* but the race condition cannot cause significant harm. Monitors are never
|
||||
* freed so the pointer stays valid. */
|
||||
MXS_MONITOR* mon = monitor_server_in_use(server);
|
||||
std::lock_guard<std::mutex> guard(server->m_lock);
|
||||
|
||||
MXS_MONITOR* mon = monitor_server_in_use(srv);
|
||||
if (mon && mon->state == MONITOR_STATE_RUNNING)
|
||||
{
|
||||
/* This server is monitored, in which case modifying any other status bit than Maintenance is
|
||||
* disallowed. Maintenance is set/cleared using a special variable which the monitor reads when
|
||||
* starting the next update cycle. Also set a flag so the next loop happens sooner. */
|
||||
* disallowed. */
|
||||
if (bit & ~SERVER_MAINT)
|
||||
{
|
||||
MXS_ERROR(ERR_CANNOT_MODIFY);
|
||||
@ -1044,43 +958,36 @@ bool mxs::server_set_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(&server->maint_request, SERVER::MAINTENANCE_ON);
|
||||
/* Maintenance is set/cleared using a special variable which the monitor reads when
|
||||
* starting the next update cycle. */
|
||||
int previous_request = atomic_exchange_int(&srv->maint_request, SERVER::MAINTENANCE_ON);
|
||||
written = true;
|
||||
// Warn if the previous request hasn't been read.
|
||||
if (previous_request != SERVER::MAINTENANCE_NO_CHANGE)
|
||||
{
|
||||
MXS_WARNING(WRN_REQUEST_OVERWRITTEN);
|
||||
}
|
||||
// Also set a flag so the next loop happens sooner.
|
||||
atomic_store_int(&mon->check_maintenance_flag, SERVER::MAINTENANCE_FLAG_CHECK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the bit directly */
|
||||
server_set_status_nolock(server, bit);
|
||||
srv->set_status(bit);
|
||||
written = true;
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
/**
|
||||
* Clear a status bit in the server under a lock. This ensures synchronization
|
||||
* with the server monitor thread. Calling this inside the monitor will likely
|
||||
* cause a deadlock. If the server is monitored, only clear the pending bit.
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param bit The bit to clear for the server
|
||||
*/
|
||||
|
||||
bool mxs::server_clear_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
{
|
||||
Server* server = static_cast<Server*>(srv);
|
||||
// See server_set_status().
|
||||
bool written = false;
|
||||
MXS_MONITOR* mon = monitor_server_in_use(server);
|
||||
std::lock_guard<std::mutex> guard(server->m_lock);
|
||||
|
||||
MXS_MONITOR* mon = monitor_server_in_use(srv);
|
||||
if (mon && mon->state == MONITOR_STATE_RUNNING)
|
||||
{
|
||||
// See server_set_status().
|
||||
if (bit & ~SERVER_MAINT)
|
||||
{
|
||||
MXS_ERROR(ERR_CANNOT_MODIFY);
|
||||
@ -1092,7 +999,7 @@ bool mxs::server_clear_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(&server->maint_request, SERVER::MAINTENANCE_OFF);
|
||||
int previous_request = atomic_exchange_int(&srv->maint_request, SERVER::MAINTENANCE_OFF);
|
||||
written = true;
|
||||
if (previous_request != SERVER::MAINTENANCE_NO_CHANGE)
|
||||
{
|
||||
@ -1104,7 +1011,7 @@ bool mxs::server_clear_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
else
|
||||
{
|
||||
/* Clear bit directly */
|
||||
server_clear_status_nolock(server, bit);
|
||||
srv->clear_status(bit);
|
||||
written = true;
|
||||
}
|
||||
|
||||
@ -1158,7 +1065,7 @@ json_t* Server::server_json_attributes(const Server* server)
|
||||
json_object_set_new(attr, CN_PARAMETERS, params);
|
||||
|
||||
/** Store general information about the server state */
|
||||
string stat = mxs::server_status(server);
|
||||
string stat = server->status_string();
|
||||
json_object_set_new(attr, CN_STATE, json_string(stat.c_str()));
|
||||
|
||||
json_object_set_new(attr, CN_VERSION_STRING, json_string(server->version_string().c_str()));
|
||||
@ -1258,7 +1165,7 @@ json_t* Server::server_list_to_json(const char* host)
|
||||
return mxs_json_resource(host, MXS_JSON_API_SERVERS, data);
|
||||
}
|
||||
|
||||
bool Server::server_set_disk_space_threshold(const char* disk_space_threshold)
|
||||
bool Server::set_disk_space_threshold(const char* disk_space_threshold)
|
||||
{
|
||||
MxsDiskSpaceThreshold dst;
|
||||
bool rv = config_parse_disk_space_threshold(&dst, disk_space_threshold);
|
||||
|
@ -59,7 +59,6 @@ static int test1()
|
||||
{
|
||||
int result;
|
||||
std::string status;
|
||||
using mxs::server_status;
|
||||
|
||||
/* Server tests */
|
||||
fprintf(stderr, "testserver : creating server called MyServer");
|
||||
@ -77,20 +76,20 @@ static int test1()
|
||||
"Should not find non-existent unique name.");
|
||||
mxb_assert_message(server == Server::find_by_unique_name("uniquename"), "Should find by unique name.");
|
||||
fprintf(stderr, "\t..done\nTesting Status Setting for Server.");
|
||||
status = server_status(server);
|
||||
status = server->status_string();
|
||||
mxb_assert_message(status == "Running", "Status of Server should be Running by default.");
|
||||
server_set_status_nolock(server, SERVER_MASTER);
|
||||
status = server_status(server);
|
||||
server->set_status(SERVER_MASTER);
|
||||
status = server->status_string();
|
||||
mxb_assert_message(status == "Master, Running", "Should find correct status.");
|
||||
server_clear_status_nolock(server, SERVER_MASTER);
|
||||
status = server_status(server);
|
||||
server->clear_status(SERVER_MASTER);
|
||||
status = server->status_string();
|
||||
mxb_assert_message(status == "Running",
|
||||
"Status of Server should be Running after master status cleared.");
|
||||
fprintf(stderr, "\t..done\nRun Prints for Server and all Servers.");
|
||||
server->printServer();
|
||||
Server::printAllServers();
|
||||
fprintf(stderr, "\t..done\nFreeing Server.");
|
||||
server_free((Server*)server);
|
||||
Server::server_free(server);
|
||||
fprintf(stderr, "\t..done\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ static void handle_error_response(DCB* dcb, GWBUF* buffer)
|
||||
dcb->server->address,
|
||||
dcb->server->port);
|
||||
|
||||
mxs::server_set_status(dcb->server, SERVER_MAINT, NULL);
|
||||
mxs::server_set_status(dcb->server, SERVER_MAINT);
|
||||
}
|
||||
else if (errcode == ER_ACCESS_DENIED_ERROR
|
||||
|| errcode == ER_DBACCESS_DENIED_ERROR
|
||||
@ -1214,7 +1214,7 @@ static int gw_MySQLWrite_backend(DCB* dcb, GWBUF* queue)
|
||||
dcb->server->name(),
|
||||
backend_protocol->protocol_auth_state == MXS_AUTH_STATE_HANDSHAKE_FAILED ?
|
||||
"handshake" : "authentication",
|
||||
mxs::server_status(dcb->server).c_str());
|
||||
dcb->server->status_string().c_str());
|
||||
}
|
||||
|
||||
gwbuf_free(queue);
|
||||
|
@ -2521,7 +2521,7 @@ static void set_server(DCB* dcb, Server* server, char* bit)
|
||||
{
|
||||
unsigned int bitvalue;
|
||||
|
||||
if ((bitvalue = server_map_status(bit)) != 0)
|
||||
if ((bitvalue = SERVER::status_from_string(bit)) != 0)
|
||||
{
|
||||
std::string errmsg;
|
||||
if (!mxs::server_set_status(server, bitvalue, &errmsg))
|
||||
@ -2547,7 +2547,7 @@ static void clear_server(DCB* dcb, Server* server, char* bit)
|
||||
{
|
||||
unsigned int bitvalue;
|
||||
|
||||
if ((bitvalue = server_map_status(bit)) != 0)
|
||||
if ((bitvalue = SERVER::status_from_string(bit)) != 0)
|
||||
{
|
||||
std::string errmsg;
|
||||
if (!mxs::server_clear_status(server, bitvalue, &errmsg))
|
||||
|
@ -320,7 +320,7 @@ void exec_set_server(DCB* dcb, MAXINFO_TREE* tree)
|
||||
|
||||
if (server)
|
||||
{
|
||||
int status = server_map_status(tree->right->value);
|
||||
int status = SERVER::status_from_string(tree->right->value);
|
||||
if (status != 0)
|
||||
{
|
||||
std::string errmsgs;
|
||||
@ -407,7 +407,7 @@ void exec_clear_server(DCB* dcb, MAXINFO_TREE* tree)
|
||||
|
||||
if (server)
|
||||
{
|
||||
int status = server_map_status(tree->right->value);
|
||||
int status = SERVER::status_from_string(tree->right->value);
|
||||
if (status != 0)
|
||||
{
|
||||
std::string errmsgs;
|
||||
|
@ -273,7 +273,7 @@ static void log_server_connections(select_criteria_t criteria, const PRWBackends
|
||||
b->server->stats.n_current,
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
break;
|
||||
|
||||
case LEAST_ROUTER_CONNECTIONS:
|
||||
@ -281,7 +281,7 @@ static void log_server_connections(select_criteria_t criteria, const PRWBackends
|
||||
b->connections,
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
break;
|
||||
|
||||
case LEAST_CURRENT_OPERATIONS:
|
||||
@ -289,7 +289,7 @@ static void log_server_connections(select_criteria_t criteria, const PRWBackends
|
||||
b->server->stats.n_current_ops,
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
break;
|
||||
|
||||
case LEAST_BEHIND_MASTER:
|
||||
@ -297,7 +297,7 @@ static void log_server_connections(select_criteria_t criteria, const PRWBackends
|
||||
b->server->rlag,
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
break;
|
||||
|
||||
case ADAPTIVE_ROUTING:
|
||||
@ -309,7 +309,7 @@ static void log_server_connections(select_criteria_t criteria, const PRWBackends
|
||||
os.str().c_str(),
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -116,7 +116,7 @@ bool connect_backend_servers(SSRBackendList& backends, MXS_SESSION* session)
|
||||
b->server->stats.n_current,
|
||||
b->server->address,
|
||||
b->server->port,
|
||||
mxs::server_status(b->server).c_str());
|
||||
b->server->status_string().c_str());
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -170,7 +170,7 @@ bool connect_backend_servers(SSRBackendList& backends, MXS_SESSION* session)
|
||||
if ((*it)->in_use())
|
||||
{
|
||||
MXS_INFO("Connected %s in \t%s:%d",
|
||||
mxs::server_status(b->server).c_str(),
|
||||
b->server->status_string().c_str(),
|
||||
b->server->address,
|
||||
b->server->port);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user