pgpool2.git / summary / log / commit / refs
commit a8cb87fcc51af56568af92cc0319aca2bf7ca960
Author: Guillaume Lelarge <guillaume at lelarge.info>
Date: Sun Nov 28 14:57:17 2010 +0000
Add node_id column in pool_nodes "view".
Patch from Jean-Paul Argudo.
pool_process_reporting.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/pool_process_reporting.c b/pool_process_reporting.c
index 4523c063d..6a7c2e5c7 100644
--- a/pool_process_reporting.c
+++ b/pool_process_reporting.c
@@ -50,6 +50,7 @@ typedef struct {
/* nodes report struct */
typedef struct {
+ char node_id[POOLCONFIG_MAXSTATLEN+1];
char hostname[POOLCONFIG_MAXIDENTLEN+1];
char port[POOLCONFIG_MAXIDENTLEN+1];
char status[POOLCONFIG_MAXSTATLEN+1];
@@ -646,8 +647,8 @@ void config_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
static char *cursorname = "blank";
- static short num_fields = 4;
- static char *field_names[] = {"hostname", "port", "status", "lb_weight"};
+ static short num_fields = 5;
+ static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight"};
static int oid = 0;
static short fsize = -1;
static int mod = 0;
@@ -671,10 +672,11 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
bi = pool_get_node_info(i);
- strncpy(nodes[i].hostname, bi->backend_hostname, strlen(bi->backend_hostname)+1);
- snprintf(nodes[i].port, POOLCONFIG_MAXIDENTLEN, "%d", bi->backend_port);
- snprintf(nodes[i].status, POOLCONFIG_MAXSTATLEN, "%d", bi->backend_status);
- snprintf(nodes[i].lb_weight, POOLCONFIG_MAXWEIGHTLEN, "%f", bi->backend_weight/RAND_MAX);
+ snprintf(nodes[i].node_id, POOLCONFIG_MAXSTATLEN, "%d", i);
+ strncpy(nodes[i].hostname, bi->backend_hostname, strlen(bi->backend_hostname)+1);
+ snprintf(nodes[i].port, POOLCONFIG_MAXIDENTLEN, "%d", bi->backend_port);
+ snprintf(nodes[i].status, POOLCONFIG_MAXSTATLEN, "%d", bi->backend_status);
+ snprintf(nodes[i].lb_weight, POOLCONFIG_MAXWEIGHTLEN, "%f", bi->backend_weight/RAND_MAX);
}
nrows = i;
@@ -746,6 +748,11 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
pool_write(frontend, "D", 1);
pool_write_and_flush(frontend, nullmap, nbytes);
+ size = strlen(nodes[i].node_id);
+ hsize = htonl(size+4);
+ pool_write(frontend, &hsize, sizeof(hsize));
+ pool_write(frontend, nodes[i].node_id, size);
+
size = strlen(nodes[i].hostname);
hsize = htonl(size+4);
pool_write(frontend, &hsize, sizeof(hsize));
@@ -774,6 +781,7 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
pool_write(frontend, "D", 1);
len = sizeof(len) + sizeof(nrows);
+ len += sizeof(int) + strlen(nodes[i].node_id);
len += sizeof(int) + strlen(nodes[i].hostname);
len += sizeof(int) + strlen(nodes[i].port);
len += sizeof(int) + strlen(nodes[i].status);
@@ -783,6 +791,10 @@ void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
s = htons(num_fields);
pool_write(frontend, &s, sizeof(s));
+ len = htonl(strlen(nodes[i].node_id));
+ pool_write(frontend, &len, sizeof(len));
+ pool_write(frontend, nodes[i].node_id, strlen(nodes[i].node_id));
+
len = htonl(strlen(nodes[i].hostname));
pool_write(frontend, &len, sizeof(len));
pool_write(frontend, nodes[i].hostname, strlen(nodes[i].hostname));
[parent: 1d4559268458]