From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 13 Oct 2006 09:36:16 -0000 Subject: [Cluster-devel] conga/ricci common/XML.cpp modules/cluster/clu ... Message-ID: <20061013093616.29720.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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 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::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::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 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 {