38 # include <dsn/c/api_common.h> 108 extern DSN_API
const char*
dsn_cli_run(
const char* command_line);
115 extern DSN_API
void dsn_cli_free(
const char* command_output);
150 const char* help_one_line,
151 const char* help_long,
163 const char* help_one_line,
164 const char* help_long,
190 const char* default_value,
193 extern DSN_API
bool dsn_config_get_value_bool(
199 extern DSN_API uint64_t dsn_config_get_value_uint64(
202 uint64_t default_value,
205 extern DSN_API
double dsn_config_get_value_double(
208 double default_value,
212 extern DSN_API
int dsn_config_get_all_sections(
213 const char** buffers,
217 extern DSN_API
int dsn_config_get_all_keys(
219 const char** buffers,
222 extern DSN_API
void dsn_config_dump(
const char* file);
237 typedef enum dsn_log_level_t
239 LOG_LEVEL_INFORMATION,
249 extern DSN_API dsn_log_level_t dsn_log_start_level;
250 extern DSN_API dsn_log_level_t dsn_log_get_start_level();
251 extern DSN_API
void dsn_logv(
253 const char *
function,
255 dsn_log_level_t log_level,
260 extern DSN_API
void dsn_logf(
262 const char *
function,
264 dsn_log_level_t log_level,
269 extern DSN_API
void dsn_log(
271 const char *
function,
273 dsn_log_level_t log_level,
276 extern DSN_API
void dsn_coredump();
279 #define dlog(level, title, ...) do {if (level >= dsn_log_start_level) \ 280 dsn_logf(__FILE__, __FUNCTION__, __LINE__, level, title, __VA_ARGS__); } while(false) 281 #define dinfo(...) dlog(LOG_LEVEL_INFORMATION, __TITLE__, __VA_ARGS__) 282 #define ddebug(...) dlog(LOG_LEVEL_DEBUG, __TITLE__, __VA_ARGS__) 283 #define dwarn(...) dlog(LOG_LEVEL_WARNING, __TITLE__, __VA_ARGS__) 284 #define derror(...) dlog(LOG_LEVEL_ERROR, __TITLE__, __VA_ARGS__) 285 #define dfatal(...) dlog(LOG_LEVEL_FATAL, __TITLE__, __VA_ARGS__) 286 #define dassert(x, ...) do { if (!(x)) { \ 287 dlog(LOG_LEVEL_FATAL, __FILE__, "assertion expression: "#x); \ 288 dlog(LOG_LEVEL_FATAL, __FILE__, __VA_ARGS__); \ 293 #define dbg_dassert dassert 295 #define dbg_dassert(x, ...) 309 extern DSN_API uint32_t dsn_crc32_compute(
const void* ptr,
size_t size, uint32_t init_crc);
320 extern DSN_API uint32_t dsn_crc32_concatenate(
330 extern DSN_API uint64_t dsn_crc64_compute(
const void* ptr,
size_t size, uint64_t init_crc);
342 extern DSN_API uint64_t dsn_crc64_concatenate(
364 typedef enum dsn_perf_counter_type_t
368 COUNTER_TYPE_NUMBER_PERCENTILES,
369 COUNTER_TYPE_INVALID,
371 } dsn_perf_counter_type_t;
373 typedef enum dsn_perf_counter_percentile_type_t
375 COUNTER_PERCENTILE_50,
376 COUNTER_PERCENTILE_90,
377 COUNTER_PERCENTILE_95,
378 COUNTER_PERCENTILE_99,
379 COUNTER_PERCENTILE_999,
381 COUNTER_PERCENTILE_COUNT,
382 COUNTER_PERCENTILE_INVALID
383 } dsn_perf_counter_percentile_type_t;
385 extern DSN_API dsn_handle_t dsn_perf_counter_create(
const char* section,
const char* name, dsn_perf_counter_type_t type,
const char* description);
386 extern DSN_API
void dsn_perf_counter_remove(dsn_handle_t handle);
387 extern DSN_API
void dsn_perf_counter_increment(dsn_handle_t handle);
388 extern DSN_API
void dsn_perf_counter_decrement(dsn_handle_t handle);
389 extern DSN_API
void dsn_perf_counter_add(dsn_handle_t handle, uint64_t val);
390 extern DSN_API
void dsn_perf_counter_set(dsn_handle_t handle, uint64_t val);
391 extern DSN_API
double dsn_perf_counter_get_value(dsn_handle_t handle);
392 extern DSN_API uint64_t dsn_perf_counter_get_integer_value(dsn_handle_t handle);
393 extern DSN_API
double dsn_perf_counter_get_percentile(dsn_handle_t handle, dsn_perf_counter_percentile_type_t type);
415 extern DSN_API
void dsn_free(
void* ptr);
uint64_t size
message_size
Definition: api_utilities.h:121
DSN_API dsn_error_t dsn_error_register(const char *name)
register error code
DSN_API void * dsn_malloc(uint32_t size)
common malloc, paird with dsn_free to ensure malloc/free are done by dsn.core
DSN_API void dsn_cli_deregister(dsn_handle_t cli_handle)
remove a cli handler
void(* dsn_cli_handler)(void *context, int argc, const char **argv, dsn_cli_reply *reply)
cli request handler definition
Definition: api_utilities.h:126
const char * message
zero-ended reply message
Definition: api_utilities.h:120
cli response definition
Definition: api_utilities.h:118
DSN_API void dsn_transient_free(void *ptr)
high-performance free for transient objects, paired with dsn_transient_malloc
DSN_API void * dsn_transient_malloc(uint32_t size)
high-performance malloc for transient objects, i.e., their life-time is short
void(* dsn_cli_free_handler)(dsn_cli_reply reply)
cli response resource gc handler definition
Definition: api_utilities.h:134
DSN_API dsn_handle_t dsn_cli_app_register(const char *command, const char *help_one_line, const char *help_long, void *context, dsn_cli_handler cmd_handler, dsn_cli_free_handler output_freer)
same as dsn_cli_register, except that the command name is auto-augmented by rDSN as $app_full_name...
void * context
context for free_handler
Definition: api_utilities.h:122
DSN_API const char * dsn_cli_run(const char *command_line)
run a given cli command
DSN_API dsn_error_t dsn_error_from_string(const char *s, dsn_error_t default_err)
parse string error code into integer code
DSN_API void dsn_free(void *ptr)
common free, paird with dsn_malloc to ensure malloc/free are done by dsn.core
DSN_API void dsn_cli_free(const char *command_output)
free memory occupied by cli response
struct dsn_cli_reply dsn_cli_reply
cli response definition
DSN_API dsn_handle_t dsn_cli_register(const char *command, const char *help_one_line, const char *help_long, void *context, dsn_cli_handler cmd_handler, dsn_cli_free_handler output_freer)
register a customized cli command handler
DSN_API const char * dsn_config_get_value_string(const char *section, const char *key, const char *default_value, const char *dsptr)
DSN_API const char * dsn_error_to_string(dsn_error_t err)
translate interger error code to a string