removed some bits from invalid LR design

pull/7391/head
David Garcia Quintas 8 years ago
parent 824363dc2f
commit fa30de9b39
  1. 2
      src/core/ext/load_reporting/load_reporting.h
  2. 33
      src/core/ext/load_reporting/load_reporting_filter.c
  3. 62
      test/core/end2end/tests/load_reporting_hook.c

@ -38,9 +38,11 @@
#include "src/core/lib/channel/channel_stack.h"
/** Metadata key for initial metadata coming from clients */
/* TODO(dgq): change to the final value TBD */
#define GRPC_LOAD_REPORTING_INITIAL_MD_KEY "load-reporting-initial"
/** Metadata key for trailing metadata from servers */
/* TODO(dgq): change to the final value TBD */
#define GRPC_LOAD_REPORTING_TRAILING_MD_KEY "load-reporting-trailing"
/** Identifiers for the invocation point of the users LR callback */

@ -43,11 +43,6 @@
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/transport/static_metadata.h"
void (*g_load_reporting_fn)(const grpc_load_reporting_call_data *call_data);
/* The function to be defined */
void load_reporting_fn(const grpc_load_reporting_call_data *call_data) {}
typedef struct call_data {
intptr_t id; /**< an id unique to the call */
char *trailing_md_string;
@ -68,15 +63,6 @@ typedef struct channel_data {
intptr_t id; /**< an id unique to the channel */
} channel_data;
static void invoke_lr_fn(grpc_load_reporting_call_data *lr_call_data) {
if (g_load_reporting_fn == NULL) {
g_load_reporting_fn = load_reporting_fn;
}
GPR_TIMER_BEGIN("load_reporting_fn", 0);
g_load_reporting_fn(lr_call_data);
GPR_TIMER_END("load_reporting_fn", 0);
}
typedef struct {
grpc_call_element *elem;
grpc_exec_ctx *exec_ctx;
@ -91,6 +77,7 @@ static grpc_mdelem *recv_md_filter(void *user_data, grpc_mdelem *md) {
calld->service_method = grpc_mdstr_as_c_string(md->value);
} else if (md->key == GRPC_MDSTR_LOAD_REPORTING_INITIAL) {
calld->initial_md_string = gpr_strdup(grpc_mdstr_as_c_string(md->value));
return NULL;
}
return md;
@ -122,13 +109,14 @@ static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
/* Constructor for call_data */
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
channel_data *chand = elem->channel_data;
call_data *calld = elem->call_data;
memset(calld, 0, sizeof(call_data));
calld->id = (intptr_t)args->call_stack;
grpc_closure_init(&calld->on_initial_md_ready, on_initial_md_ready, elem);
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_CREATION,
(intptr_t)chand->id,
(intptr_t)calld->id,
@ -136,16 +124,17 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
NULL,
NULL,
NULL};
invoke_lr_fn(&lr_call_data);
*/
}
/* Destructor for call_data */
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
void *ignored) {
channel_data *chand = elem->channel_data;
call_data *calld = elem->call_data;
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_DESTRUCTION,
(intptr_t)chand->id,
(intptr_t)calld->id,
@ -153,8 +142,7 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
calld->initial_md_string,
calld->trailing_md_string,
calld->service_method};
invoke_lr_fn(&lr_call_data);
*/
gpr_free(calld->initial_md_string);
gpr_free(calld->trailing_md_string);
@ -171,6 +159,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
chand->id = (intptr_t)args->channel_stack;
/* TODO(dgq): do something with the data
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CHANNEL_CREATION,
(intptr_t)chand,
0,
@ -178,12 +167,13 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
NULL,
NULL,
NULL};
invoke_lr_fn(&lr_call_data);
*/
}
/* Destructor for channel data */
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
grpc_load_reporting_call_data lr_call_data = {
GRPC_LR_POINT_CHANNEL_DESTRUCTION,
@ -193,7 +183,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
NULL,
NULL,
NULL};
invoke_lr_fn(&lr_call_data);
*/
}
static grpc_mdelem *lr_trailing_md_filter(void *user_data, grpc_mdelem *md) {
@ -202,6 +192,7 @@ static grpc_mdelem *lr_trailing_md_filter(void *user_data, grpc_mdelem *md) {
if (md->key == GRPC_MDSTR_LOAD_REPORTING_TRAILING) {
calld->trailing_md_string = gpr_strdup(grpc_mdstr_as_c_string(md->value));
return NULL;
}
return md;

@ -69,44 +69,6 @@ typedef struct {
bool fully_processed;
} load_reporting_data;
static load_reporting_data lr_data;
static void load_reporting_test_fn(
const grpc_load_reporting_call_data *call_data) {
gpr_mu_lock(&lr_data.mu);
switch (call_data->source) {
case GRPC_LR_POINT_CHANNEL_CREATION:
lr_data.channel_id = call_data->channel_id;
break;
case GRPC_LR_POINT_CHANNEL_DESTRUCTION:
break;
case GRPC_LR_POINT_CALL_CREATION:
lr_data.call_id = call_data->call_id;
break;
case GRPC_LR_POINT_CALL_DESTRUCTION:
if (lr_data.initial_md_str == NULL) {
lr_data.initial_md_str = gpr_strdup(call_data->initial_md_string);
}
if (lr_data.trailing_md_str == NULL) {
lr_data.trailing_md_str = gpr_strdup(call_data->trailing_md_string);
}
if (lr_data.method_name == NULL) {
lr_data.method_name = gpr_strdup(call_data->method_name);
}
lr_data.incoming_bytes = call_data->final_info->stats
.transport_stream_stats.incoming.data_bytes;
lr_data.outgoing_bytes = call_data->final_info->stats
.transport_stream_stats.outgoing.data_bytes;
lr_data.call_final_status = call_data->final_info->final_status;
lr_data.fully_processed = true;
break;
default:
abort();
}
gpr_mu_unlock(&lr_data.mu);
}
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
const char *test_name,
grpc_channel_args *client_args,
@ -315,8 +277,8 @@ extern void (*g_load_reporting_fn)(
const grpc_load_reporting_call_data *call_data);
static void test_load_reporting_hook(grpc_end2end_test_config config) {
gpr_mu_init(&lr_data.mu);
g_load_reporting_fn = load_reporting_test_fn;
/* TODO(dgq): this test is currently a noop until LR is fully defined.
* Leaving the rest here, as it'll likely be reusable. */
/* Introduce load reporting for the server through its arguments */
grpc_arg arg = grpc_load_reporting_enable_arg();
@ -350,26 +312,6 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
end_test(&f);
grpc_channel_args_destroy(lr_server_args);
config.tear_down_data(&f);
GPR_ASSERT(lr_data.fully_processed);
GPR_ASSERT(lr_data.incoming_bytes == strlen(request_msg));
GPR_ASSERT(lr_data.outgoing_bytes == strlen(response_msg));
GPR_ASSERT(lr_data.call_id > 0);
GPR_ASSERT(lr_data.channel_id > 0);
GPR_ASSERT(strcmp(lr_data.method_name, "/gRPCFTW") == 0);
GPR_ASSERT(lr_data.initial_md_str != NULL);
GPR_ASSERT(lr_data.trailing_md_str != NULL);
GPR_ASSERT(strcmp(lr_data.initial_md_str, "client-token") == 0);
GPR_ASSERT(strcmp(lr_data.trailing_md_str, "server-token") == 0);
GPR_ASSERT(lr_data.call_final_status == GRPC_STATUS_OK);
gpr_free(lr_data.initial_md_str);
gpr_free(lr_data.trailing_md_str);
gpr_free(lr_data.method_name);
}
void load_reporting_hook(grpc_end2end_test_config config) {

Loading…
Cancel
Save