[corosync] [PATCH 11/14] Move SAM to use CMAP service

Jan Friesse jfriesse at redhat.com
Wed Dec 14 15:41:19 GMT 2011


Signed-off-by: Jan Friesse <jfriesse at redhat.com>
---
 cts/agents/Makefile.am      |    2 +-
 cts/agents/sam_test_agent.c |  407 ++++++++++++++-----------------------------
 include/corosync/sam.h      |    9 +-
 lib/sam.c                   |  215 ++++++++++-------------
 test/Makefile.am            |    2 +-
 test/testsam.c              |  368 +++++++++------------------------------
 6 files changed, 315 insertions(+), 688 deletions(-)

diff --git a/cts/agents/Makefile.am b/cts/agents/Makefile.am
index f5ae3c2..9c25377 100644
--- a/cts/agents/Makefile.am
+++ b/cts/agents/Makefile.am
@@ -66,7 +66,7 @@ confdb_test_agent_LDADD =  -lconfdb $(LIBQB_LIBS)
 confdb_test_agent_LDFLAGS =  -L../../lib 
 
 sam_test_agent_SOURCES = sam_test_agent.c common_test_agent.c
-sam_test_agent_LDADD =  -lsam -lquorum -lconfdb $(LIBQB_LIBS)
+sam_test_agent_LDADD =  -lsam -lquorum -lcmap $(LIBQB_LIBS)
 sam_test_agent_LDFLAGS =  -L../../lib 
 
 votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
diff --git a/cts/agents/sam_test_agent.c b/cts/agents/sam_test_agent.c
index 9e681be..3ac366b 100644
--- a/cts/agents/sam_test_agent.c
+++ b/cts/agents/sam_test_agent.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009-2011 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -51,12 +51,13 @@
 #include <netdb.h>
 #include <sys/un.h>
 #include <corosync/corotypes.h>
-#include <corosync/confdb.h>
 #include <corosync/sam.h>
 #include <signal.h>
 #include <string.h>
 #include <syslog.h>
 #include <sys/wait.h>
+#include <corosync/cmap.h>
+
 #include "common_test_agent.h"
 
 extern const char *__progname;
@@ -246,6 +247,44 @@ static int test2 (void) {
 }
 
 /*
+ * Smoke test. Better to turn off coredump ;) This has no time limit, just restart process
+ * when it dies.
+ */
+static int test3 (void) {
+	cs_error_t error;
+	unsigned int instance_id;
+
+	syslog (LOG_INFO, "%s: initialize\n", __FUNCTION__);
+	error = sam_initialize (0, SAM_RECOVERY_POLICY_RESTART);
+	if (error != CS_OK) {
+		syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", error);
+		return 1;
+	}
+	syslog (LOG_INFO, "%s: register\n", __FUNCTION__);
+	error = sam_register (&instance_id);
+	if (error != CS_OK) {
+		syslog (LOG_ERR, "Can't register. Error %d\n", error);
+		return 1;
+	}
+
+	if (instance_id < 100) {
+		syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
+		error = sam_start ();
+		if (error != CS_OK) {
+			syslog (LOG_ERR, "Can't start hc. Error %d\n", error);
+			return 1;
+		}
+
+		syslog (LOG_INFO, "%s iid %d: Sending signal\n", __FUNCTION__, instance_id);
+		kill(getpid(), SIGSEGV);
+		return 1;
+	}
+
+	return 0;
+
+}
+
+/*
  * Test sam_data_store, sam_data_restore and sam_data_getsize
  */
 static int test4 (void)
@@ -504,7 +543,7 @@ static int test5_hc_cb (void)
 
 	if (res != CS_OK)
 		return 1;
-	
+
 	if (test5_hc_cb_count > 10)
 		return 1;
 
