cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/ricci common/XML.cpp modules/cluster/clu ...
@ 2006-10-13  9:36 kupcevic
  0 siblings, 0 replies; 2+ messages in thread
From: kupcevic @ 2006-10-13  9:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-13 09:36:16

Modified files:
	ricci/common   : XML.cpp 
	ricci/modules/cluster/clumon/src/daemon: Monitor.cpp Monitor.h 
	                                         main.cpp 

Log message:
	modcluster: perform probe on request if autoprobe hasn't been completed

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/XML.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- conga/ricci/common/XML.cpp	2006/09/26 00:54:26	1.5
+++ conga/ricci/common/XML.cpp	2006/10/13 09:36:15	1.6
@@ -231,6 +231,8 @@
 {
   char* buff = 0;
   try {
+    if (access(filename.c_str(), R_OK))
+      throw String("missing ") + filename;
     ifstream is(filename.c_str());
     is.seekg(0, ios::end);
     unsigned int length = is.tellg();
--- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp	2006/10/12 20:01:51	1.7
+++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp	2006/10/13 09:36:16	1.8
@@ -84,6 +84,20 @@
 }
 
 
+void 
+Monitor::update_now()
+{
+  try {
+    MutexLocker l(_mutex);
+    String my_nodename, clustername, msg;
+    vector<String> nodenames = get_local_info(my_nodename,
+					      clustername,
+					      msg);
+    msg_arrived(my_nodename, msg);
+    _cluster = merge_data(clustername);
+  } catch ( ... ) {}
+}
+
 void
 Monitor::run()
 {
@@ -132,7 +146,11 @@
 {
   MutexLocker l(_mutex);
   if (msg == "GET") {
-    String def(generateXML(XMLObject("cluster")) + "\n");
+    XMLObject def_xml("cluster");
+    def_xml.set_attr("cluster_version", _cl_version);
+    String def(generateXML(def_xml) + "\n");
+    if (_cluster.get() == NULL) 
+      update_now();
     if (_cluster.get() == NULL) 
       return def;
     try {
@@ -178,7 +196,7 @@
 			String& clustername,
 			String& msg)
 {
-  XMLObject cluster = parse_cluster_conf();
+  XMLObject cluster(parse_cluster_conf());
   
   // nodes
   vector<String> nodes;
@@ -255,30 +273,11 @@
 XMLObject 
 Monitor::parse_cluster_conf()
 {
-  XMLObject cluster_conf;
-  char* buff = 0;
-  try {
-    if (access("/etc/cluster/cluster.conf", R_OK))
-      throw String("missing /etc/cluster/cluster.conf");
-    ifstream is("/etc/cluster/cluster.conf");
-    is.seekg(0, ios::end);
-    unsigned int length = is.tellg();
-    is.seekg(0, ios::beg);
-    if (length < 5)
-      throw String("cluster.conf too short");
-    buff = new char[length];
-    is.read(buff, length);
-    String conf(buff, length);
-    delete [] buff; buff = 0;
-    cluster_conf = parseXML(conf);
-    if (cluster_conf.tag() != "cluster" ||
-	utils::strip(cluster_conf.get_attr("name")).empty())
-      throw String("parse_cluster_conf(): invalid cluster.conf");
-  } catch ( ... ) {
-    delete [] buff;
-    throw;
-  }
-  
+  XMLObject cluster_conf(readXML("/etc/cluster/cluster.conf"));
+  if (cluster_conf.tag() != "cluster" ||
+      utils::strip(cluster_conf.get_attr("name")).empty() ||
+      utils::strip(cluster_conf.get_attr("config_version")).empty())
+    throw String("parse_cluster_conf(): invalid cluster.conf");
   
   XMLObject cluster("cluster");
   for (map<String, String>::const_iterator iter = cluster_conf.attrs().begin();
@@ -311,12 +310,17 @@
 	   iter_s != kid.children().end();
 	   iter_s++) {
 	const XMLObject& service_conf = *iter_s;
-	if (service_conf.tag() == "service") {
+	if (service_conf.tag() == "service" ||
+	    service_conf.tag() == "xenvm") {
 	  XMLObject service("service");
 	  for (map<String, String>::const_iterator iter_a = service_conf.attrs().begin();
 	       iter_a != service_conf.attrs().end();
 	       iter_a++)
 	    service.set_attr(iter_a->first, iter_a->second);
+	  if (service_conf.tag() == "xenvm")
+	    service.set_attr("xenvm", "true");
+	  else
+	    service.set_attr("xenvm", "false");
 	  cluster.add_child(service);
 	}
       }
--- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h	2006/08/15 00:12:33	1.4
+++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h	2006/10/13 09:36:16	1.5
@@ -70,6 +70,8 @@
   
   bool _cman_locking;
   
+  void update_now();
+  
   // return (nodenames - my_nodename)
   std::vector<String> get_local_info(String& nodename,
 				     String& clustername,
--- conga/ricci/modules/cluster/clumon/src/daemon/main.cpp	2006/08/10 22:53:08	1.2
+++ conga/ricci/modules/cluster/clumon/src/daemon/main.cpp	2006/10/13 09:36:16	1.3
@@ -182,9 +182,8 @@
 	}
 	if (poll_info.revents & (POLLERR | POLLHUP | POLLNVAL))
 	  throw String("serve_clients(): server socket error????");
-      }
-      // client socket
-      else {
+      } else {
+	// client socket
 	if (poll_info.revents & POLLIN) {
 	  ClientInfo& info = clients[poll_info.fd];
 	  try {



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Cluster-devel] conga/ricci common/XML.cpp modules/cluster/clu ...
@ 2007-09-05 22:27 rmccabe
  0 siblings, 0 replies; 2+ messages in thread
From: rmccabe @ 2007-09-05 22:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-09-05 22:27:29

Modified files:
	ricci/common   : XML.cpp 
	ricci/modules/cluster/clumon/src/daemon: Communicator.cpp 
	                                         Monitor.cpp 

Log message:
	Cleanup and log more debugging info

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/XML.cpp.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/ricci/common/XML.cpp	2007/08/31 04:57:37	1.11
+++ conga/ricci/common/XML.cpp	2007/09/05 22:27:29	1.12
@@ -136,10 +136,10 @@
 static void
 _parseXML(XMLObject& parent, xmlNode* children)
 {
-	for (xmlNode* curr_node = children; curr_node; curr_node = curr_node->next)
+	for (xmlNode *curr_node = children; curr_node ; curr_node = curr_node->next)
 	{
 		if (curr_node->type == XML_ELEMENT_NODE) {
-			XMLObject me((const char*) curr_node->name);
+			XMLObject me((const char *) curr_node->name);
 
 			// attrs
 			for (xmlAttr* curr_attr = curr_node->properties ;
@@ -147,11 +147,12 @@
 					curr_attr = curr_attr->next)
 			{
 				if (curr_attr->type == XML_ATTRIBUTE_NODE) {
-					const xmlChar* name = curr_attr->name;
-					const xmlChar* value = xmlGetProp(curr_node, name);
+					const xmlChar *name = curr_attr->name;
+					const xmlChar *value = xmlGetProp(curr_node, name);
 
 					if (!value)
-						throw String("xmlGetProp() returned NULL!!!");
+						throw String("xmlGetProp() returned NULL");
+
 					try {
 						const String name_str((const char *) name);
 						const String value_str =
@@ -183,11 +184,12 @@
 		initialized = true;
 	}
 
-	xmlDoc* doc = xmlReadMemory(xml.c_str(),
+	xmlDoc *doc = xmlReadMemory(xml.c_str(),
 					xml.size(),
 					"noname.xml",
 					NULL,
 					XML_PARSE_NONET | XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
+
 	if (!doc)
 		throw String("parseXML(): couldn't parse xml");
 
@@ -199,7 +201,6 @@
 		return *(root.children().begin());
 	} catch ( ... ) {
 		xmlFreeDoc(doc);
-		xmlCleanupParser();
 		throw String("parseXML(): low memory");
 	}
 }
--- conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp	2007/09/04 18:28:40	1.5
+++ conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp	2007/09/05 22:27:29	1.6
@@ -240,12 +240,19 @@
 				vector<String> msgs;
 				try {
 					msgs = peer.receive();
+				} catch (String e) {
+					log("error receiving data from "
+							+ peer.hostname() + ": " + e,
+						LogCommunicator);
+					_peers.erase(peer.hostname());
+					continue;
 				} catch ( ... ) {
 					log("error receiving data from " + peer.hostname(),
 						LogCommunicator);
 					_peers.erase(peer.hostname());
 					continue;
 				}
+
 				for (unsigned int i = 0 ; i < msgs.size() ; i++)
 					_delivery_point.msg_arrived(peer.hostname(), msgs[i]);
 				continue;
@@ -257,6 +264,12 @@
 			if (poll_info.revents & POLLOUT) {
 				try {
 					peer.send();
+				} catch (String e) {
+					log("error sending data to "
+							+ peer.hostname() + " : " + e,
+						LogCommunicator);
+					_peers.erase(peer.hostname());
+					continue;
 				} catch ( ... ) {
 					log("error sending data to " + peer.hostname(),
 						LogCommunicator);
--- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp	2007/09/04 18:28:40	1.16
+++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp	2007/09/05 22:27:29	1.17
@@ -79,9 +79,11 @@
 	try {
 		MutexLocker l(_mutex);
 		String my_nodename, clustername, msg;
-		vector<String> nodenames= get_local_info(my_nodename, clustername, msg);
+		vector<String> nodenames=get_local_info(my_nodename, clustername, msg);
 		msg_arrived(my_nodename, msg);
 		_cluster = merge_data(clustername);
+	} catch (String e) {
+		log(__LINE__ + ": caught exception: " + e, LogCommunicator);
 	} catch ( ... ) {}
 }
 
@@ -110,6 +112,10 @@
 				MutexLocker l(_mutex);
 				_cluster = merge_data(clustername);
 			}
+		} catch (String e) {
+			log(__LINE__ + ": caught exception: " + e, LogCommunicator);
+			MutexLocker l(_mutex);
+			_cluster = counting_auto_ptr<Cluster>();
 		} catch ( ... ) {
 			MutexLocker l(_mutex);
 			_cluster = counting_auto_ptr<Cluster>();
@@ -149,6 +155,9 @@
 
 		try {
 			return cluster2xml(*_cluster) + "\n";
+		} catch (String e) {
+			log(__LINE__ + ": caught exception: " + e, LogCommunicator);
+			return def;
 		} catch ( ... ) {
 			return def;
 		}
@@ -185,6 +194,8 @@
 				// TODO: other msgs
 			}
 		}
+	} catch (String e) {
+		log(__LINE__ + ": caught exception: " + e, LogCommunicator);
 	} catch ( ... ) {}
 }
 
@@ -656,15 +667,15 @@
 		throw String("nodename(): ifconfig failed");
 
 	for (vector<String>::const_iterator
-			iter = nodenames.begin();
-			iter != nodenames.end();
+			iter = nodenames.begin() ;
+			iter != nodenames.end() ;
 			iter++)
 	{
 		const String& nodename = *iter;
 		vector<String> ips = Network::name2IP(nodename);
 		for (vector<String>::iterator
-				iter_ip = ips.begin();
-				iter_ip != ips.end();
+				iter_ip = ips.begin() ;
+				iter_ip != ips.end() ;
 				iter_ip++)
 		{
 			if (out.find(*iter_ip) != out.npos)
@@ -776,6 +787,8 @@
 				}
 			}
 		}
+	} catch (String e) {
+		log(__LINE__ + ": caught exception: " + e, LogCommunicator);
 	} catch ( ... ) {}
 
 	return services;



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-05 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-05 22:27 [Cluster-devel] conga/ricci common/XML.cpp modules/cluster/clu rmccabe
  -- strict thread matches above, loose matches on Subject: below --
2006-10-13  9:36 kupcevic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).