38 #include <qb/qblist.h>
39 #include <qb/qbutil.h>
40 #include <qb/qbipc_common.h>
78 static void message_handler_req_exec_pload_start (
const void *msg,
80 static void req_exec_pload_start_endian_convert (
void *msg);
82 static void message_handler_req_exec_pload_mcast (
const void *msg,
84 static void req_exec_pload_mcast_endian_convert (
void *msg);
90 .exec_endian_convert_fn = req_exec_pload_start_endian_convert
93 .exec_handler_fn = message_handler_req_exec_pload_mcast,
94 .exec_endian_convert_fn = req_exec_pload_mcast_endian_convert
105 static char *buffer = NULL;
111 static uint32_t msgs_wanted = 0;
112 static uint32_t msg_size = 0;
113 static uint32_t msgs_sent = 0;
114 static uint32_t msgs_delivered = 0;
119 static uint8_t pload_started = 0;
129 static unsigned long long int tv1;
130 static unsigned long long int tv2;
131 static unsigned long long int tv_elapsed;
137 .
name =
"corosync profile loading service",
141 .exec_engine = pload_exec_engine,
143 .exec_init_fn = pload_exec_init_fn
148 return (&pload_service_engine);
160 #warning Using internal timersub definition. Check your include header files
161 #define timersub(a, b, result) \
163 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
164 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
165 if ((result)->tv_usec < 0) { \
166 --(result)->tv_sec; \
167 (result)->tv_usec += 1000000; \
175 static void pload_send_start (uint32_t count, uint32_t size)
182 req_exec_pload_start.
msg_size = size;
183 iov.iov_base = (
void *)&req_exec_pload_start;
184 iov.iov_len =
sizeof (
struct req_exec_pload_start);
192 static int pload_send_message (
const void *arg)
197 unsigned int iov_len = 1;
205 iov[1].iov_base = &buffer;
217 }
while (msgs_sent < msgs_wanted);
219 if (msgs_sent == msgs_wanted) {
230 static void pload_read_config(
232 const char *key_name,
237 uint32_t pload_count = 1500000;
238 uint32_t pload_size = 300;
239 char *pload_start = NULL;
249 if ((!pload_started) &&
251 if (!strcmp(pload_start,
252 "i_totally_understand_pload_will_crash_my_cluster_and_kill_corosync_on_exit")) {
253 buffer = malloc(pload_size);
256 pload_send_start(pload_count, pload_size);
259 "Unable to allocate pload buffer!");
282 &pload_track) !=
CS_OK) {
283 return (
char *)
"Unable to setup pload config tracking!\n";
293 static void req_exec_pload_start_endian_convert (
void *msg)
301 static void message_handler_req_exec_pload_start (
316 msgs_wanted = req_exec_pload_start->
msg_count;
320 &start_mcasting_handle,
322 &start_mcasting_handle);
325 static void req_exec_pload_mcast_endian_convert (
void *msg)
329 static void message_handler_req_exec_pload_mcast (
333 char log_buffer[1024];
335 if (msgs_delivered == 0) {
336 tv1 = qb_util_nano_current_get ();
339 if (msgs_delivered == msgs_wanted) {
340 tv2 = qb_util_nano_current_get ();
341 tv_elapsed = tv2 - tv1;
342 sprintf (log_buffer,
"%5d Writes %d bytes per write %7.3f seconds runtime, %9.3f TP/S, %9.3f MB/S.",
345 (tv_elapsed / 1000000000.0),
346 ((
float)msgs_delivered) / (tv_elapsed / 1000000000.0),
347 (((
float)msgs_delivered) * ((
float)
msg_size) /
348 (tv_elapsed / 1000000000.0)) / (1024.0 * 1024.0));
pload_exec_message_req_types
LOGSYS_DECLARE_SUBSYS("PLOAD")
struct qb_ipc_request_header header
The corosync_service_engine struct.
struct corosync_service_engine pload_service_engine
The corosync_exec_handler struct.
#define log_printf(level, format, args...)
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
#define SERVICE_ID_MAKE(a, b)
#define ICMAP_TRACK_DELETE
int(* schedwrk_create)(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
#define LOGSYS_LEVEL_WARNING
#define ICMAP_TRACK_MODIFY
The corosync_api_v1 struct.
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
#define swab32(x)
The swab32 macro.
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
struct qb_ipc_request_header header
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
#define LOGSYS_LEVEL_NOTICE
struct corosync_service_engine * pload_get_service_engine_ver0(void)
Structure passed as new_value and old_value in change callback.
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem.nodeid", "totem.version", ...