@@ -721,49 +760,35 @@ static void *test7_thread (void *arg)
  * Test quorum
  */
 static int test_quorum (void) {
-	confdb_handle_t cdb_handle;
+	cmap_handle_t cmap_handle;
 	cs_error_t err;
-	hdb_handle_t quorum_handle;
-	size_t value_len;
-	char key_value[256];
 	unsigned int instance_id;
 	pthread_t kill_thread;
+	char *str;
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		syslog (LOG_INFO, "Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		syslog (LOG_INFO, "Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
-	err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-	if (err != CS_OK) {
-		syslog (LOG_INFO, "Could not start object_find %d. Test skipped\n", err);
-		return (1);
-        }
 
-	err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &quorum_handle);
-	if (err != CS_OK) {
-		syslog (LOG_INFO, "Could not object_find \"quorum\": %d. Test skipped\n", err);
-		return (1);
-	}
-
-	err = confdb_key_get(cdb_handle, quorum_handle, "provider", strlen("provider"), key_value, &value_len);
-	if (err != CS_OK) {
+	if (cmap_get_string(cmap_handle, "quorum.provider", &str) != CS_OK) {
 		syslog (LOG_INFO, "Could not get \"provider\" key: %d. Test skipped\n", err);
 		return (1);
 	}
-
-        if (!(value_len - 1 == strlen ("testquorum") && memcmp (key_value, "testquorum", value_len - 1) == 0)) {
+        if (strcmp(str, "testquorum") != 0) {
 		syslog (LOG_INFO, "Provider is not testquorum. Test skipped\n");
 		return (1);
         }
+	free(str);
 
 	/*
 	 * Set to not quorate
 	 */
-	err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "0", strlen("0"));
+	err = cmap_set_uint8(cmap_handle, "quorum.quorate", 0);
 	if (err != CS_OK) {
-		syslog (LOG_INFO, "Can't create confdb key. Error %d\n", err);
+		syslog (LOG_INFO, "Can't set map key. Error %d\n", err);
 		return (2);
 	}
 
@@ -802,9 +827,9 @@ static int test_quorum (void) {
 		/*
 		 * Set to quorate
 		 */
-		err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "1", strlen("1"));
+		err = cmap_set_uint8(cmap_handle, "quorum.quorate", 1);
 		if (err != CS_OK) {
-			syslog (LOG_INFO, "Can't create confdb key. Error %d\n", err);
+			syslog (LOG_INFO, "Can't set map key. Error %d\n", err);
 			return (2);
 		}
 
@@ -818,9 +843,9 @@ static int test_quorum (void) {
 		/*
 		 * Set corosync unquorate
 		 */
-		err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "0", strlen("0"));
+		err = cmap_set_uint8(cmap_handle, "quorum.quorate", 0);
 		if (err != CS_OK) {
-			syslog (LOG_INFO, "Can't create confdb key. Error %d\n", err);
+			syslog (LOG_INFO, "Can't set map key. Error %d\n", err);
 			return (2);
 		}
 
@@ -839,23 +864,20 @@ static int test_quorum (void) {
 }
 
 /*
- * Test confdb integration + quit policy
+ * Test cmap integration + quit policy
  */
 static int test8 (pid_t pid, pid_t old_pid, int test_n) {
-	confdb_handle_t cdb_handle;
+	cmap_handle_t cmap_handle;
 	cs_error_t err;
-	hdb_handle_t res_handle, proc_handle, pid_handle;
-	size_t value_len;
 	uint64_t tstamp1, tstamp2;
 	int32_t msec_diff;
-	char key_value[256];
 	unsigned int instance_id;
-	char tmp_obj[PATH_MAX];
-	confdb_value_types_t cdbtype;
+	char key_name[CMAP_KEYNAME_MAXLEN];
+	char *str;
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		syslog (LOG_INFO, "Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		syslog (LOG_INFO, "Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
@@ -867,50 +889,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		 */
 		syslog (LOG_INFO, "%s Testing if object exists (it shouldn't)\n", __FUNCTION__);
 
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err == CS_OK) {
-			syslog (LOG_INFO, "Could find object \"%s\": %d.\n", tmp_obj, err);
+			syslog (LOG_INFO, "Could find key \"%s\": %d.\n", key_name, err);
+			free(str);
 			return (2);
 		}
 	}
 
 	if (test_n == 1 || test_n == 2) {
 		syslog (LOG_INFO, "%s: initialize\n", __FUNCTION__);
-		err = sam_initialize (2000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CONFDB);
+		err = sam_initialize (2000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CMAP);
 		if (err != CS_OK) {
 			syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
 			return 2;
@@ -923,67 +913,31 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "recovery", strlen("recovery"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.recovery", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("quit") || memcmp (key_value, "quit", value_len) != 0) {
-			syslog (LOG_INFO, "Recovery key \"%s\" is not \"watchdog\".\n", key_value);
+		if (strcmp(str, "quit") != 0) {
+			syslog (LOG_INFO, "Recovery key \"%s\" is not \"quit\".\n", key_name);
 			return (2);
 		}
+		free(str);
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			syslog (LOG_INFO, "State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
 		err = sam_start ();
@@ -992,16 +946,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+		if (strcmp(str, "running") != 0) {
 			syslog (LOG_INFO, "State key is not \"running\".\n");
 			return (2);
 		}
+		free(str);
 
 		syslog (LOG_INFO, "%s iid %d: stop\n", __FUNCTION__, instance_id);
 		err = sam_stop ();
@@ -1010,30 +965,32 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			syslog (LOG_INFO, "State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		syslog (LOG_INFO, "%s iid %d: sleeping 5\n", __FUNCTION__, instance_id);
 		sleep (5);
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			syslog (LOG_INFO, "State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		syslog (LOG_INFO, "%s iid %d: start 2\n", __FUNCTION__, instance_id);
 		err = sam_start ();
@@ -1042,16 +999,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+		if (strcmp(str, "running") != 0) {
 			syslog (LOG_INFO, "State key is not \"running\".\n");
 			return (2);
 		}
+		free(str);
 
 		if (test_n == 2) {
 			syslog (LOG_INFO, "%s iid %d: sleeping 5. Should be killed\n", __FUNCTION__, instance_id);
@@ -1065,9 +1023,11 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				syslog (LOG_ERR, "Can't send hc. Error %d\n", err);
 				return 2;
 			}
-			err = confdb_key_get_typed (cdb_handle, pid_handle, "last_updated", &tstamp1, &value_len, &cdbtype);
+
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.last_updated", pid);
+			err = cmap_get_uint64(cmap_handle, key_name, &tstamp1);
 			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
+				syslog (LOG_INFO, "Could not get \"last_updated\" key: %d.\n", err);
 				return (2);
 			}
 			syslog (LOG_INFO, "%s iid %d: Sleep 1\n", __FUNCTION__, instance_id);
@@ -1078,9 +1038,9 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 			sleep (1);
-			err = confdb_key_get_typed (cdb_handle, pid_handle, "last_updated", &tstamp2, &value_len, &cdbtype);
+			err = cmap_get_uint64(cmap_handle, key_name, &tstamp2);
 			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
+				syslog (LOG_INFO, "Could not get \"last_updated\" key: %d.\n", err);
 				return (2);
 			}
 			msec_diff = (tstamp2 - tstamp1)/CS_TIME_NS_IN_MSEC;
@@ -1097,16 +1057,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+			if (strcmp(str, "stopped") != 0) {
 				syslog (LOG_INFO, "State key is not \"stopped\".\n");
 				return (2);
 			}
+			free(str);
 
 			syslog (LOG_INFO, "%s iid %d: exiting\n", __FUNCTION__, instance_id);
 			return (0);
@@ -1119,53 +1081,15 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		/*
 		 * Previous should be FAILED
 		 */
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
 
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("failed") || memcmp (key_value, "failed", value_len) != 0) {
+		if (strcmp(str, "failed") != 0) {
 			syslog (LOG_INFO, "State key is not \"failed\".\n");
 			return (2);
 		}
@@ -1177,20 +1101,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 }
 
 /*
- * Test confdb integration + restart policy
+ * Test cmap integration + restart policy
  */
 static int test9 (pid_t pid, pid_t old_pid, int test_n) {
-	confdb_handle_t cdb_handle;
 	cs_error_t err;
-	hdb_handle_t res_handle, proc_handle, pid_handle;
-	size_t value_len;
-	char key_value[256];
+	cmap_handle_t cmap_handle;
 	unsigned int instance_id;
-	char tmp_obj[PATH_MAX];
+	char *str;
+	char key_name[CMAP_KEYNAME_MAXLEN];
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		syslog (LOG_INFO, "Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		syslog (LOG_INFO, "Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
@@ -1198,7 +1120,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 
 	if (test_n == 1) {
 		syslog (LOG_INFO, "%s: initialize\n", __FUNCTION__);
-		err = sam_initialize (2000, SAM_RECOVERY_POLICY_RESTART | SAM_RECOVERY_POLICY_CONFDB);
+		err = sam_initialize (2000, SAM_RECOVERY_POLICY_RESTART | SAM_RECOVERY_POLICY_CMAP);
 		if (err != CS_OK) {
 			syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
 			return 2;
@@ -1213,68 +1135,31 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 		syslog (LOG_INFO, "%s: iid %d\n", __FUNCTION__, instance_id);
 
 		if (instance_id < 3) {
-			err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"),
-			    &res_handle);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not object_find \"resources\": %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find_start(cdb_handle, res_handle);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not object_find \"process\": %d.\n", err);
-				return (2);
-			}
-
-			if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-				snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-			}
-
-			err = confdb_object_find_start(cdb_handle, proc_handle);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-			if (err != CS_OK) {
-				syslog (LOG_INFO, "Could not object_find \"%s\": %d.\n", tmp_obj, err);
-				return (2);
-			}
-
-			err = confdb_key_get(cdb_handle, pid_handle, "recovery", strlen("recovery"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.recovery", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("restart") || memcmp (key_value, "restart", value_len) != 0) {
-				syslog (LOG_INFO, "Recovery key \"%s\" is not \"restart\".\n", key_value);
+			if (strcmp(str, "restart") != 0) {
+				syslog (LOG_INFO, "Recovery key \"%s\" is not \"restart\".\n", str);
 				return (2);
 			}
+			free(str);
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+			if (strcmp(str, "stopped") != 0) {
 				syslog (LOG_INFO, "State key is not \"stopped\".\n");
 				return (2);
 			}
+			free(str);
 
 			syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
 			err = sam_start ();
@@ -1283,16 +1168,17 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+			if (strcmp(str, "running") != 0) {
 				syslog (LOG_INFO, "State key is not \"running\".\n");
 				return (2);
 			}
+			free(str);
 
 			syslog (LOG_INFO, "%s iid %d: waiting for kill\n", __FUNCTION__, instance_id);
 			sleep (10);
@@ -1302,6 +1188,10 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 
 		if (instance_id == 3) {
 			syslog (LOG_INFO, "%s iid %d: mark failed\n", __FUNCTION__, instance_id);
+			if (err != CS_OK) {
+				syslog (LOG_ERR, "Can't start hc. Error %d\n", err);
+				return 2;
+			}
 			err = sam_mark_failed ();
 			if (err != CS_OK) {
 				syslog (LOG_ERR, "Can't mark failed. Error %d\n", err);
@@ -1322,56 +1212,18 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 		/*
 		 * Previous should be FAILED
 		 */
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			syslog (LOG_INFO, "Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("failed") || memcmp (key_value, "failed", value_len) != 0) {
+		if (strcmp(str, "failed") != 0) {
 			syslog (LOG_INFO, "State key is not \"failed\".\n");
 			return (2);
 		}
+		free(str);
 
 		return (0);
 	}
@@ -1390,7 +1242,7 @@ static int setup_hc (void)
 	cs_error_t err;
 	unsigned int instance_id;
 
-	err = sam_initialize (1000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CONFDB);
+	err = sam_initialize (1000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CMAP);
 	if (err != CS_OK) {
 		syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
 		return 2;
@@ -1432,6 +1284,8 @@ static int do_test_command(int sock, char* func, char*args[], int num_args)
 			err = test1 ();
 		} else if (strcmp ("test2", func) == 0) {
 			err = test2 ();
+		} else if (strcmp ("test3", func) == 0) {
+			err = test3 ();
 		} else if (strcmp ("test4", func) == 0) {
 			err = test4 ();
 		} else if (strcmp ("test5", func) == 0) {
@@ -1509,4 +1363,3 @@ int main (int argc, char *argv[])
 
 	return ret;
 }
-
diff --git a/include/corosync/sam.h b/include/corosync/sam.h
index 84bf532..c06aa3f 100644
--- a/include/corosync/sam.h
+++ b/include/corosync/sam.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * Copyright (c) 2009-2011 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -46,6 +46,7 @@ typedef enum {
 	SAM_RECOVERY_POLICY_QUORUM = 0x08,
 	SAM_RECOVERY_POLICY_QUORUM_QUIT = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_QUIT,
 	SAM_RECOVERY_POLICY_QUORUM_RESTART = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_RESTART,
+	SAM_RECOVERY_POLICY_CMAP = 0x10,
 	SAM_RECOVERY_POLICY_CONFDB = 0x10,
 } sam_recovery_policy_t;
 
@@ -227,13 +228,13 @@ cs_error_t sam_data_store (
 /**
  * Marks child as failed.
  *
- * This can be called only with SAM_RECOVERY_POLICY_CONFDB flag set and
+ * This can be called only with SAM_RECOVERY_POLICY_CMAP flag set and
  * makes sense only for SAM_RECOVERY_POLICY_RESTART. This will kill child without sending warn
- * signal. Confdb state key will be set to failed.
+ * signal. Cmap state key will be set to failed.
  *
  * @retval CS_OK in case no problem appeared
  * @retval CS_ERR_BAD_HANDLE library was not initialized or was already finalized
- * @retval CS_ERR_INVALID_PARAM recovery policy doesn't has SAM_RECOVERY_POLICY_CONFDB flag set
+ * @retval CS_ERR_INVALID_PARAM recovery policy doesn't has SAM_RECOVERY_POLICY_CMAP flag set
  * @retval CS_ERR_LIBRARY if some internal error appeared (communication with parent
  *         process)
  */
diff --git a/lib/sam.c b/lib/sam.c
index 5009264..0cfdbbe 100644
--- a/lib/sam.c
+++ b/lib/sam.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2010 Red Hat, Inc.
+ * Copyright (c) 2009-2011 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -50,7 +50,7 @@
 #include <corosync/corotypes.h>
 #include <qb/qbipcc.h>
 #include <corosync/corodefs.h>
-#include <corosync/confdb.h>
+#include <corosync/cmap.h>
 #include <corosync/hdb.h>
 #include <corosync/quorum.h>
 
@@ -62,14 +62,14 @@
 #include <sys/wait.h>
 #include <signal.h>
 
-#define SAM_CONFDB_S_FAILED		"failed"
-#define SAM_CONFDB_S_REGISTERED		"stopped"
-#define SAM_CONFDB_S_STARTED		"running"
-#define SAM_CONFDB_S_Q_WAIT		"waiting for quorum"
+#define SAM_CMAP_S_FAILED		"failed"
+#define SAM_CMAP_S_REGISTERED		"stopped"
+#define SAM_CMAP_S_STARTED		"running"
+#define SAM_CMAP_S_Q_WAIT		"waiting for quorum"
 
 #define SAM_RP_MASK_Q(pol)	(pol & (~SAM_RECOVERY_POLICY_QUORUM))
-#define SAM_RP_MASK_C(pol)	(pol & (~SAM_RECOVERY_POLICY_CONFDB))
-#define SAM_RP_MASK(pol)	(pol & (~(SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_CONFDB)))
+#define SAM_RP_MASK_C(pol)	(pol & (~SAM_RECOVERY_POLICY_CMAP))
+#define SAM_RP_MASK(pol)	(pol & (~(SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_CMAP)))
 
 enum sam_internal_status_t {
 	SAM_INTERNAL_STATUS_NOT_INITIALIZED = 0,
@@ -100,11 +100,11 @@ enum sam_parent_action_t {
 	SAM_PARENT_ACTION_CONTINUE
 };
 
-enum sam_confdb_key_t {
-	SAM_CONFDB_KEY_RECOVERY,
-	SAM_CONFDB_KEY_HC_PERIOD,
-	SAM_CONFDB_KEY_LAST_HC,
-	SAM_CONFDB_KEY_STATE,
+enum sam_cmap_key_t {
+	SAM_CMAP_KEY_RECOVERY,
+	SAM_CMAP_KEY_HC_PERIOD,
+	SAM_CMAP_KEY_LAST_HC,
+	SAM_CMAP_KEY_STATE,
 };
 
 static struct {
@@ -133,48 +133,53 @@ static struct {
 	uint32_t quorate;
 	int quorum_fd;
 
-	confdb_handle_t confdb_handle;
-	hdb_handle_t confdb_pid_handle;
+	cmap_handle_t cmap_handle;
+	char cmap_pid_path[CMAP_KEYNAME_MAXLEN];
 } sam_internal_data;
 
 extern const char *__progname;
 
-static cs_error_t sam_confdb_update_key (enum sam_confdb_key_t key, const char *value)
+static cs_error_t sam_cmap_update_key (enum sam_cmap_key_t key, const char *value)
 {
 	cs_error_t err;
 	const char *svalue;
 	uint64_t hc_period, last_hc;
 	const char *ssvalue[] = { [SAM_RECOVERY_POLICY_QUIT] = "quit", [SAM_RECOVERY_POLICY_RESTART] = "restart" };
+	char key_name[CMAP_KEYNAME_MAXLEN];
 
 	switch (key) {
-	case SAM_CONFDB_KEY_RECOVERY:
+	case SAM_CMAP_KEY_RECOVERY:
 		svalue = ssvalue[SAM_RP_MASK (sam_internal_data.recovery_policy)];
 
-		if ((err = confdb_key_create_typed (sam_internal_data.confdb_handle, sam_internal_data.confdb_pid_handle,
-			"recovery", svalue, strlen ((const char *)svalue), CONFDB_VALUETYPE_STRING)) != CS_OK) {
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path,
+				"recovery");
+		if ((err = cmap_set_string(sam_internal_data.cmap_handle, key_name, svalue)) != CS_OK) {
 			goto exit_error;
 		}
 		break;
-	case SAM_CONFDB_KEY_HC_PERIOD:
+	case SAM_CMAP_KEY_HC_PERIOD:
 		hc_period = sam_internal_data.time_interval;
 
-		if ((err = confdb_key_create_typed (sam_internal_data.confdb_handle, sam_internal_data.confdb_pid_handle,
-			"poll_period", &hc_period, sizeof (hc_period), CONFDB_VALUETYPE_UINT64)) != CS_OK) {
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path,
+				"poll_period");
+		if ((err = cmap_set_uint64(sam_internal_data.cmap_handle, key_name, hc_period)) != CS_OK) {
 			goto exit_error;
 		}
 		break;
-	case SAM_CONFDB_KEY_LAST_HC:
+	case SAM_CMAP_KEY_LAST_HC:
 		last_hc = cs_timestamp_get();
 
-		if ((err = confdb_key_create_typed (sam_internal_data.confdb_handle, sam_internal_data.confdb_pid_handle,
-			"last_updated", &last_hc, sizeof (last_hc), CONFDB_VALUETYPE_UINT64)) != CS_OK) {
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path,
+				"last_updated");
+		if ((err = cmap_set_uint64(sam_internal_data.cmap_handle, key_name, last_hc)) != CS_OK) {
 			goto exit_error;
 		}
 		break;
-	case SAM_CONFDB_KEY_STATE:
+	case SAM_CMAP_KEY_STATE:
 		svalue = value;
-		if ((err = confdb_key_create_typed (sam_internal_data.confdb_handle, sam_internal_data.confdb_pid_handle,
-			"state", svalue, strlen ((const char *)svalue), CONFDB_VALUETYPE_STRING)) != CS_OK) {
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "%s%s", sam_internal_data.cmap_pid_path,
+				"state");
+		if ((err = cmap_set_string(sam_internal_data.cmap_handle, key_name, svalue)) != CS_OK) {
 			goto exit_error;
 		}
 		break;
@@ -186,89 +191,53 @@ exit_error:
 	return (err);
 }
 
-static cs_error_t sam_confdb_destroy_pid_obj (void)
+static cs_error_t sam_cmap_destroy_pid_path (void)
 {
-	return (confdb_object_destroy (sam_internal_data.confdb_handle, sam_internal_data.confdb_pid_handle));
-}
-
-static cs_error_t sam_confdb_register (void)
-{
-	const char *obj_name;
+	cmap_iter_handle_t iter;
 	cs_error_t err;
-	confdb_handle_t confdb_handle;
-	hdb_handle_t resource_handle, process_handle, pid_handle, obj_handle;
-	hdb_handle_t *res_handle;
-	char tmp_obj[PATH_MAX];
-	int i;
+	char key_name[CMAP_KEYNAME_MAXLEN];
 
-	if ((err = confdb_initialize (&confdb_handle, NULL)) != CS_OK) {
-		return (err);
+	err = cmap_iter_init(sam_internal_data.cmap_handle, sam_internal_data.cmap_pid_path, &iter);
+	if (err != CS_OK) {
+		goto error_exit;
 	}
 
-	for (i = 0; i < 3; i++) {
-		switch (i) {
-		case 0:
-			obj_name = "resources";
-			obj_handle = OBJECT_PARENT_HANDLE;
-			res_handle = &resource_handle;
-			break;
-		case 1:
-			obj_name = "process";
-			obj_handle = resource_handle;
-			res_handle = &process_handle;
-			break;
-		case 2:
-			if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, getpid ()) >= sizeof (tmp_obj)) {
-				snprintf (tmp_obj, sizeof (tmp_obj), "%d", getpid ());
-			}
+	while ((err = cmap_iter_next(sam_internal_data.cmap_handle, iter, key_name, NULL, NULL)) == CS_OK) {
+		cmap_delete(sam_internal_data.cmap_handle, key_name);
+	}
 
-			obj_name = tmp_obj;
-			obj_handle = process_handle;
-			res_handle = &pid_handle;
-			break;
-		}
+	err = cmap_iter_finalize(sam_internal_data.cmap_handle, iter);
 
-		if ((err = confdb_object_find_start (confdb_handle, obj_handle)) != CS_OK) {
-			goto finalize_error;
-		}
+error_exit:
+	return (err);
+}
 
-		if ((err = confdb_object_find (confdb_handle, obj_handle, obj_name, strlen (obj_name),
-			res_handle)) != CS_OK) {
-			if (err == CONFDB_ERR_ACCESS) {
-				/*
-				 * Try to create object
-				 */
-				if ((err = confdb_object_create (confdb_handle, obj_handle, obj_name,
-					strlen (obj_name), res_handle)) != CS_OK) {
-					goto finalize_error;
-				}
-			} else {
-				goto finalize_error;
-			}
-		} else  {
-			if ((err = confdb_object_find_destroy (confdb_handle, obj_handle)) != CS_OK) {
-				goto finalize_error;
-			}
-		}
+static cs_error_t sam_cmap_register (void)
+{
+	cs_error_t err;
+	cmap_handle_t cmap_handle;
+
+	if ((err = cmap_initialize (&cmap_handle)) != CS_OK) {
+		return (err);
 	}
 
-	sam_internal_data.confdb_pid_handle = pid_handle;
-	sam_internal_data.confdb_handle = confdb_handle;
+	snprintf(sam_internal_data.cmap_pid_path, CMAP_KEYNAME_MAXLEN, "resources.process.%d.", getpid());
+
+	sam_internal_data.cmap_handle = cmap_handle;
 
-	if ((err = sam_confdb_update_key (SAM_CONFDB_KEY_RECOVERY, NULL)) != CS_OK) {
+	if ((err = sam_cmap_update_key (SAM_CMAP_KEY_RECOVERY, NULL)) != CS_OK) {
 		goto destroy_finalize_error;
 	}
 
-	if ((err = sam_confdb_update_key (SAM_CONFDB_KEY_HC_PERIOD, NULL)) != CS_OK) {
+	if ((err = sam_cmap_update_key (SAM_CMAP_KEY_HC_PERIOD, NULL)) != CS_OK) {
 		goto destroy_finalize_error;
 	}
 
 	return (CS_OK);
 
 destroy_finalize_error:
-	sam_confdb_destroy_pid_obj ();
-finalize_error:
-	confdb_finalize (confdb_handle);
+	sam_cmap_destroy_pid_path ();
+	cmap_finalize (cmap_handle);
 	return (err);
 }
 
@@ -605,21 +574,21 @@ cs_error_t sam_start (void)
 
 	recpol = sam_internal_data.recovery_policy;
 
-	if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CONFDB) {
+	if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CMAP) {
 		pthread_mutex_lock (&sam_internal_data.lock);
 	}
 
 	command = SAM_COMMAND_START;
 
 	if (sam_safe_write (sam_internal_data.child_fd_out, &command, sizeof (command)) != sizeof (command)) {
-		if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CONFDB) {
+		if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CMAP) {
 			pthread_mutex_unlock (&sam_internal_data.lock);
 		}
 
 		return (CS_ERR_LIBRARY);
 	}
 
-	if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CONFDB) {
+	if (recpol & SAM_RECOVERY_POLICY_QUORUM || recpol & SAM_RECOVERY_POLICY_CMAP) {
 		/*
 		 * Wait for parent reply
 		 */
@@ -652,19 +621,19 @@ cs_error_t sam_stop (void)
 
 	command = SAM_COMMAND_STOP;
 
-	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
+	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
 		pthread_mutex_lock (&sam_internal_data.lock);
 	}
 
 	if (sam_safe_write (sam_internal_data.child_fd_out, &command, sizeof (command)) != sizeof (command)) {
-		if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
+		if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
 			pthread_mutex_unlock (&sam_internal_data.lock);
 		}
 
 		return (CS_ERR_LIBRARY);
 	}
 
-	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
+	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
 		/*
 		 * Wait for parent reply
 		 */
@@ -735,7 +704,7 @@ cs_error_t sam_mark_failed (void)
 		return (CS_ERR_BAD_HANDLE);
 	}
 
-	if (!(sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB)) {
+	if (!(sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP)) {
 		return (CS_ERR_INVALID_PARAM);
 	}
 
@@ -866,8 +835,8 @@ static cs_error_t sam_parent_wait_for_quorum (
 	struct pollfd pfds[2];
 	int poll_err;
 
-	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
-		if ((err = sam_confdb_update_key (SAM_CONFDB_KEY_STATE, SAM_CONFDB_S_Q_WAIT)) != CS_OK) {
+	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
+		if ((err = sam_cmap_update_key (SAM_CMAP_KEY_STATE, SAM_CMAP_S_Q_WAIT)) != CS_OK) {
 			goto error_reply;
 		}
 	}
@@ -920,8 +889,8 @@ static cs_error_t sam_parent_wait_for_quorum (
 		}
 	}
 
-	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
-		if ((err = sam_confdb_update_key (SAM_CONFDB_KEY_STATE, SAM_CONFDB_S_STARTED)) != CS_OK) {
+	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
+		if ((err = sam_cmap_update_key (SAM_CMAP_KEY_STATE, SAM_CMAP_S_STARTED)) != CS_OK) {
 			goto error_reply;
 		}
 	}
@@ -929,14 +898,14 @@ static cs_error_t sam_parent_wait_for_quorum (
 	return (sam_parent_reply_send (CS_OK, parent_fd_in, parent_fd_out));
 
 error_reply:
-	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CONFDB) {
-		sam_confdb_update_key (SAM_CONFDB_KEY_STATE, SAM_CONFDB_S_REGISTERED);
+	if (sam_internal_data.recovery_policy & SAM_RECOVERY_POLICY_CMAP) {
+		sam_cmap_update_key (SAM_CMAP_KEY_STATE, SAM_CMAP_S_REGISTERED);
 	}
 
 	return (sam_parent_reply_send (err, parent_fd_in, parent_fd_out));
 }
 
-static cs_error_t sam_parent_confdb_state_set (
+static cs_error_t sam_parent_cmap_state_set (
 	int parent_fd_in,
 	int parent_fd_out,
 	int state)
@@ -945,12 +914,12 @@ static cs_error_t sam_parent_confdb_state_set (
 	const char *state_s;
 
 	if (state == 1) {
-		state_s = SAM_CONFDB_S_STARTED;
+		state_s = SAM_CMAP_S_STARTED;
 	} else {
-		state_s = SAM_CONFDB_S_REGISTERED;
+		state_s = SAM_CMAP_S_REGISTERED;
 	}
 
-	if ((err = sam_confdb_update_key (SAM_CONFDB_KEY_STATE, state_s)) != CS_OK) {
+	if ((err = sam_cmap_update_key (SAM_CMAP_KEY_STATE, state_s)) != CS_OK) {
 		goto error_reply;
 	}
 
@@ -995,7 +964,7 @@ static cs_error_t sam_parent_mark_child_failed (
 
 	sam_internal_data.term_send = 1;
 	sam_internal_data.recovery_policy = SAM_RECOVERY_POLICY_QUIT |
-	    (SAM_RP_MASK_C (recpol) ? SAM_RECOVERY_POLICY_CONFDB : 0) |
+	    (SAM_RP_MASK_C (recpol) ? SAM_RECOVERY_POLICY_CMAP : 0) |
 	    (SAM_RP_MASK_Q (recpol) ? SAM_RECOVERY_POLICY_QUORUM : 0);
 
 	return (sam_parent_kill_child (action, child_pid));
@@ -1132,8 +1101,8 @@ static enum sam_parent_action_t sam_parent_handler (
 					goto action_exit;
 				}
 
-				if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
-					sam_confdb_update_key (SAM_CONFDB_KEY_LAST_HC, NULL);
+				if (recpol & SAM_RECOVERY_POLICY_CMAP) {
+					sam_cmap_update_key (SAM_CMAP_KEY_LAST_HC, NULL);
 				}
 
 				/*
@@ -1152,8 +1121,8 @@ static enum sam_parent_action_t sam_parent_handler (
 							}
 						}
 
-						if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
-							if (sam_parent_confdb_state_set (parent_fd_in,
+						if (recpol & SAM_RECOVERY_POLICY_CMAP) {
+							if (sam_parent_cmap_state_set (parent_fd_in,
 							    parent_fd_out, 1) != CS_OK) {
 								continue;
 							    }
@@ -1167,8 +1136,8 @@ static enum sam_parent_action_t sam_parent_handler (
 						/*
 						 *  Started
 						 */
-						if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
-							if (sam_parent_confdb_state_set (parent_fd_in,
+						if (recpol & SAM_RECOVERY_POLICY_CMAP) {
+							if (sam_parent_cmap_state_set (parent_fd_in,
 							    parent_fd_out, 0) != CS_OK) {
 								continue;
 							    }
@@ -1226,11 +1195,11 @@ cs_error_t sam_register (
 
 	recpol = sam_internal_data.recovery_policy;
 
-	if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
+	if (recpol & SAM_RECOVERY_POLICY_CMAP) {
 		/*
-		 * Register to objdb
+		 * Register to cmap
 		 */
-		if ((error = sam_confdb_register ()) != CS_OK) {
+		if ((error = sam_cmap_register ()) != CS_OK) {
 			goto error_exit;
 		}
 	}
@@ -1251,8 +1220,8 @@ cs_error_t sam_register (
 			goto error_exit;
 		}
 
-		if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
-			if ((error = sam_confdb_update_key (SAM_CONFDB_KEY_STATE, SAM_CONFDB_S_REGISTERED)) != CS_OK) {
+		if (recpol & SAM_RECOVERY_POLICY_CMAP) {
+			if ((error = sam_cmap_update_key (SAM_CMAP_KEY_STATE, SAM_CMAP_S_REGISTERED)) != CS_OK) {
 				goto error_exit;
 			}
 		}
@@ -1328,14 +1297,14 @@ cs_error_t sam_register (
 					quorum_finalize (sam_internal_data.quorum_handle);
 				}
 
-				if (recpol & SAM_RECOVERY_POLICY_CONFDB) {
+				if (recpol & SAM_RECOVERY_POLICY_CMAP) {
 					if (old_action == SAM_PARENT_ACTION_RECOVERY) {
 						/*
 						 * Mark as failed
 						 */
-						sam_confdb_update_key (SAM_CONFDB_KEY_STATE, SAM_CONFDB_S_FAILED);
+						sam_cmap_update_key (SAM_CMAP_KEY_STATE, SAM_CMAP_S_FAILED);
 					} else {
-						sam_confdb_destroy_pid_obj ();
+						sam_cmap_destroy_pid_path ();
 					}
 				}
 
diff --git a/test/Makefile.am b/test/Makefile.am
index 1b28643..0f1c818 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -82,7 +82,7 @@ logsys_t1_LDADD		= -llogsys  $(LIBQB_LIBS)
 logsys_t1_LDFLAGS	= -L../exec
 logsys_t2_LDADD		= -llogsys  $(LIBQB_LIBS)
 logsys_t2_LDFLAGS	= -L../exec
-testsam_LDADD		= -lsam -lconfdb -lquorum $(LIBQB_LIBS)
+testsam_LDADD		= -lsam -lcmap -lquorum $(LIBQB_LIBS)
 testsam_LDFLAGS		= -L../lib
 
 LINT_FILES1:=$(filter-out sa_error.c, $(wildcard *.c))
diff --git a/test/testsam.c b/test/testsam.c
index ee4d59f..7765ffa 100644
--- a/test/testsam.c
+++ b/test/testsam.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009-2011 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -46,12 +46,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <corosync/corotypes.h>
-#include <corosync/confdb.h>
 #include <corosync/sam.h>
 #include <signal.h>
 #include <string.h>
 #include <sys/wait.h>
-
+#include <corosync/cmap.h>
 extern const char *__progname;
 
 static int test2_sig_delivered = 0;
@@ -245,7 +244,6 @@ static int test2 (void) {
 static int test3 (void) {
 	cs_error_t error;
 	unsigned int instance_id;
-	int tmp1, tmp2, tmp3;
 
 	printf ("%s: initialize\n", __FUNCTION__);
 	error = sam_initialize (0, SAM_RECOVERY_POLICY_RESTART);
@@ -268,12 +266,8 @@ static int test3 (void) {
 			return 1;
 		}
 
-		printf ("%s iid %d: divide by zero\n", __FUNCTION__, instance_id);
-		tmp2 = rand ();
-		tmp3 = 0;
-		tmp1 = tmp2 / tmp3;
-		tmp3 = tmp1;
-
+		printf ("%s iid %d: Sending signal\n", __FUNCTION__, instance_id);
+		kill(getpid(), SIGSEGV);
 		return 1;
 	}
 
@@ -755,49 +749,35 @@ static void *test7_thread (void *arg)
  * Test quorum
  */
 static int test7 (void) {
-	confdb_handle_t cdb_handle;
+	cmap_handle_t cmap_handle;
 	cs_error_t err;
-	hdb_handle_t quorum_handle;
-	size_t value_len;
-	char key_value[256];
 	unsigned int instance_id;
 	pthread_t kill_thread;
+	char *str;
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		printf ("Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		printf ("Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
-	err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-	if (err != CS_OK) {
-		printf ("Could not start object_find %d. Test skipped\n", err);
-		return (1);
-        }
-
-	err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &quorum_handle);
-	if (err != CS_OK) {
-		printf ("Could not object_find \"quorum\": %d. Test skipped\n", err);
-		return (1);
-	}
 
-	err = confdb_key_get(cdb_handle, quorum_handle, "provider", strlen("provider"), key_value, &value_len);
-	if (err != CS_OK) {
+	if (cmap_get_string(cmap_handle, "quorum.provider", &str) != CS_OK) {
 		printf ("Could not get \"provider\" key: %d. Test skipped\n", err);
 		return (1);
 	}
-
-        if (!(value_len - 1 == strlen ("testquorum") && memcmp (key_value, "testquorum", value_len - 1) == 0)) {
+        if (strcmp(str, "testquorum") != 0) {
 		printf ("Provider is not testquorum. Test skipped\n");
 		return (1);
         }
+	free(str);
 
 	/*
 	 * Set to not quorate
 	 */
-	err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "0", strlen("0"));
+	err = cmap_set_uint8(cmap_handle, "quorum.quorate", 0);
 	if (err != CS_OK) {
-		printf ("Can't create confdb key. Error %d\n", err);
+		printf ("Can't set map key. Error %d\n", err);
 		return (2);
 	}
 
@@ -836,9 +816,9 @@ static int test7 (void) {
 		/*
 		 * Set to quorate
 		 */
-		err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "1", strlen("1"));
+		err = cmap_set_uint8(cmap_handle, "quorum.quorate", 1);
 		if (err != CS_OK) {
-			printf ("Can't create confdb key. Error %d\n", err);
+			printf ("Can't set map key. Error %d\n", err);
 			return (2);
 		}
 
@@ -852,9 +832,9 @@ static int test7 (void) {
 		/*
 		 * Set corosync unquorate
 		 */
-		err = confdb_key_create(cdb_handle, quorum_handle, "quorate", strlen("quorate"), "0", strlen("0"));
+		err = cmap_set_uint8(cmap_handle, "quorum.quorate", 0);
 		if (err != CS_OK) {
-			printf ("Can't create confdb key. Error %d\n", err);
+			printf ("Can't set map key. Error %d\n", err);
 			return (2);
 		}
 
@@ -873,23 +853,20 @@ static int test7 (void) {
 }
 
 /*
- * Test confdb integration + quit policy
+ * Test cmap integration + quit policy
  */
 static int test8 (pid_t pid, pid_t old_pid, int test_n) {
-	confdb_handle_t cdb_handle;
+	cmap_handle_t cmap_handle;
 	cs_error_t err;
-	hdb_handle_t res_handle, proc_handle, pid_handle;
-	size_t value_len;
 	uint64_t tstamp1, tstamp2;
 	int32_t msec_diff;
-	char key_value[256];
 	unsigned int instance_id;
-	char tmp_obj[PATH_MAX];
-	confdb_value_types_t cdbtype;
+	char key_name[CMAP_KEYNAME_MAXLEN];
+	char *str;
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		printf ("Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		printf ("Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
@@ -901,50 +878,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		 */
 		printf ("%s Testing if object exists (it shouldn't)\n", __FUNCTION__);
 
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err == CS_OK) {
-			printf ("Could find object \"%s\": %d.\n", tmp_obj, err);
+			printf ("Could find key \"%s\": %d.\n", key_name, err);
+			free(str);
 			return (2);
 		}
 	}
 
 	if (test_n == 1 || test_n == 2) {
 		printf ("%s: initialize\n", __FUNCTION__);
-		err = sam_initialize (2000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CONFDB);
+		err = sam_initialize (2000, SAM_RECOVERY_POLICY_QUIT | SAM_RECOVERY_POLICY_CMAP);
 		if (err != CS_OK) {
 			fprintf (stderr, "Can't initialize SAM API. Error %d\n", err);
 			return 2;
@@ -957,67 +902,31 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "recovery", strlen("recovery"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.recovery", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"recovery\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("quit") || memcmp (key_value, "quit", value_len) != 0) {
-			printf ("Recovery key \"%s\" is not \"watchdog\".\n", key_value);
+		if (strcmp(str, "quit") != 0) {
+			printf ("Recovery key \"%s\" is not \"quit\".\n", key_name);
 			return (2);
 		}
+		free(str);
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			printf ("State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		printf ("%s iid %d: start\n", __FUNCTION__, instance_id);
 		err = sam_start ();
@@ -1026,16 +935,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+		if (strcmp(str, "running") != 0) {
 			printf ("State key is not \"running\".\n");
 			return (2);
 		}
+		free(str);
 
 		printf ("%s iid %d: stop\n", __FUNCTION__, instance_id);
 		err = sam_stop ();
@@ -1044,30 +954,32 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			printf ("State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		printf ("%s iid %d: sleeping 5\n", __FUNCTION__, instance_id);
 		sleep (5);
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+		if (strcmp(str, "stopped") != 0) {
 			printf ("State key is not \"stopped\".\n");
 			return (2);
 		}
+		free(str);
 
 		printf ("%s iid %d: start 2\n", __FUNCTION__, instance_id);
 		err = sam_start ();
@@ -1076,16 +988,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			return 2;
 		}
 
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+		if (strcmp(str, "running") != 0) {
 			printf ("State key is not \"running\".\n");
 			return (2);
 		}
+		free(str);
 
 		if (test_n == 2) {
 			printf ("%s iid %d: sleeping 5. Should be killed\n", __FUNCTION__, instance_id);
@@ -1099,9 +1012,11 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				fprintf (stderr, "Can't send hc. Error %d\n", err);
 				return 2;
 			}
-			err = confdb_key_get_typed (cdb_handle, pid_handle, "last_updated", &tstamp1, &value_len, &cdbtype);
+
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.last_updated", pid);
+			err = cmap_get_uint64(cmap_handle, key_name, &tstamp1);
 			if (err != CS_OK) {
-				printf ("Could not get \"state\" key: %d.\n", err);
+				printf ("Could not get \"last_updated\" key: %d.\n", err);
 				return (2);
 			}
 			printf ("%s iid %d: Sleep 1\n", __FUNCTION__, instance_id);
@@ -1112,9 +1027,9 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 			sleep (1);
-			err = confdb_key_get_typed (cdb_handle, pid_handle, "last_updated", &tstamp2, &value_len, &cdbtype);
+			err = cmap_get_uint64(cmap_handle, key_name, &tstamp2);
 			if (err != CS_OK) {
-				printf ("Could not get \"state\" key: %d.\n", err);
+				printf ("Could not get \"last_updated\" key: %d.\n", err);
 				return (2);
 			}
 			msec_diff = (tstamp2 - tstamp1)/CS_TIME_NS_IN_MSEC;
@@ -1131,16 +1046,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				printf ("Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+			if (strcmp(str, "stopped") != 0) {
 				printf ("State key is not \"stopped\".\n");
 				return (2);
 			}
+			free(str);
 
 			printf ("%s iid %d: exiting\n", __FUNCTION__, instance_id);
 			return (0);
@@ -1153,53 +1070,15 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		/*
 		 * Previous should be FAILED
 		 */
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
 
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("failed") || memcmp (key_value, "failed", value_len) != 0) {
+		if (strcmp(str, "failed") != 0) {
 			printf ("State key is not \"failed\".\n");
 			return (2);
 		}
@@ -1211,20 +1090,18 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 }
 
 /*
- * Test confdb integration + restart policy
+ * Test cmap integration + restart policy
  */
 static int test9 (pid_t pid, pid_t old_pid, int test_n) {
-	confdb_handle_t cdb_handle;
 	cs_error_t err;
-	hdb_handle_t res_handle, proc_handle, pid_handle;
-	size_t value_len;
-	char key_value[256];
+	cmap_handle_t cmap_handle;
 	unsigned int instance_id;
-	char tmp_obj[PATH_MAX];
+	char *str;
+	char key_name[CMAP_KEYNAME_MAXLEN];
 
-	err = confdb_initialize (&cdb_handle, NULL);
+	err = cmap_initialize (&cmap_handle);
 	if (err != CS_OK) {
-		printf ("Could not initialize Cluster Configuration Database API instance error %d. Test skipped\n", err);
+		printf ("Could not initialize Cluster Map API instance error %d. Test skipped\n", err);
 		return (1);
 	}
 
@@ -1232,7 +1109,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 
 	if (test_n == 1) {
 		printf ("%s: initialize\n", __FUNCTION__);
-		err = sam_initialize (2000, SAM_RECOVERY_POLICY_RESTART | SAM_RECOVERY_POLICY_CONFDB);
+		err = sam_initialize (2000, SAM_RECOVERY_POLICY_RESTART | SAM_RECOVERY_POLICY_CMAP);
 		if (err != CS_OK) {
 			fprintf (stderr, "Can't initialize SAM API. Error %d\n", err);
 			return 2;
@@ -1247,68 +1124,31 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 		printf ("%s: iid %d\n", __FUNCTION__, instance_id);
 
 		if (instance_id < 3) {
-			err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-			if (err != CS_OK) {
-				printf ("Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"),
-			    &res_handle);
-			if (err != CS_OK) {
-				printf ("Could not object_find \"resources\": %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find_start(cdb_handle, res_handle);
-			if (err != CS_OK) {
-				printf ("Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-			if (err != CS_OK) {
-				printf ("Could not object_find \"process\": %d.\n", err);
-				return (2);
-			}
-
-			if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-				snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-			}
-
-			err = confdb_object_find_start(cdb_handle, proc_handle);
-			if (err != CS_OK) {
-				printf ("Could not start object_find %d.\n", err);
-				return (2);
-			}
-
-			err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-			if (err != CS_OK) {
-				printf ("Could not object_find \"%s\": %d.\n", tmp_obj, err);
-				return (2);
-			}
-
-			err = confdb_key_get(cdb_handle, pid_handle, "recovery", strlen("recovery"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.recovery", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				printf ("Could not get \"recovery\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("restart") || memcmp (key_value, "restart", value_len) != 0) {
-				printf ("Recovery key \"%s\" is not \"restart\".\n", key_value);
+			if (strcmp(str, "restart") != 0) {
+				printf ("Recovery key \"%s\" is not \"restart\".\n", str);
 				return (2);
 			}
+			free(str);
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				printf ("Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("stopped") || memcmp (key_value, "stopped", value_len) != 0) {
+			if (strcmp(str, "stopped") != 0) {
 				printf ("State key is not \"stopped\".\n");
 				return (2);
 			}
+			free(str);
 
 			printf ("%s iid %d: start\n", __FUNCTION__, instance_id);
 			err = sam_start ();
@@ -1317,16 +1157,17 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 				return 2;
 			}
 
-			err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+			err = cmap_get_string(cmap_handle, key_name, &str);
 			if (err != CS_OK) {
 				printf ("Could not get \"state\" key: %d.\n", err);
 				return (2);
 			}
 
-			if (value_len != strlen ("running") || memcmp (key_value, "running", value_len) != 0) {
+			if (strcmp(str, "running") != 0) {
 				printf ("State key is not \"running\".\n");
 				return (2);
 			}
+			free(str);
 
 			printf ("%s iid %d: waiting for kill\n", __FUNCTION__, instance_id);
 			sleep (10);
@@ -1360,56 +1201,18 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 		/*
 		 * Previous should be FAILED
 		 */
-		err = confdb_object_find_start(cdb_handle, OBJECT_PARENT_HANDLE);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, OBJECT_PARENT_HANDLE, "resources", strlen("resources"), &res_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"resources\": %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find_start(cdb_handle, res_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, res_handle, "process", strlen("process"), &proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"process\": %d.\n", err);
-			return (2);
-		}
-
-		if (snprintf (tmp_obj, sizeof (tmp_obj), "%s:%d", __progname, pid) >= sizeof (tmp_obj)) {
-			snprintf (tmp_obj, sizeof (tmp_obj), "%d", pid);
-		}
-
-		err = confdb_object_find_start(cdb_handle, proc_handle);
-		if (err != CS_OK) {
-			printf ("Could not start object_find %d.\n", err);
-			return (2);
-		}
-
-		err = confdb_object_find(cdb_handle, proc_handle, tmp_obj, strlen(tmp_obj), &pid_handle);
-		if (err != CS_OK) {
-			printf ("Could not object_find \"%s\": %d.\n", tmp_obj, err);
-			return (2);
-		}
-
-		err = confdb_key_get(cdb_handle, pid_handle, "state", strlen("state"), key_value, &value_len);
+		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
+		err = cmap_get_string(cmap_handle, key_name, &str);
 		if (err != CS_OK) {
 			printf ("Could not get \"state\" key: %d.\n", err);
 			return (2);
 		}
 
-		if (value_len != strlen ("failed") || memcmp (key_value, "failed", value_len) != 0) {
+		if (strcmp(str, "failed") != 0) {
 			printf ("State key is not \"failed\".\n");
 			return (2);
 		}
+		free(str);
 
 		return (0);
 	}
@@ -1610,6 +1413,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	fprintf (stderr, "test8 %s\n", (WEXITSTATUS (stat) == 0 ? "passed" : (WEXITSTATUS (stat) == 1 ? "skipped" : "failed")));
 	if (WEXITSTATUS (stat) == 1)
 		no_skipped++;
 	if (WEXITSTATUS (stat) > 1)
-- 
1.7.1



More information about the discuss mailing list