[Ocfs2-tools-commits] zab commits r649 - in branches/usysfsify:
clusterbo libo2cb libo2cb/include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Mar 17 13:38:00 CST 2005
Author: zab
Date: 2005-03-17 13:37:58 -0600 (Thu, 17 Mar 2005)
New Revision: 649
Modified:
branches/usysfsify/clusterbo/o2cb_ctl.c
branches/usysfsify/libo2cb/include/o2cb.h
branches/usysfsify/libo2cb/o2cb_abi.c
Log:
o decide if a node is local by comparing its name with the hostname
o set the local attribute after setting the ipv4 port/addr of the node
Modified: branches/usysfsify/clusterbo/o2cb_ctl.c
===================================================================
--- branches/usysfsify/clusterbo/o2cb_ctl.c 2005-03-17 02:18:23 UTC (rev 648)
+++ branches/usysfsify/clusterbo/o2cb_ctl.c 2005-03-17 19:37:58 UTC (rev 649)
@@ -1,5 +1,7 @@
/* -*- mode: c; c-basic-offset: 4; -*-
+ * vim:expandtab:shiftwidth=4:tabstop=4:
*
+ *
* o2cb_ctl.c
*
* Control program for O2CB.
@@ -568,11 +570,30 @@
return rc;
} /* find_type_for_objects() */
+static gchar *o2cb_node_is_local(gchar *node_name)
+{
+ int ret;
+ char hostname[PATH_MAX]; /* la la la */
+ gchar *local = NULL;
+
+ ret = gethostname(hostname, sizeof(hostname));
+ if (ret)
+ return NULL;
+
+ /* XXX no g_strcasecmp()? */
+ if (strcasecmp(hostname, node_name) == 0)
+ local = g_strdup("1");
+ else
+ local = g_strdup("0");
+
+ return local;
+}
+
static gint online_cluster(O2CBContext *ctxt)
{
errcode_t ret;
gint rc;
- gchar *name, *node_name, *node_num, *ip_address, *ip_port;
+ gchar *name, *node_name, *node_num, *ip_address, *ip_port, *local;
JIterator *iter;
O2CBNode *node;
@@ -607,9 +628,10 @@
node_name = o2cb_node_get_name(node);
ip_port = g_strdup_printf("%d", o2cb_node_get_port(node));
ip_address = o2cb_node_get_ip_string(node);
+ local = o2cb_node_is_local(node_name);
ret = o2cb_add_node(name, node_name, node_num, ip_address,
- ip_port);
+ ip_port, local);
if (ret)
{
if (ret != O2CB_ET_CLUSTER_EXISTS)
@@ -628,6 +650,7 @@
g_free(node_name);
g_free(ip_port);
g_free(ip_address);
+ g_free(local);
if (rc)
break;
}
Modified: branches/usysfsify/libo2cb/include/o2cb.h
===================================================================
--- branches/usysfsify/libo2cb/include/o2cb.h 2005-03-17 02:18:23 UTC (rev 648)
+++ branches/usysfsify/libo2cb/include/o2cb.h 2005-03-17 19:37:58 UTC (rev 649)
@@ -50,7 +50,8 @@
errcode_t o2cb_create_cluster(const char *cluster_name);
errcode_t o2cb_add_node(const char *cluster_name,
const char *node_name, const char *node_num,
- const char *ip_address, const char *ip_port);
+ const char *ip_address, const char *ip_port,
+ const char *local);
errcode_t o2cb_create_heartbeat_region_disk(const char *cluster_name,
const char *region_name,
Modified: branches/usysfsify/libo2cb/o2cb_abi.c
===================================================================
--- branches/usysfsify/libo2cb/o2cb_abi.c 2005-03-17 02:18:23 UTC (rev 648)
+++ branches/usysfsify/libo2cb/o2cb_abi.c 2005-03-17 19:37:58 UTC (rev 649)
@@ -230,7 +230,8 @@
* successfully then the node is live */
errcode_t o2cb_add_node(const char *cluster_name,
const char *node_name, const char *node_num,
- const char *ip_address, const char *ip_port)
+ const char *ip_address, const char *ip_port,
+ const char *local)
{
char node_path[PATH_MAX];
int ret;
@@ -287,6 +288,11 @@
err = o2cb_set_node_attribute(cluster_name, node_name,
"ipv4_address", ip_address);
+ if (err)
+ goto out_rmdir;
+
+ err = o2cb_set_node_attribute(cluster_name, node_name,
+ "local", local);
out_rmdir:
if (err)
rmdir(node_path);
More information about the Ocfs2-tools-commits
mailing list