[Cluster-devel] conga/ricci common/Time.cpp docs/cluster_api.h ...
kupcevic at sourceware.org
kupcevic at sourceware.org
Tue Jun 20 19:37:24 UTC 2006
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-06-20 19:37:23
Modified files:
ricci/common : Time.cpp
ricci/docs : cluster_api.html
ricci/include : Time.h
ricci/modules/cluster: ClusterModule.cpp ClusterStatus.cpp
ClusterStatus.h
Log message:
cluster module: add optional cluster_startup/shutdown arguments to start/stop_node functions (cluster startup without fencing / shutdown without bouncing services)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Time.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/cluster_api.html.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Time.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
--- conga/ricci/common/Time.cpp 2006/03/10 17:50:11 1.2
+++ conga/ricci/common/Time.cpp 2006/06/20 19:37:22 1.3
@@ -66,3 +66,11 @@
req.tv_nsec = rem.tv_nsec;
} while (nanosleep(&req, &rem) == -1 && errno == EINTR);
}
+
+void
+sleep_sec(unsigned char num)
+{
+ for (unsigned char i=0; i<num; i++)
+ for (int j=0; j<4; j++)
+ sleep_mil(250);
+}
--- conga/ricci/docs/cluster_api.html 2006/05/25 15:54:56 1.2
+++ conga/ricci/docs/cluster_api.html 2006/06/20 19:37:22 1.3
@@ -5,7 +5,7 @@
<TITLE>Cluster Module</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.2 (Linux)">
<META NAME="CREATED" CONTENT="20060410;13011800">
- <META NAME="CHANGED" CONTENT="20060411;16472300">
+ <META NAME="CHANGED" CONTENT="20060620;15340700">
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P>Cluster module manages Redhat Cluster Suite.
@@ -63,9 +63,10 @@
online="true" uptime="331625"
votes="1"/><BR><service autostart="true"
failed="false" name="dsa" nodename="green"
- running="true" time_since_transition="12345"/><BR><service autostart="true"
- failed="false" name="new_serv" nodename="green"
- running="true" time_since_transition="54321"/><BR></cluster></P>
+ running="true" time_since_transition="12345"/><BR><service
+ autostart="true" failed="false" name="new_serv"
+ nodename="green" running="true"
+ time_since_transition="54321"/><BR></cluster></P>
<P ALIGN=LEFT>On failure:<BR>- No special errors defined, only
generic ones might get returned.</P>
</UL>
@@ -105,26 +106,33 @@
<P>On failure:<BR>- 1 â service manager is not running on this
managed system<BR>- generic ones</P>
</UL>
- <LI><P>start_node</P>
+ <LI><P>start_node
+ </P>
<UL>
- <P>Start cluster infrastructure and configured services. It is not
- an error to start already started node.</P>
- <P>No input variables.</P>
- <P>No output variables.</P>
+ <P>Start cluster infrastructure on this node (also, enable daemons'
+ boot startup). <BR>It is not an error to start already started
+ node.</P>
+ <P>Input variables:<BR>- âcluster_startupâ (boolean) â
+ optional, default âfalseâ, cluster is starting up (wait for all
+ to come up, then start services â avoid fencing on startup)</P>
+ <P>No output variables.
+ </P>
<P>On failure:<BR>- No special errors defined, only generic ones
might get returned.</P>
</UL>
<LI><P>stop_node</P>
<UL>
- <P>Stop cluster infrastructure and configured services. It is not
- an error to stop already stopped node.
- </P>
- <P>No input variables.
- </P>
+ <P>Stop cluster infrastructure on this node (also, disable daemons'
+ boot startup). <BR>It is not an error to stop already stopped node.
+ </P>
+ <P>Input variables:<BR>- âcluster_shutdownâ (boolean) â
+ optional, default âfalseâ, cluster is shutting down (don't
+ bounce services around)</P>
<P>No output variables.
</P>
<P>On failure:<BR>- No special errors defined, only generic ones
- might get returned.</P>
+ might get returned.
+ </P>
</UL>
<LI><P>fence_node</P>
<UL>
@@ -140,4 +148,4 @@
<P><BR><BR>
</P>
</BODY>
-</HTML>
+</HTML>
\ No newline at end of file
--- conga/ricci/include/Time.h 2006/03/10 17:50:11 1.2
+++ conga/ricci/include/Time.h 2006/06/20 19:37:23 1.3
@@ -35,6 +35,8 @@
// sleep num milliseconds
void sleep_mil(unsigned char num);
+// sleep num seconds
+void sleep_sec(unsigned char num);
std::string time_formated();
--- conga/ricci/modules/cluster/ClusterModule.cpp 2006/04/12 15:47:09 1.2
+++ conga/ricci/modules/cluster/ClusterModule.cpp 2006/06/20 19:37:23 1.3
@@ -205,7 +205,16 @@
VarMap
start_node(const VarMap& args)
{
- Cluster::start_node();
+ bool cluster_startup = false;
+ try {
+ VarMap::const_iterator iter = args.find("cluster_startup");
+ if (iter != args.end())
+ cluster_startup = iter->second.get_bool();
+ } catch ( string e ) {
+ throw APIerror(e);
+ }
+
+ Cluster::start_node(cluster_startup);
VarMap ret;
return ret;
@@ -214,7 +223,16 @@
VarMap
stop_node(const VarMap& args)
{
- Cluster::stop_node();
+ bool cluster_shutdown = false;
+ try {
+ VarMap::const_iterator iter = args.find("cluster_shutdown");
+ if (iter != args.end())
+ cluster_shutdown = iter->second.get_bool();
+ } catch ( string e ) {
+ throw APIerror(e);
+ }
+
+ Cluster::stop_node(cluster_shutdown);
VarMap ret;
return ret;
--- conga/ricci/modules/cluster/ClusterStatus.cpp 2006/05/23 17:39:52 1.6
+++ conga/ricci/modules/cluster/ClusterStatus.cpp 2006/06/20 19:37:23 1.7
@@ -25,6 +25,7 @@
#include "Socket.h"
#include "Time.h"
#include "ClusterConf.h"
+#include "Clusvcadm.h"
#include "utils.h"
#include <string>
@@ -105,13 +106,36 @@
void
-Cluster::start_node()
+Cluster::start_node(bool cluster_startup)
{
run_initd("ccsd", true, false);
if (ClusterConf::is_cman(ClusterConf::get()))
- run_initd("cman", true, true);
+ try {
+ run_initd("cman", true, true);
+ } catch ( ... ) {
+ // try again
+ run_initd("cman", true, true);
+ }
else
run_initd("lock_gulmd", true, true);
+
+ if (cluster_startup) {
+ // wait for all nodes to join -> avoid fencing
+ bool all_in = false;
+ while (all_in == false) {
+ all_in = true;
+ XMLObject stat = status();
+ for (list<XMLObject>::const_iterator iter = stat.children().begin();
+ iter != stat.children().end();
+ iter++)
+ if (iter->tag() == "node")
+ if (iter->get_attr("clustered") == "false")
+ all_in = false;
+ if (all_in == false)
+ sleep_sec(8);
+ }
+ }
+
run_initd("fenced", true, false);
run_initd("clvmd", true, false);
run_initd("gfs", true, false);
@@ -131,8 +155,19 @@
}
void
-Cluster::stop_node()
+Cluster::stop_node(bool cluster_shutdown)
{
+ if (cluster_shutdown) {
+ // stop all services, so they don't bounce around
+ XMLObject stat = status();
+ for (list<XMLObject>::const_iterator iter = stat.children().begin();
+ iter != stat.children().end();
+ iter++)
+ if (iter->tag() == "service")
+ if (iter->get_attr("running") == "true")
+ Clusvcadm::stop(iter->get_attr("name"));
+ }
+
run_initd("rgmanager", false, true);
run_initd("gfs", false, false);
run_initd("clvmd", false, false);
--- conga/ricci/modules/cluster/ClusterStatus.h 2006/03/30 19:53:32 1.2
+++ conga/ricci/modules/cluster/ClusterStatus.h 2006/06/20 19:37:23 1.3
@@ -32,8 +32,8 @@
public:
static XMLObject status();
- static void start_node();
- static void stop_node();
+ static void start_node(bool cluster_startup = false);
+ static void stop_node(bool cluster_shutdown = false);
};
More information about the Cluster-devel
mailing list