[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/rgmanager include/resgroup.h src/daemo ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh sourceware org	2006-12-14 22:03:17

Modified files:
	rgmanager/include: resgroup.h 
	rgmanager/src/daemons: rg_forward.c rg_state.c 
	rgmanager/src/utils: clusvcadm.c 

Log message:
	Fix #216774

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_forward.c.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- cluster/rgmanager/include/resgroup.h	2006/10/06 21:22:27	1.15
+++ cluster/rgmanager/include/resgroup.h	2006/12/14 22:03:17	1.16
@@ -125,7 +125,7 @@
 		       msgctx_t *resp_ctx,
        		       int max, uint32_t target, int arg0, int arg1);
 
-void send_response(int ret, request_t *req);
+void send_response(int ret, int node, request_t *req);
 void send_ret(msgctx_t *ctx, char *name, int ret, int req);
 
 /* do this op on all resource groups.  The handler for the request 
--- cluster/rgmanager/src/daemons/rg_forward.c	2006/10/23 22:47:01	1.8
+++ cluster/rgmanager/src/daemons/rg_forward.c	2006/12/14 22:03:17	1.9
@@ -91,7 +91,7 @@
 	msg_free_ctx(ctx);
 
 	swab_SmMessageSt(&msg);
-	send_response(msg.sm_data.d_ret, req);
+	send_response(msg.sm_data.d_ret, msg.sm_data.d_svcOwner, req);
 	rq_free(req);
 	pthread_exit(NULL);
 	
--- cluster/rgmanager/src/daemons/rg_state.c	2006/10/23 22:47:01	1.24
+++ cluster/rgmanager/src/daemons/rg_state.c	2006/12/14 22:03:17	1.25
@@ -213,7 +213,7 @@
 
 	
 void
-send_response(int ret, request_t *req)
+send_response(int ret, int nodeid, request_t *req)
 {
 	SmMessageSt msg, *msgp = &msg;
 
@@ -226,7 +226,10 @@
 	msgp->sm_data.d_action = req->rr_orig_request;
 	strncpy(msgp->sm_data.d_svcName, req->rr_group,
 		sizeof(msgp->sm_data.d_svcName));
-	msgp->sm_data.d_svcOwner = my_id(); /* XXX Broken */
+	if (!nodeid)
+		msgp->sm_data.d_svcOwner = my_id();
+	else 
+		msgp->sm_data.d_svcOwner = nodeid;
 	msgp->sm_data.d_ret = ret;
 
 	swab_SmMessageSt(msgp);
--- cluster/rgmanager/src/utils/clusvcadm.c	2006/09/01 19:02:22	1.12
+++ cluster/rgmanager/src/utils/clusvcadm.c	2006/12/14 22:03:17	1.13
@@ -180,6 +180,46 @@
 
 
 int
+find_closest_node(cluster_member_list_t *cml, char *name, size_t maxlen)
+{
+	int x, c = 0, cl = 0, nc = 0, ncl = 0, cur = 0;
+
+	for (x=0; x<cml->cml_count; x++) {
+		cur = 0;
+
+		while (cml->cml_members[x].cn_name[cur] && name[cur] &&
+		       (cml->cml_members[x].cn_name[cur] == name[cur]))
+			cur++;
+		if (!cur)
+			continue;
+		if (cur >= cl) {
+			ncl = cl; /* Next-closest */
+			nc = c;
+			cl = cur;
+			c = x;
+		}
+	}
+
+	if (!cl) {
+		printf("No matches for '%s' found\n", name);
+		return 0;
+	}
+
+	if (ncl == cl) {
+		printf("More than one possible match for '%s' found\n",
+		       name);
+		return 0;
+	}
+
+	printf("Closest match: '%s'\n", 
+	       cml->cml_members[c].cn_name);
+
+	strncpy(name, cml->cml_members[c].cn_name, maxlen);
+	return cml->cml_members[c].cn_nodeid;
+}
+
+
+int
 main(int argc, char **argv)
 {
 	extern char *optarg;
@@ -291,9 +331,12 @@
 	if (node_specified) {
 		svctarget = memb_name_to_id(membership, nodename);
 		if (svctarget == 0) {
-			fprintf(stderr, "Member %s not in membership list\n",
-				nodename);
-			return 1;
+			printf("'%s' not in membership list\n",
+			       nodename);
+			svctarget = find_closest_node(membership, nodename,
+						      sizeof(nodename));
+			if (!svctarget)
+				return 1;
 		}
 	} else {
 		svctarget = 0;
@@ -301,9 +344,9 @@
 		clu_local_nodename(RG_SERVICE_GROUP, nodename,
 				   sizeof(nodename));
 				   */
+		strcpy(nodename,"me");
 	}
 	
-	strcpy(nodename,"me");
 	build_message(&msg, action, svcname, svctarget);
 
 	if (action != RG_RELOCATE && action != RG_MIGRATE) {
@@ -312,7 +355,11 @@
 		fflush(stdout);
 		msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5);
 	} else {
-		printf("Trying to relocate %s to %s", svcname, nodename);
+		if (!svctarget)
+			printf("Trying to relocate %s", svcname);
+		else 
+			printf("Trying to relocate %s to %s", svcname,
+			       nodename);
 		printf("...");
 		fflush(stdout);
 		msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5);
@@ -342,5 +389,19 @@
 
 	swab_SmMessageSt(&msg);
 	printf("%s\n", rg_strerror(msg.sm_data.d_ret));
+	switch (action) {
+	case RG_MIGRATE:
+	case RG_RELOCATE:
+	case RG_START:
+	case RG_ENABLE:
+		printf("%s%s is now running on %s\n",
+		       msg.sm_data.d_svcOwner==svctarget?"":"Warning: ",
+		       svcname, memb_id_to_name(membership,
+		       			        msg.sm_data.d_svcOwner));
+		break;
+	default:
+		break;
+	}
+	
 	return msg.sm_data.d_ret;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]