mirror of https://github.com/grpc/grpc.git
commit
85c1168d17
57 changed files with 1402 additions and 394 deletions
@ -0,0 +1,71 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/ext/census/base_resources.h" |
||||||
|
|
||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include <grpc/census.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
|
||||||
|
#include "src/core/ext/census/resource.h" |
||||||
|
|
||||||
|
// Add base RPC resource definitions for use by RPC runtime.
|
||||||
|
//
|
||||||
|
// TODO(aveitch): All of these are currently hardwired definitions encoded in
|
||||||
|
// the code in this file. These should be converted to use an external
|
||||||
|
// configuration mechanism, in which these resources are defined in a text
|
||||||
|
// file, which is compiled to .pb format and read by still-to-be-written
|
||||||
|
// configuration functions.
|
||||||
|
|
||||||
|
// Define all base resources. This should be called by census initialization.
|
||||||
|
void define_base_resources() { |
||||||
|
google_census_Resource_BasicUnit numerator = |
||||||
|
google_census_Resource_BasicUnit_SECS; |
||||||
|
resource r = {"client_rpc_latency", // name
|
||||||
|
"Client RPC latency in seconds", // description
|
||||||
|
0, // prefix
|
||||||
|
1, // n_numerators
|
||||||
|
&numerator, // numerators
|
||||||
|
0, // n_denominators
|
||||||
|
NULL}; // denominators
|
||||||
|
define_resource(&r); |
||||||
|
r = (resource){"server_rpc_latency", // name
|
||||||
|
"Server RPC latency in seconds", // description
|
||||||
|
0, // prefix
|
||||||
|
1, // n_numerators
|
||||||
|
&numerator, // numerators
|
||||||
|
0, // n_denominators
|
||||||
|
NULL}; // denominators
|
||||||
|
define_resource(&r); |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H |
||||||
|
#define GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H |
||||||
|
|
||||||
|
/* Define all base resources. This should be called by census initialization. */ |
||||||
|
void define_base_resources(); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ |
@ -0,0 +1,312 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/ext/census/resource.h" |
||||||
|
#include "third_party/nanopb/pb_decode.h" |
||||||
|
|
||||||
|
#include <grpc/census.h> |
||||||
|
#include <grpc/support/alloc.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <grpc/support/sync.h> |
||||||
|
|
||||||
|
#include <stdbool.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
// Protect local resource data structures.
|
||||||
|
static gpr_mu resource_lock; |
||||||
|
|
||||||
|
// Deleteing and creating resources are relatively rare events, and should not
|
||||||
|
// be done in the critical path of performance sensitive code. We record
|
||||||
|
// current resource id's used in a simple array, and just search it each time
|
||||||
|
// we need to assign a new id, or look up a resource.
|
||||||
|
static resource **resources = NULL; |
||||||
|
|
||||||
|
// Number of entries in *resources
|
||||||
|
static size_t n_resources = 0; |
||||||
|
|
||||||
|
// Number of defined resources
|
||||||
|
static size_t n_defined_resources = 0; |
||||||
|
|
||||||
|
void initialize_resources(void) { |
||||||
|
gpr_mu_init(&resource_lock); |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
GPR_ASSERT(resources == NULL && n_resources == 0 && n_defined_resources == 0); |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
} |
||||||
|
|
||||||
|
// Delete a resource given it's ID. The ID must be a valid resource ID. Must be
|
||||||
|
// called with resource_lock held.
|
||||||
|
static void delete_resource_locked(size_t rid) { |
||||||
|
GPR_ASSERT(resources[rid] != NULL); |
||||||
|
gpr_free(resources[rid]->name); |
||||||
|
gpr_free(resources[rid]->description); |
||||||
|
gpr_free(resources[rid]->numerators); |
||||||
|
gpr_free(resources[rid]->denominators); |
||||||
|
gpr_free(resources[rid]); |
||||||
|
resources[rid] = NULL; |
||||||
|
n_defined_resources--; |
||||||
|
} |
||||||
|
|
||||||
|
void shutdown_resources(void) { |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
for (size_t i = 0; i < n_resources; i++) { |
||||||
|
if (resources[i] != NULL) { |
||||||
|
delete_resource_locked(i); |
||||||
|
} |
||||||
|
} |
||||||
|
GPR_ASSERT(n_defined_resources == 0); |
||||||
|
gpr_free(resources); |
||||||
|
resources = NULL; |
||||||
|
n_resources = 0; |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
} |
||||||
|
|
||||||
|
// Check the contents of string fields in a resource proto.
|
||||||
|
static bool validate_string(pb_istream_t *stream, const pb_field_t *field, |
||||||
|
void **arg) { |
||||||
|
resource *vresource = (resource *)*arg; |
||||||
|
switch (field->tag) { |
||||||
|
case google_census_Resource_name_tag: |
||||||
|
// Name must have at least one character
|
||||||
|
if (stream->bytes_left == 0) { |
||||||
|
gpr_log(GPR_INFO, "Zero-length Resource name."); |
||||||
|
return false; |
||||||
|
} |
||||||
|
vresource->name = gpr_malloc(stream->bytes_left + 1); |
||||||
|
vresource->name[stream->bytes_left] = '\0'; |
||||||
|
if (!pb_read(stream, (uint8_t *)vresource->name, stream->bytes_left)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
// Can't have same name as an existing resource.
|
||||||
|
for (size_t i = 0; i < n_resources; i++) { |
||||||
|
resource *compare = resources[i]; |
||||||
|
if (compare == vresource || compare == NULL) continue; |
||||||
|
if (strcmp(compare->name, vresource->name) == 0) { |
||||||
|
gpr_log(GPR_INFO, "Duplicate Resource name %s.", vresource->name); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
break; |
||||||
|
case google_census_Resource_description_tag: |
||||||
|
if (stream->bytes_left == 0) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
vresource->description = gpr_malloc(stream->bytes_left + 1); |
||||||
|
vresource->description[stream->bytes_left] = '\0'; |
||||||
|
if (!pb_read(stream, (uint8_t *)vresource->description, |
||||||
|
stream->bytes_left)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
break; |
||||||
|
default: |
||||||
|
// No other string fields in Resource. Print warning and skip.
|
||||||
|
gpr_log(GPR_INFO, "Unknown string field type in Resource protobuf."); |
||||||
|
if (!pb_read(stream, NULL, stream->bytes_left)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
break; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
// Decode numerators/denominators in a stream. The `count` and `bup`
|
||||||
|
// (BasicUnit pointer) are pointers to the approriate fields in a resource
|
||||||
|
// struct.
|
||||||
|
static bool validate_units_helper(pb_istream_t *stream, int *count, |
||||||
|
google_census_Resource_BasicUnit **bup) { |
||||||
|
while (stream->bytes_left) { |
||||||
|
(*count)++; |
||||||
|
// Have to allocate a new array of values. Normal case is 0 or 1, so
|
||||||
|
// this should normally not be an issue.
|
||||||
|
google_census_Resource_BasicUnit *new_bup = |
||||||
|
gpr_malloc((size_t)*count * sizeof(google_census_Resource_BasicUnit)); |
||||||
|
if (*count != 1) { |
||||||
|
memcpy(new_bup, *bup, |
||||||
|
(size_t)(*count - 1) * sizeof(google_census_Resource_BasicUnit)); |
||||||
|
gpr_free(*bup); |
||||||
|
} |
||||||
|
*bup = new_bup; |
||||||
|
uint64_t value; |
||||||
|
if (!pb_decode_varint(stream, &value)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
*(*bup + *count - 1) = (google_census_Resource_BasicUnit)value; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
// Validate units field of a Resource proto.
|
||||||
|
static bool validate_units(pb_istream_t *stream, const pb_field_t *field, |
||||||
|
void **arg) { |
||||||
|
resource *vresource = (resource *)(*arg); |
||||||
|
switch (field->tag) { |
||||||
|
case google_census_Resource_MeasurementUnit_numerator_tag: |
||||||
|
return validate_units_helper(stream, &vresource->n_numerators, |
||||||
|
&vresource->numerators); |
||||||
|
break; |
||||||
|
case google_census_Resource_MeasurementUnit_denominator_tag: |
||||||
|
return validate_units_helper(stream, &vresource->n_denominators, |
||||||
|
&vresource->denominators); |
||||||
|
break; |
||||||
|
default: |
||||||
|
gpr_log(GPR_ERROR, "Unknown field type."); |
||||||
|
return false; |
||||||
|
break; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
// Validate the contents of a Resource proto. `id` is the intended resource id.
|
||||||
|
static bool validate_resource_pb(const uint8_t *resource_pb, |
||||||
|
size_t resource_pb_size, size_t id) { |
||||||
|
GPR_ASSERT(id < n_resources); |
||||||
|
if (resource_pb == NULL) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
google_census_Resource vresource; |
||||||
|
vresource.name.funcs.decode = &validate_string; |
||||||
|
vresource.name.arg = resources[id]; |
||||||
|
vresource.description.funcs.decode = &validate_string; |
||||||
|
vresource.description.arg = resources[id]; |
||||||
|
vresource.unit.numerator.funcs.decode = &validate_units; |
||||||
|
vresource.unit.numerator.arg = resources[id]; |
||||||
|
vresource.unit.denominator.funcs.decode = &validate_units; |
||||||
|
vresource.unit.denominator.arg = resources[id]; |
||||||
|
|
||||||
|
pb_istream_t stream = |
||||||
|
pb_istream_from_buffer((uint8_t *)resource_pb, resource_pb_size); |
||||||
|
if (!pb_decode(&stream, google_census_Resource_fields, &vresource)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
// A Resource must have a name, a unit, with at least one numerator.
|
||||||
|
return (resources[id]->name != NULL && vresource.has_unit && |
||||||
|
resources[id]->n_numerators > 0); |
||||||
|
} |
||||||
|
|
||||||
|
// Allocate a blank resource, and return associated ID. Must be called with
|
||||||
|
// resource_lock held.
|
||||||
|
size_t allocate_resource(void) { |
||||||
|
// use next_id to optimize expected placement of next new resource.
|
||||||
|
static size_t next_id = 0; |
||||||
|
size_t id = n_resources; // resource ID - initialize to invalid value.
|
||||||
|
// Expand resources if needed.
|
||||||
|
if (n_resources == n_defined_resources) { |
||||||
|
size_t new_n_resources = n_resources ? n_resources * 2 : 2; |
||||||
|
resource **new_resources = gpr_malloc(new_n_resources * sizeof(resource *)); |
||||||
|
memcpy(new_resources, resources, n_resources * sizeof(resource *)); |
||||||
|
memset(new_resources + n_resources, 0, |
||||||
|
(new_n_resources - n_resources) * sizeof(resource *)); |
||||||
|
gpr_free(resources); |
||||||
|
resources = new_resources; |
||||||
|
n_resources = new_n_resources; |
||||||
|
id = n_defined_resources; |
||||||
|
} else { |
||||||
|
GPR_ASSERT(n_defined_resources < n_resources); |
||||||
|
// Find a free id.
|
||||||
|
for (size_t base = 0; base < n_resources; base++) { |
||||||
|
id = (next_id + base) % n_resources; |
||||||
|
if (resources[id] == NULL) break; |
||||||
|
} |
||||||
|
} |
||||||
|
GPR_ASSERT(id < n_resources && resources[id] == NULL); |
||||||
|
resources[id] = gpr_malloc(sizeof(resource)); |
||||||
|
memset(resources[id], 0, sizeof(resource)); |
||||||
|
n_defined_resources++; |
||||||
|
next_id = (id + 1) % n_resources; |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
int32_t census_define_resource(const uint8_t *resource_pb, |
||||||
|
size_t resource_pb_size) { |
||||||
|
if (resource_pb == NULL) { |
||||||
|
return -1; |
||||||
|
} |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
size_t id = allocate_resource(); |
||||||
|
// Validate pb, extract name.
|
||||||
|
if (!validate_resource_pb(resource_pb, resource_pb_size, id)) { |
||||||
|
delete_resource_locked(id); |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
return -1; |
||||||
|
} |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
return (int32_t)id; |
||||||
|
} |
||||||
|
|
||||||
|
void census_delete_resource(int32_t rid) { |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
if (rid >= 0 && (size_t)rid < n_resources && resources[rid] != NULL) { |
||||||
|
delete_resource_locked((size_t)rid); |
||||||
|
} |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
} |
||||||
|
|
||||||
|
int32_t census_resource_id(const char *name) { |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
for (int32_t id = 0; (size_t)id < n_resources; id++) { |
||||||
|
if (resources[id] != NULL && strcmp(resources[id]->name, name) == 0) { |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
return id; |
||||||
|
} |
||||||
|
} |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
int32_t define_resource(const resource *base) { |
||||||
|
GPR_ASSERT(base != NULL && base->name != NULL && base->n_numerators > 0 && |
||||||
|
base->numerators != NULL); |
||||||
|
gpr_mu_lock(&resource_lock); |
||||||
|
size_t id = allocate_resource(); |
||||||
|
size_t len = strlen(base->name) + 1; |
||||||
|
resources[id]->name = gpr_malloc(len); |
||||||
|
memcpy(resources[id]->name, base->name, len); |
||||||
|
if (base->description) { |
||||||
|
len = strlen(base->description) + 1; |
||||||
|
resources[id]->description = gpr_malloc(len); |
||||||
|
memcpy(resources[id]->description, base->description, len); |
||||||
|
} |
||||||
|
resources[id]->prefix = base->prefix; |
||||||
|
resources[id]->n_numerators = base->n_numerators; |
||||||
|
len = (size_t)base->n_numerators * sizeof(*base->numerators); |
||||||
|
resources[id]->numerators = gpr_malloc(len); |
||||||
|
memcpy(resources[id]->numerators, base->numerators, len); |
||||||
|
resources[id]->n_denominators = base->n_denominators; |
||||||
|
if (base->n_denominators != 0) { |
||||||
|
len = (size_t)base->n_denominators * sizeof(*base->denominators); |
||||||
|
resources[id]->denominators = gpr_malloc(len); |
||||||
|
memcpy(resources[id]->denominators, base->denominators, len); |
||||||
|
} |
||||||
|
gpr_mu_unlock(&resource_lock); |
||||||
|
return (int32_t)id; |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Census-internal resource definition and manipluation functions. */ |
||||||
|
#ifndef GRPC_CORE_EXT_CENSUS_RESOURCE_H |
||||||
|
#define GRPC_CORE_EXT_CENSUS_RESOURCE_H |
||||||
|
|
||||||
|
#include <grpc/grpc.h> |
||||||
|
#include "src/core/ext/census/gen/census.pb.h" |
||||||
|
|
||||||
|
/* Internal representation of a resource. */ |
||||||
|
typedef struct { |
||||||
|
char *name; |
||||||
|
char *description; |
||||||
|
int32_t prefix; |
||||||
|
int n_numerators; |
||||||
|
google_census_Resource_BasicUnit *numerators; |
||||||
|
int n_denominators; |
||||||
|
google_census_Resource_BasicUnit *denominators; |
||||||
|
} resource; |
||||||
|
|
||||||
|
/* Initialize and shutdown the resources subsystem. */ |
||||||
|
void initialize_resources(void); |
||||||
|
void shutdown_resources(void); |
||||||
|
|
||||||
|
/* Add a new resource, given a proposed resource structure. Returns the
|
||||||
|
resource ID, or -ve on failure. |
||||||
|
TODO(aveitch): this function exists to support addition of the base |
||||||
|
resources. It should be removed when we have the ability to add resources |
||||||
|
from configuration files. */ |
||||||
|
int32_t define_resource(const resource *base); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */ |
@ -0,0 +1,7 @@ |
|||||||
|
Test source and data files for Census. |
||||||
|
|
||||||
|
binary proto files (*.pb) in data directory are generated from the *.txt file, |
||||||
|
via: |
||||||
|
|
||||||
|
BASE="filename" |
||||||
|
cat $BASE.txt | protoc --encode=google.census.Resource census.proto > $BASE.pb |
@ -0,0 +1,5 @@ |
|||||||
|
# Name is present, but empty. |
||||||
|
name : '' |
||||||
|
unit { |
||||||
|
numerator : SECS |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
# A full resource definition - all fields filled out. |
||||||
|
name : 'full_resource' |
||||||
|
description : 'A resource with everything defined' |
||||||
|
unit { |
||||||
|
# Megabits per second. |
||||||
|
prefix : 6 |
||||||
|
numerator : BITS |
||||||
|
denominator : SECS |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
# A minimal "good" Resource definition: has a name and numerator/unit. |
||||||
|
name : 'minimal_good' |
||||||
|
unit { |
||||||
|
numerator : SECS |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
# The minimal good Resource without a name. |
||||||
|
unit { |
||||||
|
numerator : SECS |
||||||
|
} |
@ -0,0 +1,6 @@ |
|||||||
|
# Resource without a numerator |
||||||
|
name : 'resource_no_numerator' |
||||||
|
unit { |
||||||
|
prefix : -3 |
||||||
|
denominator : SECS |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
# The minimal good resource without a unit |
||||||
|
name : 'resource_no_unit' |
@ -0,0 +1,157 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/ext/census/resource.h" |
||||||
|
#include <grpc/census.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
#include <grpc/support/useful.h> |
||||||
|
#include <stdbool.h> |
||||||
|
#include <stdio.h> |
||||||
|
#include <stdlib.h> |
||||||
|
#include "src/core/ext/census/base_resources.h" |
||||||
|
#include "test/core/util/test_config.h" |
||||||
|
|
||||||
|
// Test all the functionality for dealing with Resources.
|
||||||
|
|
||||||
|
// Just startup and shutdown resources subsystem.
|
||||||
|
static void test_enable_disable() { |
||||||
|
initialize_resources(); |
||||||
|
shutdown_resources(); |
||||||
|
} |
||||||
|
|
||||||
|
// A blank/empty initialization should not work.
|
||||||
|
static void test_empty_definition() { |
||||||
|
initialize_resources(); |
||||||
|
int32_t rid = census_define_resource(NULL, 0); |
||||||
|
GPR_ASSERT(rid == -1); |
||||||
|
uint8_t buffer[50] = {0}; |
||||||
|
rid = census_define_resource(buffer, 50); |
||||||
|
GPR_ASSERT(rid == -1); |
||||||
|
shutdown_resources(); |
||||||
|
} |
||||||
|
|
||||||
|
// Given a file name, read raw proto and define the resource included within.
|
||||||
|
// Returns resource id from census_define_resource().
|
||||||
|
static int32_t define_resource_from_file(const char *file) { |
||||||
|
#define BUF_SIZE 512 |
||||||
|
uint8_t buffer[BUF_SIZE]; |
||||||
|
FILE *input = fopen(file, "rb"); |
||||||
|
GPR_ASSERT(input != NULL); |
||||||
|
size_t nbytes = fread(buffer, 1, BUF_SIZE, input); |
||||||
|
GPR_ASSERT(nbytes != 0 && nbytes < BUF_SIZE && feof(input) && !ferror(input)); |
||||||
|
int32_t rid = census_define_resource(buffer, nbytes); |
||||||
|
GPR_ASSERT(fclose(input) == 0); |
||||||
|
return rid; |
||||||
|
} |
||||||
|
|
||||||
|
// Test definition of a single resource, using a proto read from a file. The
|
||||||
|
// `succeed` parameter indicates whether we expect the definition to succeed or
|
||||||
|
// fail. `name` is used to check that the returned resource can be looked up by
|
||||||
|
// name.
|
||||||
|
static void test_define_single_resource(const char *file, const char *name, |
||||||
|
bool succeed) { |
||||||
|
gpr_log(GPR_INFO, "Test defining resource \"%s\"\n", name); |
||||||
|
initialize_resources(); |
||||||
|
int32_t rid = define_resource_from_file(file); |
||||||
|
if (succeed) { |
||||||
|
GPR_ASSERT(rid >= 0); |
||||||
|
int32_t rid2 = census_resource_id(name); |
||||||
|
GPR_ASSERT(rid == rid2); |
||||||
|
} else { |
||||||
|
GPR_ASSERT(rid < 0); |
||||||
|
} |
||||||
|
shutdown_resources(); |
||||||
|
} |
||||||
|
|
||||||
|
// Try deleting various resources (both those that exist and those that don't).
|
||||||
|
static void test_delete_resource() { |
||||||
|
initialize_resources(); |
||||||
|
// Try deleting resource before any are defined.
|
||||||
|
census_delete_resource(0); |
||||||
|
// Create and check a couple of resources.
|
||||||
|
int32_t rid1 = define_resource_from_file( |
||||||
|
"test/core/census/data/resource_minimal_good.pb"); |
||||||
|
int32_t rid2 = |
||||||
|
define_resource_from_file("test/core/census/data/resource_full.pb"); |
||||||
|
GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2); |
||||||
|
int32_t rid3 = census_resource_id("minimal_good"); |
||||||
|
int32_t rid4 = census_resource_id("full_resource"); |
||||||
|
GPR_ASSERT(rid1 == rid3 && rid2 == rid4); |
||||||
|
// Try deleting non-existant resources.
|
||||||
|
census_delete_resource(-1); |
||||||
|
census_delete_resource(rid1 + rid2 + 1); |
||||||
|
census_delete_resource(10000000); |
||||||
|
// Delete one of the previously defined resources and check for deletion.
|
||||||
|
census_delete_resource(rid1); |
||||||
|
rid3 = census_resource_id("minimal_good"); |
||||||
|
GPR_ASSERT(rid3 < 0); |
||||||
|
// Check that re-adding works.
|
||||||
|
rid1 = define_resource_from_file( |
||||||
|
"test/core/census/data/resource_minimal_good.pb"); |
||||||
|
GPR_ASSERT(rid1 >= 0); |
||||||
|
rid3 = census_resource_id("minimal_good"); |
||||||
|
GPR_ASSERT(rid1 == rid3); |
||||||
|
shutdown_resources(); |
||||||
|
} |
||||||
|
|
||||||
|
// Test define base resources.
|
||||||
|
static void test_base_resources() { |
||||||
|
initialize_resources(); |
||||||
|
define_base_resources(); |
||||||
|
int32_t rid1 = census_resource_id("client_rpc_latency"); |
||||||
|
int32_t rid2 = census_resource_id("server_rpc_latency"); |
||||||
|
GPR_ASSERT(rid1 >= 0 && rid2 >= 0 && rid1 != rid2); |
||||||
|
shutdown_resources(); |
||||||
|
} |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
grpc_test_init(argc, argv); |
||||||
|
test_enable_disable(); |
||||||
|
test_empty_definition(); |
||||||
|
test_define_single_resource("test/core/census/data/resource_minimal_good.pb", |
||||||
|
"minimal_good", true); |
||||||
|
test_define_single_resource("test/core/census/data/resource_full.pb", |
||||||
|
"full_resource", true); |
||||||
|
test_define_single_resource("test/core/census/data/resource_no_name.pb", |
||||||
|
"resource_no_name", false); |
||||||
|
test_define_single_resource("test/core/census/data/resource_no_numerator.pb", |
||||||
|
"resource_no_numerator", false); |
||||||
|
test_define_single_resource("test/core/census/data/resource_no_unit.pb", |
||||||
|
"resource_no_unit", false); |
||||||
|
test_define_single_resource("test/core/census/data/resource_empty_name.pb", |
||||||
|
"resource_empty_name", false); |
||||||
|
test_delete_resource(); |
||||||
|
test_base_resources(); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,199 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||||
|
<ItemGroup Label="ProjectConfigurations"> |
||||||
|
<ProjectConfiguration Include="Debug|Win32"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Debug|x64"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|Win32"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|x64"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
</ItemGroup> |
||||||
|
<PropertyGroup Label="Globals"> |
||||||
|
<ProjectGuid>{18CF99B5-3C61-EC3D-9509-3C95334C3B88}</ProjectGuid> |
||||||
|
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||||
|
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v100</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v110</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v120</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v140</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>true</UseDebugLibraries> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>false</UseDebugLibraries> |
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||||
|
<ImportGroup Label="ExtensionSettings"> |
||||||
|
</ImportGroup> |
||||||
|
<ImportGroup Label="PropertySheets"> |
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||||
|
</ImportGroup> |
||||||
|
<PropertyGroup Label="UserMacros" /> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||||
|
<TargetName>census_resource_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||||
|
<TargetName>census_resource_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\census\resource_test.c"> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc_test_util\grpc_test_util.vcxproj"> |
||||||
|
<Project>{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj"> |
||||||
|
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj"> |
||||||
|
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||||
|
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<None Include="packages.config" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||||
|
<ImportGroup Label="ExtensionTargets"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
</ImportGroup> |
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||||
|
<PropertyGroup> |
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||||
|
</PropertyGroup> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||||
|
</Target> |
||||||
|
</Project> |
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\census\resource_test.c"> |
||||||
|
<Filter>test\core\census</Filter> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Filter Include="test"> |
||||||
|
<UniqueIdentifier>{313aad4e-d33b-88c5-7d94-e04a4cb0c912}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core"> |
||||||
|
<UniqueIdentifier>{ff2d74ef-228a-1739-7fa7-7dccbec5b0c5}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core\census"> |
||||||
|
<UniqueIdentifier>{4f529bd9-396f-027c-bc49-f9a6bbc97c72}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
</ItemGroup> |
||||||
|
</Project> |
||||||
|
|
Loading…
Reference in new issue