Merge pull request #5186 from yang-g/inherit_from_grpc_library
Provide explicit API for user to set user agent string prefix
diff --git a/.yardopts b/.yardopts
new file mode 100644
index 0000000..3bc779d
--- /dev/null
+++ b/.yardopts
@@ -0,0 +1 @@
+src/ruby/**/*.rb
\ No newline at end of file
diff --git a/BUILD b/BUILD
index 72d5caa..495af2a 100644
--- a/BUILD
+++ b/BUILD
@@ -282,6 +282,7 @@
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/security/base64.c",
@@ -433,6 +434,7 @@
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/tracing.c",
@@ -584,6 +586,7 @@
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
"src/core/surface/init_unsecure.c",
"src/core/census/grpc_context.c",
@@ -715,6 +718,7 @@
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/tracing.c",
@@ -775,7 +779,6 @@
"src/cpp/client/create_channel_internal.h",
"src/cpp/common/create_auth_context.h",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/thread_pool_interface.h",
"src/cpp/client/secure_credentials.cc",
"src/cpp/common/auth_property_iterator.cc",
@@ -799,7 +802,6 @@
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
- "src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
@@ -906,7 +908,6 @@
"src/cpp/client/create_channel_internal.h",
"src/cpp/common/create_auth_context.h",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/thread_pool_interface.h",
"src/cpp/common/insecure_create_auth_context.cc",
"src/cpp/client/channel.cc",
@@ -925,7 +926,6 @@
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
- "src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
@@ -1395,6 +1395,7 @@
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/tracing.c",
@@ -1541,6 +1542,7 @@
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
],
includes = [
diff --git a/Makefile b/Makefile
index 3c215b3..cce7118 100644
--- a/Makefile
+++ b/Makefile
@@ -826,6 +826,7 @@
alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test
census_context_test: $(BINDIR)/$(CONFIG)/census_context_test
+census_log_test: $(BINDIR)/$(CONFIG)/census_log_test
channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test
chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test
chttp2_status_conversion_test: $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test
@@ -1134,6 +1135,7 @@
$(BINDIR)/$(CONFIG)/alpn_test \
$(BINDIR)/$(CONFIG)/bin_encoder_test \
$(BINDIR)/$(CONFIG)/census_context_test \
+ $(BINDIR)/$(CONFIG)/census_log_test \
$(BINDIR)/$(CONFIG)/channel_create_test \
$(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \
$(BINDIR)/$(CONFIG)/chttp2_status_conversion_test \
@@ -1369,6 +1371,8 @@
$(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 )
$(E) "[RUN] Testing census_context_test"
$(Q) $(BINDIR)/$(CONFIG)/census_context_test || ( echo test census_context_test failed ; exit 1 )
+ $(E) "[RUN] Testing census_log_test"
+ $(Q) $(BINDIR)/$(CONFIG)/census_log_test || ( echo test census_log_test failed ; exit 1 )
$(E) "[RUN] Testing channel_create_test"
$(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 )
$(E) "[RUN] Testing chttp2_hpack_encoder_test"
@@ -1597,6 +1601,8 @@
$(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 )
$(E) "[RUN] Testing mock_test"
$(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 )
+ $(E) "[RUN] Testing qps_openloop_test"
+ $(Q) $(BINDIR)/$(CONFIG)/qps_openloop_test || ( echo test qps_openloop_test failed ; exit 1 )
$(E) "[RUN] Testing qps_test"
$(Q) $(BINDIR)/$(CONFIG)/qps_test || ( echo test qps_test failed ; exit 1 )
$(E) "[RUN] Testing secure_auth_context_test"
@@ -2462,6 +2468,7 @@
src/core/transport/transport_op_string.c \
src/core/census/context.c \
src/core/census/initialize.c \
+ src/core/census/log.c \
src/core/census/operation.c \
src/core/census/placeholders.c \
src/core/census/tracing.c \
@@ -2746,6 +2753,7 @@
src/core/transport/transport_op_string.c \
src/core/census/context.c \
src/core/census/initialize.c \
+ src/core/census/log.c \
src/core/census/operation.c \
src/core/census/placeholders.c \
src/core/census/tracing.c \
@@ -2943,7 +2951,6 @@
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
- src/cpp/server/fixed_size_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
@@ -3223,7 +3230,6 @@
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
- src/cpp/server/fixed_size_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
@@ -5829,6 +5835,38 @@
endif
+CENSUS_LOG_TEST_SRC = \
+ test/core/census/log_test.c \
+
+CENSUS_LOG_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_LOG_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/census_log_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/census_log_test: $(CENSUS_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(CENSUS_LOG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/census_log_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/census/log_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_census_log_test: $(CENSUS_LOG_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(CENSUS_LOG_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
CHANNEL_CREATE_TEST_SRC = \
test/core/surface/channel_create_test.c \
diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in
index 3c46d61..072089a 100644
--- a/PYTHON-MANIFEST.in
+++ b/PYTHON-MANIFEST.in
@@ -7,6 +7,7 @@
include src/python/grpcio/commands.py
include src/python/grpcio/grpc_version.py
include src/python/grpcio/grpc_core_dependencies.py
+include src/python/grpcio/precompiled.py
include src/python/grpcio/support.py
include src/python/grpcio/README.rst
include requirements.txt
diff --git a/binding.gyp b/binding.gyp
index 82e36c4..6d7f75e 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -707,6 +707,7 @@
'src/core/transport/transport_op_string.c',
'src/core/census/context.c',
'src/core/census/initialize.c',
+ 'src/core/census/log.c',
'src/core/census/operation.c',
'src/core/census/placeholders.c',
'src/core/census/tracing.c',
diff --git a/build.yaml b/build.yaml
index 7f33ef3..dc7fce3 100644
--- a/build.yaml
+++ b/build.yaml
@@ -14,10 +14,12 @@
- include/grpc/census.h
headers:
- src/core/census/aggregation.h
+ - src/core/census/log.h
- src/core/census/rpc_metric_id.h
src:
- src/core/census/context.c
- src/core/census/initialize.c
+ - src/core/census/log.c
- src/core/census/operation.c
- src/core/census/placeholders.c
- src/core/census/tracing.c
@@ -172,7 +174,6 @@
- src/cpp/client/create_channel_internal.h
- src/cpp/common/create_auth_context.h
- src/cpp/server/dynamic_thread_pool.h
- - src/cpp/server/fixed_size_thread_pool.h
- src/cpp/server/thread_pool_interface.h
src:
- src/cpp/client/channel.cc
@@ -191,7 +192,6 @@
- src/cpp/server/async_generic_service.cc
- src/cpp/server/create_default_thread_pool.cc
- src/cpp/server/dynamic_thread_pool.cc
- - src/cpp/server/fixed_size_thread_pool.cc
- src/cpp/server/insecure_server_credentials.cc
- src/cpp/server/server.cc
- src/cpp/server/server_builder.cc
@@ -953,6 +953,16 @@
- grpc
- gpr_test_util
- gpr
+- name: census_log_test
+ build: test
+ language: c
+ src:
+ - test/core/census/log_test.c
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr_test_util
+ - gpr
- name: channel_create_test
build: test
language: c
@@ -2299,7 +2309,6 @@
- posix
- name: qps_openloop_test
build: test
- run: false
language: c++
src:
- test/cpp/qps/qps_openloop_test.cc
diff --git a/examples/node/README.md b/examples/node/README.md
index 09c56f7..7a2bc97 100644
--- a/examples/node/README.md
+++ b/examples/node/README.md
@@ -4,14 +4,10 @@
PREREQUISITES
-------------
-- `node`: This requires Node 0.10.x or greater.
-- [homebrew][] on Mac OS X. This simplifies the installation of the gRPC C core.
+- `node`: This requires Node 0.12.x or greater.
INSTALL
-------
- - [Install gRPC Node][]
-
- - Install this package's dependencies
```sh
$ cd examples/node
@@ -35,15 +31,9 @@
$ node ./greeter_client.js
```
-NOTE
-----
-This directory has a copy of `helloworld.proto` because it currently depends on
-some Protocol Buffer 2.0 syntax that is deprecated in Protocol Buffer 3.0.
-
TUTORIAL
--------
You can find a more detailed tutorial in [gRPC Basics: Node.js][]
-[homebrew]:http://brew.sh
[Install gRPC Node]:../../src/node
[gRPC Basics: Node.js]:http://www.grpc.io/docs/tutorials/basic/node.html
diff --git a/examples/node/greeter_client.js b/examples/node/greeter_client.js
index 9b4b0a7..ca57815 100644
--- a/examples/node/greeter_client.js
+++ b/examples/node/greeter_client.js
@@ -31,7 +31,7 @@
*
*/
-var PROTO_PATH = __dirname + '/helloworld.proto';
+var PROTO_PATH = __dirname + '/../protos/helloworld.proto';
var grpc = require('grpc');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
diff --git a/examples/node/greeter_server.js b/examples/node/greeter_server.js
index 2712b3d..47d9892 100644
--- a/examples/node/greeter_server.js
+++ b/examples/node/greeter_server.js
@@ -31,7 +31,7 @@
*
*/
-var PROTO_PATH = __dirname + '/helloworld.proto';
+var PROTO_PATH = __dirname + '/../protos/helloworld.proto';
var grpc = require('grpc');
var hello_proto = grpc.load(PROTO_PATH).helloworld;
diff --git a/examples/node/helloworld.proto b/examples/node/helloworld.proto
deleted file mode 100644
index a52c947..0000000
--- a/examples/node/helloworld.proto
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2015, 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.
-
-syntax = "proto3";
-
-option java_package = "ex.grpc";
-
-package helloworld;
-
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (HelloReply) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- optional string name = 1;
-}
-
-// The response message containing the greetings
-message HelloReply {
- optional string message = 1;
-}
diff --git a/examples/node/package.json b/examples/node/package.json
index 65c5789..00ba428 100644
--- a/examples/node/package.json
+++ b/examples/node/package.json
@@ -2,6 +2,6 @@
"name": "grpc-examples",
"version": "0.1.0",
"dependencies": {
- "grpc": "0.12.0"
+ "grpc": "0.13.0"
}
}
diff --git a/examples/node/route_guide/route_guide.proto b/examples/node/route_guide/route_guide.proto
deleted file mode 100644
index 38daa93..0000000
--- a/examples/node/route_guide/route_guide.proto
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2015, 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.
-
-syntax = "proto3";
-
-option java_package = "io.grpc.routeguide";
-
-package routeguide;
-
-// Interface exported by the server.
-service RouteGuide {
- // A simple RPC.
- //
- // Obtains the feature at a given position.
- rpc GetFeature(Point) returns (Feature) {}
-
- // A server-to-client streaming RPC.
- //
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-
- // A client-to-server streaming RPC.
- //
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-
- // A Bidirectional streaming RPC.
- //
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-}
-
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- optional int32 latitude = 1;
- optional int32 longitude = 2;
-}
-
-// A latitude-longitude rectangle, represented as two diagonally opposite
-// points "lo" and "hi".
-message Rectangle {
- // One corner of the rectangle.
- optional Point lo = 1;
-
- // The other corner of the rectangle.
- optional Point hi = 2;
-}
-
-// A feature names something at a given point.
-//
-// If a feature could not be named, the name is empty.
-message Feature {
- // The name of the feature.
- optional string name = 1;
-
- // The point where the feature is detected.
- optional Point location = 2;
-}
-
-// A RouteNote is a message sent while at a given point.
-message RouteNote {
- // The location from which the message is sent.
- optional Point location = 1;
-
- // The message to be sent.
- optional string message = 2;
-}
-
-// A RouteSummary is received in response to a RecordRoute rpc.
-//
-// It contains the number of individual points received, the number of
-// detected features, and the total distance covered as the cumulative sum of
-// the distance between each point.
-message RouteSummary {
- // The number of points received.
- optional int32 point_count = 1;
-
- // The number of known features passed while traversing the route.
- optional int32 feature_count = 2;
-
- // The distance covered in metres.
- optional int32 distance = 3;
-
- // The duration of the traversal in seconds.
- optional int32 elapsed_time = 4;
-}
diff --git a/examples/node/route_guide/route_guide_client.js b/examples/node/route_guide/route_guide_client.js
index e38a21f..6ff0279 100644
--- a/examples/node/route_guide/route_guide_client.js
+++ b/examples/node/route_guide/route_guide_client.js
@@ -31,15 +31,17 @@
*
*/
+var PROTO_PATH = __dirname + '/../../protos/route_guide.proto';
+
var async = require('async');
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
var _ = require('lodash');
var grpc = require('grpc');
-var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
+var routeguide = grpc.load(PROTO_PATH).routeguide;
var client = new routeguide.RouteGuide('localhost:50051',
- grpc.Credentials.createInsecure());
+ grpc.credentials.createInsecure());
var COORD_FACTOR = 1e7;
diff --git a/examples/node/route_guide/route_guide_server.js b/examples/node/route_guide/route_guide_server.js
index 06cf292..9fa9827 100644
--- a/examples/node/route_guide/route_guide_server.js
+++ b/examples/node/route_guide/route_guide_server.js
@@ -31,12 +31,14 @@
*
*/
+var PROTO_PATH = __dirname + '/../../protos/route_guide.proto';
+
var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
var _ = require('lodash');
var grpc = require('grpc');
-var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
+var routeguide = grpc.load(PROTO_PATH).routeguide;
var COORD_FACTOR = 1e7;
diff --git a/gRPC.podspec b/gRPC.podspec
index 5b4d24e..c930bbd 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -286,6 +286,7 @@
'src/core/transport/transport.h',
'src/core/transport/transport_impl.h',
'src/core/census/aggregation.h',
+ 'src/core/census/log.h',
'src/core/census/rpc_metric_id.h',
'include/grpc/grpc_security.h',
'include/grpc/impl/codegen/byte_buffer.h',
@@ -450,6 +451,7 @@
'src/core/transport/transport_op_string.c',
'src/core/census/context.c',
'src/core/census/initialize.c',
+ 'src/core/census/log.c',
'src/core/census/operation.c',
'src/core/census/placeholders.c',
'src/core/census/tracing.c'
@@ -592,6 +594,7 @@
'src/core/transport/transport.h',
'src/core/transport/transport_impl.h',
'src/core/census/aggregation.h',
+ 'src/core/census/log.h',
'src/core/census/rpc_metric_id.h'
ss.header_mappings_dir = '.'
diff --git a/grpc.def b/grpc.def
index d37e687..bd0bc85 100644
--- a/grpc.def
+++ b/grpc.def
@@ -99,6 +99,7 @@
grpc_auth_context_set_peer_identity_property_name
grpc_channel_credentials_release
grpc_google_default_credentials_create
+ grpc_set_ssl_roots_override_callback
grpc_ssl_credentials_create
grpc_call_credentials_release
grpc_composite_channel_credentials_create
diff --git a/grpc.gemspec b/grpc.gemspec
index 9e4683f..4a4a928 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -15,7 +15,7 @@
s.required_ruby_version = '>= 2.0.0'
- s.files = %w( Makefile )
+ s.files = %w( Makefile .yardopts )
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
@@ -31,7 +31,7 @@
s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
s.platform = Gem::Platform::RUBY
- s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.2'
+ s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.3'
s.add_dependency 'googleauth', '~> 0.5.1'
s.add_development_dependency 'bundler', '~> 1.9'
@@ -282,6 +282,7 @@
s.files += %w( src/core/transport/transport.h )
s.files += %w( src/core/transport/transport_impl.h )
s.files += %w( src/core/census/aggregation.h )
+ s.files += %w( src/core/census/log.h )
s.files += %w( src/core/census/rpc_metric_id.h )
s.files += %w( src/core/httpcli/httpcli_security_connector.c )
s.files += %w( src/core/security/base64.c )
@@ -433,6 +434,7 @@
s.files += %w( src/core/transport/transport_op_string.c )
s.files += %w( src/core/census/context.c )
s.files += %w( src/core/census/initialize.c )
+ s.files += %w( src/core/census/log.c )
s.files += %w( src/core/census/operation.c )
s.files += %w( src/core/census/placeholders.c )
s.files += %w( src/core/census/tracing.c )
diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h
index aff9c29..80eed06 100644
--- a/include/grpc++/create_channel.h
+++ b/include/grpc++/create_channel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
#include <memory>
+#include <grpc++/channel.h>
#include <grpc++/security/credentials.h>
#include <grpc++/support/channel_arguments.h>
#include <grpc++/support/config.h>
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 3de5cae..ef7205d 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -167,7 +167,8 @@
before any ssl credentials are created to have the desired side effect.
If GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is set to a valid path, the
callback will not be called. */
-void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb);
+GRPCAPI void grpc_set_ssl_roots_override_callback(
+ grpc_ssl_roots_override_callback cb);
/* Object that holds a private key / certificate chain pair in PEM format. */
typedef struct {
diff --git a/package.json b/package.json
index 1b79ecf..f814e3c 100644
--- a/package.json
+++ b/package.json
@@ -23,13 +23,12 @@
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
- "preinstall": "npm install node-pre-gyp",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
},
+ "bundledDependencies": ["node-pre-gyp"],
"dependencies": {
"lodash": "^3.9.3",
"nan": "^2.0.0",
- "node-pre-gyp": "^0.6.19",
"protobufjs": "^4.0.0"
},
"devDependencies": {
@@ -228,6 +227,7 @@
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/aggregation.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/security/base64.c",
@@ -379,6 +379,7 @@
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/tracing.c",
diff --git a/requirements.txt b/requirements.txt
index a1cc88c..e3208e6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@
cython>=0.23
coverage>=4.0
six>=1.10
+wheel>=0.29
diff --git a/setup.py b/setup.py
index 69e59e3..5b9f9b6 100644
--- a/setup.py
+++ b/setup.py
@@ -53,6 +53,7 @@
# Break import-style to ensure we can actually find our in-repo dependencies.
import commands
+import precompiled
import grpc_core_dependencies
import grpc_version
@@ -156,15 +157,14 @@
) + INSTALL_REQUIRES
COMMAND_CLASS = {
- 'install': commands.Install,
'doc': commands.SphinxDocumentation,
'build_proto_modules': commands.BuildProtoModules,
'build_project_metadata': commands.BuildProjectMetadata,
'build_py': commands.BuildPy,
'build_ext': commands.BuildExt,
+ 'build_tagged_ext': precompiled.BuildTaggedExt,
'gather': commands.Gather,
'run_interop': commands.RunInterop,
- 'bdist_egg_grpc_custom': commands.BdistEggCustomName,
}
# Ensure that package data is copied over before any commands have been run:
@@ -202,10 +202,13 @@
TEST_RUNNER = 'tests:Runner'
PACKAGE_DATA = {
+ # Binaries that may or may not be present in the final installation, but are
+ # mentioned here for completeness.
'grpc._cython': [
'_credentials/roots.pem',
'_windows/grpc_c.32.python',
'_windows/grpc_c.64.python',
+ 'cygrpc.so',
],
}
if INSTALL_TESTS:
@@ -215,19 +218,23 @@
PACKAGES = setuptools.find_packages(
PYTHON_STEM, exclude=['tests', 'tests.*'])
-setuptools.setup(
- name='grpcio',
- version=grpc_version.VERSION,
- license=LICENSE,
- ext_modules=CYTHON_EXTENSION_MODULES,
- packages=list(PACKAGES),
- package_dir=PACKAGE_DIRECTORIES,
- package_data=PACKAGE_DATA,
- install_requires=INSTALL_REQUIRES,
- setup_requires=SETUP_REQUIRES,
- cmdclass=COMMAND_CLASS,
- tests_require=TESTS_REQUIRE,
- test_suite=TEST_SUITE,
- test_loader=TEST_LOADER,
- test_runner=TEST_RUNNER,
-)
+setup_arguments = {
+ 'name': 'grpcio',
+ 'version': grpc_version.VERSION,
+ 'license': LICENSE,
+ 'ext_modules': CYTHON_EXTENSION_MODULES,
+ 'packages': list(PACKAGES),
+ 'package_dir': PACKAGE_DIRECTORIES,
+ 'package_data': PACKAGE_DATA,
+ 'install_requires': INSTALL_REQUIRES,
+ 'setup_requires': SETUP_REQUIRES,
+ 'cmdclass': COMMAND_CLASS,
+ 'tests_require': TESTS_REQUIRE,
+ 'test_suite': TEST_SUITE,
+ 'test_loader': TEST_LOADER,
+ 'test_runner': TEST_RUNNER,
+}
+
+precompiled.update_setup_arguments(setup_arguments)
+
+setuptools.setup(**setup_arguments)
diff --git a/src/core/census/log.c b/src/core/census/log.c
new file mode 100644
index 0000000..91b2694
--- /dev/null
+++ b/src/core/census/log.c
@@ -0,0 +1,600 @@
+/*
+ *
+ * Copyright 2015-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.
+ *
+ */
+
+// Implements an efficient in-memory log, optimized for multiple writers and
+// a single reader. Available log space is divided up in blocks of
+// CENSUS_LOG_2_MAX_RECORD_SIZE bytes. A block can be in one of the following
+// three data structures:
+// - Free blocks (free_block_list)
+// - Blocks with unread data (dirty_block_list)
+// - Blocks currently attached to cores (core_local_blocks[])
+//
+// census_log_start_write() moves a block from core_local_blocks[] to the end of
+// dirty_block_list when block:
+// - is out-of-space OR
+// - has an incomplete record (an incomplete record occurs when a thread calls
+// census_log_start_write() and is context-switched before calling
+// census_log_end_write()
+// So, blocks in dirty_block_list are ordered, from oldest to newest, by the
+// time when block is detached from the core.
+//
+// census_log_read_next() first iterates over dirty_block_list and then
+// core_local_blocks[]. It moves completely read blocks from dirty_block_list
+// to free_block_list. Blocks in core_local_blocks[] are not freed, even when
+// completely read.
+//
+// If the log is configured to discard old records and free_block_list is empty,
+// census_log_start_write() iterates over dirty_block_list to allocate a
+// new block. It moves the oldest available block (no pending read/write) to
+// core_local_blocks[].
+//
+// core_local_block_struct is used to implement a map from core id to the block
+// associated with that core. This mapping is advisory. It is possible that the
+// block returned by this mapping is no longer associated with that core. This
+// mapping is updated, lazily, by census_log_start_write().
+//
+// Locking in block struct:
+//
+// Exclusive g_log.lock must be held before calling any functions operating on
+// block structs except census_log_start_write() and census_log_end_write().
+//
+// Writes to a block are serialized via writer_lock. census_log_start_write()
+// acquires this lock and census_log_end_write() releases it. On failure to
+// acquire the lock, writer allocates a new block for the current core and
+// updates core_local_block accordingly.
+//
+// Simultaneous read and write access is allowed. Readers can safely read up to
+// committed bytes (bytes_committed).
+//
+// reader_lock protects the block, currently being read, from getting recycled.
+// start_read() acquires reader_lock and end_read() releases the lock.
+//
+// Read/write access to a block is disabled via try_disable_access(). It returns
+// with both writer_lock and reader_lock held. These locks are subsequently
+// released by enable_access() to enable access to the block.
+//
+// A note on naming: Most function/struct names are prepended by cl_
+// (shorthand for census_log). Further, functions that manipulate structures
+// include the name of the structure, which will be passed as the first
+// argument. E.g. cl_block_initialize() will initialize a cl_block.
+
+#include "src/core/census/log.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/atm.h>
+#include <grpc/support/cpu.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/useful.h>
+#include <stdbool.h>
+#include <string.h>
+
+// End of platform specific code
+
+typedef struct census_log_block_list_struct {
+ struct census_log_block_list_struct* next;
+ struct census_log_block_list_struct* prev;
+ struct census_log_block* block;
+} cl_block_list_struct;
+
+typedef struct census_log_block {
+ // Pointer to underlying buffer.
+ char* buffer;
+ gpr_atm writer_lock;
+ gpr_atm reader_lock;
+ // Keeps completely written bytes. Declared atomic because accessed
+ // simultaneously by reader and writer.
+ gpr_atm bytes_committed;
+ // Bytes already read.
+ size_t bytes_read;
+ // Links for list.
+ cl_block_list_struct link;
+// We want this structure to be cacheline aligned. We assume the following
+// sizes for the various parts on 32/64bit systems:
+// type 32b size 64b size
+// char* 4 8
+// 3x gpr_atm 12 24
+// size_t 4 8
+// cl_block_list_struct 12 24
+// TOTAL 32 64
+//
+// Depending on the size of our cacheline and the architecture, we
+// selectively add char buffering to this structure. The size is checked
+// via assert in census_log_initialize().
+#if defined(GPR_ARCH_64)
+#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 64)
+#else
+#if defined(GPR_ARCH_32)
+#define CL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 32)
+#else
+#error "Unknown architecture"
+#endif
+#endif
+#if CL_BLOCK_PAD_SIZE > 0
+ char padding[CL_BLOCK_PAD_SIZE];
+#endif
+} cl_block;
+
+// A list of cl_blocks, doubly-linked through cl_block::link.
+typedef struct census_log_block_list {
+ int32_t count; // Number of items in list.
+ cl_block_list_struct ht; // head/tail of linked list.
+} cl_block_list;
+
+// Cacheline aligned block pointers to avoid false sharing. Block pointer must
+// be initialized via set_block(), before calling other functions
+typedef struct census_log_core_local_block {
+ gpr_atm block;
+// Ensure cachline alignment: we assume sizeof(gpr_atm) == 4 or 8
+#if defined(GPR_ARCH_64)
+#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 8)
+#else
+#if defined(GPR_ARCH_32)
+#define CL_CORE_LOCAL_BLOCK_PAD_SIZE (GPR_CACHELINE_SIZE - 4)
+#else
+#error "Unknown architecture"
+#endif
+#endif
+#if CL_CORE_LOCAL_BLOCK_PAD_SIZE > 0
+ char padding[CL_CORE_LOCAL_BLOCK_PAD_SIZE];
+#endif
+} cl_core_local_block;
+
+struct census_log {
+ int discard_old_records;
+ // Number of cores (aka hardware-contexts)
+ unsigned num_cores;
+ // number of CENSUS_LOG_2_MAX_RECORD_SIZE blocks in log
+ uint32_t num_blocks;
+ cl_block* blocks; // Block metadata.
+ cl_core_local_block* core_local_blocks; // Keeps core to block mappings.
+ gpr_mu lock;
+ int initialized; // has log been initialized?
+ // Keeps the state of the reader iterator. A value of 0 indicates that
+ // iterator has reached the end. census_log_init_reader() resets the value
+ // to num_core to restart iteration.
+ uint32_t read_iterator_state;
+ // Points to the block being read. If non-NULL, the block is locked for
+ // reading(block_being_read_->reader_lock is held).
+ cl_block* block_being_read;
+ char* buffer;
+ cl_block_list free_block_list;
+ cl_block_list dirty_block_list;
+ gpr_atm out_of_space_count;
+};
+
+// Single internal log.
+static struct census_log g_log;
+
+// Functions that operate on an atomic memory location used as a lock.
+
+// Returns non-zero if lock is acquired.
+static int cl_try_lock(gpr_atm* lock) { return gpr_atm_acq_cas(lock, 0, 1); }
+
+static void cl_unlock(gpr_atm* lock) { gpr_atm_rel_store(lock, 0); }
+
+// Functions that operate on cl_core_local_block's.
+
+static void cl_core_local_block_set_block(cl_core_local_block* clb,
+ cl_block* block) {
+ gpr_atm_rel_store(&clb->block, (gpr_atm)block);
+}
+
+static cl_block* cl_core_local_block_get_block(cl_core_local_block* clb) {
+ return (cl_block*)gpr_atm_acq_load(&clb->block);
+}
+
+// Functions that operate on cl_block_list_struct's.
+
+static void cl_block_list_struct_initialize(cl_block_list_struct* bls,
+ cl_block* block) {
+ bls->next = bls->prev = bls;
+ bls->block = block;
+}
+
+// Functions that operate on cl_block_list's.
+
+static void cl_block_list_initialize(cl_block_list* list) {
+ list->count = 0;
+ cl_block_list_struct_initialize(&list->ht, NULL);
+}
+
+// Returns head of *this, or NULL if empty.
+static cl_block* cl_block_list_head(cl_block_list* list) {
+ return list->ht.next->block;
+}
+
+// Insert element *e after *pos.
+static void cl_block_list_insert(cl_block_list* list, cl_block_list_struct* pos,
+ cl_block_list_struct* e) {
+ list->count++;
+ e->next = pos->next;
+ e->prev = pos;
+ e->next->prev = e;
+ e->prev->next = e;
+}
+
+// Insert block at the head of the list
+static void cl_block_list_insert_at_head(cl_block_list* list, cl_block* block) {
+ cl_block_list_insert(list, &list->ht, &block->link);
+}
+
+// Insert block at the tail of the list.
+static void cl_block_list_insert_at_tail(cl_block_list* list, cl_block* block) {
+ cl_block_list_insert(list, list->ht.prev, &block->link);
+}
+
+// Removes block *b. Requires *b be in the list.
+static void cl_block_list_remove(cl_block_list* list, cl_block* b) {
+ list->count--;
+ b->link.next->prev = b->link.prev;
+ b->link.prev->next = b->link.next;
+}
+
+// Functions that operate on cl_block's
+
+static void cl_block_initialize(cl_block* block, char* buffer) {
+ block->buffer = buffer;
+ gpr_atm_rel_store(&block->writer_lock, 0);
+ gpr_atm_rel_store(&block->reader_lock, 0);
+ gpr_atm_rel_store(&block->bytes_committed, 0);
+ block->bytes_read = 0;
+ cl_block_list_struct_initialize(&block->link, block);
+}
+
+// Guards against exposing partially written buffer to the reader.
+static void cl_block_set_bytes_committed(cl_block* block,
+ size_t bytes_committed) {
+ gpr_atm_rel_store(&block->bytes_committed, (gpr_atm)bytes_committed);
+}
+
+static size_t cl_block_get_bytes_committed(cl_block* block) {
+ return (size_t)gpr_atm_acq_load(&block->bytes_committed);
+}
+
+// Tries to disable future read/write access to this block. Succeeds if:
+// - no in-progress write AND
+// - no in-progress read AND
+// - 'discard_data' set to true OR no unread data
+// On success, clears the block state and returns with writer_lock_ and
+// reader_lock_ held. These locks are released by a subsequent
+// cl_block_access_enable() call.
+static bool cl_block_try_disable_access(cl_block* block, int discard_data) {
+ if (!cl_try_lock(&block->writer_lock)) {
+ return false;
+ }
+ if (!cl_try_lock(&block->reader_lock)) {
+ cl_unlock(&block->writer_lock);
+ return false;
+ }
+ if (!discard_data &&
+ (block->bytes_read != cl_block_get_bytes_committed(block))) {
+ cl_unlock(&block->reader_lock);
+ cl_unlock(&block->writer_lock);
+ return false;
+ }
+ cl_block_set_bytes_committed(block, 0);
+ block->bytes_read = 0;
+ return true;
+}
+
+static void cl_block_enable_access(cl_block* block) {
+ cl_unlock(&block->reader_lock);
+ cl_unlock(&block->writer_lock);
+}
+
+// Returns with writer_lock held.
+static void* cl_block_start_write(cl_block* block, size_t size) {
+ if (!cl_try_lock(&block->writer_lock)) {
+ return NULL;
+ }
+ size_t bytes_committed = cl_block_get_bytes_committed(block);
+ if (bytes_committed + size > CENSUS_LOG_MAX_RECORD_SIZE) {
+ cl_unlock(&block->writer_lock);
+ return NULL;
+ }
+ return block->buffer + bytes_committed;
+}
+
+// Releases writer_lock and increments committed bytes by 'bytes_written'.
+// 'bytes_written' must be <= 'size' specified in the corresponding
+// StartWrite() call. This function is thread-safe.
+static void cl_block_end_write(cl_block* block, size_t bytes_written) {
+ cl_block_set_bytes_committed(
+ block, cl_block_get_bytes_committed(block) + bytes_written);
+ cl_unlock(&block->writer_lock);
+}
+
+// Returns a pointer to the first unread byte in buffer. The number of bytes
+// available are returned in 'bytes_available'. Acquires reader lock that is
+// released by a subsequent cl_block_end_read() call. Returns NULL if:
+// - read in progress
+// - no data available
+static void* cl_block_start_read(cl_block* block, size_t* bytes_available) {
+ if (!cl_try_lock(&block->reader_lock)) {
+ return NULL;
+ }
+ // bytes_committed may change from under us. Use bytes_available to update
+ // bytes_read below.
+ size_t bytes_committed = cl_block_get_bytes_committed(block);
+ GPR_ASSERT(bytes_committed >= block->bytes_read);
+ *bytes_available = bytes_committed - block->bytes_read;
+ if (*bytes_available == 0) {
+ cl_unlock(&block->reader_lock);
+ return NULL;
+ }
+ void* record = block->buffer + block->bytes_read;
+ block->bytes_read += *bytes_available;
+ return record;
+}
+
+static void cl_block_end_read(cl_block* block) {
+ cl_unlock(&block->reader_lock);
+}
+
+// Internal functions operating on g_log
+
+// Allocates a new free block (or recycles an available dirty block if log is
+// configured to discard old records). Returns NULL if out-of-space.
+static cl_block* cl_allocate_block(void) {
+ cl_block* block = cl_block_list_head(&g_log.free_block_list);
+ if (block != NULL) {
+ cl_block_list_remove(&g_log.free_block_list, block);
+ return block;
+ }
+ if (!g_log.discard_old_records) {
+ // No free block and log is configured to keep old records.
+ return NULL;
+ }
+ // Recycle dirty block. Start from the oldest.
+ for (block = cl_block_list_head(&g_log.dirty_block_list); block != NULL;
+ block = block->link.next->block) {
+ if (cl_block_try_disable_access(block, 1 /* discard data */)) {
+ cl_block_list_remove(&g_log.dirty_block_list, block);
+ return block;
+ }
+ }
+ return NULL;
+}
+
+// Allocates a new block and updates core id => block mapping. 'old_block'
+// points to the block that the caller thinks is attached to
+// 'core_id'. 'old_block' may be NULL. Returns true if:
+// - allocated a new block OR
+// - 'core_id' => 'old_block' mapping changed (another thread allocated a
+// block before lock was acquired).
+static bool cl_allocate_core_local_block(uint32_t core_id,
+ cl_block* old_block) {
+ // Now that we have the lock, check if core-local mapping has changed.
+ cl_core_local_block* core_local_block = &g_log.core_local_blocks[core_id];
+ cl_block* block = cl_core_local_block_get_block(core_local_block);
+ if ((block != NULL) && (block != old_block)) {
+ return true;
+ }
+ if (block != NULL) {
+ cl_core_local_block_set_block(core_local_block, NULL);
+ cl_block_list_insert_at_tail(&g_log.dirty_block_list, block);
+ }
+ block = cl_allocate_block();
+ if (block == NULL) {
+ return false;
+ }
+ cl_core_local_block_set_block(core_local_block, block);
+ cl_block_enable_access(block);
+ return true;
+}
+
+static cl_block* cl_get_block(void* record) {
+ uintptr_t p = (uintptr_t)((char*)record - g_log.buffer);
+ uintptr_t index = p >> CENSUS_LOG_2_MAX_RECORD_SIZE;
+ return &g_log.blocks[index];
+}
+
+// Gets the next block to read and tries to free 'prev' block (if not NULL).
+// Returns NULL if reached the end.
+static cl_block* cl_next_block_to_read(cl_block* prev) {
+ cl_block* block = NULL;
+ if (g_log.read_iterator_state == g_log.num_cores) {
+ // We are traversing dirty list; find the next dirty block.
+ if (prev != NULL) {
+ // Try to free the previous block if there is no unread data. This
+ // block
+ // may have unread data if previously incomplete record completed
+ // between
+ // read_next() calls.
+ block = prev->link.next->block;
+ if (cl_block_try_disable_access(prev, 0 /* do not discard data */)) {
+ cl_block_list_remove(&g_log.dirty_block_list, prev);
+ cl_block_list_insert_at_head(&g_log.free_block_list, prev);
+ }
+ } else {
+ block = cl_block_list_head(&g_log.dirty_block_list);
+ }
+ if (block != NULL) {
+ return block;
+ }
+ // We are done with the dirty list; moving on to core-local blocks.
+ }
+ while (g_log.read_iterator_state > 0) {
+ g_log.read_iterator_state--;
+ block = cl_core_local_block_get_block(
+ &g_log.core_local_blocks[g_log.read_iterator_state]);
+ if (block != NULL) {
+ return block;
+ }
+ }
+ return NULL;
+}
+
+#define CL_LOG_2_MB 20 // 2^20 = 1MB
+
+// External functions: primary stats_log interface
+void census_log_initialize(size_t size_in_mb, int discard_old_records) {
+ // Check cacheline alignment.
+ GPR_ASSERT(sizeof(cl_block) % GPR_CACHELINE_SIZE == 0);
+ GPR_ASSERT(sizeof(cl_core_local_block) % GPR_CACHELINE_SIZE == 0);
+ GPR_ASSERT(!g_log.initialized);
+ g_log.discard_old_records = discard_old_records;
+ g_log.num_cores = gpr_cpu_num_cores();
+ // Ensure that we will not get any overflow in calaculating num_blocks
+ GPR_ASSERT(CL_LOG_2_MB >= CENSUS_LOG_2_MAX_RECORD_SIZE);
+ GPR_ASSERT(size_in_mb < 1000);
+ // Ensure at least 2x as many blocks as there are cores.
+ g_log.num_blocks =
+ (uint32_t)GPR_MAX(2 * g_log.num_cores, (size_in_mb << CL_LOG_2_MB) >>
+ CENSUS_LOG_2_MAX_RECORD_SIZE);
+ gpr_mu_init(&g_log.lock);
+ g_log.read_iterator_state = 0;
+ g_log.block_being_read = NULL;
+ g_log.core_local_blocks = (cl_core_local_block*)gpr_malloc_aligned(
+ g_log.num_cores * sizeof(cl_core_local_block), GPR_CACHELINE_SIZE_LOG);
+ memset(g_log.core_local_blocks, 0,
+ g_log.num_cores * sizeof(cl_core_local_block));
+ g_log.blocks = (cl_block*)gpr_malloc_aligned(
+ g_log.num_blocks * sizeof(cl_block), GPR_CACHELINE_SIZE_LOG);
+ memset(g_log.blocks, 0, g_log.num_blocks * sizeof(cl_block));
+ g_log.buffer = gpr_malloc(g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
+ memset(g_log.buffer, 0, g_log.num_blocks * CENSUS_LOG_MAX_RECORD_SIZE);
+ cl_block_list_initialize(&g_log.free_block_list);
+ cl_block_list_initialize(&g_log.dirty_block_list);
+ for (uint32_t i = 0; i < g_log.num_blocks; ++i) {
+ cl_block* block = g_log.blocks + i;
+ cl_block_initialize(block, g_log.buffer + (CENSUS_LOG_MAX_RECORD_SIZE * i));
+ cl_block_try_disable_access(block, 1 /* discard data */);
+ cl_block_list_insert_at_tail(&g_log.free_block_list, block);
+ }
+ gpr_atm_rel_store(&g_log.out_of_space_count, 0);
+ g_log.initialized = 1;
+}
+
+void census_log_shutdown(void) {
+ GPR_ASSERT(g_log.initialized);
+ gpr_mu_destroy(&g_log.lock);
+ gpr_free_aligned(g_log.core_local_blocks);
+ g_log.core_local_blocks = NULL;
+ gpr_free_aligned(g_log.blocks);
+ g_log.blocks = NULL;
+ gpr_free(g_log.buffer);
+ g_log.buffer = NULL;
+ g_log.initialized = 0;
+}
+
+void* census_log_start_write(size_t size) {
+ // Used to bound number of times block allocation is attempted.
+ GPR_ASSERT(size > 0);
+ GPR_ASSERT(g_log.initialized);
+ if (size > CENSUS_LOG_MAX_RECORD_SIZE) {
+ return NULL;
+ }
+ uint32_t attempts_remaining = g_log.num_blocks;
+ uint32_t core_id = gpr_cpu_current_cpu();
+ do {
+ void* record = NULL;
+ cl_block* block =
+ cl_core_local_block_get_block(&g_log.core_local_blocks[core_id]);
+ if (block && (record = cl_block_start_write(block, size))) {
+ return record;
+ }
+ // Need to allocate a new block. We are here if:
+ // - No block associated with the core OR
+ // - Write in-progress on the block OR
+ // - block is out of space
+ gpr_mu_lock(&g_log.lock);
+ bool allocated = cl_allocate_core_local_block(core_id, block);
+ gpr_mu_unlock(&g_log.lock);
+ if (!allocated) {
+ gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
+ return NULL;
+ }
+ } while (attempts_remaining--);
+ // Give up.
+ gpr_atm_no_barrier_fetch_add(&g_log.out_of_space_count, 1);
+ return NULL;
+}
+
+void census_log_end_write(void* record, size_t bytes_written) {
+ GPR_ASSERT(g_log.initialized);
+ cl_block_end_write(cl_get_block(record), bytes_written);
+}
+
+void census_log_init_reader(void) {
+ GPR_ASSERT(g_log.initialized);
+ gpr_mu_lock(&g_log.lock);
+ // If a block is locked for reading unlock it.
+ if (g_log.block_being_read != NULL) {
+ cl_block_end_read(g_log.block_being_read);
+ g_log.block_being_read = NULL;
+ }
+ g_log.read_iterator_state = g_log.num_cores;
+ gpr_mu_unlock(&g_log.lock);
+}
+
+const void* census_log_read_next(size_t* bytes_available) {
+ GPR_ASSERT(g_log.initialized);
+ gpr_mu_lock(&g_log.lock);
+ if (g_log.block_being_read != NULL) {
+ cl_block_end_read(g_log.block_being_read);
+ }
+ do {
+ g_log.block_being_read = cl_next_block_to_read(g_log.block_being_read);
+ if (g_log.block_being_read != NULL) {
+ void* record =
+ cl_block_start_read(g_log.block_being_read, bytes_available);
+ if (record != NULL) {
+ gpr_mu_unlock(&g_log.lock);
+ return record;
+ }
+ }
+ } while (g_log.block_being_read != NULL);
+ gpr_mu_unlock(&g_log.lock);
+ return NULL;
+}
+
+size_t census_log_remaining_space(void) {
+ GPR_ASSERT(g_log.initialized);
+ size_t space = 0;
+ gpr_mu_lock(&g_log.lock);
+ if (g_log.discard_old_records) {
+ // Remaining space is not meaningful; just return the entire log space.
+ space = g_log.num_blocks << CENSUS_LOG_2_MAX_RECORD_SIZE;
+ } else {
+ GPR_ASSERT(g_log.free_block_list.count >= 0);
+ space = (size_t)g_log.free_block_list.count * CENSUS_LOG_MAX_RECORD_SIZE;
+ }
+ gpr_mu_unlock(&g_log.lock);
+ return space;
+}
+
+int64_t census_log_out_of_space_count(void) {
+ GPR_ASSERT(g_log.initialized);
+ return gpr_atm_acq_load(&g_log.out_of_space_count);
+}
diff --git a/src/core/census/log.h b/src/core/census/log.h
new file mode 100644
index 0000000..05daea0
--- /dev/null
+++ b/src/core/census/log.h
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2015-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_INTERNAL_CORE_CENSUS_LOG_H
+#define GRPC_INTERNAL_CORE_CENSUS_LOG_H
+
+#include <grpc/support/port_platform.h>
+#include <stddef.h>
+
+/* Maximum record size, in bytes. */
+#define CENSUS_LOG_2_MAX_RECORD_SIZE 14 /* 2^14 = 16KB */
+#define CENSUS_LOG_MAX_RECORD_SIZE (1 << CENSUS_LOG_2_MAX_RECORD_SIZE)
+
+/* Initialize the statistics logging subsystem with the given log size. A log
+ size of 0 will result in the smallest possible log for the platform
+ (approximately CENSUS_LOG_MAX_RECORD_SIZE * gpr_cpu_num_cores()). If
+ discard_old_records is non-zero, then new records will displace older ones
+ when the log is full. This function must be called before any other
+ census_log functions.
+*/
+void census_log_initialize(size_t size_in_mb, int discard_old_records);
+
+/* Shutdown the logging subsystem. Caller must ensure that:
+ - no in progress or future call to any census_log functions
+ - no incomplete records
+*/
+void census_log_shutdown(void);
+
+/* Allocates and returns a 'size' bytes record and marks it in use. A
+ subsequent census_log_end_write() marks the record complete. The
+ 'bytes_written' census_log_end_write() argument must be <=
+ 'size'. Returns NULL if out-of-space AND:
+ - log is configured to keep old records OR
+ - all blocks are pinned by incomplete records.
+*/
+void* census_log_start_write(size_t size);
+
+void census_log_end_write(void* record, size_t bytes_written);
+
+void census_log_init_reader(void);
+
+/* census_log_read_next() iterates over blocks with data and for each block
+ returns a pointer to the first unread byte. The number of bytes that can be
+ read are returned in 'bytes_available'. Reader is expected to read all
+ available data. Reading the data consumes it i.e. it cannot be read again.
+ census_log_read_next() returns NULL if the end is reached i.e last block
+ is read. census_log_init_reader() starts the iteration or aborts the
+ current iteration.
+*/
+const void* census_log_read_next(size_t* bytes_available);
+
+/* Returns estimated remaining space across all blocks, in bytes. If log is
+ configured to discard old records, returns total log space. Otherwise,
+ returns space available in empty blocks (partially filled blocks are
+ treated as full).
+*/
+size_t census_log_remaining_space(void);
+
+/* Returns the number of times gprc_stats_log_start_write() failed due to
+ out-of-space. */
+int64_t census_log_out_of_space_count(void);
+
+#endif /* GRPC_INTERNAL_CORE_CENSUS_LOG_H */
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c
index fe006c6..ef548cf 100644
--- a/src/core/iomgr/udp_server.c
+++ b/src/core/iomgr/udp_server.c
@@ -137,7 +137,7 @@
}
static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
- grpc_exec_ctx_enqueue(exec_ctx, s->shutdown_complete, 1);
+ grpc_exec_ctx_enqueue(exec_ctx, s->shutdown_complete, 1, NULL);
gpr_mu_destroy(&s->mu);
gpr_cv_destroy(&s->cv);
@@ -146,7 +146,8 @@
gpr_free(s);
}
-static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server, int success) {
+static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
+ bool success) {
grpc_udp_server *s = server;
gpr_mu_lock(&s->mu);
s->destroyed_ports++;
@@ -263,10 +264,10 @@
}
/* event manager callback when reads are ready */
-static void on_read(grpc_exec_ctx *exec_ctx, void *arg, int success) {
+static void on_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
server_port *sp = arg;
- if (success == 0) {
+ if (!success) {
gpr_mu_lock(&sp->server->mu);
if (0 == --sp->server->active_ports) {
gpr_mu_unlock(&sp->server->mu);
diff --git a/src/core/surface/alarm.c b/src/core/surface/alarm.c
index d753023..fb496f6 100644
--- a/src/core/surface/alarm.c
+++ b/src/core/surface/alarm.c
@@ -63,9 +63,9 @@
alarm->cq = cq;
alarm->tag = tag;
+ grpc_cq_begin_op(cq, tag);
grpc_timer_init(&exec_ctx, &alarm->alarm, deadline, alarm_cb, alarm,
gpr_now(GPR_CLOCK_MONOTONIC));
- grpc_cq_begin_op(cq, tag);
grpc_exec_ctx_finish(&exec_ctx);
return alarm;
}
diff --git a/src/cpp/server/fixed_size_thread_pool.cc b/src/cpp/server/fixed_size_thread_pool.cc
deleted file mode 100644
index 2bdc44b..0000000
--- a/src/cpp/server/fixed_size_thread_pool.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Copyright 2015, 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 <grpc++/impl/sync.h>
-#include <grpc++/impl/thd.h>
-#include "src/cpp/server/fixed_size_thread_pool.h"
-
-namespace grpc {
-
-void FixedSizeThreadPool::ThreadFunc() {
- for (;;) {
- // Wait until work is available or we are shutting down.
- grpc::unique_lock<grpc::mutex> lock(mu_);
- if (!shutdown_ && callbacks_.empty()) {
- cv_.wait(lock);
- }
- // Drain callbacks before considering shutdown to ensure all work
- // gets completed.
- if (!callbacks_.empty()) {
- auto cb = callbacks_.front();
- callbacks_.pop();
- lock.unlock();
- cb();
- } else if (shutdown_) {
- return;
- }
- }
-}
-
-FixedSizeThreadPool::FixedSizeThreadPool(int num_threads) : shutdown_(false) {
- for (int i = 0; i < num_threads; i++) {
- threads_.push_back(
- new grpc::thread(&FixedSizeThreadPool::ThreadFunc, this));
- }
-}
-
-FixedSizeThreadPool::~FixedSizeThreadPool() {
- {
- grpc::lock_guard<grpc::mutex> lock(mu_);
- shutdown_ = true;
- cv_.notify_all();
- }
- for (auto t = threads_.begin(); t != threads_.end(); t++) {
- (*t)->join();
- delete *t;
- }
-}
-
-void FixedSizeThreadPool::Add(const std::function<void()>& callback) {
- grpc::lock_guard<grpc::mutex> lock(mu_);
- callbacks_.push(callback);
- cv_.notify_one();
-}
-
-} // namespace grpc
diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc
index a8c188e..c54cf64 100644
--- a/src/cpp/server/server_builder.cc
+++ b/src/cpp/server/server_builder.cc
@@ -38,7 +38,6 @@
#include <grpc++/impl/service_type.h>
#include <grpc++/server.h>
#include "src/cpp/server/thread_pool_interface.h"
-#include "src/cpp/server/fixed_size_thread_pool.h"
namespace grpc {
diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj
index 9587503..8d7d2ca 100644
--- a/src/csharp/Grpc.Core/Grpc.Core.csproj
+++ b/src/csharp/Grpc.Core/Grpc.Core.csproj
@@ -59,6 +59,7 @@
<Compile Include="IServerStreamWriter.cs" />
<Compile Include="IAsyncStreamWriter.cs" />
<Compile Include="IAsyncStreamReader.cs" />
+ <Compile Include="Logging\NullLogger.cs" />
<Compile Include="ServerPort.cs" />
<Compile Include="Version.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
diff --git a/src/csharp/Grpc.Core/Logging/NullLogger.cs b/src/csharp/Grpc.Core/Logging/NullLogger.cs
new file mode 100644
index 0000000..58679a0
--- /dev/null
+++ b/src/csharp/Grpc.Core/Logging/NullLogger.cs
@@ -0,0 +1,122 @@
+#region Copyright notice and license
+
+// 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.
+
+#endregion
+
+using System;
+
+namespace Grpc.Core.Logging
+{
+ /// <summary>
+ /// Logger which doesn't log any information anywhere.
+ /// </summary>
+ public sealed class NullLogger : ILogger
+ {
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Debug(string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Debug(string format, params object[] formatArgs)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Error(string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Error(Exception exception, string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Error(string format, params object[] formatArgs)
+ {
+ }
+
+ /// <summary>
+ /// Returns a reference to the instance on which the method is called, as
+ /// instances aren't associated with specific types.
+ /// </summary>
+ public ILogger ForType<T>()
+ {
+ return this;
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Info(string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Info(string format, params object[] formatArgs)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Warning(string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Warning(Exception exception, string message)
+ {
+ }
+
+ /// <summary>
+ /// As with all logging calls on this logger, this method is a no-op.
+ /// </summary>
+ public void Warning(string format, params object[] formatArgs)
+ {
+ }
+ }
+}
diff --git a/src/node/performance/worker_server.js b/src/node/performance/worker.js
similarity index 100%
rename from src/node/performance/worker_server.js
rename to src/node/performance/worker.js
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index 7ba14a3..4f48d6f 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -129,9 +129,9 @@
zend_throw_exception(zend_exception_get_default(),
"Metadata hash somehow contains wrong types.",
1 TSRMLS_CC);
- efree(str_key);
- efree(str_val);
- return NULL;
+ efree(str_key);
+ efree(str_val);
+ return NULL;
}
add_next_index_stringl(*data, str_val, elem->value_length, false);
} else {
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index 60c9441..f0bc734 100644
--- a/src/php/ext/grpc/channel.c
+++ b/src/php/ext/grpc/channel.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -141,44 +141,40 @@
HashTable *array_hash;
zval **creds_obj = NULL;
wrapped_grpc_channel_credentials *creds = NULL;
- /* "s|a" == 1 string, 1 optional array */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &target,
+ /* "sa" == 1 string, 1 array */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa", &target,
&target_length, &args_array) == FAILURE) {
zend_throw_exception(spl_ce_InvalidArgumentException,
"Channel expects a string and an array", 1 TSRMLS_CC);
return;
}
- if (args_array == NULL) {
- channel->wrapped = grpc_insecure_channel_create(target, NULL, NULL);
- } else {
- array_hash = Z_ARRVAL_P(args_array);
- if (zend_hash_find(array_hash, "credentials", sizeof("credentials"),
- (void **)&creds_obj) == SUCCESS) {
- if (Z_TYPE_P(*creds_obj) == IS_NULL) {
- creds = NULL;
- zend_hash_del(array_hash, "credentials", 12);
- } else if (zend_get_class_entry(*creds_obj TSRMLS_CC) !=
- grpc_ce_channel_credentials) {
- zend_throw_exception(spl_ce_InvalidArgumentException,
- "credentials must be a ChannelCredentials object",
- 1 TSRMLS_CC);
- return;
- } else {
- creds = (wrapped_grpc_channel_credentials *)zend_object_store_get_object(
- *creds_obj TSRMLS_CC);
- zend_hash_del(array_hash, "credentials", 12);
- }
- }
- php_grpc_read_args_array(args_array, &args);
- if (creds == NULL) {
- channel->wrapped = grpc_insecure_channel_create(target, &args, NULL);
+ array_hash = Z_ARRVAL_P(args_array);
+ if (zend_hash_find(array_hash, "credentials", sizeof("credentials"),
+ (void **)&creds_obj) == SUCCESS) {
+ if (Z_TYPE_P(*creds_obj) == IS_NULL) {
+ creds = NULL;
+ zend_hash_del(array_hash, "credentials", 12);
+ } else if (zend_get_class_entry(*creds_obj TSRMLS_CC) !=
+ grpc_ce_channel_credentials) {
+ zend_throw_exception(spl_ce_InvalidArgumentException,
+ "credentials must be a ChannelCredentials object",
+ 1 TSRMLS_CC);
+ return;
} else {
- gpr_log(GPR_DEBUG, "Initialized secure channel");
- channel->wrapped =
- grpc_secure_channel_create(creds->wrapped, target, &args, NULL);
+ creds = (wrapped_grpc_channel_credentials *)zend_object_store_get_object(
+ *creds_obj TSRMLS_CC);
+ zend_hash_del(array_hash, "credentials", 12);
}
- efree(args.args);
}
+ php_grpc_read_args_array(args_array, &args);
+ if (creds == NULL) {
+ channel->wrapped = grpc_insecure_channel_create(target, &args, NULL);
+ } else {
+ gpr_log(GPR_DEBUG, "Initialized secure channel");
+ channel->wrapped =
+ grpc_secure_channel_create(creds->wrapped, target, &args, NULL);
+ }
+ efree(args.args);
}
/**
diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
index 1fe81b9..f70525e 100644
--- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
+++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
@@ -1,7 +1,7 @@
<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -106,6 +106,34 @@
$this->assertSame(\Grpc\STATUS_CANCELLED, $status->code);
}
+ public function testCallCredentialsCallback()
+ {
+ $div_arg = new math\DivArgs();
+ $call = self::$client->Div($div_arg, array(), array(
+ 'call_credentials_callback' => function ($context) {
+ return array();
+ },
+ ));
+ $call->cancel();
+ list($response, $status) = $call->wait();
+ $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code);
+ }
+
+ public function testCallCredentialsCallback2()
+ {
+ $div_arg = new math\DivArgs();
+ $call = self::$client->Div($div_arg);
+ $call_credentials = Grpc\CallCredentials::createFromPlugin(
+ function ($context) {
+ return array();
+ }
+ );
+ $call->setCallCredentials($call_credentials);
+ $call->cancel();
+ list($response, $status) = $call->wait();
+ $this->assertSame(\Grpc\STATUS_CANCELLED, $status->code);
+ }
+
/**
* @expectedException InvalidArgumentException
*/
@@ -118,6 +146,23 @@
$invalid_client->InvalidUnaryCall($div_arg);
}
+ /**
+ * @expectedException Exception
+ */
+ public function testMissingCredentials()
+ {
+ $invalid_client = new DummyInvalidClient('host', [
+ ]);
+ }
+
+ public function testPrimaryUserAgentString()
+ {
+ $invalid_client = new DummyInvalidClient('host', [
+ 'credentials' => Grpc\ChannelCredentials::createInsecure(),
+ 'grpc.primary_user_agent' => 'testUserAgent',
+ ]);
+ }
+
public function testWriteFlags()
{
$div_arg = new math\DivArgs();
diff --git a/src/php/tests/unit_tests/CallCredentials2Test.php b/src/php/tests/unit_tests/CallCredentials2Test.php
new file mode 100644
index 0000000..1282db6
--- /dev/null
+++ b/src/php/tests/unit_tests/CallCredentials2Test.php
@@ -0,0 +1,135 @@
+<?php
+/*
+ *
+ * Copyright 2015-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.
+ *
+ */
+
+class CallCredentials2Test extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $credentials = Grpc\ChannelCredentials::createSsl(
+ file_get_contents(dirname(__FILE__).'/../data/ca.pem'));
+ $server_credentials = Grpc\ServerCredentials::createSsl(
+ null,
+ file_get_contents(dirname(__FILE__).'/../data/server1.key'),
+ file_get_contents(dirname(__FILE__).'/../data/server1.pem'));
+ $this->server = new Grpc\Server();
+ $this->port = $this->server->addSecureHttp2Port('0.0.0.0:0',
+ $server_credentials);
+ $this->server->start();
+ $this->host_override = 'foo.test.google.fr';
+ $this->channel = new Grpc\Channel(
+ 'localhost:'.$this->port,
+ [
+ 'grpc.ssl_target_name_override' => $this->host_override,
+ 'grpc.default_authority' => $this->host_override,
+ 'credentials' => $credentials,
+ ]
+ );
+ }
+
+ public function tearDown()
+ {
+ unset($this->channel);
+ unset($this->server);
+ }
+
+ public function callbackFunc($context)
+ {
+ $this->assertTrue(is_string($context->service_url));
+ $this->assertTrue(is_string($context->method_name));
+
+ return ['k1' => ['v1'], 'k2' => ['v2']];
+ }
+
+ public function testCreateFromPlugin()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ '/abc/dummy_method',
+ $deadline,
+ $this->host_override);
+
+ $call_credentials = Grpc\CallCredentials::createFromPlugin(
+ array($this, 'callbackFunc'));
+ $call->setCredentials($call_credentials);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+
+ $event = $this->server->requestCall();
+
+ $this->assertTrue(is_array($event->metadata));
+ $metadata = $event->metadata;
+ $this->assertTrue(array_key_exists('k1', $metadata));
+ $this->assertTrue(array_key_exists('k2', $metadata));
+ $this->assertSame($metadata['k1'], ['v1']);
+ $this->assertSame($metadata['k2'], ['v2']);
+
+ $this->assertSame('/abc/dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => $status_text,
+ ],
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_status);
+ $this->assertFalse($event->cancelled);
+
+ $event = $call->startBatch([
+ Grpc\OP_RECV_INITIAL_METADATA => true,
+ Grpc\OP_RECV_STATUS_ON_CLIENT => true,
+ ]);
+
+ $this->assertSame([], $event->metadata);
+ $status = $event->status;
+ $this->assertSame([], $status->metadata);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
+
+ unset($call);
+ unset($server_call);
+ }
+}
diff --git a/src/php/tests/unit_tests/CallCredentials3Test.php b/src/php/tests/unit_tests/CallCredentials3Test.php
new file mode 100644
index 0000000..a458f1d
--- /dev/null
+++ b/src/php/tests/unit_tests/CallCredentials3Test.php
@@ -0,0 +1,136 @@
+<?php
+/*
+ *
+ * Copyright 2015-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.
+ *
+ */
+
+class CallCredentials3Test extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->credentials = Grpc\ChannelCredentials::createSsl(
+ file_get_contents(dirname(__FILE__).'/../data/ca.pem'));
+ $server_credentials = Grpc\ServerCredentials::createSsl(
+ null,
+ file_get_contents(dirname(__FILE__).'/../data/server1.key'),
+ file_get_contents(dirname(__FILE__).'/../data/server1.pem'));
+ $this->server = new Grpc\Server();
+ $this->port = $this->server->addSecureHttp2Port('0.0.0.0:0',
+ $server_credentials);
+ $this->server->start();
+ $this->host_override = 'foo.test.google.fr';
+ $this->channel = new Grpc\Channel(
+ 'localhost:'.$this->port,
+ [
+ 'grpc.ssl_target_name_override' => $this->host_override,
+ 'grpc.default_authority' => $this->host_override,
+ 'credentials' => $this->credentials,
+ ]
+ );
+ }
+
+ public function tearDown()
+ {
+ unset($this->channel);
+ unset($this->server);
+ }
+
+ public function callbackFunc($context)
+ {
+ $this->assertTrue(is_string($context->service_url));
+ $this->assertTrue(is_string($context->method_name));
+
+ return ['k1' => ['v1'], 'k2' => ['v2']];
+ }
+
+ public function testCreateFromPlugin()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ '/abc/dummy_method',
+ $deadline,
+ $this->host_override);
+
+ $call_credentials = Grpc\CallCredentials::createFromPlugin(
+ [$this, 'callbackFunc']);
+ $call->setCredentials($call_credentials);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+
+ $event = $this->server->requestCall();
+
+ $this->assertTrue(is_array($event->metadata));
+ $metadata = $event->metadata;
+ $this->assertTrue(array_key_exists('k1', $metadata));
+ $this->assertTrue(array_key_exists('k2', $metadata));
+ $this->assertSame($metadata['k1'], ['v1']);
+ $this->assertSame($metadata['k2'], ['v2']);
+
+ $this->assertSame('/abc/dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => $status_text,
+ ],
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_status);
+ $this->assertFalse($event->cancelled);
+
+ $event = $call->startBatch([
+ Grpc\OP_RECV_INITIAL_METADATA => true,
+ Grpc\OP_RECV_STATUS_ON_CLIENT => true,
+ ]);
+
+ $this->assertSame([], $event->metadata);
+ $status = $event->status;
+ $this->assertSame([], $status->metadata);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
+
+ unset($call);
+ unset($server_call);
+ }
+
+}
diff --git a/src/php/tests/unit_tests/CallCredentialsTest.php b/src/php/tests/unit_tests/CallCredentialsTest.php
index 0918412..2870248 100644
--- a/src/php/tests/unit_tests/CallCredentialsTest.php
+++ b/src/php/tests/unit_tests/CallCredentialsTest.php
@@ -1,7 +1,7 @@
<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,13 +36,13 @@
{
public function setUp()
{
- $credentials = Grpc\ChannelCredentials::createSsl(
+ $this->credentials = Grpc\ChannelCredentials::createSsl(
file_get_contents(dirname(__FILE__).'/../data/ca.pem'));
- $call_credentials = Grpc\CallCredentials::createFromPlugin(
- array($this, 'callbackFunc'));
- $credentials = Grpc\ChannelCredentials::createComposite(
- $credentials,
- $call_credentials
+ $this->call_credentials = Grpc\CallCredentials::createFromPlugin(
+ [$this, 'callbackFunc']);
+ $this->credentials = Grpc\ChannelCredentials::createComposite(
+ $this->credentials,
+ $this->call_credentials
);
$server_credentials = Grpc\ServerCredentials::createSsl(
null,
@@ -58,7 +58,7 @@
[
'grpc.ssl_target_name_override' => $this->host_override,
'grpc.default_authority' => $this->host_override,
- 'credentials' => $credentials,
+ 'credentials' => $this->credentials,
]
);
}
@@ -134,4 +134,41 @@
unset($call);
unset($server_call);
}
+
+ public function callbackFunc2($context)
+ {
+ return [];
+ }
+
+ public function testCreateComposite()
+ {
+ $call_credentials2 = Grpc\CallCredentials::createFromPlugin(
+ [$this, 'callbackFunc2']);
+ $call_credentials3 = Grpc\CallCredentials::createComposite(
+ $this->call_credentials,
+ $call_credentials2
+ );
+ $this->assertSame('Grpc\CallCredentials', get_class($call_credentials3));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCreateFromPluginInvalidParam()
+ {
+ $call_credentials = Grpc\CallCredentials::createFromPlugin(
+ 'callbackFunc'
+ );
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCreateCompositeInvalidParam()
+ {
+ $call_credentials3 = Grpc\CallCredentials::createComposite(
+ $this->call_credentials,
+ $this->credentials
+ );
+ }
}
diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php
index 3b697b5..a2522fb 100755
--- a/src/php/tests/unit_tests/CallTest.php
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -1,7 +1,7 @@
<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -91,4 +91,32 @@
{
$this->assertTrue(is_string($this->call->getPeer()));
}
+
+ public function testCancel()
+ {
+ $this->assertNull($this->call->cancel());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidMetadataKey()
+ {
+ $batch = [
+ 'invalid' => ['key1' => 'value1'],
+ ];
+ $result = $this->call->startBatch($batch);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidMetadataInnerValue()
+ {
+ $batch = [
+ Grpc\OP_SEND_INITIAL_METADATA => ['key1' => 'value1'],
+ ];
+ $result = $this->call->startBatch($batch);
+ }
+
}
diff --git a/src/php/tests/unit_tests/ChannelCredentialsTest.php b/src/php/tests/unit_tests/ChannelCredentialsTest.php
new file mode 100644
index 0000000..6d472dc
--- /dev/null
+++ b/src/php/tests/unit_tests/ChannelCredentialsTest.php
@@ -0,0 +1,73 @@
+<?php
+/*
+ *
+ * Copyright 2015-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.
+ *
+ */
+
+class ChanellCredentialsTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ }
+
+ public function tearDown()
+ {
+ }
+
+ public function testCreateDefault()
+ {
+ $channel_credentials = Grpc\ChannelCredentials::createDefault();
+ $this->assertSame('Grpc\ChannelCredentials', get_class($channel_credentials));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidCreateSsl()
+ {
+ $channel_credentials = Grpc\ChannelCredentials::createSsl([]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidCreateComposite()
+ {
+ $channel_credentials = Grpc\ChannelCredentials::createComposite(
+ 'something', 'something');
+ }
+
+ public function testCreateInsecure()
+ {
+ $channel_credentials = Grpc\ChannelCredentials::createInsecure();
+ $this->assertNull($channel_credentials);
+ }
+}
\ No newline at end of file
diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php
new file mode 100644
index 0000000..acb8a0a
--- /dev/null
+++ b/src/php/tests/unit_tests/ChannelTest.php
@@ -0,0 +1,82 @@
+<?php
+/*
+ *
+ * Copyright 2015-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.
+ *
+ */
+
+class ChannelTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ }
+
+ public function tearDown()
+ {
+ }
+
+ public function testInsecureCredentials()
+ {
+ $this->channel = new Grpc\Channel(
+ 'localhost:0',
+ [
+ 'credentials' => Grpc\ChannelCredentials::createInsecure(),
+ ]
+ );
+ $this->assertSame('Grpc\Channel', get_class($this->channel));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidCredentials()
+ {
+ $this->channel = new Grpc\Channel(
+ 'localhost:0',
+ [
+ 'credentials' => new Grpc\Timeval(100),
+ ]
+ );
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidOptionsArray()
+ {
+ $this->channel = new Grpc\Channel(
+ 'localhost:0',
+ [
+ 'abc' => [],
+ ]
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index 5a38262..45f6708 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -1,7 +1,7 @@
<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -201,6 +201,318 @@
unset($server_call);
}
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidClientMessageArray()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => 'invalid',
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidClientMessageString()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => 0],
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidClientMessageFlags()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => 'abc',
+ 'flags' => 'invalid'],
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidServerStatusMetadata()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+ $this->assertTrue($event->send_message);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => 'invalid',
+ 'code' => Grpc\STATUS_OK,
+ 'details' => $status_text,
+ ],
+ Grpc\OP_RECV_MESSAGE => true,
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidServerStatusCode()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+ $this->assertTrue($event->send_message);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => 'invalid',
+ 'details' => $status_text,
+ ],
+ Grpc\OP_RECV_MESSAGE => true,
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testMissingServerStatusCode()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+ $this->assertTrue($event->send_message);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'details' => $status_text,
+ ],
+ Grpc\OP_RECV_MESSAGE => true,
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidServerStatusDetails()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+ $this->assertTrue($event->send_message);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => 0,
+ ],
+ Grpc\OP_RECV_MESSAGE => true,
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testMissingServerStatusDetails()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+ $this->assertTrue($event->send_message);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ ],
+ Grpc\OP_RECV_MESSAGE => true,
+ Grpc\OP_RECV_CLOSE_ON_SERVER => true,
+ ]);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidStartBatchKey()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ 9999999 => [],
+ ]);
+ }
+
+ /**
+ * @expectedException LogicException
+ */
+ public function testInvalidStartBatch()
+ {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'client_server_full_request_response';
+ $reply_text = 'reply:client_server_full_request_response';
+ $status_text = 'status:client_server_full_response_text';
+
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => 'abc',
+ ],
+ ]);
+ }
+
public function testGetTarget()
{
$this->assertTrue(is_string($this->channel->getTarget()));
@@ -255,4 +567,36 @@
$new_state = $this->channel->getConnectivityState();
$this->assertTrue($new_state == Grpc\CHANNEL_IDLE);
}
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testGetConnectivityStateInvalidParam()
+ {
+ $this->assertTrue($this->channel->getConnectivityState(
+ new Grpc\Timeval));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testWatchConnectivityStateInvalidParam()
+ {
+ $this->assertTrue($this->channel->watchConnectivityState(
+ 0, 1000));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testChannelConstructorInvalidParam()
+ {
+ $this->channel = new Grpc\Channel('localhost:'.$this->port, NULL);
+ }
+
+ public function testClose()
+ {
+ $this->assertNull($this->channel->close());
+ }
+
}
diff --git a/src/cpp/server/fixed_size_thread_pool.h b/src/php/tests/unit_tests/ServerTest.php
similarity index 64%
rename from src/cpp/server/fixed_size_thread_pool.h
rename to src/php/tests/unit_tests/ServerTest.php
index 394ae58..cde6a9a 100644
--- a/src/cpp/server/fixed_size_thread_pool.h
+++ b/src/php/tests/unit_tests/ServerTest.php
@@ -1,6 +1,7 @@
+<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,37 +32,40 @@
*
*/
-#ifndef GRPC_INTERNAL_CPP_FIXED_SIZE_THREAD_POOL_H
-#define GRPC_INTERNAL_CPP_FIXED_SIZE_THREAD_POOL_H
+class ServerTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ }
-#include <queue>
-#include <vector>
+ public function tearDown()
+ {
+ }
-#include <grpc++/impl/sync.h>
-#include <grpc++/impl/thd.h>
-#include <grpc++/support/config.h>
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidConstructor()
+ {
+ $server = new Grpc\Server('invalid_host');
+ }
-#include "src/cpp/server/thread_pool_interface.h"
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidAddHttp2Port()
+ {
+ $this->server = new Grpc\Server([]);
+ $this->port = $this->server->addHttp2Port(['0.0.0.0:0']);
+ }
-namespace grpc {
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidAddSecureHttp2Port()
+ {
+ $this->server = new Grpc\Server([]);
+ $this->port = $this->server->addSecureHttp2Port(['0.0.0.0:0']);
+ }
-class FixedSizeThreadPool GRPC_FINAL : public ThreadPoolInterface {
- public:
- explicit FixedSizeThreadPool(int num_threads);
- ~FixedSizeThreadPool();
-
- void Add(const std::function<void()>& callback) GRPC_OVERRIDE;
-
- private:
- grpc::mutex mu_;
- grpc::condition_variable cv_;
- bool shutdown_;
- std::queue<std::function<void()>> callbacks_;
- std::vector<grpc::thread*> threads_;
-
- void ThreadFunc();
-};
-
-} // namespace grpc
-
-#endif // GRPC_INTERNAL_CPP_FIXED_SIZE_THREAD_POOL_H
+}
\ No newline at end of file
diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php
index 1d2a8d3..9e4bc29 100755
--- a/src/php/tests/unit_tests/TimevalTest.php
+++ b/src/php/tests/unit_tests/TimevalTest.php
@@ -1,7 +1,7 @@
<?php
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -91,4 +91,69 @@
$back_to_now = $deadline->subtract($delta);
$this->assertSame(0, Grpc\Timeval::compare($back_to_now, $now));
}
+
+ public function testSimilar()
+ {
+ $a = Grpc\Timeval::now();
+ $delta = new Grpc\Timeval(1000);
+ $b = $a->add($delta);
+ $thresh = new Grpc\Timeval(1100);
+ $this->assertTrue(Grpc\Timeval::similar($a, $b, $thresh));
+ $thresh = new Grpc\Timeval(900);
+ $this->assertFalse(Grpc\Timeval::similar($a, $b, $thresh));
+ }
+
+ public function testSleepUntil()
+ {
+ $curr_microtime = microtime(true);
+ $now = Grpc\Timeval::now();
+ $delta = new Grpc\Timeval(1000);
+ $deadline = $now->add($delta);
+ $deadline->sleepUntil();
+ $done_microtime = microtime(true);
+ $this->assertTrue(($done_microtime - $curr_microtime) > 0.0009);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testConstructorInvalidParam()
+ {
+ $delta = new Grpc\Timeval('abc');
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testAddInvalidParam()
+ {
+ $a = Grpc\Timeval::now();
+ $a->add(1000);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testSubtractInvalidParam()
+ {
+ $a = Grpc\Timeval::now();
+ $a->subtract(1000);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testCompareInvalidParam()
+ {
+ $a = Grpc\Timeval::compare(1000, 1100);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testSimilarInvalidParam()
+ {
+ $a = Grpc\Timeval::similar(1000, 1100, 1200);
+ }
+
}
diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst
index c7b5a3b..698c760 100644
--- a/src/python/grpcio/README.rst
+++ b/src/python/grpcio/README.rst
@@ -1,22 +1,40 @@
gRPC Python
===========
-Package for GRPC Python.
+Package for gRPC Python.
-Dependencies
+Installation
------------
-Ensure you have installed the gRPC core. On Mac OS X, install homebrew_.
-Run the following command to install gRPC Python.
+gRPC Python is available for Linux and Mac OS X running Python 2.7.
+
+From PyPI
+~~~~~~~~~
+
+If you are installing locally...
::
- $ curl -fsSL https://goo.gl/getgrpc | bash -s python
+ $ pip install grpcio
-This will download and run the [gRPC install script][] to install grpc core. The script then uses pip to install this package. It also installs the Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin for python.
+Else system wide (on Ubuntu)...
-Otherwise, `install from source`_
+::
-.. _`install from source`: https://github.com/grpc/grpc/blob/master/src/python/README.md#building-from-source
-.. _homebrew: http://brew.sh
-.. _`gRPC install script`: https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
+ $ sudo pip install grpcio
+
+From Source
+~~~~~~~~~~~
+
+Building from source requires that you have the Python headers (usually a
+package named `python-dev`).
+
+::
+
+ $ export REPO_ROOT=grpc
+ $ git clone https://github.com/grpc/grpc.git $REPO_ROOT
+ $ cd $REPO_ROOT
+ $ pip install .
+
+Note that `$REPO_ROOT` can be assigned to whatever directory name floats your
+fancy.
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index 774e7ad..aa29c72 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -41,7 +41,6 @@
import traceback
import setuptools
-from setuptools.command import bdist_egg
from setuptools.command import build_ext
from setuptools.command import build_py
from setuptools.command import easy_install
@@ -52,13 +51,6 @@
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))
-BINARIES_REPOSITORY = os.environ.get(
- 'GRPC_PYTHON_BINARIES_REPOSITORY',
- 'https://storage.googleapis.com/grpc-precompiled-binaries/python')
-
-USE_GRPC_CUSTOM_BDIST = bool(int(os.environ.get(
- 'GRPC_PYTHON_USE_CUSTOM_BDIST', '1')))
-
CONF_PY_ADDENDUM = """
extensions.append('sphinx.ext.napoleon')
napoleon_google_docstring = True
@@ -74,126 +66,39 @@
# TODO(atash): Remove this once PyPI has better Linux bdist support. See
# https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
-def _get_grpc_custom_bdist_egg(decorated_basename, target_egg_basename):
- """Returns a string path to a .egg file for Linux to install.
+def _get_grpc_custom_bdist(decorated_basename, target_bdist_basename):
+ """Returns a string path to a bdist file for Linux to install.
- If we can retrieve a pre-compiled egg from online, uses it. Else, emits a
+ If we can retrieve a pre-compiled bdist from online, uses it. Else, emits a
warning and builds from source.
"""
+ # TODO(atash): somehow the name that's returned from `wheel` is different
+ # between different versions of 'wheel' (but from a compatibility standpoint,
+ # the names are compatible); we should have some way of determining name
+ # compatibility in the same way `wheel` does to avoid having to rename all of
+ # the custom wheels that we build/upload to GCS.
+
# Break import style to ensure that setup.py has had a chance to install the
- # relevant package eggs.
+ # relevant package.
from six.moves.urllib import request
- decorated_path = decorated_basename + '.egg'
+ decorated_path = decorated_basename + GRPC_CUSTOM_BDIST_EXT
try:
url = BINARIES_REPOSITORY + '/{target}'.format(target=decorated_path)
- egg_data = request.urlopen(url).read()
+ bdist_data = request.urlopen(url).read()
except IOError as error:
raise CommandError(
- '{}\n\nCould not find the bdist egg {}: {}'
+ '{}\n\nCould not find the bdist {}: {}'
.format(traceback.format_exc(), decorated_path, error.message))
- # Our chosen local egg path.
- egg_path = target_egg_basename + '.egg'
+ # Our chosen local bdist path.
+ bdist_path = target_bdist_basename + GRPC_CUSTOM_BDIST_EXT
try:
- with open(egg_path, 'w') as egg_file:
- egg_file.write(egg_data)
+ with open(bdist_path, 'w') as bdist_file:
+ bdist_file.write(bdist_data)
except IOError as error:
raise CommandError(
- '{}\n\nCould not write grpcio egg: {}'
+ '{}\n\nCould not write grpcio bdist: {}'
.format(traceback.format_exc(), error.message))
- return egg_path
-
-
-class EggNameMixin(object):
- """Mixin for setuptools.Command classes to enable acquiring the egg name."""
-
- def egg_name(self, with_custom):
- """
- Args:
- with_custom: Boolean describing whether or not to decorate the egg name
- with custom gRPC-specific target information.
- """
- egg_command = self.get_finalized_command('bdist_egg')
- base = os.path.splitext(os.path.basename(egg_command.egg_output))[0]
- if with_custom:
- flavor = 'ucs2' if sys.maxunicode == 65535 else 'ucs4'
- return '{base}-{flavor}'.format(base=base, flavor=flavor)
- else:
- return base
-
-
-class Install(install.install, EggNameMixin):
- """Custom Install command for gRPC Python.
-
- This is for bdist shims and whatever else we might need a custom install
- command for.
- """
-
- user_options = install.install.user_options + [
- # TODO(atash): remove this once PyPI has better Linux bdist support. See
- # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
- ('use-grpc-custom-bdist', None,
- 'Whether to retrieve a binary from the gRPC binary repository instead '
- 'of building from source.'),
- ]
-
- def initialize_options(self):
- install.install.initialize_options(self)
- self.use_grpc_custom_bdist = USE_GRPC_CUSTOM_BDIST
-
- def finalize_options(self):
- install.install.finalize_options(self)
-
- def run(self):
- if self.use_grpc_custom_bdist:
- try:
- try:
- egg_path = _get_grpc_custom_bdist_egg(self.egg_name(True),
- self.egg_name(False))
- except CommandError as error:
- sys.stderr.write(
- '\nWARNING: Failed to acquire grpcio prebuilt binary:\n'
- '{}.\n\n'.format(error.message))
- raise
- try:
- self._run_bdist_retrieval_install(egg_path)
- except Exception as error:
- # if anything else happens (and given how there's no way to really know
- # what's happening in setuptools here, I mean *anything*), warn the user
- # and fall back to building from source.
- sys.stderr.write(
- '{}\nWARNING: Failed to install grpcio prebuilt binary.\n\n'
- .format(traceback.format_exc()))
- raise
- except Exception:
- install.install.run(self)
- else:
- install.install.run(self)
-
- # TODO(atash): Remove this once PyPI has better Linux bdist support. See
- # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported
- def _run_bdist_retrieval_install(self, bdist_egg):
- easy_install = self.distribution.get_command_class('easy_install')
- easy_install_command = easy_install(
- self.distribution, args='x', root=self.root, record=self.record,
- )
- easy_install_command.ensure_finalized()
- easy_install_command.always_copy_from = '.'
- easy_install_command.package_index.scan(glob.glob('*.egg'))
- arguments = [bdist_egg]
- if setuptools.bootstrap_install_from:
- args.insert(0, setuptools.bootstrap_install_from)
- easy_install_command.args = arguments
- easy_install_command.run()
- setuptools.bootstrap_install_from = None
-
-
-class BdistEggCustomName(bdist_egg.bdist_egg, EggNameMixin):
- """Thin wrapper around the bdist_egg command to build with our custom name."""
-
- def run(self):
- bdist_egg.bdist_egg.run(self)
- target = os.path.join(self.dist_dir, '{}.egg'.format(self.egg_name(True)))
- shutil.move(self.get_outputs()[0], target)
+ return bdist_path
class SphinxDocumentation(setuptools.Command):
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index bbeed9a..800d0ea 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -36,7 +36,7 @@
ctypedef unsigned uint32_t
ctypedef long int64_t
- int pygrpc_load_core(const char*)
+ int pygrpc_load_core(char*)
void *gpr_malloc(size_t size)
void gpr_free(void *ptr)
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c
index 817303c..4b1860c 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.c
+++ b/src/python/grpcio/grpc/_cython/imports.generated.c
@@ -137,6 +137,7 @@
grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import;
grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
+grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
grpc_call_credentials_release_type grpc_call_credentials_release_import;
grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
@@ -296,6 +297,10 @@
gpr_thd_currentid_type gpr_thd_currentid_import;
gpr_thd_join_type gpr_thd_join_import;
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cpluslus */
+
void pygrpc_load_imports(HMODULE library) {
census_initialize_import = (census_initialize_type) GetProcAddress(library, "census_initialize");
census_shutdown_import = (census_shutdown_type) GetProcAddress(library, "census_shutdown");
@@ -397,6 +402,7 @@
grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name");
grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
+ grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create");
grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create");
@@ -557,4 +563,8 @@
gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join");
}
+#ifdef __cplusplus
+}
+#endif /* __cpluslus */
+
#endif /* !GPR_WIN32 */
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h
index 6d0a6e0..ca30742 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.h
+++ b/src/python/grpcio/grpc/_cython/imports.generated.h
@@ -361,6 +361,9 @@
typedef grpc_channel_credentials *(*grpc_google_default_credentials_create_type)(void);
extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
+typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
+extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
+#define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import
typedef grpc_channel_credentials *(*grpc_ssl_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved);
extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import
@@ -836,8 +839,16 @@
extern gpr_thd_join_type gpr_thd_join_import;
#define gpr_thd_join gpr_thd_join_import
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cpluslus */
+
void pygrpc_load_imports(HMODULE library);
+#ifdef __cplusplus
+}
+#endif /* __cpluslus */
+
#else /* !GPR_WIN32 */
#include <grpc/support/alloc.h>
diff --git a/src/python/grpcio/grpc/_cython/loader.c b/src/python/grpcio/grpc/_cython/loader.c
index cdd47de..3b72806 100644
--- a/src/python/grpcio/grpc/_cython/loader.c
+++ b/src/python/grpcio/grpc/_cython/loader.c
@@ -33,6 +33,10 @@
#include "loader.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cpluslus */
+
#if GPR_WIN32
int pygrpc_load_core(char *path) {
@@ -56,4 +60,9 @@
int pygrpc_load_core(char *path) { return 1; }
-#endif
+#endif /* !GPR_WIN32 */
+
+#ifdef __cplusplus
+}
+#endif /* __cpluslus */
+
diff --git a/src/python/grpcio/grpc/_cython/loader.h b/src/python/grpcio/grpc/_cython/loader.h
index dd31e15..3b8796d 100644
--- a/src/python/grpcio/grpc/_cython/loader.h
+++ b/src/python/grpcio/grpc/_cython/loader.h
@@ -39,7 +39,16 @@
/* Additional inclusions not covered by "imports.generated.h" */
#include <grpc/byte_buffer_reader.h>
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cpluslus */
+
/* Attempts to load the core if necessary, and return non-zero upon succes. */
int pygrpc_load_core(char *path);
+#ifdef __cplusplus
+}
+#endif /* __cpluslus */
+
#endif /* GRPC_RB_BYTE_BUFFER_H_ */
+
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 8e90f7a..632a7c4 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -223,6 +223,7 @@
'src/core/transport/transport_op_string.c',
'src/core/census/context.c',
'src/core/census/initialize.c',
+ 'src/core/census/log.c',
'src/core/census/operation.c',
'src/core/census/placeholders.c',
'src/core/census/tracing.c',
diff --git a/src/python/grpcio/precompiled.py b/src/python/grpcio/precompiled.py
new file mode 100644
index 0000000..05c651b
--- /dev/null
+++ b/src/python/grpcio/precompiled.py
@@ -0,0 +1,102 @@
+# Copyright 2015-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.
+
+import os
+import platform
+import shutil
+import sys
+
+import setuptools
+
+import commands
+import grpc_version
+
+try:
+ from urllib2 import urlopen
+except ImportError:
+ from urllib.request import urlopen
+
+PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))
+BINARIES_REPOSITORY = os.environ.get(
+ 'GRPC_PYTHON_BINARIES_REPOSITORY',
+ 'https://storage.googleapis.com/grpc-precompiled-binaries/python')
+USE_PRECOMPILED_BINARIES = bool(int(os.environ.get(
+ 'GRPC_PYTHON_USE_PRECOMPILED_BINARIES', '1')))
+
+def _tagged_ext_name(base):
+ uname = platform.uname()
+ tags = '-'.join((grpc_version.VERSION, uname[0], uname[4]))
+ flavor = 'ucs2' if sys.maxunicode == 65535 else 'ucs4'
+ return '{base}-{tags}-{flavor}'.format(base=base, tags=tags, flavor=flavor)
+
+
+class BuildTaggedExt(setuptools.Command):
+
+ description = 'build the gRPC tagged extensions'
+ user_options = []
+
+ def initialize_options(self):
+ # distutils requires this override.
+ pass
+
+ def finalize_options(self):
+ # distutils requires this override.
+ pass
+
+ def run(self):
+ if 'linux' in sys.platform:
+ self.run_command('build_ext')
+ try:
+ os.makedirs('dist/')
+ except OSError:
+ pass
+ shutil.copyfile(
+ os.path.join(PYTHON_STEM, 'grpc/_cython/cygrpc.so'),
+ 'dist/{}.so'.format(_tagged_ext_name('cygrpc')))
+ else:
+ sys.stderr.write('nothing to do for build_tagged_ext\n')
+
+
+def update_setup_arguments(setup_arguments):
+ url = '{}/{}.so'.format(BINARIES_REPOSITORY, _tagged_ext_name('cygrpc'))
+ target_path = os.path.join(PYTHON_STEM, 'grpc/_cython/cygrpc.so')
+ try:
+ extension = urlopen(url).read()
+ except:
+ sys.stderr.write(
+ 'could not download precompiled extension: {}\n'.format(url))
+ return
+ try:
+ with open(target_path, 'w') as target:
+ target.write(extension)
+ setup_arguments['ext_modules'] = []
+ except:
+ sys.stderr.write(
+ 'could not write precompiled extension to directory: {} -> {}\n'
+ .format(url, target_path))
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index d4ddb73..1af34d9 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -137,6 +137,7 @@
grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import;
grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
+grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
grpc_call_credentials_release_type grpc_call_credentials_release_import;
grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
@@ -397,6 +398,7 @@
grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name");
grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
+ grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create");
grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index 618ae5e..b61c528 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -361,6 +361,9 @@
typedef grpc_channel_credentials *(*grpc_google_default_credentials_create_type)(void);
extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
+typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
+extern grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
+#define grpc_set_ssl_roots_override_callback grpc_set_ssl_roots_override_callback_import
typedef grpc_channel_credentials *(*grpc_ssl_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved);
extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import
diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template
index 6cc3e96..701e1c7 100644
--- a/templates/grpc.gemspec.template
+++ b/templates/grpc.gemspec.template
@@ -17,7 +17,7 @@
s.required_ruby_version = '>= 2.0.0'
- s.files = %w( Makefile )
+ s.files = %w( Makefile .yardopts )
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
@@ -33,7 +33,7 @@
s.require_paths = %w( src/ruby/bin src/ruby/lib src/ruby/pb )
s.platform = Gem::Platform::RUBY
- s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.2'
+ s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.3'
s.add_dependency 'googleauth', '~> 0.5.1'
s.add_development_dependency 'bundler', '~> 1.9'
diff --git a/templates/package.json.template b/templates/package.json.template
index d6279b9..99e8287 100644
--- a/templates/package.json.template
+++ b/templates/package.json.template
@@ -25,13 +25,12 @@
"test": "./node_modules/.bin/mocha src/node/test && npm run-script lint",
"gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test",
- "preinstall": "npm install node-pre-gyp",
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build"
},
+ "bundledDependencies": ["node-pre-gyp"],
"dependencies": {
"lodash": "^3.9.3",
"nan": "^2.0.0",
- "node-pre-gyp": "^0.6.19",
"protobufjs": "^4.0.0"
},
"devDependencies": {
diff --git a/templates/src/python/grpcio/grpc/_cython/imports.generated.c.template b/templates/src/python/grpcio/grpc/_cython/imports.generated.c.template
index be33280..62fe094 100644
--- a/templates/src/python/grpcio/grpc/_cython/imports.generated.c.template
+++ b/templates/src/python/grpcio/grpc/_cython/imports.generated.c.template
@@ -43,10 +43,19 @@
${api.name}_type ${api.name}_import;
%endfor
+ #ifdef __cplusplus
+ extern "C" {
+ #endif /* __cpluslus */
+
void pygrpc_load_imports(HMODULE library) {
%for api in c_apis:
${api.name}_import = (${api.name}_type) GetProcAddress(library, "${api.name}");
%endfor
}
+ #ifdef __cplusplus
+ }
+ #endif /* __cpluslus */
+
#endif /* !GPR_WIN32 */
+
diff --git a/templates/src/python/grpcio/grpc/_cython/imports.generated.h.template b/templates/src/python/grpcio/grpc/_cython/imports.generated.h.template
index 6866a61c..8e7c183 100644
--- a/templates/src/python/grpcio/grpc/_cython/imports.generated.h.template
+++ b/templates/src/python/grpcio/grpc/_cython/imports.generated.h.template
@@ -52,8 +52,16 @@
#define ${api.name} ${api.name}_import
%endfor
+ #ifdef __cplusplus
+ extern "C" {
+ #endif /* __cpluslus */
+
void pygrpc_load_imports(HMODULE library);
+ #ifdef __cplusplus
+ }
+ #endif /* __cpluslus */
+
#else /* !GPR_WIN32 */
#include <grpc/support/alloc.h>
diff --git a/test/core/census/log_test.c b/test/core/census/log_test.c
new file mode 100644
index 0000000..b68ca11
--- /dev/null
+++ b/test/core/census/log_test.c
@@ -0,0 +1,589 @@
+/*
+ *
+ * Copyright 2015-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/census/log.h"
+#include <grpc/support/cpu.h>
+#include <grpc/support/log.h>
+#include <grpc/support/port_platform.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/thd.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "test/core/util/test_config.h"
+
+// Change this to non-zero if you want more output.
+#define VERBOSE 0
+
+// Log size to use for all tests.
+#define LOG_SIZE_IN_MB 1
+#define LOG_SIZE_IN_BYTES (LOG_SIZE_IN_MB << 20)
+
+// Fills in 'record' of size 'size'. Each byte in record is filled in with the
+// same value. The value is extracted from 'record' pointer.
+static void write_record(char* record, size_t size) {
+ char data = (char)((uintptr_t)record % 255);
+ memset(record, data, size);
+}
+
+// Reads fixed size records. Returns the number of records read in
+// 'num_records'.
+static void read_records(size_t record_size, const char* buffer,
+ size_t buffer_size, int* num_records) {
+ GPR_ASSERT(buffer_size >= record_size);
+ GPR_ASSERT(buffer_size % record_size == 0);
+ *num_records = (int)(buffer_size / record_size);
+ for (int i = 0; i < *num_records; ++i) {
+ const char* record = buffer + (record_size * (size_t)i);
+ char data = (char)((uintptr_t)record % 255);
+ for (size_t j = 0; j < record_size; ++j) {
+ GPR_ASSERT(data == record[j]);
+ }
+ }
+}
+
+// Tries to write the specified number of records. Stops when the log gets
+// full. Returns the number of records written. Spins for random
+// number of times, up to 'max_spin_count', between writes.
+static int write_records_to_log(int writer_id, size_t record_size,
+ int num_records, int max_spin_count) {
+ int counter = 0;
+ for (int i = 0; i < num_records; ++i) {
+ int spin_count = max_spin_count ? rand() % max_spin_count : 0;
+ if (VERBOSE && (counter++ == num_records / 10)) {
+ printf(" Writer %d: %d out of %d written\n", writer_id, i, num_records);
+ counter = 0;
+ }
+ char* record = (char*)(census_log_start_write(record_size));
+ if (record == NULL) {
+ return i;
+ }
+ write_record(record, record_size);
+ census_log_end_write(record, record_size);
+ for (int j = 0; j < spin_count; ++j) {
+ GPR_ASSERT(j >= 0);
+ }
+ }
+ return num_records;
+}
+
+// Performs a single read iteration. Returns the number of records read.
+static int perform_read_iteration(size_t record_size) {
+ const void* read_buffer = NULL;
+ size_t bytes_available;
+ int records_read = 0;
+ census_log_init_reader();
+ while ((read_buffer = census_log_read_next(&bytes_available))) {
+ int num_records = 0;
+ read_records(record_size, (const char*)read_buffer, bytes_available,
+ &num_records);
+ records_read += num_records;
+ }
+ return records_read;
+}
+
+// Asserts that the log is empty.
+static void assert_log_empty(void) {
+ census_log_init_reader();
+ size_t bytes_available;
+ GPR_ASSERT(census_log_read_next(&bytes_available) == NULL);
+}
+
+// Fills the log and verifies data. If 'no fragmentation' is true, records
+// are sized such that CENSUS_LOG_2_MAX_RECORD_SIZE is a multiple of record
+// size. If not a circular log, verifies that the number of records written
+// match the number of records read.
+static void fill_log(size_t log_size, int no_fragmentation, int circular_log) {
+ size_t size;
+ if (no_fragmentation) {
+ int log2size = rand() % (CENSUS_LOG_2_MAX_RECORD_SIZE + 1);
+ size = ((size_t)1 << log2size);
+ } else {
+ while (1) {
+ size = 1 + ((size_t)rand() % CENSUS_LOG_MAX_RECORD_SIZE);
+ if (CENSUS_LOG_MAX_RECORD_SIZE % size) {
+ break;
+ }
+ }
+ }
+ int records_written =
+ write_records_to_log(0 /* writer id */, size,
+ (int)((log_size / size) * 2), 0 /* spin count */);
+ int records_read = perform_read_iteration(size);
+ if (!circular_log) {
+ GPR_ASSERT(records_written == records_read);
+ }
+ assert_log_empty();
+}
+
+// Structure to pass args to writer_thread
+typedef struct writer_thread_args {
+ // Index of this thread in the writers vector.
+ int index;
+ // Record size.
+ size_t record_size;
+ // Number of records to write.
+ int num_records;
+ // Used to signal when writer is complete
+ gpr_cv* done;
+ gpr_mu* mu;
+ int* count;
+} writer_thread_args;
+
+// Writes the given number of records of random size (up to kMaxRecordSize) and
+// random data to the specified log.
+static void writer_thread(void* arg) {
+ writer_thread_args* args = (writer_thread_args*)arg;
+ // Maximum number of times to spin between writes.
+ static const int MAX_SPIN_COUNT = 50;
+ int records_written = 0;
+ if (VERBOSE) {
+ printf(" Writer %d starting\n", args->index);
+ }
+ while (records_written < args->num_records) {
+ records_written += write_records_to_log(args->index, args->record_size,
+ args->num_records - records_written,
+ MAX_SPIN_COUNT);
+ if (records_written < args->num_records) {
+ // Ran out of log space. Sleep for a bit and let the reader catch up.
+ // This should never happen for circular logs.
+ if (VERBOSE) {
+ printf(
+ " Writer %d stalled due to out-of-space: %d out of %d "
+ "written\n",
+ args->index, records_written, args->num_records);
+ }
+ gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10));
+ }
+ }
+ // Done. Decrement count and signal.
+ gpr_mu_lock(args->mu);
+ (*args->count)--;
+ gpr_cv_signal(args->done);
+ if (VERBOSE) {
+ printf(" Writer %d done\n", args->index);
+ }
+ gpr_mu_unlock(args->mu);
+}
+
+// struct to pass args to reader_thread
+typedef struct reader_thread_args {
+ // Record size.
+ size_t record_size;
+ // Interval between read iterations.
+ int read_iteration_interval_in_msec;
+ // Total number of records.
+ int total_records;
+ // Signalled when reader should stop.
+ gpr_cv stop;
+ int stop_flag;
+ // Used to signal when reader has finished
+ gpr_cv* done;
+ gpr_mu* mu;
+ int running;
+} reader_thread_args;
+
+// Reads and verifies the specified number of records. Reader can also be
+// stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec'
+// between read iterations.
+static void reader_thread(void* arg) {
+ reader_thread_args* args = (reader_thread_args*)arg;
+ if (VERBOSE) {
+ printf(" Reader starting\n");
+ }
+ gpr_timespec interval = gpr_time_from_micros(
+ args->read_iteration_interval_in_msec * 1000, GPR_TIMESPAN);
+ gpr_mu_lock(args->mu);
+ int records_read = 0;
+ int num_iterations = 0;
+ int counter = 0;
+ while (!args->stop_flag && records_read < args->total_records) {
+ gpr_cv_wait(&args->stop, args->mu, interval);
+ if (!args->stop_flag) {
+ records_read += perform_read_iteration(args->record_size);
+ GPR_ASSERT(records_read <= args->total_records);
+ if (VERBOSE && (counter++ == 100000)) {
+ printf(" Reader: %d out of %d read\n", records_read,
+ args->total_records);
+ counter = 0;
+ }
+ ++num_iterations;
+ }
+ }
+ // Done
+ args->running = 0;
+ gpr_cv_signal(args->done);
+ if (VERBOSE) {
+ printf(" Reader: records: %d, iterations: %d\n", records_read,
+ num_iterations);
+ }
+ gpr_mu_unlock(args->mu);
+}
+
+// Creates NUM_WRITERS writers where each writer writes NUM_RECORDS_PER_WRITER
+// records. Also, starts a reader that iterates over and reads blocks every
+// READ_ITERATION_INTERVAL_IN_MSEC.
+// Number of writers.
+#define NUM_WRITERS 5
+static void multiple_writers_single_reader(int circular_log) {
+ // Sleep interval between read iterations.
+ static const int READ_ITERATION_INTERVAL_IN_MSEC = 10;
+ // Maximum record size.
+ static const size_t MAX_RECORD_SIZE = 20;
+ // Number of records written by each writer. This is sized such that we
+ // will write through the entire log ~10 times.
+ const int NUM_RECORDS_PER_WRITER =
+ (int)((10 * census_log_remaining_space()) / (MAX_RECORD_SIZE / 2)) /
+ NUM_WRITERS;
+ size_t record_size = ((size_t)rand() % MAX_RECORD_SIZE) + 1;
+ // Create and start writers.
+ writer_thread_args writers[NUM_WRITERS];
+ int writers_count = NUM_WRITERS;
+ gpr_cv writers_done;
+ gpr_mu writers_mu; // protects writers_done and writers_count
+ gpr_cv_init(&writers_done);
+ gpr_mu_init(&writers_mu);
+ gpr_thd_id id;
+ for (int i = 0; i < NUM_WRITERS; ++i) {
+ writers[i].index = i;
+ writers[i].record_size = record_size;
+ writers[i].num_records = NUM_RECORDS_PER_WRITER;
+ writers[i].done = &writers_done;
+ writers[i].count = &writers_count;
+ writers[i].mu = &writers_mu;
+ gpr_thd_new(&id, &writer_thread, &writers[i], NULL);
+ }
+ // Start reader.
+ gpr_cv reader_done;
+ gpr_mu reader_mu; // protects reader_done and reader.running
+ reader_thread_args reader;
+ reader.record_size = record_size;
+ reader.read_iteration_interval_in_msec = READ_ITERATION_INTERVAL_IN_MSEC;
+ reader.total_records = NUM_WRITERS * NUM_RECORDS_PER_WRITER;
+ reader.stop_flag = 0;
+ gpr_cv_init(&reader.stop);
+ gpr_cv_init(&reader_done);
+ reader.done = &reader_done;
+ gpr_mu_init(&reader_mu);
+ reader.mu = &reader_mu;
+ reader.running = 1;
+ gpr_thd_new(&id, &reader_thread, &reader, NULL);
+ // Wait for writers to finish.
+ gpr_mu_lock(&writers_mu);
+ while (writers_count != 0) {
+ gpr_cv_wait(&writers_done, &writers_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ }
+ gpr_mu_unlock(&writers_mu);
+ gpr_mu_destroy(&writers_mu);
+ gpr_cv_destroy(&writers_done);
+ gpr_mu_lock(&reader_mu);
+ if (circular_log) {
+ // Stop reader.
+ reader.stop_flag = 1;
+ gpr_cv_signal(&reader.stop);
+ }
+ // wait for reader to finish
+ while (reader.running) {
+ gpr_cv_wait(&reader_done, &reader_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
+ }
+ if (circular_log) {
+ // Assert that there were no out-of-space errors.
+ GPR_ASSERT(0 == census_log_out_of_space_count());
+ }
+ gpr_mu_unlock(&reader_mu);
+ gpr_mu_destroy(&reader_mu);
+ gpr_cv_destroy(&reader_done);
+ if (VERBOSE) {
+ printf(" Reader: finished\n");
+ }
+}
+
+static void setup_test(int circular_log) {
+ census_log_initialize(LOG_SIZE_IN_MB, circular_log);
+ GPR_ASSERT(census_log_remaining_space() == LOG_SIZE_IN_BYTES);
+}
+
+// Attempts to create a record of invalid size (size >
+// CENSUS_LOG_MAX_RECORD_SIZE).
+void test_invalid_record_size(void) {
+ static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1;
+ static const size_t VALID_SIZE = 1;
+ printf("Starting test: invalid record size\n");
+ setup_test(0);
+ void* record = census_log_start_write(INVALID_SIZE);
+ GPR_ASSERT(record == NULL);
+ // Now try writing a valid record.
+ record = census_log_start_write(VALID_SIZE);
+ GPR_ASSERT(record != NULL);
+ census_log_end_write(record, VALID_SIZE);
+ // Verifies that available space went down by one block. In theory, this
+ // check can fail if the thread is context switched to a new CPU during the
+ // start_write execution (multiple blocks get allocated), but this has not
+ // been observed in practice.
+ GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
+ census_log_remaining_space());
+ census_log_shutdown();
+}
+
+// Tests end_write() with a different size than what was specified in
+// start_write().
+void test_end_write_with_different_size(void) {
+ static const size_t START_WRITE_SIZE = 10;
+ static const size_t END_WRITE_SIZE = 7;
+ printf("Starting test: end write with different size\n");
+ setup_test(0);
+ void* record_written = census_log_start_write(START_WRITE_SIZE);
+ GPR_ASSERT(record_written != NULL);
+ census_log_end_write(record_written, END_WRITE_SIZE);
+ census_log_init_reader();
+ size_t bytes_available;
+ const void* record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(record_written == record_read);
+ GPR_ASSERT(END_WRITE_SIZE == bytes_available);
+ assert_log_empty();
+ census_log_shutdown();
+}
+
+// Verifies that pending records are not available via read_next().
+void test_read_pending_record(void) {
+ static const size_t PR_RECORD_SIZE = 1024;
+ printf("Starting test: read pending record\n");
+ setup_test(0);
+ // Start a write.
+ void* record_written = census_log_start_write(PR_RECORD_SIZE);
+ GPR_ASSERT(record_written != NULL);
+ // As write is pending, read should fail.
+ census_log_init_reader();
+ size_t bytes_available;
+ const void* record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(record_read == NULL);
+ // A read followed by end_write() should succeed.
+ census_log_end_write(record_written, PR_RECORD_SIZE);
+ census_log_init_reader();
+ record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(record_written == record_read);
+ GPR_ASSERT(PR_RECORD_SIZE == bytes_available);
+ assert_log_empty();
+ census_log_shutdown();
+}
+
+// Tries reading beyond pending write.
+void test_read_beyond_pending_record(void) {
+ printf("Starting test: read beyond pending record\n");
+ setup_test(0);
+ // Start a write.
+ const size_t incomplete_record_size = 10;
+ void* incomplete_record = census_log_start_write(incomplete_record_size);
+ GPR_ASSERT(incomplete_record != NULL);
+ const size_t complete_record_size = 20;
+ void* complete_record = census_log_start_write(complete_record_size);
+ GPR_ASSERT(complete_record != NULL);
+ GPR_ASSERT(complete_record != incomplete_record);
+ census_log_end_write(complete_record, complete_record_size);
+ // Now iterate over blocks to read completed records.
+ census_log_init_reader();
+ size_t bytes_available;
+ const void* record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(complete_record == record_read);
+ GPR_ASSERT(complete_record_size == bytes_available);
+ // Complete first record.
+ census_log_end_write(incomplete_record, incomplete_record_size);
+ // Have read past the incomplete record, so read_next() should return NULL.
+ // NB: this test also assumes our thread did not get switched to a different
+ // CPU between the two start_write calls
+ record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(record_read == NULL);
+ // Reset reader to get the newly completed record.
+ census_log_init_reader();
+ record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(incomplete_record == record_read);
+ GPR_ASSERT(incomplete_record_size == bytes_available);
+ assert_log_empty();
+ census_log_shutdown();
+}
+
+// Tests scenario where block being read is detached from a core and put on the
+// dirty list.
+void test_detached_while_reading(void) {
+ printf("Starting test: detached while reading\n");
+ setup_test(0);
+ // Start a write.
+ static const size_t DWR_RECORD_SIZE = 10;
+ void* record_written = census_log_start_write(DWR_RECORD_SIZE);
+ GPR_ASSERT(record_written != NULL);
+ census_log_end_write(record_written, DWR_RECORD_SIZE);
+ // Read this record.
+ census_log_init_reader();
+ size_t bytes_available;
+ const void* record_read = census_log_read_next(&bytes_available);
+ GPR_ASSERT(record_read != NULL);
+ GPR_ASSERT(DWR_RECORD_SIZE == bytes_available);
+ // Now fill the log. This will move the block being read from core-local
+ // array to the dirty list.
+ while ((record_written = census_log_start_write(DWR_RECORD_SIZE))) {
+ census_log_end_write(record_written, DWR_RECORD_SIZE);
+ }
+
+ // In this iteration, read_next() should only traverse blocks in the
+ // core-local array. Therefore, we expect at most gpr_cpu_num_cores() more
+ // blocks. As log is full, if read_next() is traversing the dirty list, we
+ // will get more than gpr_cpu_num_cores() blocks.
+ int block_read = 0;
+ while ((record_read = census_log_read_next(&bytes_available))) {
+ ++block_read;
+ GPR_ASSERT(block_read <= (int)gpr_cpu_num_cores());
+ }
+ census_log_shutdown();
+}
+
+// Fills non-circular log with records sized such that size is a multiple of
+// CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation).
+void test_fill_log_no_fragmentation(void) {
+ printf("Starting test: fill log no fragmentation\n");
+ const int circular = 0;
+ setup_test(circular);
+ fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
+ census_log_shutdown();
+}
+
+// Fills circular log with records sized such that size is a multiple of
+// CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation).
+void test_fill_circular_log_no_fragmentation(void) {
+ printf("Starting test: fill circular log no fragmentation\n");
+ const int circular = 1;
+ setup_test(circular);
+ fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
+ census_log_shutdown();
+}
+
+// Fills non-circular log with records that may straddle end of a block.
+void test_fill_log_with_straddling_records(void) {
+ printf("Starting test: fill log with straddling records\n");
+ const int circular = 0;
+ setup_test(circular);
+ fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
+ census_log_shutdown();
+}
+
+// Fills circular log with records that may straddle end of a block.
+void test_fill_circular_log_with_straddling_records(void) {
+ printf("Starting test: fill circular log with straddling records\n");
+ const int circular = 1;
+ setup_test(circular);
+ fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
+ census_log_shutdown();
+}
+
+// Tests scenario where multiple writers and a single reader are using a log
+// that is configured to discard old records.
+void test_multiple_writers_circular_log(void) {
+ printf("Starting test: multiple writers circular log\n");
+ const int circular = 1;
+ setup_test(circular);
+ multiple_writers_single_reader(circular);
+ census_log_shutdown();
+}
+
+// Tests scenario where multiple writers and a single reader are using a log
+// that is configured to discard old records.
+void test_multiple_writers(void) {
+ printf("Starting test: multiple writers\n");
+ const int circular = 0;
+ setup_test(circular);
+ multiple_writers_single_reader(circular);
+ census_log_shutdown();
+}
+
+// Repeat the straddling records and multiple writers tests with a small log.
+void test_small_log(void) {
+ printf("Starting test: small log\n");
+ const int circular = 0;
+ census_log_initialize(0, circular);
+ size_t log_size = census_log_remaining_space();
+ GPR_ASSERT(log_size > 0);
+ fill_log(log_size, 0, circular);
+ census_log_shutdown();
+ census_log_initialize(0, circular);
+ multiple_writers_single_reader(circular);
+ census_log_shutdown();
+}
+
+void test_performance(void) {
+ for (size_t write_size = 1; write_size < CENSUS_LOG_MAX_RECORD_SIZE;
+ write_size *= 2) {
+ setup_test(0);
+ gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME);
+ int nrecords = 0;
+ while (1) {
+ void* record = census_log_start_write(write_size);
+ if (record == NULL) {
+ break;
+ }
+ census_log_end_write(record, write_size);
+ nrecords++;
+ }
+ gpr_timespec write_time =
+ gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time);
+ double write_time_micro =
+ (double)write_time.tv_sec * 1000000 + (double)write_time.tv_nsec / 1000;
+ census_log_shutdown();
+ printf(
+ "Wrote %d %d byte records in %.3g microseconds: %g records/us "
+ "(%g ns/record), %g gigabytes/s\n",
+ nrecords, (int)write_size, write_time_micro,
+ nrecords / write_time_micro, 1000 * write_time_micro / nrecords,
+ (double)((int)write_size * nrecords) / write_time_micro / 1000);
+ }
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ gpr_time_init();
+ srand((unsigned)gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
+ test_invalid_record_size();
+ test_end_write_with_different_size();
+ test_read_pending_record();
+ test_read_beyond_pending_record();
+ test_detached_while_reading();
+ test_fill_log_no_fragmentation();
+ test_fill_circular_log_no_fragmentation();
+ test_fill_log_with_straddling_records();
+ test_fill_circular_log_with_straddling_records();
+ test_small_log();
+ test_multiple_writers();
+ test_multiple_writers_circular_log();
+ test_performance();
+ return 0;
+}
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 85e2873..2e253d8 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -173,7 +173,7 @@
grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, int success) {
+static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool success) {
grpc_pollset_destroy(p);
}
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 50b2bf2..c94a523 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -41,6 +41,7 @@
#include <grpc++/support/byte_buffer.h>
#include <grpc++/support/slice.h>
#include <grpc/support/log.h>
+#include <grpc/support/time.h>
#include "src/proto/grpc/testing/payloads.grpc.pb.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
@@ -52,27 +53,8 @@
#include "test/cpp/util/create_test_channel.h"
namespace grpc {
-
-#if defined(__APPLE__)
-// Specialize Timepoint for high res clock as we need that
-template <>
-class TimePoint<std::chrono::high_resolution_clock::time_point> {
- public:
- TimePoint(const std::chrono::high_resolution_clock::time_point& time) {
- TimepointHR2Timespec(time, &time_);
- }
- gpr_timespec raw_time() const { return time_; }
-
- private:
- gpr_timespec time_;
-};
-#endif
-
namespace testing {
-typedef std::chrono::high_resolution_clock grpc_time_source;
-typedef std::chrono::time_point<grpc_time_source> grpc_time;
-
template <class RequestType>
class ClientRequestCreator {
public:
@@ -184,7 +166,7 @@
// Set up the load distribution based on the number of threads
const auto& load = config.load_params();
- std::unique_ptr<RandomDist> random_dist;
+ std::unique_ptr<RandomDistInterface> random_dist;
switch (load.load_case()) {
case LoadParams::kClosedLoop:
// Closed-loop doesn't use random dist at all
@@ -218,25 +200,26 @@
closed_loop_ = false;
// set up interarrival timer according to random dist
interarrival_timer_.init(*random_dist, num_threads);
+ const auto now = gpr_now(GPR_CLOCK_MONOTONIC);
for (size_t i = 0; i < num_threads; i++) {
- next_time_.push_back(
- grpc_time_source::now() +
- std::chrono::duration_cast<grpc_time_source::duration>(
- interarrival_timer_(i)));
+ next_time_.push_back(gpr_time_add(
+ now,
+ gpr_time_from_nanos(interarrival_timer_.next(i), GPR_TIMESPAN)));
}
}
}
- bool NextIssueTime(int thread_idx, grpc_time* time_delay) {
- if (closed_loop_) {
- return false;
- } else {
- *time_delay = next_time_[thread_idx];
- next_time_[thread_idx] +=
- std::chrono::duration_cast<grpc_time_source::duration>(
- interarrival_timer_(thread_idx));
- return true;
- }
+ gpr_timespec NextIssueTime(int thread_idx) {
+ const gpr_timespec result = next_time_[thread_idx];
+ next_time_[thread_idx] =
+ gpr_time_add(next_time_[thread_idx],
+ gpr_time_from_nanos(interarrival_timer_.next(thread_idx),
+ GPR_TIMESPAN));
+ return result;
+ }
+ std::function<gpr_timespec()> NextIssuer(int thread_idx) {
+ return closed_loop_ ? std::function<gpr_timespec()>()
+ : std::bind(&Client::NextIssueTime, this, thread_idx);
}
private:
@@ -306,7 +289,7 @@
Histogram* new_stats_;
Histogram histogram_;
Client* client_;
- size_t idx_;
+ const size_t idx_;
std::thread impl_;
};
@@ -314,7 +297,7 @@
std::unique_ptr<Timer> timer_;
InterarrivalTimer interarrival_timer_;
- std::vector<grpc_time> next_time_;
+ std::vector<gpr_timespec> next_time_;
};
template <class StubType, class RequestType>
@@ -323,9 +306,9 @@
ClientImpl(const ClientConfig& config,
std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)>
create_stub)
- : channels_(config.client_channels()), create_stub_(create_stub) {
- cores_ = LimitCores(config.core_list().data(), config.core_list_size());
-
+ : cores_(LimitCores(config.core_list().data(), config.core_list_size())),
+ channels_(config.client_channels()),
+ create_stub_(create_stub) {
for (int i = 0; i < config.client_channels(); i++) {
channels_[i].init(config.server_targets(i % config.server_targets_size()),
config, create_stub_);
@@ -337,7 +320,7 @@
virtual ~ClientImpl() {}
protected:
- int cores_;
+ const int cores_;
RequestType request_;
class ClientChannelInfo {
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index f3f8f37..9e8767d 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -43,9 +43,9 @@
#include <vector>
#include <gflags/gflags.h>
+#include <grpc++/alarm.h>
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
-#include <grpc++/client_context.h>
#include <grpc++/generic/generic_stub.h>
#include <grpc/grpc.h>
#include <grpc/support/cpu.h>
@@ -60,11 +60,9 @@
namespace grpc {
namespace testing {
-typedef std::list<grpc_time> deadline_list;
-
class ClientRpcContext {
public:
- explicit ClientRpcContext(int ch) : channel_id_(ch) {}
+ ClientRpcContext() {}
virtual ~ClientRpcContext() {}
// next state, return false if done. Collect stats when appropriate
virtual bool RunNextState(bool, Histogram* hist) = 0;
@@ -74,72 +72,73 @@
return reinterpret_cast<ClientRpcContext*>(t);
}
- deadline_list::iterator deadline_posn() const { return deadline_posn_; }
- void set_deadline_posn(const deadline_list::iterator& it) {
- deadline_posn_ = it;
- }
virtual void Start(CompletionQueue* cq) = 0;
- int channel_id() const { return channel_id_; }
-
- protected:
- int channel_id_;
-
- private:
- deadline_list::iterator deadline_posn_;
};
template <class RequestType, class ResponseType>
class ClientRpcContextUnaryImpl : public ClientRpcContext {
public:
ClientRpcContextUnaryImpl(
- int channel_id, BenchmarkService::Stub* stub, const RequestType& req,
+ BenchmarkService::Stub* stub, const RequestType& req,
+ std::function<gpr_timespec()> next_issue,
std::function<
std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&,
CompletionQueue*)> start_req,
std::function<void(grpc::Status, ResponseType*)> on_done)
- : ClientRpcContext(channel_id),
- context_(),
+ : context_(),
stub_(stub),
+ cq_(nullptr),
req_(req),
response_(),
- next_state_(&ClientRpcContextUnaryImpl::RespDone),
+ next_state_(State::READY),
callback_(on_done),
+ next_issue_(next_issue),
start_req_(start_req) {}
- void Start(CompletionQueue* cq) GRPC_OVERRIDE {
- start_ = Timer::Now();
- response_reader_ = start_req_(stub_, &context_, req_, cq);
- response_reader_->Finish(&response_, &status_, ClientRpcContext::tag(this));
- }
~ClientRpcContextUnaryImpl() GRPC_OVERRIDE {}
- bool RunNextState(bool ok, Histogram* hist) GRPC_OVERRIDE {
- bool ret = (this->*next_state_)(ok);
- if (!ret) {
- hist->Add((Timer::Now() - start_) * 1e9);
+ void Start(CompletionQueue* cq) GRPC_OVERRIDE {
+ cq_ = cq;
+ if (!next_issue_) { // ready to issue
+ RunNextState(true, nullptr);
+ } else { // wait for the issue time
+ alarm_.reset(new Alarm(cq_, next_issue_(), ClientRpcContext::tag(this)));
}
- return ret;
}
-
+ bool RunNextState(bool ok, Histogram* hist) GRPC_OVERRIDE {
+ switch (next_state_) {
+ case State::READY:
+ start_ = Timer::Now();
+ response_reader_ = start_req_(stub_, &context_, req_, cq_);
+ response_reader_->Finish(&response_, &status_,
+ ClientRpcContext::tag(this));
+ next_state_ = State::RESP_DONE;
+ return true;
+ case State::RESP_DONE:
+ hist->Add((Timer::Now() - start_) * 1e9);
+ callback_(status_, &response_);
+ next_state_ = State::INVALID;
+ return false;
+ default:
+ GPR_ASSERT(false);
+ return false;
+ }
+ }
ClientRpcContext* StartNewClone() GRPC_OVERRIDE {
- return new ClientRpcContextUnaryImpl(channel_id_, stub_, req_, start_req_,
+ return new ClientRpcContextUnaryImpl(stub_, req_, next_issue_, start_req_,
callback_);
}
private:
- bool RespDone(bool) {
- next_state_ = &ClientRpcContextUnaryImpl::DoCallBack;
- return false;
- }
- bool DoCallBack(bool) {
- callback_(status_, &response_);
- return true; // we're done, this'll be ignored
- }
grpc::ClientContext context_;
BenchmarkService::Stub* stub_;
+ CompletionQueue* cq_;
+ std::unique_ptr<Alarm> alarm_;
RequestType req_;
ResponseType response_;
- bool (ClientRpcContextUnaryImpl::*next_state_)(bool);
+ enum State { INVALID, READY, RESP_DONE };
+ State next_state_;
std::function<void(grpc::Status, ResponseType*)> callback_;
+ std::function<gpr_timespec()> next_issue_;
std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&,
CompletionQueue*)> start_req_;
@@ -157,49 +156,35 @@
// member name resolution until the template types are fully resolved
public:
using Client::SetupLoadTest;
- using Client::NextIssueTime;
using Client::closed_loop_;
+ using Client::NextIssuer;
using ClientImpl<StubType, RequestType>::cores_;
using ClientImpl<StubType, RequestType>::channels_;
using ClientImpl<StubType, RequestType>::request_;
AsyncClient(const ClientConfig& config,
- std::function<ClientRpcContext*(int, StubType*,
- const RequestType&)> setup_ctx,
+ std::function<ClientRpcContext*(
+ StubType*, std::function<gpr_timespec()> next_issue,
+ const RequestType&)> setup_ctx,
std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)>
create_stub)
: ClientImpl<StubType, RequestType>(config, create_stub),
- num_async_threads_(NumThreads(config)),
- channel_lock_(new std::mutex[config.client_channels()]),
- contexts_(config.client_channels()),
- max_outstanding_per_channel_(config.outstanding_rpcs_per_channel()),
- channel_count_(config.client_channels()),
- pref_channel_inc_(num_async_threads_) {
+ num_async_threads_(NumThreads(config)) {
SetupLoadTest(config, num_async_threads_);
for (int i = 0; i < num_async_threads_; i++) {
cli_cqs_.emplace_back(new CompletionQueue);
- if (!closed_loop_) {
- rpc_deadlines_.emplace_back();
- next_channel_.push_back(i % channel_count_);
- issue_allowed_.emplace_back(true);
-
- grpc_time next_issue;
- NextIssueTime(i, &next_issue);
- next_issue_.push_back(next_issue);
- }
+ next_issuers_.emplace_back(NextIssuer(i));
}
+ using namespace std::placeholders;
int t = 0;
for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) {
- for (int ch = 0; ch < channel_count_; ch++) {
+ for (int ch = 0; ch < config.client_channels(); ch++) {
auto* cq = cli_cqs_[t].get();
+ auto ctx =
+ setup_ctx(channels_[ch].get_stub(), next_issuers_[t], request_);
+ ctx->Start(cq);
t = (t + 1) % cli_cqs_.size();
- auto ctx = setup_ctx(ch, channels_[ch].get_stub(), request_);
- if (closed_loop_) {
- ctx->Start(cq);
- } else {
- contexts_[ch].push_front(ctx);
- }
}
}
}
@@ -212,140 +197,34 @@
delete ClientRpcContext::detag(got_tag);
}
}
- // Now clear out all the pre-allocated idle contexts
- for (int ch = 0; ch < channel_count_; ch++) {
- while (!contexts_[ch].empty()) {
- // Get an idle context from the front of the list
- auto* ctx = *(contexts_[ch].begin());
- contexts_[ch].pop_front();
- delete ctx;
- }
- }
- delete[] channel_lock_;
}
bool ThreadFunc(Histogram* histogram,
size_t thread_idx) GRPC_OVERRIDE GRPC_FINAL {
void* got_tag;
bool ok;
- grpc_time deadline, short_deadline;
- if (closed_loop_) {
- deadline = grpc_time_source::now() + std::chrono::seconds(1);
- short_deadline = deadline;
- } else {
- if (rpc_deadlines_[thread_idx].empty()) {
- deadline = grpc_time_source::now() + std::chrono::seconds(1);
- } else {
- deadline = *(rpc_deadlines_[thread_idx].begin());
- }
- short_deadline =
- issue_allowed_[thread_idx] ? next_issue_[thread_idx] : deadline;
- }
- bool got_event;
-
- switch (cli_cqs_[thread_idx]->AsyncNext(&got_tag, &ok, short_deadline)) {
- case CompletionQueue::SHUTDOWN:
- return false;
- case CompletionQueue::TIMEOUT:
- got_event = false;
- break;
- case CompletionQueue::GOT_EVENT:
- got_event = true;
- break;
- default:
- GPR_ASSERT(false);
- break;
- }
- if (got_event) {
+ if (cli_cqs_[thread_idx]->Next(&got_tag, &ok)) {
+ // Got a regular event, so process it
ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
- if (ctx->RunNextState(ok, histogram) == false) {
- // call the callback and then clone the ctx
- ctx->RunNextState(ok, histogram);
- ClientRpcContext* clone_ctx = ctx->StartNewClone();
- if (closed_loop_) {
- clone_ctx->Start(cli_cqs_[thread_idx].get());
- } else {
- // Remove the entry from the rpc deadlines list
- rpc_deadlines_[thread_idx].erase(ctx->deadline_posn());
- // Put the clone_ctx in the list of idle contexts for this channel
- // Under lock
- int ch = clone_ctx->channel_id();
- std::lock_guard<std::mutex> g(channel_lock_[ch]);
- contexts_[ch].push_front(clone_ctx);
- }
+ if (!ctx->RunNextState(ok, histogram)) {
+ // The RPC and callback are done, so clone the ctx
+ // and kickstart the new one
+ auto clone = ctx->StartNewClone();
+ clone->Start(cli_cqs_[thread_idx].get());
// delete the old version
delete ctx;
}
- if (!closed_loop_)
- issue_allowed_[thread_idx] =
- true; // may be ok now even if it hadn't been
+ return true;
+ } else { // queue is shutting down
+ return false;
}
- if (!closed_loop_ && issue_allowed_[thread_idx] &&
- grpc_time_source::now() >= next_issue_[thread_idx]) {
- // Attempt to issue
- bool issued = false;
- for (int num_attempts = 0, channel_attempt = next_channel_[thread_idx];
- num_attempts < channel_count_ && !issued; num_attempts++) {
- bool can_issue = false;
- ClientRpcContext* ctx = nullptr;
- {
- std::lock_guard<std::mutex> g(channel_lock_[channel_attempt]);
- if (!contexts_[channel_attempt].empty()) {
- // Get an idle context from the front of the list
- ctx = *(contexts_[channel_attempt].begin());
- contexts_[channel_attempt].pop_front();
- can_issue = true;
- }
- }
- if (can_issue) {
- // do the work to issue
- rpc_deadlines_[thread_idx].emplace_back(grpc_time_source::now() +
- std::chrono::seconds(1));
- auto it = rpc_deadlines_[thread_idx].end();
- --it;
- ctx->set_deadline_posn(it);
- ctx->Start(cli_cqs_[thread_idx].get());
- issued = true;
- // If we did issue, then next time, try our thread's next
- // preferred channel
- next_channel_[thread_idx] += pref_channel_inc_;
- if (next_channel_[thread_idx] >= channel_count_)
- next_channel_[thread_idx] = (thread_idx % channel_count_);
- } else {
- // Do a modular increment of channel attempt if we couldn't issue
- channel_attempt = (channel_attempt + 1) % channel_count_;
- }
- }
- if (issued) {
- // We issued one; see when we can issue the next
- grpc_time next_issue;
- NextIssueTime(thread_idx, &next_issue);
- next_issue_[thread_idx] = next_issue;
- } else {
- issue_allowed_[thread_idx] = false;
- }
- }
- return true;
}
protected:
- int num_async_threads_;
+ const int num_async_threads_;
private:
- class boolean { // exists only to avoid data-race on vector<bool>
- public:
- boolean() : val_(false) {}
- boolean(bool b) : val_(b) {}
- operator bool() const { return val_; }
- boolean& operator=(bool b) {
- val_ = b;
- return *this;
- }
-
- private:
- bool val_;
- };
int NumThreads(const ClientConfig& config) {
int num_threads = config.async_client_threads();
if (num_threads <= 0) { // Use dynamic sizing
@@ -356,18 +235,7 @@
}
std::vector<std::unique_ptr<CompletionQueue>> cli_cqs_;
-
- std::vector<deadline_list> rpc_deadlines_; // per thread deadlines
- std::vector<int> next_channel_; // per thread round-robin channel ctr
- std::vector<boolean> issue_allowed_; // may this thread attempt to issue
- std::vector<grpc_time> next_issue_; // when should it issue?
-
- std::mutex*
- channel_lock_; // a vector, but avoid std::vector for old compilers
- std::vector<context_list> contexts_; // per-channel list of idle contexts
- int max_outstanding_per_channel_;
- int channel_count_;
- int pref_channel_inc_;
+ std::vector<std::function<gpr_timespec()>> next_issuers_;
};
static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator(
@@ -391,11 +259,11 @@
const SimpleRequest& request, CompletionQueue* cq) {
return stub->AsyncUnaryCall(ctx, request, cq);
};
- static ClientRpcContext* SetupCtx(int channel_id,
- BenchmarkService::Stub* stub,
+ static ClientRpcContext* SetupCtx(BenchmarkService::Stub* stub,
+ std::function<gpr_timespec()> next_issue,
const SimpleRequest& req) {
return new ClientRpcContextUnaryImpl<SimpleRequest, SimpleResponse>(
- channel_id, stub, req, AsyncUnaryClient::StartReq,
+ stub, req, next_issue, AsyncUnaryClient::StartReq,
AsyncUnaryClient::CheckDone);
}
};
@@ -404,62 +272,94 @@
class ClientRpcContextStreamingImpl : public ClientRpcContext {
public:
ClientRpcContextStreamingImpl(
- int channel_id, BenchmarkService::Stub* stub, const RequestType& req,
+ BenchmarkService::Stub* stub, const RequestType& req,
+ std::function<gpr_timespec()> next_issue,
std::function<std::unique_ptr<
grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>(
BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*,
void*)> start_req,
std::function<void(grpc::Status, ResponseType*)> on_done)
- : ClientRpcContext(channel_id),
- context_(),
+ : context_(),
stub_(stub),
+ cq_(nullptr),
req_(req),
response_(),
- next_state_(&ClientRpcContextStreamingImpl::ReqSent),
+ next_state_(State::INVALID),
callback_(on_done),
+ next_issue_(next_issue),
start_req_(start_req),
start_(Timer::Now()) {}
~ClientRpcContextStreamingImpl() GRPC_OVERRIDE {}
+ void Start(CompletionQueue* cq) GRPC_OVERRIDE {
+ cq_ = cq;
+ stream_ = start_req_(stub_, &context_, cq, ClientRpcContext::tag(this));
+ next_state_ = State::STREAM_IDLE;
+ }
bool RunNextState(bool ok, Histogram* hist) GRPC_OVERRIDE {
- return (this->*next_state_)(ok, hist);
+ while (true) {
+ switch (next_state_) {
+ case State::STREAM_IDLE:
+ if (!next_issue_) { // ready to issue
+ next_state_ = State::READY_TO_WRITE;
+ } else {
+ next_state_ = State::WAIT;
+ }
+ break; // loop around, don't return
+ case State::WAIT:
+ alarm_.reset(
+ new Alarm(cq_, next_issue_(), ClientRpcContext::tag(this)));
+ next_state_ = State::READY_TO_WRITE;
+ return true;
+ case State::READY_TO_WRITE:
+ if (!ok) {
+ return false;
+ }
+ start_ = Timer::Now();
+ next_state_ = State::WRITE_DONE;
+ stream_->Write(req_, ClientRpcContext::tag(this));
+ return true;
+ case State::WRITE_DONE:
+ if (!ok) {
+ return false;
+ }
+ next_state_ = State::READ_DONE;
+ stream_->Read(&response_, ClientRpcContext::tag(this));
+ return true;
+ break;
+ case State::READ_DONE:
+ hist->Add((Timer::Now() - start_) * 1e9);
+ callback_(status_, &response_);
+ next_state_ = State::STREAM_IDLE;
+ break; // loop around
+ default:
+ GPR_ASSERT(false);
+ return false;
+ }
+ }
}
ClientRpcContext* StartNewClone() GRPC_OVERRIDE {
- return new ClientRpcContextStreamingImpl(channel_id_, stub_, req_,
+ return new ClientRpcContextStreamingImpl(stub_, req_, next_issue_,
start_req_, callback_);
}
- void Start(CompletionQueue* cq) GRPC_OVERRIDE {
- stream_ = start_req_(stub_, &context_, cq, ClientRpcContext::tag(this));
- }
private:
- bool ReqSent(bool ok, Histogram*) { return StartWrite(ok); }
- bool StartWrite(bool ok) {
- if (!ok) {
- return (false);
- }
- start_ = Timer::Now();
- next_state_ = &ClientRpcContextStreamingImpl::WriteDone;
- stream_->Write(req_, ClientRpcContext::tag(this));
- return true;
- }
- bool WriteDone(bool ok, Histogram*) {
- if (!ok) {
- return (false);
- }
- next_state_ = &ClientRpcContextStreamingImpl::ReadDone;
- stream_->Read(&response_, ClientRpcContext::tag(this));
- return true;
- }
- bool ReadDone(bool ok, Histogram* hist) {
- hist->Add((Timer::Now() - start_) * 1e9);
- return StartWrite(ok);
- }
grpc::ClientContext context_;
BenchmarkService::Stub* stub_;
+ CompletionQueue* cq_;
+ std::unique_ptr<Alarm> alarm_;
RequestType req_;
ResponseType response_;
- bool (ClientRpcContextStreamingImpl::*next_state_)(bool, Histogram*);
+ enum State {
+ INVALID,
+ STREAM_IDLE,
+ WAIT,
+ READY_TO_WRITE,
+ WRITE_DONE,
+ READ_DONE
+ };
+ State next_state_;
std::function<void(grpc::Status, ResponseType*)> callback_;
+ std::function<gpr_timespec()> next_issue_;
std::function<
std::unique_ptr<grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>(
BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*,
@@ -475,9 +375,6 @@
public:
explicit AsyncStreamingClient(const ClientConfig& config)
: AsyncClient(config, SetupCtx, BenchmarkStubCreator) {
- // async streaming currently only supports closed loop
- GPR_ASSERT(closed_loop_);
-
StartThreads(num_async_threads_);
}
@@ -492,11 +389,11 @@
auto stream = stub->AsyncStreamingCall(ctx, cq, tag);
return stream;
};
- static ClientRpcContext* SetupCtx(int channel_id,
- BenchmarkService::Stub* stub,
+ static ClientRpcContext* SetupCtx(BenchmarkService::Stub* stub,
+ std::function<gpr_timespec()> next_issue,
const SimpleRequest& req) {
return new ClientRpcContextStreamingImpl<SimpleRequest, SimpleResponse>(
- channel_id, stub, req, AsyncStreamingClient::StartReq,
+ stub, req, next_issue, AsyncStreamingClient::StartReq,
AsyncStreamingClient::CheckDone);
}
};
@@ -504,64 +401,96 @@
class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
public:
ClientRpcContextGenericStreamingImpl(
- int channel_id, grpc::GenericStub* stub, const ByteBuffer& req,
+ grpc::GenericStub* stub, const ByteBuffer& req,
+ std::function<gpr_timespec()> next_issue,
std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>(
grpc::GenericStub*, grpc::ClientContext*,
const grpc::string& method_name, CompletionQueue*, void*)> start_req,
std::function<void(grpc::Status, ByteBuffer*)> on_done)
- : ClientRpcContext(channel_id),
- context_(),
+ : context_(),
stub_(stub),
+ cq_(nullptr),
req_(req),
response_(),
- next_state_(&ClientRpcContextGenericStreamingImpl::ReqSent),
+ next_state_(State::INVALID),
callback_(on_done),
+ next_issue_(next_issue),
start_req_(start_req),
start_(Timer::Now()) {}
~ClientRpcContextGenericStreamingImpl() GRPC_OVERRIDE {}
- bool RunNextState(bool ok, Histogram* hist) GRPC_OVERRIDE {
- return (this->*next_state_)(ok, hist);
- }
- ClientRpcContext* StartNewClone() GRPC_OVERRIDE {
- return new ClientRpcContextGenericStreamingImpl(channel_id_, stub_, req_,
- start_req_, callback_);
- }
void Start(CompletionQueue* cq) GRPC_OVERRIDE {
+ cq_ = cq;
const grpc::string kMethodName(
"/grpc.testing.BenchmarkService/StreamingCall");
stream_ = start_req_(stub_, &context_, kMethodName, cq,
ClientRpcContext::tag(this));
+ next_state_ = State::STREAM_IDLE;
+ }
+ bool RunNextState(bool ok, Histogram* hist) GRPC_OVERRIDE {
+ while (true) {
+ switch (next_state_) {
+ case State::STREAM_IDLE:
+ if (!next_issue_) { // ready to issue
+ next_state_ = State::READY_TO_WRITE;
+ } else {
+ next_state_ = State::WAIT;
+ }
+ break; // loop around, don't return
+ case State::WAIT:
+ alarm_.reset(
+ new Alarm(cq_, next_issue_(), ClientRpcContext::tag(this)));
+ next_state_ = State::READY_TO_WRITE;
+ return true;
+ case State::READY_TO_WRITE:
+ if (!ok) {
+ return false;
+ }
+ start_ = Timer::Now();
+ next_state_ = State::WRITE_DONE;
+ stream_->Write(req_, ClientRpcContext::tag(this));
+ return true;
+ case State::WRITE_DONE:
+ if (!ok) {
+ return false;
+ }
+ next_state_ = State::READ_DONE;
+ stream_->Read(&response_, ClientRpcContext::tag(this));
+ return true;
+ break;
+ case State::READ_DONE:
+ hist->Add((Timer::Now() - start_) * 1e9);
+ callback_(status_, &response_);
+ next_state_ = State::STREAM_IDLE;
+ break; // loop around
+ default:
+ GPR_ASSERT(false);
+ return false;
+ }
+ }
+ }
+ ClientRpcContext* StartNewClone() GRPC_OVERRIDE {
+ return new ClientRpcContextGenericStreamingImpl(stub_, req_, next_issue_,
+ start_req_, callback_);
}
private:
- bool ReqSent(bool ok, Histogram*) { return StartWrite(ok); }
- bool StartWrite(bool ok) {
- if (!ok) {
- return (false);
- }
- start_ = Timer::Now();
- next_state_ = &ClientRpcContextGenericStreamingImpl::WriteDone;
- stream_->Write(req_, ClientRpcContext::tag(this));
- return true;
- }
- bool WriteDone(bool ok, Histogram*) {
- if (!ok) {
- return (false);
- }
- next_state_ = &ClientRpcContextGenericStreamingImpl::ReadDone;
- stream_->Read(&response_, ClientRpcContext::tag(this));
- return true;
- }
- bool ReadDone(bool ok, Histogram* hist) {
- hist->Add((Timer::Now() - start_) * 1e9);
- return StartWrite(ok);
- }
grpc::ClientContext context_;
grpc::GenericStub* stub_;
+ CompletionQueue* cq_;
+ std::unique_ptr<Alarm> alarm_;
ByteBuffer req_;
ByteBuffer response_;
- bool (ClientRpcContextGenericStreamingImpl::*next_state_)(bool, Histogram*);
+ enum State {
+ INVALID,
+ STREAM_IDLE,
+ WAIT,
+ READY_TO_WRITE,
+ WRITE_DONE,
+ READ_DONE
+ };
+ State next_state_;
std::function<void(grpc::Status, ByteBuffer*)> callback_;
+ std::function<gpr_timespec()> next_issue_;
std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>(
grpc::GenericStub*, grpc::ClientContext*, const grpc::string&,
CompletionQueue*, void*)> start_req_;
@@ -580,9 +509,6 @@
public:
explicit GenericAsyncStreamingClient(const ClientConfig& config)
: AsyncClient(config, SetupCtx, GenericStubCreator) {
- // async streaming currently only supports closed loop
- GPR_ASSERT(closed_loop_);
-
StartThreads(num_async_threads_);
}
@@ -596,10 +522,11 @@
auto stream = stub->Call(ctx, method_name, cq, tag);
return stream;
};
- static ClientRpcContext* SetupCtx(int channel_id, grpc::GenericStub* stub,
+ static ClientRpcContext* SetupCtx(grpc::GenericStub* stub,
+ std::function<gpr_timespec()> next_issue,
const ByteBuffer& req) {
return new ClientRpcContextGenericStreamingImpl(
- channel_id, stub, req, GenericAsyncStreamingClient::StartReq,
+ stub, req, next_issue, GenericAsyncStreamingClient::StartReq,
GenericAsyncStreamingClient::CheckDone);
}
};
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index d93537b..edfc246 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -84,11 +84,8 @@
protected:
void WaitToIssue(int thread_idx) {
- grpc_time next_time;
- if (NextIssueTime(thread_idx, &next_time)) {
- gpr_timespec next_timespec;
- TimepointHR2Timespec(next_time, &next_timespec);
- gpr_sleep_until(next_timespec);
+ if (!closed_loop_) {
+ gpr_sleep_until(NextIssueTime(thread_idx));
}
}
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 80f6ada..1c7fdf8 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -197,9 +197,7 @@
workers.resize(num_clients + num_servers);
gpr_timespec deadline =
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(
- warmup_seconds + benchmark_seconds + 20, GPR_TIMESPAN));
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(warmup_seconds + benchmark_seconds + 20);
// Start servers
using runsc::ServerData;
diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h
index 841619e..b6fd67b 100644
--- a/test/cpp/qps/interarrival.h
+++ b/test/cpp/qps/interarrival.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,15 +51,15 @@
// stacks. Thus, this code only uses a uniform distribution of doubles [0,1)
// and then provides the distribution functions itself.
-class RandomDist {
+class RandomDistInterface {
public:
- RandomDist() {}
- virtual ~RandomDist() = 0;
- // Argument to operator() is a uniform double in the range [0,1)
- virtual double operator()(double uni) const = 0;
+ RandomDistInterface() {}
+ virtual ~RandomDistInterface() = 0;
+ // Argument to transform is a uniform double in the range [0,1)
+ virtual double transform(double uni) const = 0;
};
-inline RandomDist::~RandomDist() {}
+inline RandomDistInterface::~RandomDistInterface() {}
// ExpDist implements an exponential distribution, which is the
// interarrival distribution for a Poisson process. The parameter
@@ -69,11 +69,11 @@
// independent identical stationary sources. For more information,
// see http://en.wikipedia.org/wiki/Exponential_distribution
-class ExpDist GRPC_FINAL : public RandomDist {
+class ExpDist GRPC_FINAL : public RandomDistInterface {
public:
explicit ExpDist(double lambda) : lambda_recip_(1.0 / lambda) {}
~ExpDist() GRPC_OVERRIDE {}
- double operator()(double uni) const GRPC_OVERRIDE {
+ double transform(double uni) const GRPC_OVERRIDE {
// Note: Use 1.0-uni above to avoid NaN if uni is 0
return lambda_recip_ * (-log(1.0 - uni));
}
@@ -87,11 +87,11 @@
// mean interarrival time is (lo+hi)/2. For more information,
// see http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29
-class UniformDist GRPC_FINAL : public RandomDist {
+class UniformDist GRPC_FINAL : public RandomDistInterface {
public:
UniformDist(double lo, double hi) : lo_(lo), range_(hi - lo) {}
~UniformDist() GRPC_OVERRIDE {}
- double operator()(double uni) const GRPC_OVERRIDE {
+ double transform(double uni) const GRPC_OVERRIDE {
return uni * range_ + lo_;
}
@@ -106,11 +106,11 @@
// clients) will not preserve any deterministic interarrival gap across
// requests.
-class DetDist GRPC_FINAL : public RandomDist {
+class DetDist GRPC_FINAL : public RandomDistInterface {
public:
explicit DetDist(double val) : val_(val) {}
~DetDist() GRPC_OVERRIDE {}
- double operator()(double uni) const GRPC_OVERRIDE { return val_; }
+ double transform(double uni) const GRPC_OVERRIDE { return val_; }
private:
double val_;
@@ -123,12 +123,12 @@
// good representation of the response times of data center jobs. See
// http://en.wikipedia.org/wiki/Pareto_distribution
-class ParetoDist GRPC_FINAL : public RandomDist {
+class ParetoDist GRPC_FINAL : public RandomDistInterface {
public:
ParetoDist(double base, double alpha)
: base_(base), alpha_recip_(1.0 / alpha) {}
~ParetoDist() GRPC_OVERRIDE {}
- double operator()(double uni) const GRPC_OVERRIDE {
+ double transform(double uni) const GRPC_OVERRIDE {
// Note: Use 1.0-uni above to avoid div by zero if uni is 0
return base_ / pow(1.0 - uni, alpha_recip_);
}
@@ -145,13 +145,14 @@
class InterarrivalTimer {
public:
InterarrivalTimer() {}
- void init(const RandomDist& r, int threads, int entries = 1000000) {
+ void init(const RandomDistInterface& r, int threads, int entries = 1000000) {
for (int i = 0; i < entries; i++) {
// rand is the only choice that is portable across POSIX and Windows
// and that supports new and old compilers
- const double uniform_0_1 = rand() / RAND_MAX;
+ const double uniform_0_1 =
+ static_cast<double>(rand()) / static_cast<double>(RAND_MAX);
random_table_.push_back(
- std::chrono::nanoseconds(static_cast<int64_t>(1e9 * r(uniform_0_1))));
+ static_cast<int64_t>(1e9 * r.transform(uniform_0_1)));
}
// Now set up the thread positions
for (int i = 0; i < threads; i++) {
@@ -160,7 +161,7 @@
}
virtual ~InterarrivalTimer(){};
- std::chrono::nanoseconds operator()(int thread_num) {
+ int64_t next(int thread_num) {
auto ret = *(thread_posns_[thread_num]++);
if (thread_posns_[thread_num] == random_table_.end())
thread_posns_[thread_num] = random_table_.begin();
@@ -168,7 +169,7 @@
}
private:
- typedef std::vector<std::chrono::nanoseconds> time_table;
+ typedef std::vector<int64_t> time_table;
std::vector<time_table::const_iterator> thread_posns_;
time_table random_table_;
};
diff --git a/test/cpp/qps/qps-sweep.sh b/test/cpp/qps/qps-sweep.sh
index 539da1d..7a35788 100755
--- a/test/cpp/qps/qps-sweep.sh
+++ b/test/cpp/qps/qps-sweep.sh
@@ -37,9 +37,26 @@
bins=`find . .. ../.. ../../.. -name bins | head -1`
+# Print out each command that gets executed
set -x
+#
+# Specify parameters used in some of the tests
+#
+
+# big is the size in bytes of large messages (0 is the size otherwise)
big=65536
+
+# wide is the number of client channels in multi-channel tests (1 otherwise)
+wide=64
+
+# deep is the number of RPCs outstanding on a channel in non-ping-pong tests
+# (the value used is 1 otherwise)
+deep=100
+
+# half is half the count of worker processes, used in the crossbar scenario
+# that uses equal clients and servers. The other scenarios use only 1 server
+# and either 1 client or N-1 clients as appropriate
half=`echo $QPS_WORKERS | awk -F, '{print int(NF/2)}'`
for secure in true false; do
@@ -52,30 +69,40 @@
# Scenario 2: generic async streaming "unconstrained" (QPS)
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
- --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
+ --client_channels=$wide --bbuf_req_size=0 --bbuf_resp_size=0 \
--async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
- --num_servers=1 --num_clients=0
+ --num_servers=1 --num_clients=0 |& tee /tmp/qps-test.$$
# Scenario 2b: QPS with a single server core
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
- --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
+ --client_channels=$wide --bbuf_req_size=0 --bbuf_resp_size=0 \
--async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
--num_servers=1 --num_clients=0 --server_core_limit=1
# Scenario 2c: protobuf-based QPS
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=100 \
- --client_channels=64 --simple_req_size=0 --simple_resp_size=0 \
+ --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=$deep \
+ --client_channels=$wide --simple_req_size=0 --simple_resp_size=0 \
--async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
--num_servers=1 --num_clients=0
- # Scenario 3: Latency at near-peak load (TBD)
+ # Scenario 3: Latency at sub-peak load (all clients equally loaded)
+ for loadfactor in 0.2 0.5 0.7; do
+ "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
+ --client_channels=$wide --bbuf_req_size=0 --bbuf_resp_size=0 \
+ --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
+ --num_servers=1 --num_clients=0 --poisson_load=`awk -v lf=$loadfactor \
+ '$5 == "QPS:" {print int(lf * $6); exit}' /tmp/qps-test.$$`
+ done
+
+ rm /tmp/qps-test.$$
# Scenario 4: Single-channel bidirectional throughput test (like TCP_STREAM).
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
--client_channels=1 --bbuf_req_size=$big --bbuf_resp_size=$big \
--async_client_threads=1 --async_server_threads=1 --secure_test=$secure \
--num_servers=1 --num_clients=1
@@ -108,35 +135,35 @@
# Scenario 9: Crossbar QPS test
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
- --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
+ --client_channels=$wide --bbuf_req_size=0 --bbuf_resp_size=0 \
--async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
--num_servers=$half --num_clients=0
# Scenario 10: Multi-channel bidir throughput test
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
- --client_channels=64 --bbuf_req_size=$big --bbuf_resp_size=$big \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=1 \
+ --client_channels=$wide --bbuf_req_size=$big --bbuf_resp_size=$big \
--async_client_threads=0 --async_server_threads=0 --secure_test=$secure \
--num_servers=1 --num_clients=1
# Scenario 11: Single-channel request throughput test
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
--client_channels=1 --bbuf_req_size=$big --bbuf_resp_size=0 \
--async_client_threads=1 --async_server_threads=1 --secure_test=$secure \
--num_servers=1 --num_clients=1
# Scenario 12: Single-channel response throughput test
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \
+ --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=$deep \
--client_channels=1 --bbuf_req_size=0 --bbuf_resp_size=$big \
--async_client_threads=1 --async_server_threads=1 --secure_test=$secure \
--num_servers=1 --num_clients=1
# Scenario 13: Single-channel bidirectional protobuf throughput test
"$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \
- --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=100 \
+ --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=$deep \
--client_channels=1 --simple_req_size=$big --simple_resp_size=$big \
--async_client_threads=1 --async_server_threads=1 --secure_test=$secure \
--num_servers=1 --num_clients=1
diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc
index ccda28f..77e81fb 100644
--- a/test/cpp/qps/qps_interarrival_test.cc
+++ b/test/cpp/qps/qps_interarrival_test.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,17 +39,17 @@
#include "test/cpp/qps/interarrival.h"
-using grpc::testing::RandomDist;
+using grpc::testing::RandomDistInterface;
using grpc::testing::InterarrivalTimer;
-static void RunTest(RandomDist &&r, int threads, std::string title) {
+static void RunTest(RandomDistInterface &&r, int threads, std::string title) {
InterarrivalTimer timer;
timer.init(r, threads);
gpr_histogram *h(gpr_histogram_create(0.01, 60e9));
for (int i = 0; i < 10000000; i++) {
for (int j = 0; j < threads; j++) {
- gpr_histogram_add(h, timer(j).count());
+ gpr_histogram_add(h, timer.next(j));
}
}
@@ -70,7 +70,7 @@
int main(int argc, char **argv) {
RunTest(ExpDist(10.0), 5, std::string("Exponential(10)"));
RunTest(DetDist(5.0), 5, std::string("Det(5)"));
- RunTest(UniformDist(0.0, 10.0), 5, std::string("Uniform(1,10)"));
+ RunTest(UniformDist(0.0, 10.0), 5, std::string("Uniform(0,10)"));
RunTest(ParetoDist(1.0, 1.0), 5, std::string("Pareto(1,1)"));
return 0;
}
diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc
index fe5f685..0ac41d9 100644
--- a/test/cpp/qps/qps_openloop_test.cc
+++ b/test/cpp/qps/qps_openloop_test.cc
@@ -53,7 +53,7 @@
client_config.set_outstanding_rpcs_per_channel(1000);
client_config.set_client_channels(8);
client_config.set_async_client_threads(8);
- client_config.set_rpc_type(UNARY);
+ client_config.set_rpc_type(STREAMING);
client_config.mutable_load_params()->mutable_poisson()->set_offered_load(
1000.0);
diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc
index 15054db..27aaf13 100644
--- a/test/cpp/qps/qps_test.cc
+++ b/test/cpp/qps/qps_test.cc
@@ -53,7 +53,7 @@
client_config.set_outstanding_rpcs_per_channel(1000);
client_config.set_client_channels(8);
client_config.set_async_client_threads(8);
- client_config.set_rpc_type(UNARY);
+ client_config.set_rpc_type(STREAMING);
client_config.mutable_load_params()->mutable_closed_loop();
ServerConfig server_config;
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 1302d71..2024e0b 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -51,6 +51,7 @@
#include <gtest/gtest.h>
#include "src/proto/grpc/testing/services.grpc.pb.h"
+#include "test/core/util/test_config.h"
#include "test/cpp/qps/server.h"
namespace grpc {
@@ -129,7 +130,7 @@
}
}
~AsyncQpsServerTest() {
- auto deadline = std::chrono::system_clock::now() + std::chrono::seconds(10);
+ auto deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
server_->Shutdown(deadline);
for (auto ss = shutdown_state_.begin(); ss != shutdown_state_.end(); ++ss) {
(*ss)->set_shutdown();
diff --git a/test/distrib/node/run_distrib_test.sh b/test/distrib/node/run_distrib_test.sh
index 99a51f0..9b8f157 100755
--- a/test/distrib/node/run_distrib_test.sh
+++ b/test/distrib/node/run_distrib_test.sh
@@ -38,6 +38,9 @@
npm install -g node-static
+# Kill off existing static servers
+kill -9 $(ps aux | grep '[n]ode .*static' | awk '{print $2}') || true
+
STATIC_SERVER=127.0.0.1
STATIC_PORT=8080
diff --git a/tools/distrib/check_copyright.py b/tools/distrib/check_copyright.py
index a7efdc8..d1a34a9 100755
--- a/tools/distrib/check_copyright.py
+++ b/tools/distrib/check_copyright.py
@@ -57,6 +57,9 @@
argp.add_argument('-f', '--fix',
default=False,
action='store_true');
+argp.add_argument('--precommit',
+ default=False,
+ action='store_true')
args = argp.parse_args()
# open the license text
@@ -101,6 +104,10 @@
for line in LICENSE))
for k, v in LICENSE_PREFIX.iteritems())
+if args.precommit:
+ FILE_LIST_COMMAND = 'git diff --name-only HEAD | grep -v ^third_party/'
+else:
+ FILE_LIST_COMMAND = 'git ls-tree -r --name-only -r HEAD | grep -v ^third_party/'
def load(name):
with open(name) as f:
@@ -124,8 +131,14 @@
# scan files, validate the text
ok = True
-for filename in subprocess.check_output('git ls-tree -r --name-only -r HEAD | grep -v ^third_party/',
- shell=True).splitlines():
+filename_list = []
+try:
+ filename_list = subprocess.check_output(FILE_LIST_COMMAND,
+ shell=True).splitlines()
+except subprocess.CalledProcessError:
+ sys.exit(0)
+
+for filename in filename_list:
if filename in KNOWN_BAD: continue
ext = os.path.splitext(filename)[1]
base = os.path.basename(filename)
diff --git a/tools/distrib/clang_format_code.sh b/tools/distrib/clang_format_code.sh
index 6bfa278..d904a84 100755
--- a/tools/distrib/clang_format_code.sh
+++ b/tools/distrib/clang_format_code.sh
@@ -37,4 +37,4 @@
docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format
# run clang-format against the checked out codebase
-docker run -e TEST=$TEST --rm=true -v ${HOST_GIT_ROOT:-`pwd`}:/local-code -t grpc_clang_format /clang_format_all_the_things.sh
+docker run -e TEST=$TEST -e CHANGED_FILES="$CHANGED_FILES" --rm=true -v ${HOST_GIT_ROOT:-`pwd`}:/local-code -t grpc_clang_format /clang_format_all_the_things.sh
diff --git a/tools/distrib/sanitize.sh b/tools/distrib/sanitize.sh
new file mode 100755
index 0000000..3b7ca6f
--- /dev/null
+++ b/tools/distrib/sanitize.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+# 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.
+
+set -ex
+
+cd $(dirname $0)/../..
+
+DIFF_COMMAND="git diff --name-only HEAD | grep -v ^third_party/"
+
+if [ "x$1" == 'x--pre-commit' ]; then
+ if eval $DIFF_COMMAND | grep '^build.yaml$'; then
+ ./tools/buildgen/generate_projects.sh
+ else
+ templates=$(eval $DIFF_COMMAND | grep '\.template$' || true)
+ if [ -n "$templates" ]; then
+ ./tools/buildgen/generate_projects.sh --templates $templates
+ fi
+ fi
+ CHANGED_FILES=$(eval $DIFF_COMMAND) ./tools/distrib/clang_format_code.sh
+ ./tools/distrib/check_copyright.py --fix --precommit
+ ./tools/distrib/check_trailing_newlines.sh
+else
+ ./tools/buildgen/generate_projects.sh
+ ./tools/distrib/clang_format_code.sh
+ ./tools/distrib/check_copyright.py --fix
+ ./tools/distrib/check_trailing_newlines.sh
+fi
diff --git a/tools/dockerfile/distribtest/python_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/python_fedora21_x64/Dockerfile
index b44fcff..1eb4c1e 100644
--- a/tools/dockerfile/distribtest/python_fedora21_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/python_fedora21_x64/Dockerfile
@@ -29,4 +29,9 @@
FROM fedora:21
+# Make yum work properly under docker when using overlay storage driver.
+# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9
+# https://github.com/docker/docker/issues/10180
+RUN yum install -y yum-plugin-ovl
+
RUN yum clean all && yum update -y && yum install -y python python-pip
diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
index 598dac5..b567c5b 100644
--- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
@@ -29,6 +29,11 @@
FROM fedora:21
+# Make yum work properly under docker when using overlay storage driver.
+# https://bugzilla.redhat.com/show_bug.cgi?id=1213602#c9
+# https://github.com/docker/docker/issues/10180
+RUN yum install -y yum-plugin-ovl
+
RUN yum clean all && yum update -y && yum install -y ruby
RUN gem install bundler
diff --git a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
index 86ba8b2..dd8ea1a 100755
--- a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
+++ b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
@@ -48,6 +48,12 @@
done
done
+# The CHANGED_FILES variable is used to restrict the set of files to check.
+# Here we set files to the intersection of files and CHANGED_FILES
+if [ -n "$CHANGED_FILES" ]; then
+ files=$(comm -12 <(echo $files | tr ' ' '\n' | sort -u) <(echo $CHANGED_FILES | tr ' ' '\n' | sort -u))
+fi
+
if [ "x$TEST" = "x" ]
then
echo $files | xargs $CLANG_FORMAT -i
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index e0650d7..d5e5df8 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -840,7 +840,6 @@
src/cpp/client/create_channel_internal.h \
src/cpp/common/create_auth_context.h \
src/cpp/server/dynamic_thread_pool.h \
-src/cpp/server/fixed_size_thread_pool.h \
src/cpp/server/thread_pool_interface.h \
src/cpp/client/secure_credentials.cc \
src/cpp/common/auth_property_iterator.cc \
@@ -864,7 +863,6 @@
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
-src/cpp/server/fixed_size_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index b626843..502fe39 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -901,6 +901,7 @@
src/core/transport/transport.h \
src/core/transport/transport_impl.h \
src/core/census/aggregation.h \
+src/core/census/log.h \
src/core/census/rpc_metric_id.h \
src/core/httpcli/httpcli_security_connector.c \
src/core/security/base64.c \
@@ -1052,6 +1053,7 @@
src/core/transport/transport_op_string.c \
src/core/census/context.c \
src/core/census/initialize.c \
+src/core/census/log.c \
src/core/census/operation.c \
src/core/census/placeholders.c \
src/core/census/tracing.c \
diff --git a/tools/run_tests/build_artifact_node.sh b/tools/run_tests/build_artifact_node.sh
index 9a3b9bd..6aa4824 100755
--- a/tools/run_tests/build_artifact_node.sh
+++ b/tools/run_tests/build_artifact_node.sh
@@ -36,7 +36,7 @@
cd $(dirname $0)/../..
-rm -rf build
+rm -rf build || true
mkdir -p artifacts
@@ -46,6 +46,6 @@
for version in ${node_versions[@]}
do
- node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH
+ ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH
cp -r build/stage/* artifacts/
done
diff --git a/tools/run_tests/build_artifact_python.sh b/tools/run_tests/build_artifact_python.sh
index 835fad8..6e7ab91 100755
--- a/tools/run_tests/build_artifact_python.sh
+++ b/tools/run_tests/build_artifact_python.sh
@@ -39,12 +39,20 @@
pip install -rrequirements.txt
fi
+# The bdist_wheel_grpc_custom command is finicky about command output ordering
+# and thus ought to be run in a shell command separate of others. Further, it
+# trashes the actual bdist_wheel output, so it should be run first so that
+# bdist_wheel may be run unmolested.
+GRPC_PYTHON_USE_CUSTOM_BDIST=0 \
+GRPC_PYTHON_BUILD_WITH_CYTHON=1 \
+${SETARCH_CMD} python setup.py \
+ build_tagged_ext
+
GRPC_PYTHON_USE_CUSTOM_BDIST=0 \
GRPC_PYTHON_BUILD_WITH_CYTHON=1 \
${SETARCH_CMD} python setup.py \
bdist_wheel \
- sdist \
- bdist_egg_grpc_custom
+ sdist
mkdir -p artifacts
diff --git a/tools/run_tests/build_package_node.sh b/tools/run_tests/build_package_node.sh
index a8b9448..aca90a3 100755
--- a/tools/run_tests/build_package_node.sh
+++ b/tools/run_tests/build_package_node.sh
@@ -38,6 +38,7 @@
mkdir -p artifacts/
cp -r $EXTERNAL_GIT_ROOT/architecture={x86,x64},language=node,platform={windows,linux,macos}/artifacts/* artifacts/ || true
+npm update
npm pack
cp grpc-*.tgz artifacts/grpc.tgz
diff --git a/tools/run_tests/distribtest_targets.py b/tools/run_tests/distribtest_targets.py
index b26a870..261f44b 100644
--- a/tools/run_tests/distribtest_targets.py
+++ b/tools/run_tests/distribtest_targets.py
@@ -122,11 +122,15 @@
def build_jobspec(self):
if self.platform == 'linux':
+ linux32 = ''
+ if self.arch == 'x86':
+ linux32 = 'linux32'
return create_docker_jobspec(self.name,
'tools/dockerfile/distribtest/node_%s_%s' % (
self.docker_suffix,
self.arch),
- 'test/distrib/node/run_distrib_test.sh %s' % (
+ '%s test/distrib/node/run_distrib_test.sh %s' % (
+ linux32,
self.node_version))
elif self.platform == 'macos':
return create_jobspec(self.name,
@@ -236,11 +240,7 @@
RubyDistribTest('linux', 'x64', 'ubuntu1504'),
RubyDistribTest('linux', 'x64', 'ubuntu1510'),
RubyDistribTest('linux', 'x64', 'ubuntu1604'),
- NodeDistribTest('macos', 'x64', None, '0.10'),
- NodeDistribTest('macos', 'x64', None, '0.12'),
- NodeDistribTest('macos', 'x64', None, '3'),
NodeDistribTest('macos', 'x64', None, '4'),
- NodeDistribTest('macos', 'x64', None, '5'),
NodeDistribTest('linux', 'x86', 'jessie', '4')
] + [
NodeDistribTest('linux', 'x64', os, version)
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index 6538ddc..a5ff6b5 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -90,6 +90,20 @@
],
"headers": [],
"language": "c",
+ "name": "census_log_test",
+ "src": [
+ "test/core/census/log_test.c"
+ ]
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "language": "c",
"name": "channel_create_test",
"src": [
"test/core/surface/channel_create_test.c"
@@ -2969,6 +2983,7 @@
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/grpc_filter.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
"src/core/channel/channel_args.h",
"src/core/channel/channel_stack.h",
@@ -3119,6 +3134,8 @@
"src/core/census/grpc_filter.c",
"src/core/census/grpc_filter.h",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
+ "src/core/census/log.h",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/rpc_metric_id.h",
@@ -3494,6 +3511,7 @@
"include/grpc/status.h",
"src/core/census/aggregation.h",
"src/core/census/grpc_filter.h",
+ "src/core/census/log.h",
"src/core/census/rpc_metric_id.h",
"src/core/channel/channel_args.h",
"src/core/channel/channel_stack.h",
@@ -3629,6 +3647,8 @@
"src/core/census/grpc_filter.c",
"src/core/census/grpc_filter.h",
"src/core/census/initialize.c",
+ "src/core/census/log.c",
+ "src/core/census/log.h",
"src/core/census/operation.c",
"src/core/census/placeholders.c",
"src/core/census/rpc_metric_id.h",
@@ -4009,7 +4029,6 @@
"src/cpp/common/create_auth_context.h",
"src/cpp/common/secure_auth_context.h",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/secure_server_credentials.h",
"src/cpp/server/thread_pool_interface.h"
],
@@ -4117,8 +4136,6 @@
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.cc",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/secure_server_credentials.cc",
"src/cpp/server/secure_server_credentials.h",
@@ -4265,7 +4282,6 @@
"src/cpp/client/create_channel_internal.h",
"src/cpp/common/create_auth_context.h",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/thread_pool_interface.h"
],
"language": "c++",
@@ -4366,8 +4382,6 @@
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.h",
- "src/cpp/server/fixed_size_thread_pool.cc",
- "src/cpp/server/fixed_size_thread_pool.h",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index 2c73c40..ea9c129 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -133,6 +133,26 @@
"exclude_configs": [],
"flaky": false,
"language": "c",
+ "name": "census_log_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ]
+ },
+ {
+ "args": [],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "flaky": false,
+ "language": "c",
"name": "channel_create_test",
"platforms": [
"linux",
@@ -2084,6 +2104,24 @@
"mac",
"posix"
],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "flaky": false,
+ "language": "c++",
+ "name": "qps_openloop_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ]
+ },
+ {
+ "args": [],
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
"cpu_cost": 10,
"exclude_configs": [
"tsan"
diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln
index ea8e504..b30941f 100644
--- a/vsprojects/buildtests_c.sln
+++ b/vsprojects/buildtests_c.sln
@@ -176,6 +176,17 @@
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "census_log_test", "vcxproj\test\census_log_test\census_log_test.vcxproj", "{C27CEE16-2BEC-5572-3956-677E9F6F8BED}"
+ ProjectSection(myProperties) = preProject
+ lib = "False"
+ EndProjectSection
+ ProjectSection(ProjectDependencies) = postProject
+ {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}
+ {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9}
+ {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
+ {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
+ EndProjectSection
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "channel_create_test", "vcxproj\test\channel_create_test\channel_create_test.vcxproj", "{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}"
ProjectSection(myProperties) = preProject
lib = "False"
@@ -1604,6 +1615,22 @@
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|Win32.Build.0 = Release|Win32
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.ActiveCfg = Release|x64
{5C1CFC2D-AF3C-D7CB-BA74-D267E91CBC73}.Release-DLL|x64.Build.0 = Release|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug|x64.ActiveCfg = Debug|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release|Win32.ActiveCfg = Release|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release|x64.ActiveCfg = Release|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug|Win32.Build.0 = Debug|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug|x64.Build.0 = Debug|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release|Win32.Build.0 = Release|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release|x64.Build.0 = Release|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug-DLL|Win32.ActiveCfg = Debug|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug-DLL|Win32.Build.0 = Debug|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug-DLL|x64.ActiveCfg = Debug|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Debug-DLL|x64.Build.0 = Debug|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release-DLL|Win32.ActiveCfg = Release|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release-DLL|Win32.Build.0 = Release|Win32
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release-DLL|x64.ActiveCfg = Release|x64
+ {C27CEE16-2BEC-5572-3956-677E9F6F8BED}.Release-DLL|x64.Build.0 = Release|x64
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|Win32.ActiveCfg = Debug|Win32
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Debug|x64.ActiveCfg = Debug|x64
{AFC88484-3A2E-32BC-25B2-23DF741D4F3D}.Release|Win32.ActiveCfg = Release|Win32
diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj
index bb2d0e7..c62faf3 100644
--- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj
+++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj
@@ -340,7 +340,6 @@
<ClInclude Include="$(SolutionDir)\..\src\cpp\client\create_channel_internal.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\common\create_auth_context.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.h" />
- <ClInclude Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\thread_pool_interface.h" />
</ItemGroup>
<ItemGroup>
@@ -388,8 +387,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
</ClCompile>
- <ClCompile Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.cc">
- </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\insecure_server_credentials.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\server.cc">
diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
index 72ecfe2..5f9350e 100644
--- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
@@ -67,9 +67,6 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
- <ClCompile Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.cc">
- <Filter>src\cpp\server</Filter>
- </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\insecure_server_credentials.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
@@ -347,9 +344,6 @@
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
- <ClInclude Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.h">
- <Filter>src\cpp\server</Filter>
- </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\thread_pool_interface.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
index 8ff8d8b..fb42465 100644
--- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
@@ -337,7 +337,6 @@
<ClInclude Include="$(SolutionDir)\..\src\cpp\client\create_channel_internal.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\common\create_auth_context.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.h" />
- <ClInclude Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.h" />
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\thread_pool_interface.h" />
</ItemGroup>
<ItemGroup>
@@ -375,8 +374,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
</ClCompile>
- <ClCompile Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.cc">
- </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\insecure_server_credentials.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\server.cc">
diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
index 316fdd7..eeff7d3 100644
--- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
@@ -52,9 +52,6 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
- <ClCompile Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.cc">
- <Filter>src\cpp\server</Filter>
- </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\insecure_server_credentials.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
@@ -323,9 +320,6 @@
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
- <ClInclude Include="$(SolutionDir)\..\src\cpp\server\fixed_size_thread_pool.h">
- <Filter>src\cpp\server</Filter>
- </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\cpp\server\thread_pool_interface.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj
index 7697532..faef347 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj
@@ -410,6 +410,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\transport\transport.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\transport\transport_impl.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\census\aggregation.h" />
+ <ClInclude Include="$(SolutionDir)\..\src\core\census\log.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\census\rpc_metric_id.h" />
</ItemGroup>
<ItemGroup>
@@ -713,6 +714,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\initialize.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\census\log.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\operation.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\placeholders.c">
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
index 4660572..9afcbf0 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
@@ -451,6 +451,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\census\initialize.c">
<Filter>src\core\census</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\census\log.c">
+ <Filter>src\core\census</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\operation.c">
<Filter>src\core\census</Filter>
</ClCompile>
@@ -887,6 +890,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\census\aggregation.h">
<Filter>src\core\census</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\src\core\census\log.h">
+ <Filter>src\core\census</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\census\rpc_metric_id.h">
<Filter>src\core\census</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
index 541000a..4edcfab 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
@@ -386,6 +386,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\transport\transport.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\transport\transport_impl.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\census\aggregation.h" />
+ <ClInclude Include="$(SolutionDir)\..\src\core\census\log.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\census\rpc_metric_id.h" />
</ItemGroup>
<ItemGroup>
@@ -649,6 +650,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\initialize.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\census\log.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\operation.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\placeholders.c">
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
index 48814f9..11510b5 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -391,6 +391,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\census\initialize.c">
<Filter>src\core\census</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\census\log.c">
+ <Filter>src\core\census</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\census\operation.c">
<Filter>src\core\census</Filter>
</ClCompile>
@@ -782,6 +785,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\census\aggregation.h">
<Filter>src\core\census</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\src\core\census\log.h">
+ <Filter>src\core\census</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\census\rpc_metric_id.h">
<Filter>src\core\census</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj b/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj
new file mode 100644
index 0000000..851086d
--- /dev/null
+++ b/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj
@@ -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>{C27CEE16-2BEC-5572-3956-677E9F6F8BED}</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_log_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_log_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\log_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>
+
diff --git a/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj.filters b/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj.filters
new file mode 100644
index 0000000..135c778
--- /dev/null
+++ b/vsprojects/vcxproj/test/census_log_test/census_log_test.vcxproj.filters
@@ -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\log_test.c">
+ <Filter>test\core\census</Filter>
+ </ClCompile>
+ </ItemGroup>
+
+ <ItemGroup>
+ <Filter Include="test">
+ <UniqueIdentifier>{4d0aae38-6975-cafb-30a6-a7c2c87d22ff}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="test\core">
+ <UniqueIdentifier>{fb85321f-d3b5-ef2f-c5aa-34660a5e0c7b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="test\core\census">
+ <UniqueIdentifier>{f23141da-cbe2-70fa-8207-858af868eb18}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
+