Sorry again I've sent the wrong patch, here is the one using
REAL_PRIMARY_NODE_ID.
Please apologies for so much post.
Le 30/12/2010 22:53, Gilles Darold a écrit :
> Sorry, here is the attached patch.
--
Gilles Darold
http://dalibo.com - http://dalibo.org
--- pgpool-II/pool_process_reporting.c 2010-12-30 01:47:05.000000000 +0100
+++ pgpool-II-current/pool_process_reporting.c 2010-12-30 20:03:15.000000000 +0100
@@ -55,6 +55,7 @@
char port[POOLCONFIG_MAXIDENTLEN+1];
char status[POOLCONFIG_MAXSTATLEN+1];
char lb_weight[POOLCONFIG_MAXWEIGHTLEN+1];
+ char state[POOLCONFIG_MAXSTATLEN+1];
} POOL_REPORT_NODES;
/* processes report struct */
@@ -662,8 +663,8 @@
void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
{
static char *cursorname = "blank";
- static short num_fields = 5;
- static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight"};
+ static short num_fields = 6;
+ static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight", "state"};
static int oid = 0;
static short fsize = -1;
static int mod = 0;
@@ -692,6 +693,10 @@
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);
+ if (REAL_PRIMARY_NODE_ID == i)
+ snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s", "P");
+ else
+ snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s", "S");
}
nrows = i;
@@ -787,6 +792,11 @@
hsize = htonl(size+4);
pool_write(frontend, &hsize, sizeof(hsize));
pool_write(frontend, nodes[i].lb_weight, size);
+
+ size = strlen(nodes[i].state);
+ hsize = htonl(size+4);
+ pool_write(frontend, &hsize, sizeof(hsize));
+ pool_write(frontend, nodes[i].state, size);
}
}
else
@@ -801,6 +811,7 @@
len += sizeof(int) + strlen(nodes[i].port);
len += sizeof(int) + strlen(nodes[i].status);
len += sizeof(int) + strlen(nodes[i].lb_weight);
+ len += sizeof(int) + strlen(nodes[i].state);
len = htonl(len);
pool_write(frontend, &len, sizeof(len));
s = htons(num_fields);
@@ -825,6 +836,10 @@
len = htonl(strlen(nodes[i].lb_weight));
pool_write(frontend, &len, sizeof(len));
pool_write(frontend, nodes[i].lb_weight, strlen(nodes[i].lb_weight));
+
+ len = htonl(strlen(nodes[i].state));
+ pool_write(frontend, &len, sizeof(len));
+ pool_write(frontend, nodes[i].state, strlen(nodes[i].state));
}
}
_______________________________________________
Pgpool-hackers mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-hackers