Send Linux-ha-cvs mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."
Today's Topics:
1. Linux-HA CVS: include by zhenh from
([email protected])
2. Linux-HA CVS: heartbeat by zhenh from
([email protected])
3. Linux-HA CVS: heartbeat by zhenh from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Sat, 27 May 2006 18:50:46 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : include
Dir : linux-ha/include
Modified Files:
heartbeat.h
Log Message:
add weight and site fields for node structure
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/heartbeat.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -3 -r1.85 -r1.86
--- heartbeat.h 26 May 2006 02:55:28 -0000 1.85
+++ heartbeat.h 28 May 2006 00:50:45 -0000 1.86
@@ -1,4 +1,4 @@
-/* $Id: heartbeat.h,v 1.85 2006/05/26 02:55:28 zhenh Exp $ */
+/* $Id: heartbeat.h,v 1.86 2006/05/28 00:50:45 zhenh Exp $ */
/*
* heartbeat.h: core definitions for the Linux-HA heartbeat program
*
@@ -261,6 +261,8 @@
int nodetype;
char nodename[HOSTLENG]; /* Host name from config file */
cl_uuid_t uuid;
+ char site[HOSTLENG];
+ int weight;
char status[STATUSLENG]; /* Status from heartbeat */
gboolean status_suppressed; /* Status reports suppressed
for now */
@@ -396,6 +398,8 @@
struct link * lookup_iface(struct node_info * hip, const char *iface);
struct link * iface_lookup_node(const char *);
int add_node(const char * value, int nodetype);
+int set_node_weight(const char * value, int weight);
+int set_node_site(const char * value, const char * site);
int remove_node(const char * value, int);
void SetParameterValue(const char * name, const char * value);
------------------------------
Message: 2
Date: Sat, 27 May 2006 18:52:29 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : heartbeat
Dir : linux-ha/heartbeat
Modified Files:
hb_uuid.c
Log Message:
add weight and site to hostcache
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/hb_uuid.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- hb_uuid.c 26 Apr 2006 03:42:07 -0000 1.24
+++ hb_uuid.c 28 May 2006 00:52:29 -0000 1.25
@@ -463,24 +463,28 @@
*/
static int
-node_uuid_file_out(FILE *f, const char * nodename, const cl_uuid_t * uu)
+node_uuid_file_out(FILE *f, const char * nodename, const cl_uuid_t * uu
+, int weight, const char* site)
{
char uuid_str[UU_UNPARSE_SIZEOF];
cl_uuid_unparse(uu, uuid_str);
- if (fprintf(f, "%s\t%s\n", nodename, uuid_str) > sizeof(uuid_str)) {
+ if (fprintf(f, "%s\t%s\t%d\t%s\n", nodename, uuid_str, weight,
site?site:"")
+ > sizeof(uuid_str)) {
return HA_OK;
}
return HA_FAIL;
}
static int /* Returns -, 0 + *; 0 = EOF, + = OK, - = ERROR */
-node_uuid_file_in(FILE *f, char* nodename, cl_uuid_t * uu)
+node_uuid_file_in(FILE *f, char* nodename, cl_uuid_t * uu, int* weight, char*
site)
{
char linebuf[MAXLINE];
- char * tab;
+ char * name_end;
+ char * uuid_end;
+ char * weight_end;
int len;
int hlen;
-
+
if (fgets(linebuf, MAXLINE, f) == NULL) {
if (feof(f)) {
return 0;
@@ -501,21 +505,38 @@
return -1;
}
linebuf[len] = EOS;
- tab = strchr(linebuf, '\t');
- if (tab == NULL || (hlen=(tab - linebuf)) > (HOSTLENG-1) || hlen < 1){
+ name_end = strchr(linebuf, '\t');
+ if (name_end == NULL || (hlen=(name_end - linebuf)) > (HOSTLENG-1) ||
hlen < 1){
cl_log(LOG_ERR, "Malformed node/uuid line [%s] (3)", linebuf);
return -1;
}
- if ((len - hlen) != UU_UNPARSE_SIZEOF) {
- cl_log(LOG_ERR, "Malformed node/uuid line [%s] (4)", linebuf);
- return -1;
+ *name_end = EOS;
+ strncpy(nodename, linebuf, HOSTLENG);
+ uuid_end = strchr(name_end+1, '\t');
+ if (uuid_end != NULL) {
+ *uuid_end = EOS;
}
- if (cl_uuid_parse(tab+1, uu) < 0) {
+ if (cl_uuid_parse(name_end+1, uu) < 0) {
cl_log(LOG_ERR, "Malformed uuid in line [%s] (5)", linebuf);
return -1;
}
- *tab = EOS;
- strncpy(nodename, linebuf, HOSTLENG);
+ if (uuid_end == NULL) {
+ /* old format, no weight and site columns */
+ *weight = 100;
+ *site = 0;
+ return 1;
+ }
+ weight_end = strchr(uuid_end+1, '\t');
+ if (weight_end != NULL) {
+ *weight_end = EOS;
+ }
+ *weight = atoi(uuid_end+1);
+ if (weight_end == NULL) {
+ /* no site columns */
+ *site = 0;
+ return 1;
+ }
+ strncpy(site, weight_end+1, HOSTLENG);
return 1;
}
@@ -541,7 +562,8 @@
continue;
}
if (node_uuid_file_out(f, cfg->nodes[j].nodename
- , &cfg->nodes[j].uuid) != HA_OK) {
+ , &cfg->nodes[j].uuid, cfg->nodes[j].weight
+ , cfg->nodes[j].site) != HA_OK) {
fclose(f);
unlink(tmpname);
return HA_FAIL;
@@ -579,6 +601,8 @@
FILE * f;
char host[HOSTLENG];
cl_uuid_t uu;
+ int weight;
+ char site[HOSTLENG];
int rc;
const char * uuidcachename = HOSTUUIDCACHEFILE;
gboolean outofsync = FALSE;
@@ -593,12 +617,14 @@
return HA_FAIL;
}
- while ((rc=node_uuid_file_in(f, host, &uu)) > 0) {
+ while ((rc=node_uuid_file_in(f, host, &uu, &weight, site)) > 0) {
struct node_info * thisnode = lookup_tables(host, &uu);
cl_uuid_t curuuid;
if (thisnode == NULL) {
/* auto-added node */
add_node(host, NORMALNODE_I);
+ set_node_weight(host, weight);
+ set_node_site(host, site);
update_tables(host, &uu);
continue;
}
@@ -610,6 +636,8 @@
outofsync=TRUE;
}
}
+ thisnode->weight = weight;
+ strncpy(thisnode->site, site, sizeof(thisnode->site));
}
fclose(f);
/*
@@ -653,7 +681,7 @@
}
if (node_uuid_file_out(f, hip->nodename,
- &hip->uuid) != HA_OK) {
+ &hip->uuid, hip->weight, hip->site) != HA_OK) {
fclose(f);
unlink(tmpname);
return HA_FAIL;
@@ -694,6 +722,8 @@
FILE * f;
char host[HOSTLENG];
cl_uuid_t uu;
+ int weight;
+ char site[HOSTLENG];
int rc;
const char * filename = DELHOSTCACHEFILE;
struct node_info thisnode;
@@ -708,11 +738,12 @@
, __FUNCTION__, filename);
return HA_FAIL;
}
-
- while ((rc=node_uuid_file_in(f, host, &uu)) > 0) {
+ memset(site, 0, sizeof(site));
+ while ((rc=node_uuid_file_in(f, host, &uu, &weight, site)) > 0) {
strncpy(thisnode.nodename, host, HOSTLENG);
cl_uuid_copy(&thisnode.uuid, &uu);
-
+ thisnode.weight = weight;
+ strncpy(thisnode.site, site, HOSTLENG);
remove_node(thisnode.nodename, TRUE);
}
------------------------------
Message: 3
Date: Sat, 27 May 2006 18:53:20 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by zhenh from
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
linux-ha CVS committal
Author : zhenh
Host :
Project : linux-ha
Module : heartbeat
Dir : linux-ha/heartbeat
Modified Files:
config.c
Log Message:
add functions for setting the weight and site of node
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/config.c,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -3 -r1.201 -r1.202
--- config.c 26 May 2006 02:55:28 -0000 1.201
+++ config.c 28 May 2006 00:53:19 -0000 1.202
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 1.201 2006/05/26 02:55:28 zhenh Exp $ */
+/* $Id: config.c,v 1.202 2006/05/28 00:53:19 zhenh Exp $ */
/*
* Parse various heartbeat configuration files...
*
@@ -1265,6 +1265,7 @@
hip->track.nmissing = 0;
hip->track.last_seq = NOSEQUENCE;
hip->track.ackseq = 0;
+ hip->weight = 100;
srand(time(NULL));
hip->track.ack_trigger = rand()%ACK_MSG_DIV;
hip->nodetype = nodetype;
@@ -1280,8 +1281,60 @@
return(HA_OK);
}
+int
+set_node_weight(const char* value, int weight)
+{
+ int i;
+ struct node_info * hip = NULL;
+ if (value == NULL){
+ cl_log(LOG_ERR, "%s: invalid nodename",
+ __FUNCTION__);
+ return HA_FAIL;
+ }
+
+ for (i = 0; i < config->nodecount; i++){
+ hip = &config->nodes[i];
+ if (strncasecmp(hip->nodename, value, sizeof(hip->nodename))
==0){
+ break;
+ }
+ }
+ if (i == config->nodecount){
+ cl_log(LOG_DEBUG,"set weight to non-existing node %s", value);
+ return HA_FAIL;
+ }
+
+ hip->weight = weight;
+ return HA_OK;
+}
+
+int
+set_node_site(const char* value, const char* site)
+{
+ int i;
+ struct node_info * hip = NULL;
+
+ if (value == NULL){
+ cl_log(LOG_ERR, "%s: invalid nodename",
+ __FUNCTION__);
+ return HA_FAIL;
+ }
+
+ for (i = 0; i < config->nodecount; i++){
+ hip = &config->nodes[i];
+ if (strncasecmp(hip->nodename, value, sizeof(hip->nodename))
==0){
+ break;
+ }
+ }
+
+ if (i == config->nodecount){
+ cl_log(LOG_DEBUG,"set site to non-existing node %s", value);
+ return HA_FAIL;
+ }
+ strncpy(hip->site, site, sizeof(hip->site));
+ return HA_OK;
+}
int
remove_node(const char* value, int deletion)
@@ -2585,6 +2638,9 @@
/*
* $Log: config.c,v $
+ * Revision 1.202 2006/05/28 00:53:19 zhenh
+ * add functions for setting the weight and site of node
+ *
* Revision 1.201 2006/05/26 02:55:28 zhenh
* add "cluster" directive as the name of cluster to ha.cf and parameter of
cluster
*
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 30, Issue 88
********************************************