1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * Copyright by the Board of Trustees of the University of Illinois. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14 /*-------------------------------------------------------------------------
15 *
16 * Created: H5Clog_json.c
17 *
18 * Purpose: Cache log implementation that emits JSON-formatted log
19 * entries for consumption by new-fangled data analysis tools.
20 *
21 *-------------------------------------------------------------------------
22 */
23
24 /****************/
25 /* Module Setup */
26 /****************/
27 #include "H5Cmodule.h" /* This source code file is part of the H5C module */
28
29 /***********/
30 /* Headers */
31 /***********/
32 #include "H5private.h" /* Generic Functions */
33 #include "H5Cpkg.h" /* Cache */
34 #include "H5Clog.h" /* Cache logging */
35 #include "H5Eprivate.h" /* Error handling */
36 #include "H5MMprivate.h" /* Memory management */
37
38
39 /****************/
40 /* Local Macros */
41 /****************/
42
43 /* Max log message size */
44 #define H5C_MAX_JSON_LOG_MSG_SIZE 1024
45
46
47 /******************/
48 /* Local Typedefs */
49 /******************/
50
51
52 /********************/
53 /* Package Typedefs */
54 /********************/
55
56 typedef struct H5C_log_json_udata_t {
57 FILE *outfile;
58 char *message;
59 } H5C_log_json_udata_t;
60
61
62 /********************/
63 /* Local Prototypes */
64 /********************/
65
66 /* Internal message handling calls */
67 static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata);
68
69 /* Log message callbacks */
70 static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info);
71 static herr_t H5C__json_write_start_log_msg(void *udata);
72 static herr_t H5C__json_write_stop_log_msg(void *udata);
73 static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value);
74 static herr_t H5C__json_write_destroy_cache_log_msg(void *udata);
75 static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value);
76 static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value);
77 static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value);
78 static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value);
79 static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
80 static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
81 static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
82 static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
83 static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value);
84 static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
85 static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value);
86 static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value);
87 static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value);
88 static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
89 static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value);
90 static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, herr_t fxn_ret_value);
91 static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value);
92 static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value);
93
94
95 /*********************/
96 /* Package Variables */
97 /*********************/
98
99
100 /*****************************/
101 /* Library Private Variables */
102 /*****************************/
103
104
105 /*******************/
106 /* Local Variables */
107 /*******************/
108
109 /* Note that there's no cache set up call since that's the
110 * place where this struct is wired into the cache.
111 */
112 static H5C_log_class_t H5C_json_log_class_g = {
113 "json",
114 H5C__json_tear_down_logging,
115 NULL, /* start logging */
116 NULL, /* stop logging */
117 H5C__json_write_start_log_msg,
118 H5C__json_write_stop_log_msg,
119 H5C__json_write_create_cache_log_msg,
120 H5C__json_write_destroy_cache_log_msg,
121 H5C__json_write_evict_cache_log_msg,
122 H5C__json_write_expunge_entry_log_msg,
123 H5C__json_write_flush_cache_log_msg,
124 H5C__json_write_insert_entry_log_msg,
125 H5C__json_write_mark_entry_dirty_log_msg,
126 H5C__json_write_mark_entry_clean_log_msg,
127 H5C__json_write_mark_unserialized_entry_log_msg,
128 H5C__json_write_mark_serialized_entry_log_msg,
129 H5C__json_write_move_entry_log_msg,
130 H5C__json_write_pin_entry_log_msg,
131 H5C__json_write_create_fd_log_msg,
132 H5C__json_write_protect_entry_log_msg,
133 H5C__json_write_resize_entry_log_msg,
134 H5C__json_write_unpin_entry_log_msg,
135 H5C__json_write_destroy_fd_log_msg,
136 H5C__json_write_unprotect_entry_log_msg,
137 H5C__json_write_set_cache_config_log_msg,
138 H5C__json_write_remove_entry_log_msg
139 };
140
141
142
143 /*-------------------------------------------------------------------------
144 * Function: H5C__json_write_log_message
145 *
146 * Purpose: Write a message to the log file and flush the file.
147 * The message string is neither modified nor freed.
148 *
149 * Return: SUCCEED/FAIL
150 *
151 * Programmer: Dana Robinson
152 * Fall 2018
153 *
154 *-------------------------------------------------------------------------
155 */
156 static herr_t
H5C__json_write_log_message(H5C_log_json_udata_t * json_udata)157 H5C__json_write_log_message(H5C_log_json_udata_t *json_udata)
158 {
159 size_t n_chars;
160 herr_t ret_value = SUCCEED; /* Return value */
161
162 FUNC_ENTER_STATIC
163
164 /* Sanity checks */
165 HDassert(json_udata);
166 HDassert(json_udata->outfile);
167 HDassert(json_udata->message);
168
169 /* Write the log message and flush */
170 n_chars = HDstrlen(json_udata->message);
171 if((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message))
172 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message")
173 HDmemset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char)));
174
175 done:
176 FUNC_LEAVE_NOAPI(ret_value)
177 } /* H5C__json_write_log_message() */
178
179
180 /*-------------------------------------------------------------------------
181 * Function: H5C_log_json_set_up
182 *
183 * Purpose: Setup for metadata cache logging.
184 *
185 * Metadata logging is enabled and disabled at two levels. This
186 * function and the associated tear_down function open and close
187 * the log file. the start_ and stop_logging functions are then
188 * used to switch logging on/off. Optionally, logging can begin
189 * as soon as the log file is opened (set via the start_immediately
190 * parameter to this function).
191 *
192 * The log functionality is split between the H5C and H5AC
193 * packages. Log state and direct log manipulation resides in
194 * H5C. Log messages are generated in H5AC and sent to
195 * the H5C__json_write_log_message function.
196 *
197 * Return: SUCCEED/FAIL
198 *
199 * Programmer: Dana Robinson
200 * Fall 2018
201 *
202 *-------------------------------------------------------------------------
203 */
204 herr_t
H5C_log_json_set_up(H5C_log_info_t * log_info,const char log_location[],int mpi_rank)205 H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank)
206 {
207 H5C_log_json_udata_t *json_udata = NULL;
208 char *file_name = NULL;
209 size_t n_chars;
210 herr_t ret_value = SUCCEED; /* Return value */
211
212 FUNC_ENTER_NOAPI(FAIL)
213
214 /* Sanity checks */
215 HDassert(log_info);
216 HDassert(log_location);
217
218 /* Set up the class struct */
219 log_info->cls = &H5C_json_log_class_g;
220
221 /* Allocate memory for the JSON-specific data */
222 if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t))))
223 HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed")
224 json_udata = (H5C_log_json_udata_t *)(log_info->udata);
225
226 /* Allocate memory for the message buffer */
227 if(NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char))))
228 HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed")
229
230 /* Possibly fix up the log file name.
231 * The extra 39 characters are for adding the rank to the file name
232 * under parallel HDF5. 39 characters allows > 2^127 processes which
233 * should be enough for anybody.
234 *
235 * allocation size = "RANK_" + <rank # length> + dot + <path length> + \0
236 */
237 n_chars = 5 + 39 + 1 + HDstrlen(log_location) + 1;
238 if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char))))
239 HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation")
240
241 /* Add the rank to the log file name when MPI is in use */
242 if(-1 == mpi_rank)
243 HDsnprintf(file_name, n_chars, "%s", log_location);
244 else
245 HDsnprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location);
246
247 /* Open log file and set it to be unbuffered */
248 if(NULL == (json_udata->outfile = HDfopen(file_name, "w")))
249 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file")
250 HDsetbuf(json_udata->outfile, NULL);
251
252 done:
253 if(file_name)
254 H5MM_xfree(file_name);
255
256 /* Free and reset the log info struct on errors */
257 if(FAIL == ret_value) {
258 /* Free */
259 if(json_udata && json_udata->message)
260 H5MM_xfree(json_udata->message);
261 if(json_udata)
262 H5MM_xfree(json_udata);
263
264 /* Reset */
265 log_info->udata = NULL;
266 log_info->cls = NULL;
267 }
268
269 FUNC_LEAVE_NOAPI(ret_value)
270 } /* H5C_log_json_set_up() */
271
272
273 /*-------------------------------------------------------------------------
274 * Function: H5C__json_tear_down_logging
275 *
276 * Purpose: Tear-down for metadata cache logging.
277 *
278 * Return: SUCCEED/FAIL
279 *
280 * Programmer: Dana Robinson
281 * Fall 2018
282 *
283 *-------------------------------------------------------------------------
284 */
285 static herr_t
H5C__json_tear_down_logging(H5C_log_info_t * log_info)286 H5C__json_tear_down_logging(H5C_log_info_t *log_info)
287 {
288 H5C_log_json_udata_t *json_udata = NULL;
289 herr_t ret_value = SUCCEED; /* Return value */
290
291 FUNC_ENTER_STATIC
292
293 /* Sanity checks */
294 HDassert(log_info);
295
296 /* Alias */
297 json_udata = (H5C_log_json_udata_t *)(log_info->udata);
298
299 /* Free the message buffer */
300 H5MM_xfree(json_udata->message);
301
302 /* Close log file */
303 if(EOF == HDfclose(json_udata->outfile))
304 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file")
305 json_udata->outfile = NULL;
306
307 /* Fre the udata */
308 H5MM_xfree(json_udata);
309
310 /* Reset the log class info and udata */
311 log_info->cls = NULL;
312 log_info->udata = NULL;
313
314 done:
315 FUNC_LEAVE_NOAPI(ret_value)
316 } /* H5C__json_tear_down_logging() */
317
318
319 /*-------------------------------------------------------------------------
320 * Function: H5C__json_write_start_log_msg
321 *
322 * Purpose: Write a log message when logging starts.
323 *
324 * Return: SUCCEED/FAIL
325 *
326 * Programmer: Dana Robinson
327 * Fall 2018
328 *
329 *-------------------------------------------------------------------------
330 */
331 static herr_t
H5C__json_write_start_log_msg(void * udata)332 H5C__json_write_start_log_msg(void *udata)
333 {
334 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
335 herr_t ret_value = SUCCEED; /* Return value */
336
337 FUNC_ENTER_STATIC
338
339 /* Sanity checks */
340 HDassert(json_udata);
341 HDassert(json_udata->message);
342
343 /* Create the log message string (opens the JSON array) */
344 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
345 "\
346 {\n\
347 \"HDF5 metadata cache log messages\" : [\n\
348 {\
349 \"timestamp\":%lld,\
350 \"action\":\"logging start\"\
351 },\n\
352 "
353 , (long long)HDtime(NULL));
354
355 /* Write the log message to the file */
356 if(H5C__json_write_log_message(json_udata) < 0)
357 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
358
359 done:
360 FUNC_LEAVE_NOAPI(ret_value)
361 } /* H5C__json_write_start_log_msg() */
362
363
364 /*-------------------------------------------------------------------------
365 * Function: H5C__json_write_stop_log_msg
366 *
367 * Purpose: Write a log message when logging ends.
368 *
369 * Return: SUCCEED/FAIL
370 *
371 * Programmer: Dana Robinson
372 * Fall 2018
373 *
374 *-------------------------------------------------------------------------
375 */
376 static herr_t
H5C__json_write_stop_log_msg(void * udata)377 H5C__json_write_stop_log_msg(void *udata)
378 {
379 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
380 herr_t ret_value = SUCCEED; /* Return value */
381
382 FUNC_ENTER_STATIC
383
384 /* Sanity checks */
385 HDassert(json_udata);
386 HDassert(json_udata->message);
387
388 /* Create the log message string (closes the JSON array) */
389 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
390 "\
391 {\
392 \"timestamp\":%lld,\
393 \"action\":\"logging stop\"\
394 }\n\
395 ]}\n\
396 "
397 , (long long)HDtime(NULL));
398
399 /* Write the log message to the file */
400 if(H5C__json_write_log_message(json_udata) < 0)
401 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
402
403 done:
404 FUNC_LEAVE_NOAPI(ret_value)
405 } /* H5C__json_write_stop_log_msg() */
406
407
408 /*-------------------------------------------------------------------------
409 * Function: H5C__json_write_create_cache_log_msg
410 *
411 * Purpose: Write a log message for cache creation.
412 *
413 * Return: SUCCEED/FAIL
414 *
415 * Programmer: Dana Robinson
416 * Fall 2018
417 *
418 *-------------------------------------------------------------------------
419 */
420 static herr_t
H5C__json_write_create_cache_log_msg(void * udata,herr_t fxn_ret_value)421 H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value)
422 {
423 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
424 herr_t ret_value = SUCCEED; /* Return value */
425
426 FUNC_ENTER_STATIC
427
428 /* Sanity checks */
429 HDassert(json_udata);
430 HDassert(json_udata->message);
431
432 /* Create the log message string */
433 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
434 "\
435 {\
436 \"timestamp\":%lld,\
437 \"action\":\"create\",\
438 \"returned\":%d\
439 },\n\
440 "
441 , (long long)HDtime(NULL), (int)fxn_ret_value);
442
443 /* Write the log message to the file */
444 if(H5C__json_write_log_message(json_udata) < 0)
445 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
446
447 done:
448 FUNC_LEAVE_NOAPI(ret_value)
449 } /* H5C__json_write_create_cache_log_msg() */
450
451
452 /*-------------------------------------------------------------------------
453 * Function: H5C__json_write_destroy_cache_log_msg
454 *
455 * Purpose: Write a log message for cache destruction.
456 *
457 * Return: SUCCEED/FAIL
458 *
459 * Programmer: Dana Robinson
460 * Fall 2018
461 *
462 *-------------------------------------------------------------------------
463 */
464 static herr_t
H5C__json_write_destroy_cache_log_msg(void * udata)465 H5C__json_write_destroy_cache_log_msg(void *udata)
466 {
467 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
468 herr_t ret_value = SUCCEED; /* Return value */
469
470 FUNC_ENTER_STATIC
471
472 /* Sanity checks */
473 HDassert(json_udata);
474 HDassert(json_udata->message);
475
476 /* Create the log message string */
477 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
478 "\
479 {\
480 \"timestamp\":%lld,\
481 \"action\":\"destroy\"\
482 },\n\
483 "
484 , (long long)HDtime(NULL));
485
486 /* Write the log message to the file */
487 if(H5C__json_write_log_message(json_udata) < 0)
488 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
489
490 done:
491 FUNC_LEAVE_NOAPI(ret_value)
492 } /* H5C__json_write_destroy_cache_log_msg() */
493
494
495 /*-------------------------------------------------------------------------
496 * Function: H5C__json_write_evict_cache_log_msg
497 *
498 * Purpose: Write a log message for eviction of cache entries.
499 *
500 * Return: SUCCEED/FAIL
501 *
502 * Programmer: Dana Robinson
503 * Fall 2018
504 *
505 *-------------------------------------------------------------------------
506 */
507 static herr_t
H5C__json_write_evict_cache_log_msg(void * udata,herr_t fxn_ret_value)508 H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value)
509 {
510 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
511 herr_t ret_value = SUCCEED;
512
513 FUNC_ENTER_STATIC
514
515 /* Sanity checks */
516 HDassert(json_udata);
517 HDassert(json_udata->message);
518
519 /* Create the log message string */
520 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
521 "\
522 {\
523 \"timestamp\":%lld,\
524 \"action\":\"evict\",\
525 \"returned\":%d\
526 },\n\
527 "
528 , (long long)HDtime(NULL), (int)fxn_ret_value);
529
530 /* Write the log message to the file */
531 if(H5C__json_write_log_message(json_udata) < 0)
532 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
533
534 done:
535 FUNC_LEAVE_NOAPI(ret_value)
536 } /* H5C__json_write_evict_cache_log_msg() */
537
538
539 /*-------------------------------------------------------------------------
540 * Function: H5C__json_write_expunge_entry_log_msg
541 *
542 * Purpose: Write a log message for expunge of cache entries.
543 *
544 * Return: SUCCEED/FAIL
545 *
546 * Programmer: Dana Robinson
547 * Fall 2018
548 *
549 *-------------------------------------------------------------------------
550 */
551 static herr_t
H5C__json_write_expunge_entry_log_msg(void * udata,haddr_t address,int type_id,herr_t fxn_ret_value)552 H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address,
553 int type_id, herr_t fxn_ret_value)
554 {
555 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
556 herr_t ret_value = SUCCEED;
557
558 FUNC_ENTER_STATIC
559
560 /* Sanity checks */
561 HDassert(json_udata);
562 HDassert(json_udata->message);
563
564 /* Create the log message string */
565 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
566 "\
567 {\
568 \"timestamp\":%lld,\
569 \"action\":\"expunge\",\
570 \"address\":0x%lx,\
571 \"type_id\":%d,\
572 \"returned\":%d\
573 },\n\
574 "
575 , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value);
576
577
578 /* Write the log message to the file */
579 if(H5C__json_write_log_message(json_udata) < 0)
580 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
581
582 done:
583 FUNC_LEAVE_NOAPI(ret_value)
584 } /* H5C__json_write_expunge_entry_log_msg() */
585
586
587 /*-------------------------------------------------------------------------
588 * Function: H5C__json_write_flush_cache_log_msg
589 *
590 * Purpose: Write a log message for cache flushes.
591 *
592 * Return: SUCCEED/FAIL
593 *
594 * Programmer: Dana Robinson
595 * Fall 2018
596 *
597 *-------------------------------------------------------------------------
598 */
599 static herr_t
H5C__json_write_flush_cache_log_msg(void * udata,herr_t fxn_ret_value)600 H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value)
601 {
602 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
603 herr_t ret_value = SUCCEED;
604
605 FUNC_ENTER_STATIC
606
607 /* Sanity checks */
608 HDassert(json_udata);
609 HDassert(json_udata->message);
610
611 /* Create the log message string */
612 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
613 "\
614 {\
615 \"timestamp\":%lld,\
616 \"action\":\"flush\",\
617 \"returned\":%d\
618 },\n\
619 "
620 , (long long)HDtime(NULL), (int)fxn_ret_value);
621
622 /* Write the log message to the file */
623 if(H5C__json_write_log_message(json_udata) < 0)
624 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
625
626 done:
627 FUNC_LEAVE_NOAPI(ret_value)
628 } /* H5C__json_write_flush_cache_log_msg() */
629
630
631 /*-------------------------------------------------------------------------
632 * Function: H5C__json_write_insert_entry_log_msg
633 *
634 * Purpose: Write a log message for insertion of cache entries.
635 *
636 * Return: SUCCEED/FAIL
637 *
638 * Programmer: Dana Robinson
639 * Fall 2018
640 *
641 *-------------------------------------------------------------------------
642 */
643 static herr_t
H5C__json_write_insert_entry_log_msg(void * udata,haddr_t address,int type_id,unsigned flags,size_t size,herr_t fxn_ret_value)644 H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address,
645 int type_id, unsigned flags, size_t size, herr_t fxn_ret_value)
646 {
647 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
648 herr_t ret_value = SUCCEED;
649
650 FUNC_ENTER_STATIC
651
652 /* Sanity checks */
653 HDassert(json_udata);
654 HDassert(json_udata->message);
655
656 /* Create the log message string */
657 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
658 "\
659 {\
660 \"timestamp\":%lld,\
661 \"action\":\"insert\",\
662 \"address\":0x%lx,\
663 \"type_id\":%d,\
664 \"flags\":0x%x,\
665 \"size\":%d,\
666 \"returned\":%d\
667 },\n\
668 "
669 , (long long)HDtime(NULL), (unsigned long)address, type_id, flags,
670 (int)size, (int)fxn_ret_value);
671
672 /* Write the log message to the file */
673 if(H5C__json_write_log_message(json_udata) < 0)
674 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
675
676 done:
677 FUNC_LEAVE_NOAPI(ret_value)
678 } /* H5C__json_write_insert_entry_log_msg() */
679
680
681 /*-------------------------------------------------------------------------
682 * Function: H5C__json_write_mark_entry_dirty_log_msg
683 *
684 * Purpose: Write a log message for marking cache entries as dirty.
685 *
686 * Return: SUCCEED/FAIL
687 *
688 * Programmer: Dana Robinson
689 * Fall 2018
690 *
691 *-------------------------------------------------------------------------
692 */
693 static herr_t
H5C__json_write_mark_entry_dirty_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)694 H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry,
695 herr_t fxn_ret_value)
696 {
697 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
698 herr_t ret_value = SUCCEED;
699
700 FUNC_ENTER_STATIC
701
702 /* Sanity checks */
703 HDassert(json_udata);
704 HDassert(json_udata->message);
705 HDassert(entry);
706
707 /* Create the log message string */
708 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
709 "\
710 {\
711 \"timestamp\":%lld,\
712 \"action\":\"dirty\",\
713 \"address\":0x%lx,\
714 \"returned\":%d\
715 },\n\
716 "
717 , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
718
719 /* Write the log message to the file */
720 if(H5C__json_write_log_message(json_udata) < 0)
721 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
722
723 done:
724 FUNC_LEAVE_NOAPI(ret_value)
725 } /* H5C__json_write_mark_entry_dirty_log_msg() */
726
727
728 /*-------------------------------------------------------------------------
729 * Function: H5C__json_write_mark_entry_clean_log_msg
730 *
731 * Purpose: Write a log message for marking cache entries as clean.
732 *
733 * Return: SUCCEED/FAIL
734 *
735 * Programmer: Dana Robinson
736 * Fall 2018
737 *
738 *-------------------------------------------------------------------------
739 */
740 static herr_t
H5C__json_write_mark_entry_clean_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)741 H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry,
742 herr_t fxn_ret_value)
743 {
744 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
745 herr_t ret_value = SUCCEED; /* Return value */
746
747 FUNC_ENTER_STATIC
748
749 /* Sanity checks */
750 HDassert(json_udata);
751 HDassert(json_udata->message);
752 HDassert(entry);
753
754 /* Create the log message string */
755 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
756 "\
757 {\
758 \"timestamp\":%lld,\
759 \"action\":\"clean\",\
760 \"address\":0x%lx,\
761 \"returned\":%d\
762 },\n\
763 "
764 , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
765
766 /* Write the log message to the file */
767 if(H5C__json_write_log_message(json_udata) < 0)
768 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
769
770 done:
771 FUNC_LEAVE_NOAPI(ret_value)
772 } /* H5C__json_write_mark_entry_clean_log_msg() */
773
774
775 /*-------------------------------------------------------------------------
776 * Function: H5C__json_write_mark_unserialized_entry_log_msg
777 *
778 * Purpose: Write a log message for marking cache entries as unserialized.
779 *
780 * Return: SUCCEED/FAIL
781 *
782 * Programmer: Dana Robinson
783 * Fall 2018
784 *
785 *-------------------------------------------------------------------------
786 */
787 static herr_t
H5C__json_write_mark_unserialized_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)788 H5C__json_write_mark_unserialized_entry_log_msg(void *udata,
789 const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
790 {
791 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
792 herr_t ret_value = SUCCEED;
793
794 FUNC_ENTER_STATIC
795
796 /* Sanity checks */
797 HDassert(json_udata);
798 HDassert(json_udata->message);
799 HDassert(entry);
800
801 /* Create the log message string */
802 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
803 "\
804 {\
805 \"timestamp\":%lld,\
806 \"action\":\"unserialized\",\
807 \"address\":0x%lx,\
808 \"returned\":%d\
809 },\n\
810 "
811 , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
812
813 /* Write the log message to the file */
814 if(H5C__json_write_log_message(json_udata) < 0)
815 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
816
817 done:
818 FUNC_LEAVE_NOAPI(ret_value)
819 } /* H5C__json_write_mark_unserialized_entry_log_msg() */
820
821
822 /*-------------------------------------------------------------------------
823 * Function: H5C__json_write_mark_serialize_entry_log_msg
824 *
825 * Purpose: Write a log message for marking cache entries as serialize.
826 *
827 * Return: SUCCEED/FAIL
828 *
829 * Programmer: Dana Robinson
830 * Fall 2018
831 *
832 *-------------------------------------------------------------------------
833 */
834 static herr_t
H5C__json_write_mark_serialized_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)835 H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
836 herr_t fxn_ret_value)
837 {
838 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
839 herr_t ret_value = SUCCEED; /* Return value */
840
841 FUNC_ENTER_STATIC
842
843 /* Sanity checks */
844 HDassert(json_udata);
845 HDassert(json_udata->message);
846 HDassert(entry);
847
848 /* Create the log message string */
849 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
850 "\
851 {\
852 \"timestamp\":%lld,\
853 \"action\":\"serialized\",\
854 \"address\":0x%lx,\
855 \"returned\":%d\
856 },\n\
857 "
858 , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
859
860 /* Write the log message to the file */
861 if(H5C__json_write_log_message(json_udata) < 0)
862 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
863
864 done:
865 FUNC_LEAVE_NOAPI(ret_value)
866 } /* H5C__json_write_mark_serialized_entry_log_msg() */
867
868
869 /*-------------------------------------------------------------------------
870 * Function: H5C__json_write_move_entry_log_msg
871 *
872 * Purpose: Write a log message for moving a cache entry.
873 *
874 * Return: SUCCEED/FAIL
875 *
876 * Programmer: Dana Robinson
877 * Fall 2018
878 *
879 *-------------------------------------------------------------------------
880 */
881 static herr_t
H5C__json_write_move_entry_log_msg(void * udata,haddr_t old_addr,haddr_t new_addr,int type_id,herr_t fxn_ret_value)882 H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr,
883 int type_id, herr_t fxn_ret_value)
884 {
885 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
886 herr_t ret_value = SUCCEED;
887
888 FUNC_ENTER_STATIC
889
890 /* Sanity checks */
891 HDassert(json_udata);
892 HDassert(json_udata->message);
893
894 /* Create the log message string */
895 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
896 "\
897 {\
898 \"timestamp\":%lld,\
899 \"action\":\"move\",\
900 \"old_address\":0x%lx,\
901 \"new_address\":0x%lx,\
902 \"type_id\":%d,\
903 \"returned\":%d\
904 },\n\
905 "
906 , (long long)HDtime(NULL), (unsigned long)old_addr,
907 (unsigned long)new_addr, type_id, (int)fxn_ret_value);
908
909 /* Write the log message to the file */
910 if(H5C__json_write_log_message(json_udata) < 0)
911 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
912
913 done:
914 FUNC_LEAVE_NOAPI(ret_value)
915 } /* H5C__json_write_move_entry_log_msg() */
916
917
918 /*-------------------------------------------------------------------------
919 * Function: H5C__json_write_pin_entry_log_msg
920 *
921 * Purpose: Write a log message for pinning a cache entry.
922 *
923 * Return: SUCCEED/FAIL
924 *
925 * Programmer: Dana Robinson
926 * Fall 2018
927 *
928 *-------------------------------------------------------------------------
929 */
930 static herr_t
H5C__json_write_pin_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)931 H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
932 herr_t fxn_ret_value)
933 {
934 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
935 herr_t ret_value = SUCCEED;
936
937 FUNC_ENTER_STATIC
938
939 /* Sanity checks */
940 HDassert(json_udata);
941 HDassert(json_udata->message);
942 HDassert(entry);
943
944 /* Create the log message string */
945 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
946 "\
947 {\
948 \"timestamp\":%lld,\
949 \"action\":\"pin\",\
950 \"address\":0x%lx,\
951 \"returned\":%d\
952 },\n\
953 "
954 , (long long)HDtime(NULL), (unsigned long)entry->addr,
955 (int)fxn_ret_value);
956
957 /* Write the log message to the file */
958 if(H5C__json_write_log_message(json_udata) < 0)
959 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
960
961 done:
962 FUNC_LEAVE_NOAPI(ret_value)
963 } /* H5C__json_write_pin_entry_log_msg() */
964
965
966 /*-------------------------------------------------------------------------
967 * Function: H5C__json_write_create_fd_log_msg
968 *
969 * Purpose: Write a log message for creating a flush dependency between
970 * two cache entries.
971 *
972 * Return: SUCCEED/FAIL
973 *
974 * Programmer: Dana Robinson
975 * Fall 2018
976 *
977 *-------------------------------------------------------------------------
978 */
979 static herr_t
H5C__json_write_create_fd_log_msg(void * udata,const H5C_cache_entry_t * parent,const H5C_cache_entry_t * child,herr_t fxn_ret_value)980 H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
981 const H5C_cache_entry_t *child, herr_t fxn_ret_value)
982 {
983 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
984 herr_t ret_value = SUCCEED;
985
986 FUNC_ENTER_STATIC
987
988 /* Sanity checks */
989 HDassert(json_udata);
990 HDassert(json_udata->message);
991 HDassert(parent);
992 HDassert(child);
993
994 /* Create the log message string */
995 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
996 "\
997 {\
998 \"timestamp\":%lld,\
999 \"action\":\"create_fd\",\
1000 \"parent_addr\":0x%lx,\
1001 \"child_addr\":0x%lx,\
1002 \"returned\":%d\
1003 },\n\
1004 "
1005 , (long long)HDtime(NULL), (unsigned long)parent->addr,
1006 (unsigned long)child->addr, (int)fxn_ret_value);
1007
1008 /* Write the log message to the file */
1009 if(H5C__json_write_log_message(json_udata) < 0)
1010 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1011
1012 done:
1013 FUNC_LEAVE_NOAPI(ret_value)
1014 } /* H5C__json_write_create_fd_log_msg() */
1015
1016
1017 /*-------------------------------------------------------------------------
1018 * Function: H5C__json_write_protect_entry_log_msg
1019 *
1020 * Purpose: Write a log message for protecting a cache entry.
1021 *
1022 * Return: SUCCEED/FAIL
1023 *
1024 * Programmer: Dana Robinson
1025 * Fall 2018
1026 *
1027 *-------------------------------------------------------------------------
1028 */
1029 static herr_t
H5C__json_write_protect_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,int type_id,unsigned flags,herr_t fxn_ret_value)1030 H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
1031 int type_id, unsigned flags, herr_t fxn_ret_value)
1032 {
1033 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1034 char rw_s[16];
1035 herr_t ret_value = SUCCEED;
1036
1037 FUNC_ENTER_STATIC
1038
1039 /* Sanity checks */
1040 HDassert(json_udata);
1041 HDassert(json_udata->message);
1042 HDassert(entry);
1043
1044 if(H5C__READ_ONLY_FLAG == flags)
1045 HDstrcpy(rw_s, "READ");
1046 else
1047 HDstrcpy(rw_s, "WRITE");
1048
1049 /* Create the log message string */
1050 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1051 "\
1052 {\
1053 \"timestamp\":%lld,\
1054 \"action\":\"protect\",\
1055 \"address\":0x%lx,\
1056 \"type_id\":%d,\
1057 \"readwrite\":\"%s\",\
1058 \"size\":%d,\
1059 \"returned\":%d\
1060 },\n\
1061 "
1062 , (long long)HDtime(NULL), (unsigned long)entry->addr,
1063 type_id, rw_s, (int)entry->size, (int)fxn_ret_value);
1064
1065 /* Write the log message to the file */
1066 if(H5C__json_write_log_message(json_udata) < 0)
1067 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1068
1069 done:
1070 FUNC_LEAVE_NOAPI(ret_value)
1071 } /* H5C__json_write_protect_entry_log_msg() */
1072
1073
1074 /*-------------------------------------------------------------------------
1075 * Function: H5C__json_write_resize_entry_log_msg
1076 *
1077 * Purpose: Write a log message for resizing a cache entry.
1078 *
1079 * Return: SUCCEED/FAIL
1080 *
1081 * Programmer: Dana Robinson
1082 * Fall 2018
1083 *
1084 *-------------------------------------------------------------------------
1085 */
1086 static herr_t
H5C__json_write_resize_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,size_t new_size,herr_t fxn_ret_value)1087 H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
1088 size_t new_size, herr_t fxn_ret_value)
1089 {
1090 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1091 herr_t ret_value = SUCCEED;
1092
1093 FUNC_ENTER_STATIC
1094
1095 /* Sanity checks */
1096 HDassert(json_udata);
1097 HDassert(json_udata->message);
1098 HDassert(entry);
1099
1100 /* Create the log message string */
1101 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1102 "\
1103 {\
1104 \"timestamp\":%lld,\
1105 \"action\":\"resize\",\
1106 \"address\":0x%lx,\
1107 \"new_size\":%d,\
1108 \"returned\":%d\
1109 },\n\
1110 "
1111 , (long long)HDtime(NULL), (unsigned long)entry->addr,
1112 (int)new_size, (int)fxn_ret_value);
1113
1114 /* Write the log message to the file */
1115 if(H5C__json_write_log_message(json_udata) < 0)
1116 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1117
1118 done:
1119 FUNC_LEAVE_NOAPI(ret_value)
1120 } /* H5C__json_write_resize_entry_log_msg() */
1121
1122
1123 /*-------------------------------------------------------------------------
1124 * Function: H5C__json_write_unpin_entry_log_msg
1125 *
1126 * Purpose: Write a log message for unpinning a cache entry.
1127 *
1128 * Return: SUCCEED/FAIL
1129 *
1130 * Programmer: Dana Robinson
1131 * Fall 2018
1132 *
1133 *-------------------------------------------------------------------------
1134 */
1135 static herr_t
H5C__json_write_unpin_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)1136 H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
1137 herr_t fxn_ret_value)
1138 {
1139 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1140 herr_t ret_value = SUCCEED;
1141
1142 FUNC_ENTER_STATIC
1143
1144 /* Sanity checks */
1145 HDassert(json_udata);
1146 HDassert(json_udata->message);
1147 HDassert(entry);
1148
1149 /* Create the log message string */
1150 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1151 "\
1152 {\
1153 \"timestamp\":%lld,\
1154 \"action\":\"unpin\",\
1155 \"address\":0x%lx,\
1156 \"returned\":%d\
1157 },\n\
1158 "
1159 , (long long)HDtime(NULL), (unsigned long)entry->addr,
1160 (int)fxn_ret_value);
1161
1162 /* Write the log message to the file */
1163 if(H5C__json_write_log_message(json_udata) < 0)
1164 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1165
1166 done:
1167 FUNC_LEAVE_NOAPI(ret_value)
1168 } /* H5C__json_write_unpin_entry_log_msg() */
1169
1170
1171 /*-------------------------------------------------------------------------
1172 * Function: H5C__json_write_destroy_fd_log_msg
1173 *
1174 * Purpose: Write a log message for destroying a flush dependency
1175 * between two cache entries.
1176 *
1177 * Return: SUCCEED/FAIL
1178 *
1179 * Programmer: Dana Robinson
1180 * Fall 2018
1181 *
1182 *-------------------------------------------------------------------------
1183 */
1184 static herr_t
H5C__json_write_destroy_fd_log_msg(void * udata,const H5C_cache_entry_t * parent,const H5C_cache_entry_t * child,herr_t fxn_ret_value)1185 H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
1186 const H5C_cache_entry_t *child, herr_t fxn_ret_value)
1187 {
1188 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1189 herr_t ret_value = SUCCEED;
1190
1191 FUNC_ENTER_STATIC
1192
1193 /* Sanity checks */
1194 HDassert(json_udata);
1195 HDassert(json_udata->message);
1196 HDassert(parent);
1197 HDassert(child);
1198
1199 /* Create the log message string */
1200 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1201 "\
1202 {\
1203 \"timestamp\":%lld,\
1204 \"action\":\"destroy_fd\",\
1205 \"parent_addr\":0x%lx,\
1206 \"child_addr\":0x%lx,\
1207 \"returned\":%d\
1208 },\n\
1209 "
1210 , (long long)HDtime(NULL), (unsigned long)parent->addr,
1211 (unsigned long)child->addr, (int)fxn_ret_value);
1212
1213 /* Write the log message to the file */
1214 if(H5C__json_write_log_message(json_udata) < 0)
1215 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1216
1217 done:
1218 FUNC_LEAVE_NOAPI(ret_value)
1219 } /* H5C__json_write_destroy_fd_log_msg() */
1220
1221
1222 /*-------------------------------------------------------------------------
1223 * Function: H5C__json_write_unprotect_entry_log_msg
1224 *
1225 * Purpose: Write a log message for unprotecting a cache entry.
1226 *
1227 * Return: SUCCEED/FAIL
1228 *
1229 * Programmer: Dana Robinson
1230 * Fall 2018
1231 *
1232 *-------------------------------------------------------------------------
1233 */
1234 static herr_t
H5C__json_write_unprotect_entry_log_msg(void * udata,haddr_t address,int type_id,unsigned flags,herr_t fxn_ret_value)1235 H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address,
1236 int type_id, unsigned flags, herr_t fxn_ret_value)
1237 {
1238 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1239 herr_t ret_value = SUCCEED;
1240
1241 FUNC_ENTER_STATIC
1242
1243 /* Sanity checks */
1244 HDassert(json_udata);
1245 HDassert(json_udata->message);
1246
1247 /* Create the log message string */
1248 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1249 "\
1250 {\
1251 \"timestamp\":%lld,\
1252 \"action\":\"unprotect\",\
1253 \"address\":0x%lx,\
1254 \"id\":%d,\
1255 \"flags\":%x,\
1256 \"returned\":%d\
1257 },\n\
1258 "
1259 , (long long)HDtime(NULL), (unsigned long)address,
1260 type_id, flags, (int)fxn_ret_value);
1261
1262 /* Write the log message to the file */
1263 if(H5C__json_write_log_message(json_udata) < 0)
1264 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1265
1266 done:
1267 FUNC_LEAVE_NOAPI(ret_value)
1268 } /* H5C__json_write_unprotect_entry_log_msg() */
1269
1270
1271 /*-------------------------------------------------------------------------
1272 * Function: H5C__json_write_set_cache_config_log_msg
1273 *
1274 * Purpose: Write a log message for setting the cache configuration.
1275 *
1276 * Return: SUCCEED/FAIL
1277 *
1278 * Programmer: Dana Robinson
1279 * Fall 2018
1280 *
1281 *-------------------------------------------------------------------------
1282 */
1283 static herr_t
H5C__json_write_set_cache_config_log_msg(void * udata,const H5AC_cache_config_t * config,herr_t fxn_ret_value)1284 H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config,
1285 herr_t fxn_ret_value)
1286 {
1287 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1288 herr_t ret_value = SUCCEED;
1289
1290 FUNC_ENTER_STATIC
1291
1292 /* Sanity checks */
1293 HDassert(json_udata);
1294 HDassert(json_udata->message);
1295 HDassert(config);
1296
1297 /* Create the log message string */
1298 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1299 "\
1300 {\
1301 \"timestamp\":%lld,\
1302 \"action\":\"set_config\",\
1303 \"returned\":%d\
1304 },\n\
1305 "
1306 , (long long)HDtime(NULL), (int)fxn_ret_value);
1307
1308
1309 /* Write the log message to the file */
1310 if(H5C__json_write_log_message(json_udata) < 0)
1311 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1312
1313 done:
1314 FUNC_LEAVE_NOAPI(ret_value)
1315 } /* H5C__json_write_set_cache_config_log_msg() */
1316
1317
1318 /*-------------------------------------------------------------------------
1319 * Function: H5C__json_write_remove_entry_log_msg
1320 *
1321 * Purpose: Write a log message for removing a cache entry.
1322 *
1323 * Return: SUCCEED/FAIL
1324 *
1325 * Programmer: Dana Robinson
1326 * Fall 2018
1327 *
1328 *-------------------------------------------------------------------------
1329 */
1330 static herr_t
H5C__json_write_remove_entry_log_msg(void * udata,const H5C_cache_entry_t * entry,herr_t fxn_ret_value)1331 H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
1332 herr_t fxn_ret_value)
1333 {
1334 H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1335 herr_t ret_value = SUCCEED;
1336
1337 FUNC_ENTER_STATIC
1338
1339 /* Sanity checks */
1340 HDassert(json_udata);
1341 HDassert(json_udata->message);
1342 HDassert(entry);
1343
1344 /* Create the log message string */
1345 HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE,
1346 "\
1347 {\
1348 \"timestamp\":%lld,\
1349 \"action\":\"remove\",\
1350 \"address\":0x%lx,\
1351 \"returned\":%d\
1352 },\n\
1353 "
1354 , (long long)HDtime(NULL), (unsigned long)entry->addr,
1355 (int)fxn_ret_value);
1356
1357 /* Write the log message to the file */
1358 if(H5C__json_write_log_message(json_udata) < 0)
1359 HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message")
1360
1361 done:
1362 FUNC_LEAVE_NOAPI(ret_value)
1363 } /* H5C__json_write_remove_entry_log_msg() */
1364
1365