|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
/*
|
|
|
- * Copyright (c) 2009 Red Hat, Inc.
|
|
|
|
|
|
|
+ * Copyright (c) 2009-2011 Red Hat, Inc.
|
|
|
*
|
|
*
|
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
|
*
|
|
*
|
|
@@ -51,12 +51,13 @@
|
|
|
#include <netdb.h>
|
|
#include <netdb.h>
|
|
|
#include <sys/un.h>
|
|
#include <sys/un.h>
|
|
|
#include <corosync/corotypes.h>
|
|
#include <corosync/corotypes.h>
|
|
|
-#include <corosync/confdb.h>
|
|
|
|
|
#include <corosync/sam.h>
|
|
#include <corosync/sam.h>
|
|
|
#include <signal.h>
|
|
#include <signal.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
#include <syslog.h>
|
|
#include <syslog.h>
|
|
|
#include <sys/wait.h>
|
|
#include <sys/wait.h>
|
|
|
|
|
+#include <corosync/cmap.h>
|
|
|
|
|
+
|
|
|
#include "common_test_agent.h"
|
|
#include "common_test_agent.h"
|
|
|
|
|
|
|
|
extern const char *__progname;
|
|
extern const char *__progname;
|
|
@@ -245,6 +246,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
|
|
* Test sam_data_store, sam_data_restore and sam_data_getsize
|
|
|
*/
|
|
*/
|
|
@@ -504,7 +543,7 @@ static int test5_hc_cb (void)
|
|
|
|
|
|
|
|
if (res != CS_OK)
|
|
if (res != CS_OK)
|
|
|
return 1;
|
|
return 1;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (test5_hc_cb_count > 10)
|
|
if (test5_hc_cb_count > 10)
|
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
|
@@ -721,49 +760,35 @@ static void *test7_thread (void *arg)
|
|
|
* Test quorum
|
|
* Test quorum
|
|
|
*/
|
|
*/
|
|
|
static int test_quorum (void) {
|
|
static int test_quorum (void) {
|
|
|
- confdb_handle_t cdb_handle;
|
|
|
|
|
|
|
+ cmap_handle_t cmap_handle;
|
|
|
cs_error_t err;
|
|
cs_error_t err;
|
|
|
- hdb_handle_t quorum_handle;
|
|
|
|
|
- size_t value_len;
|
|
|
|
|
- char key_value[256];
|
|
|
|
|
unsigned int instance_id;
|
|
unsigned int instance_id;
|
|
|
pthread_t kill_thread;
|
|
pthread_t kill_thread;
|
|
|
|
|
+ char *str;
|
|
|
|
|
|
|
|
- err = confdb_initialize (&cdb_handle, NULL);
|
|
|
|
|
|
|
+ err = cmap_initialize (&cmap_handle);
|
|
|
if (err != CS_OK) {
|
|
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);
|
|
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);
|
|
syslog (LOG_INFO, "Could not get \"provider\" key: %d. Test skipped\n", err);
|
|
|
return (1);
|
|
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");
|
|
syslog (LOG_INFO, "Provider is not testquorum. Test skipped\n");
|
|
|
return (1);
|
|
return (1);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
* Set to not quorate
|
|
* 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) {
|
|
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);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -802,9 +827,9 @@ static int test_quorum (void) {
|
|
|
/*
|
|
/*
|
|
|
* Set to quorate
|
|
* 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) {
|
|
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);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -818,9 +843,9 @@ static int test_quorum (void) {
|
|
|
/*
|
|
/*
|
|
|
* Set corosync unquorate
|
|
* 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) {
|
|
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);
|
|
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) {
|
|
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;
|
|
cs_error_t err;
|
|
|
- hdb_handle_t res_handle, proc_handle, pid_handle;
|
|
|
|
|
- size_t value_len;
|
|
|
|
|
uint64_t tstamp1, tstamp2;
|
|
uint64_t tstamp1, tstamp2;
|
|
|
int32_t msec_diff;
|
|
int32_t msec_diff;
|
|
|
- char key_value[256];
|
|
|
|
|
unsigned int instance_id;
|
|
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) {
|
|
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);
|
|
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__);
|
|
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) {
|
|
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);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (test_n == 1 || test_n == 2) {
|
|
if (test_n == 1 || test_n == 2) {
|
|
|
syslog (LOG_INFO, "%s: initialize\n", __FUNCTION__);
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
|
return 2;
|
|
return 2;
|
|
@@ -923,67 +913,31 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
return 2;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
|
|
|
return (2);
|
|
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);
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"stopped\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
|
|
|
err = sam_start ();
|
|
err = sam_start ();
|
|
@@ -992,16 +946,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
return 2;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"running\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: stop\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: stop\n", __FUNCTION__, instance_id);
|
|
|
err = sam_stop ();
|
|
err = sam_stop ();
|
|
@@ -1010,30 +965,32 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
return 2;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"stopped\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: sleeping 5\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: sleeping 5\n", __FUNCTION__, instance_id);
|
|
|
sleep (5);
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"stopped\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: start 2\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: start 2\n", __FUNCTION__, instance_id);
|
|
|
err = sam_start ();
|
|
err = sam_start ();
|
|
@@ -1042,16 +999,17 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
return 2;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"running\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
if (test_n == 2) {
|
|
if (test_n == 2) {
|
|
|
syslog (LOG_INFO, "%s iid %d: sleeping 5. Should be killed\n", __FUNCTION__, instance_id);
|
|
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);
|
|
syslog (LOG_ERR, "Can't send hc. Error %d\n", err);
|
|
|
return 2;
|
|
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) {
|
|
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);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
syslog (LOG_INFO, "%s iid %d: Sleep 1\n", __FUNCTION__, instance_id);
|
|
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;
|
|
return 2;
|
|
|
}
|
|
}
|
|
|
sleep (1);
|
|
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) {
|
|
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);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
msec_diff = (tstamp2 - tstamp1)/CS_TIME_NS_IN_MSEC;
|
|
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;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"stopped\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: exiting\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: exiting\n", __FUNCTION__, instance_id);
|
|
|
return (0);
|
|
return (0);
|
|
@@ -1119,53 +1081,15 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
/*
|
|
/*
|
|
|
* Previous should be FAILED
|
|
* 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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"failed\".\n");
|
|
|
return (2);
|
|
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) {
|
|
static int test9 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
- confdb_handle_t cdb_handle;
|
|
|
|
|
cs_error_t err;
|
|
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;
|
|
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) {
|
|
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);
|
|
return (1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1198,7 +1120,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
|
|
|
|
|
if (test_n == 1) {
|
|
if (test_n == 1) {
|
|
|
syslog (LOG_INFO, "%s: initialize\n", __FUNCTION__);
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
|
return 2;
|
|
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);
|
|
syslog (LOG_INFO, "%s: iid %d\n", __FUNCTION__, instance_id);
|
|
|
|
|
|
|
|
if (instance_id < 3) {
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"recovery\" key: %d.\n", err);
|
|
|
return (2);
|
|
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);
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"stopped\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: start\n", __FUNCTION__, instance_id);
|
|
|
err = sam_start ();
|
|
err = sam_start ();
|
|
@@ -1283,16 +1168,17 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
return 2;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"running\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
syslog (LOG_INFO, "%s iid %d: waiting for kill\n", __FUNCTION__, instance_id);
|
|
syslog (LOG_INFO, "%s iid %d: waiting for kill\n", __FUNCTION__, instance_id);
|
|
|
sleep (10);
|
|
sleep (10);
|
|
@@ -1302,6 +1188,10 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
|
|
|
|
|
|
|
|
if (instance_id == 3) {
|
|
if (instance_id == 3) {
|
|
|
syslog (LOG_INFO, "%s iid %d: mark failed\n", __FUNCTION__, instance_id);
|
|
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 ();
|
|
err = sam_mark_failed ();
|
|
|
if (err != CS_OK) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_ERR, "Can't mark failed. Error %d\n", err);
|
|
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
|
|
* 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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
syslog (LOG_INFO, "Could not get \"state\" key: %d.\n", err);
|
|
|
return (2);
|
|
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");
|
|
syslog (LOG_INFO, "State key is not \"failed\".\n");
|
|
|
return (2);
|
|
return (2);
|
|
|
}
|
|
}
|
|
|
|
|
+ free(str);
|
|
|
|
|
|
|
|
return (0);
|
|
return (0);
|
|
|
}
|
|
}
|
|
@@ -1390,7 +1242,7 @@ static int setup_hc (void)
|
|
|
cs_error_t err;
|
|
cs_error_t err;
|
|
|
unsigned int instance_id;
|
|
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) {
|
|
if (err != CS_OK) {
|
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
syslog (LOG_ERR, "Can't initialize SAM API. Error %d\n", err);
|
|
|
return 2;
|
|
return 2;
|
|
@@ -1432,6 +1284,8 @@ static int do_test_command(int sock, char* func, char*args[], int num_args)
|
|
|
err = test1 ();
|
|
err = test1 ();
|
|
|
} else if (strcmp ("test2", func) == 0) {
|
|
} else if (strcmp ("test2", func) == 0) {
|
|
|
err = test2 ();
|
|
err = test2 ();
|
|
|
|
|
+ } else if (strcmp ("test3", func) == 0) {
|
|
|
|
|
+ err = test3 ();
|
|
|
} else if (strcmp ("test4", func) == 0) {
|
|
} else if (strcmp ("test4", func) == 0) {
|
|
|
err = test4 ();
|
|
err = test4 ();
|
|
|
} else if (strcmp ("test5", func) == 0) {
|
|
} else if (strcmp ("test5", func) == 0) {
|
|
@@ -1509,4 +1363,3 @@ int main (int argc, char *argv[])
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
-
|
|
|