mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Consolidate some code
This commit is contained in:
@@ -148,21 +148,8 @@ do_cluster_show(void)
|
|||||||
|
|
||||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) == CONNECTION_OK)
|
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
cell->node_info->node_status = NODE_STATUS_UP;
|
|
||||||
cell->node_info->recovery_type = get_recovery_type(cell->node_info->conn);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* check if node is reachable, but just not letting us in */
|
|
||||||
if (is_server_available_quiet(cell->node_info->conninfo))
|
|
||||||
cell->node_info->node_status = NODE_STATUS_REJECTED;
|
|
||||||
else
|
|
||||||
cell->node_info->node_status = NODE_STATUS_DOWN;
|
|
||||||
|
|
||||||
cell->node_info->recovery_type = RECTYPE_UNKNOWN;
|
|
||||||
|
|
||||||
connection_error_found = true;
|
connection_error_found = true;
|
||||||
|
|
||||||
if (runtime_options.verbose)
|
if (runtime_options.verbose)
|
||||||
|
|||||||
@@ -144,13 +144,6 @@ do_daemon_status(void)
|
|||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
/* check if node is reachable, but just not letting us in */
|
|
||||||
if (is_server_available_quiet(cell->node_info->conninfo))
|
|
||||||
cell->node_info->node_status = NODE_STATUS_REJECTED;
|
|
||||||
else
|
|
||||||
cell->node_info->node_status = NODE_STATUS_DOWN;
|
|
||||||
|
|
||||||
cell->node_info->recovery_type = RECTYPE_UNKNOWN;
|
|
||||||
|
|
||||||
connection_error_found = true;
|
connection_error_found = true;
|
||||||
|
|
||||||
@@ -172,7 +165,6 @@ do_daemon_status(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
repmgrd_info[i]->pg_running = false;
|
repmgrd_info[i]->pg_running = false;
|
||||||
//maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("not running"));
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("n/a"));
|
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("n/a"));
|
||||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
||||||
}
|
}
|
||||||
@@ -180,7 +172,6 @@ do_daemon_status(void)
|
|||||||
{
|
{
|
||||||
cell->node_info->node_status = NODE_STATUS_UP;
|
cell->node_info->node_status = NODE_STATUS_UP;
|
||||||
cell->node_info->recovery_type = get_recovery_type(cell->node_info->conn);
|
cell->node_info->recovery_type = get_recovery_type(cell->node_info->conn);
|
||||||
//maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("running"));
|
|
||||||
|
|
||||||
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
||||||
|
|
||||||
|
|||||||
@@ -1977,6 +1977,22 @@ format_node_status(t_node_info *node_info, PQExpBufferData *details, ItemList *w
|
|||||||
{
|
{
|
||||||
bool error_found = false;
|
bool error_found = false;
|
||||||
|
|
||||||
|
if (PQstatus(node_info->conn) == CONNECTION_OK)
|
||||||
|
{
|
||||||
|
node_info->node_status = NODE_STATUS_UP;
|
||||||
|
node_info->recovery_type = get_recovery_type(node_info->conn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* check if node is reachable, but just not letting us in */
|
||||||
|
if (is_server_available_quiet(node_info->conninfo))
|
||||||
|
node_info->node_status = NODE_STATUS_REJECTED;
|
||||||
|
else
|
||||||
|
node_info->node_status = NODE_STATUS_DOWN;
|
||||||
|
|
||||||
|
node_info->recovery_type = RECTYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: count nodes marked as "? unreachable" and add a hint about
|
* TODO: count nodes marked as "? unreachable" and add a hint about
|
||||||
* the other cluster commands for better determining whether
|
* the other cluster commands for better determining whether
|
||||||
|
|||||||
Reference in New Issue
Block a user