MXS-2220 Move server_is_active inside the class
This commit is contained in:
parent
764d9a4e75
commit
b16ee3a94e
@ -193,7 +193,7 @@ RRRouterSession* RRRouter::create_session(MXS_SESSION* session)
|
||||
SERVER_REF* sref;
|
||||
for (sref = m_service->dbref; sref != NULL; sref = sref->next)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(sref) && (backends.size() < m_max_backends))
|
||||
if (server_ref_is_active(sref) && (backends.size() < m_max_backends))
|
||||
{
|
||||
/* Connect to server */
|
||||
DCB* conn = dcb_connect(sref->server, session, sref->server->protocol().c_str());
|
||||
|
@ -236,7 +236,7 @@ public:
|
||||
*/
|
||||
inline bool is_active() const
|
||||
{
|
||||
return SERVER_REF_IS_ACTIVE(m_backend);
|
||||
return server_ref_is_active(m_backend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,6 +212,16 @@ public:
|
||||
*/
|
||||
void update_extra_port(int new_port);
|
||||
|
||||
/**
|
||||
* Is the server valid and active? TODO: Rename once "is_active" is moved to internal class.
|
||||
*
|
||||
* @return True, if server has not been removed from the runtime configuration.
|
||||
*/
|
||||
bool server_is_active() const
|
||||
{
|
||||
return is_active;
|
||||
}
|
||||
|
||||
protected:
|
||||
SERVER()
|
||||
{
|
||||
@ -241,17 +251,6 @@ private:
|
||||
// Bits providing general information
|
||||
#define SERVER_DISK_SPACE_EXHAUSTED (1 << 31) /**<< The disk space of the server is exhausted */
|
||||
|
||||
/**
|
||||
* Is the server valid and active?
|
||||
*
|
||||
* @param server The server
|
||||
* @return True, if server has not been removed from the runtime configuration.
|
||||
*/
|
||||
inline bool server_is_active(const SERVER* server)
|
||||
{
|
||||
return server->is_active;
|
||||
}
|
||||
|
||||
inline bool status_is_usable(uint64_t status)
|
||||
{
|
||||
return (status & (SERVER_RUNNING | SERVER_MAINT)) == SERVER_RUNNING;
|
||||
|
@ -59,8 +59,10 @@ typedef struct server_ref_t
|
||||
bool active; /**< Whether this reference is valid and in use*/
|
||||
} SERVER_REF;
|
||||
|
||||
/** Macro to check whether a SERVER_REF is active */
|
||||
#define SERVER_REF_IS_ACTIVE(ref) (ref->active && server_is_active(ref->server))
|
||||
inline bool server_ref_is_active(const SERVER_REF* ref)
|
||||
{
|
||||
return ref->active && ref->server->server_is_active();
|
||||
}
|
||||
|
||||
#define SERVICE_MAX_RETRY_INTERVAL 3600 /*< The maximum interval between service start retries */
|
||||
|
||||
|
@ -499,7 +499,7 @@ void Server::dprintServer(DCB* dcb, const Server* srv)
|
||||
void Server::print_to_dcb(DCB* dcb) const
|
||||
{
|
||||
const Server* server = this;
|
||||
if (!server_is_active(server))
|
||||
if (!server->server_is_active())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -870,7 +870,7 @@ std::unique_ptr<ResultSet> serverGetList()
|
||||
Guard guard(this_unit.all_servers_lock);
|
||||
for (Server* server : this_unit.all_servers)
|
||||
{
|
||||
if (server_is_active(server))
|
||||
if (server->server_is_active())
|
||||
{
|
||||
string stat = mxs::server_status(server);
|
||||
set->add_row({server->name(), server->address, std::to_string(server->port),
|
||||
@ -1274,7 +1274,7 @@ json_t* server_list_to_json(const char* host)
|
||||
Guard guard(this_unit.all_servers_lock);
|
||||
for (Server* server : this_unit.all_servers)
|
||||
{
|
||||
if (server_is_active(server))
|
||||
if (server->server_is_active())
|
||||
{
|
||||
json_array_append_new(data, server_to_json_data(server, host));
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ void dprintService(DCB* dcb, SERVICE* svc)
|
||||
dcb_printf(dcb, "\tBackend databases:\n");
|
||||
while (server)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(server))
|
||||
if (server_ref_is_active(server))
|
||||
{
|
||||
dcb_printf(dcb,
|
||||
"\t\t[%s]:%d Protocol: %s Name: %s\n",
|
||||
@ -974,7 +974,7 @@ void dListServices(DCB* dcb)
|
||||
bool first = true;
|
||||
while (server_ref)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(server_ref))
|
||||
if (server_ref_is_active(server_ref))
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
@ -1479,7 +1479,7 @@ bool Service::dump_config(const char* filename) const
|
||||
|
||||
for (SERVER_REF* db = dbref; db; db = db->next)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(db))
|
||||
if (server_ref_is_active(db))
|
||||
{
|
||||
dprintf(file, "%s%s", sep, db->server->name());
|
||||
sep = ",";
|
||||
@ -1617,7 +1617,7 @@ static inline bool have_active_servers(const SERVICE* service)
|
||||
{
|
||||
for (SERVER_REF* ref = service->dbref; ref; ref = ref->next)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(ref))
|
||||
if (server_ref_is_active(ref))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1707,7 +1707,7 @@ json_t* Service::json_relationships(const char* host) const
|
||||
|
||||
for (SERVER_REF* ref = dbref; ref; ref = ref->next)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(ref))
|
||||
if (server_ref_is_active(ref))
|
||||
{
|
||||
mxs_json_add_relation(servers, ref->server->name(), CN_SERVERS);
|
||||
}
|
||||
@ -1813,7 +1813,7 @@ json_t* service_relations_to_server(const SERVER* server, const char* host)
|
||||
|
||||
for (SERVER_REF* ref = service->dbref; ref; ref = ref->next)
|
||||
{
|
||||
if (ref->server == server && SERVER_REF_IS_ACTIVE(ref))
|
||||
if (ref->server == server && server_ref_is_active(ref))
|
||||
{
|
||||
names.push_back(service->name);
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ int gssapi_auth_load_users(Listener* listener)
|
||||
|
||||
for (SERVER_REF* servers = listener->service()->dbref; servers; servers = servers->next)
|
||||
{
|
||||
if (!SERVER_REF_IS_ACTIVE(servers) || !server_is_active(servers->server))
|
||||
if (!server_ref_is_active(servers) || !servers->server->server_is_active())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1220,7 +1220,7 @@ static int get_users(Listener* listener, bool skip_local)
|
||||
|
||||
for (server = service->dbref; !maxscale_is_shutting_down() && server; server = server->next)
|
||||
{
|
||||
if (!SERVER_REF_IS_ACTIVE(server) || !server_is_active(server->server)
|
||||
if (!server_ref_is_active(server) || !server->server->server_is_active()
|
||||
|| (skip_local && server_is_mxs_service(server->server))
|
||||
|| !server_is_running(server->server))
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ HintRouterSession* HintRouter::newSession(MXS_SESSION* pSession)
|
||||
/* Go through the server references, find master and slaves */
|
||||
for (SERVER_REF* pSref = pSession->service->dbref; pSref; pSref = pSref->next)
|
||||
{
|
||||
if (SERVER_REF_IS_ACTIVE(pSref))
|
||||
if (server_ref_is_active(pSref))
|
||||
{
|
||||
if (server_is_master(pSref->server))
|
||||
{
|
||||
|
@ -315,7 +315,7 @@ static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session
|
||||
*/
|
||||
for (SERVER_REF* ref = inst->service->dbref; ref; ref = ref->next)
|
||||
{
|
||||
if (!SERVER_REF_IS_ACTIVE(ref) || server_is_in_maint(ref->server))
|
||||
if (!server_ref_is_active(ref) || server_is_in_maint(ref->server))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user