Commit 5939e55b authored by Philip Carns's avatar Philip Carns
Browse files

incorporate margo logging

parent 950ba473
......@@ -14,6 +14,15 @@
extern "C" {
#endif
#define BAKE_TRACE(_mid, _format, f...) margo_trace(_mid, "bake: " _format, ##f)
#define BAKE_DEBUG(_mid, _format, f...) margo_debug(_mid, "bake: " _format, ##f)
#define BAKE_INFO(_mid, _format, f...) margo_info(_mid, "bake: " _format, ##f)
#define BAKE_WARNING(_mid, _format, f...) \
margo_warning(_mid, "bake: " _format, ##f)
#define BAKE_ERROR(_mid, _format, f...) margo_error(_mid, "bake: " _format, ##f)
#define BAKE_CRITICAL(_mid, _format, f...) \
margo_critical(_mid, "bake: " _format, ##f)
typedef struct {
uuid_t id;
} bake_target_id_t;
......
......@@ -20,12 +20,12 @@ static int bake_register_provider(bedrock_args_t args,
const char* config = bedrock_args_get_config(args);
const char* name = bedrock_args_get_name(args);
printf("Registering a Bake provider\n");
printf(" -> mid = %p\n", (void*)mid);
printf(" -> provider id = %d\n", provider_id);
printf(" -> pool = %p\n", (void*)pool);
printf(" -> config = %s\n", config);
printf(" -> name = %s\n", name);
BAKE_TRACE(mid, "bake_register_provider()");
BAKE_INFO(mid, " -> mid = %p", (void*)mid);
BAKE_INFO(mid, " -> provider id = %d", provider_id);
BAKE_INFO(mid, " -> pool = %p", (void*)pool);
BAKE_INFO(mid, " -> config = %s", config);
BAKE_INFO(mid, " -> name = %s", name);
bpargs.json_config = config;
ret = bake_provider_register(mid, provider_id, &bpargs,
......@@ -39,8 +39,6 @@ static int bake_deregister_provider(bedrock_module_provider_t provider)
{
int ret;
printf("Deregistering a Bake provider\n");
ret = bake_provider_destroy(provider);
if (ret < 0) return (-1);
......@@ -57,8 +55,7 @@ static int bake_init_client(margo_instance_id mid,
{
int ret;
printf("Registering a Bake client\n");
printf(" -> mid = %p\n", (void*)mid);
BAKE_TRACE(mid, "bake_init_client()");
ret = bake_client_init(mid, (bake_client_t*)client);
if (ret < 0) return (-1);
......@@ -70,8 +67,6 @@ static int bake_finalize_client(bedrock_module_client_t client)
{
int ret;
printf("Finalizing a Bake client\n");
ret = bake_client_finalize(client);
if (ret < 0) return (-1);
......@@ -85,8 +80,6 @@ static int bake_create_provider_handle(bedrock_module_client_t client,
{
int ret;
printf("Creating Bake provider handle\n");
ret = bake_provider_handle_create(client, address, provider_id,
(bake_provider_handle_t*)ph);
if (ret < 0) return (-1);
......@@ -98,7 +91,6 @@ static int bake_destroy_provider_handle(bedrock_module_provider_handle_t ph)
{
int ret;
printf("Destroying Bake provider handle\n");
ret = bake_provider_handle_release(ph);
if (ret < 0) return (-1);
......
......@@ -157,10 +157,10 @@ int bake_client_init(margo_instance_id mid, bake_client_t* client)
int bake_client_finalize(bake_client_t client)
{
if (client->num_provider_handles != 0) {
fprintf(stderr,
"[BAKE] Warning: %llu provider handles not released before "
"bake_client_finalize was called\n",
(long long unsigned int)client->num_provider_handles);
BAKE_WARNING(client->mid,
"%llu provider handles not released before "
"bake_client_finalize was called\n",
(long long unsigned int)client->num_provider_handles);
}
free(client);
return BAKE_SUCCESS;
......
......@@ -175,13 +175,10 @@ static int bake_file_backend_initialize(bake_provider_t provider,
if (!json_object_get_boolean(
json_object_object_get(provider->json_cfg, "pipeline_enable"))) {
fprintf(stderr, "Error: The Bake file backend requires pipelining.\n");
fprintf(stderr,
" Enable pipelining with -p on the bake-server-daemon "
"command line or\n");
fprintf(stderr,
" programmatically with bake_provider_set_conf(provider, "
"\"pipeline_enabled\", \"1\")\n");
BAKE_ERROR(provider->mid, "the bake file backend requires pipelining");
BAKE_ERROR(provider->mid,
"please enable pipelining in the provider's json "
"configuration or with bake-server-daemon -p");
return (BAKE_ERR_INVALID_ARG);
}
......@@ -219,8 +216,8 @@ static int bake_file_backend_initialize(bake_provider_t provider,
new_entry->log_fd
= abt_io_open(new_entry->abtioi, path, O_RDWR | O_DIRECT, 0);
if (new_entry->log_fd < 0) {
fprintf(stderr, "open(): %s on %s\n", strerror(-new_entry->log_fd),
path);
BAKE_ERROR(provider->mid, "open(): %s on %s",
strerror(-new_entry->log_fd), path);
ret = BAKE_ERR_IO;
goto error_cleanup;
}
......@@ -252,8 +249,7 @@ static int bake_file_backend_initialize(bake_provider_t provider,
*target = new_entry->file_root->pool_id;
if (uuid_is_null(target->id)) {
fprintf(stderr, "Error: BAKE pool %s is not properly formatted\n",
path);
BAKE_ERROR(provider->mid, "pool %s is not properly formatted", path);
ret = BAKE_ERR_IO;
goto error_cleanup;
}
......@@ -262,16 +258,16 @@ static int bake_file_backend_initialize(bake_provider_t provider,
new_entry->log_alignment = json_object_get_int(
json_object_object_get(file_backend_json, "alignment"));
if (new_entry->log_alignment < 0) {
fprintf(stderr, "Error: negative alignment %d\n",
new_entry->log_alignment);
BAKE_ERROR(provider->mid, "negative alignment %d",
new_entry->log_alignment);
ret = BAKE_ERR_INVALID_ARG;
goto error_cleanup;
}
if (!(((unsigned)new_entry->log_alignment
& ((unsigned)new_entry->log_alignment - 1))
== 0)) {
fprintf(stderr, "Error: alignment %d is not a power of 2 or zero\n",
new_entry->log_alignment);
BAKE_ERROR(provider->mid, "alignment %d is not a power of 2 or zero",
new_entry->log_alignment);
ret = BAKE_ERR_INVALID_ARG;
goto error_cleanup;
}
......@@ -281,9 +277,9 @@ static int bake_file_backend_initialize(bake_provider_t provider,
*/
json_object_array_add(target_array, json_object_new_string(path));
fprintf(stderr,
"WARNING: Bake file backend does not yet support the following:\n");
fprintf(stderr, " * writes to non-zero region offsets\n");
BAKE_WARNING(provider->mid,
"bake file backend does not yet support the following:");
BAKE_WARNING(provider->mid, " * writes to non-zero region offsets");
*context = new_entry;
return 0;
......@@ -395,9 +391,9 @@ static int bake_file_write_raw(backend_context_t context,
* write offsets are aligned.
*/
if (offset != 0) {
fprintf(stderr,
"Error: Bake file backend does not yet support unaligned "
"writes.\n");
BAKE_ERROR(entry->provider->mid,
"bake file backend does not yet support writes to non-zero "
"region offsets");
return (BAKE_ERR_OP_UNSUPPORTED);
}
......@@ -446,9 +442,9 @@ static int bake_file_write_bulk(backend_context_t context,
* write offsets are aligned.
*/
if (region_offset != 0) {
fprintf(stderr,
"Error: Bake file backend does not yet support unaligned "
"writes.\n");
BAKE_ERROR(entry->provider->mid,
"bake file backend does not yet support writes to non-zero "
"region offsets");
return (BAKE_ERR_OP_UNSUPPORTED);
}
......
......@@ -102,7 +102,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
new_context->pmem_pool = pmemobj_open(path, NULL);
if (!(new_context->pmem_pool)) {
fprintf(stderr, "pmemobj_open: %s\n", pmemobj_errormsg());
BAKE_ERROR(provider->mid, "pmemobj_open: %s", pmemobj_errormsg());
free(new_context->filename);
free(new_context->root);
free(new_context);
......@@ -116,8 +116,7 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
bake_target_id_t tid = new_context->pmem_root->pool_id;
if (uuid_is_null(tid.id)) {
fprintf(stderr, "Error: BAKE pool %s is not properly initialized\n",
path);
BAKE_ERROR(provider->mid, "pool %s is not properly initialized", path);
pmemobj_close(new_context->pmem_pool);
free(new_context->filename);
free(new_context->root);
......
......@@ -85,10 +85,11 @@ int bake_provider_register(margo_instance_id mid,
margo_provider_registered_name(mid, "bake_probe_rpc", provider_id, &id,
&flag);
if (flag == HG_TRUE) {
fprintf(stderr,
"bake_provider_register(): a BAKE provider with the same "
"id (%d) already exists\n",
provider_id);
BAKE_ERROR(
mid,
"bake_provider_register(): a bake provider with the same "
"id (%d) already exists",
provider_id);
return BAKE_ERR_MERCURY;
}
}
......@@ -102,8 +103,8 @@ int bake_provider_register(margo_instance_id mid,
strlen(args.json_config));
if (!config) {
jerr = json_tokener_get_error(tokener);
fprintf(stderr, "JSON parse error: %s",
json_tokener_error_desc(jerr));
BAKE_ERROR(mid, "JSON parse error: %s",
json_tokener_error_desc(jerr));
json_tokener_free(tokener);
return BAKE_ERR_INVALID_ARG;
}
......@@ -116,7 +117,7 @@ int bake_provider_register(margo_instance_id mid,
/* validate and complete configuration */
ret = validate_and_complete_config(config, args.rpc_pool);
if (ret != 0) {
fprintf(stderr, "Could not validate and complete configuration");
BAKE_ERROR(mid, "could not validate and complete configuration");
json_object_put(config);
return BAKE_ERR_INVALID_ARG;
}
......@@ -136,7 +137,7 @@ int bake_provider_register(margo_instance_id mid,
ret = setup_poolset(tmp_provider);
if (ret != 0) {
fprintf(stderr, "Could not create poolset for pipelining");
BAKE_ERROR(mid, "could not create poolset for pipelining");
json_object_put(config);
free(tmp_provider);
return ret;
......@@ -346,7 +347,7 @@ int bake_provider_add_storage_target(bake_provider_t provider,
} else if (strcmp(backend_type, "file") == 0) {
new_entry->backend = &g_bake_file_backend;
} else {
fprintf(stderr, "ERROR: unknown backend type \"%s\"\n", backend_type);
BAKE_ERROR(provider->mid, "unknown backend type \"%s\"", backend_type);
free(backend_type);
return BAKE_ERR_BACKEND_TYPE;
}
......@@ -370,8 +371,8 @@ int bake_provider_add_storage_target(bake_provider_t provider,
HASH_FIND(hh, provider->targets, &tid, sizeof(bake_target_id_t),
check_entry);
if (check_entry != new_entry) {
fprintf(stderr,
"Error: BAKE could not insert new pmem pool into the hash\n");
BAKE_ERROR(provider->mid,
"could not insert new pmem pool into the hash");
new_entry->backend->_finalize(ctx);
free(new_entry);
ret = BAKE_ERR_ALLOCATION;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment