Merge pull request #18220 from grpc/grpc_namespace

Moving ::grpc::ResourceQuota to ::grpc_impl::ResouceQuota
reviewable/pr18340/r1^2
Karthik Ravi Shankar 6 years ago committed by GitHub
commit cc632f8121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      BUILD
  2. 3
      CMakeLists.txt
  3. 3
      Makefile
  4. 1
      build.yaml
  5. 1
      gRPC-C++.podspec
  6. 45
      include/grpcpp/resource_quota.h
  7. 68
      include/grpcpp/resource_quota_impl.h
  8. 9
      include/grpcpp/server_builder.h
  9. 9
      include/grpcpp/support/channel_arguments.h
  10. 2
      src/cpp/common/channel_arguments.cc
  11. 4
      src/cpp/common/resource_quota_cc.cc
  12. 7
      src/cpp/server/server_builder.cc
  13. 5
      test/cpp/end2end/end2end_test.cc
  14. 5
      test/cpp/end2end/thread_stress_test.cc
  15. 5
      test/cpp/qps/server.h
  16. 1
      test/cpp/qps/server_async.cc
  17. 1
      tools/doxygen/Doxyfile.c++
  18. 1
      tools/doxygen/Doxyfile.c++.internal
  19. 2
      tools/run_tests/generated/sources_and_headers.json

@ -192,8 +192,8 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_metadata_processor.h",
"include/grpc++/security/credentials.h",
"include/grpc++/security/server_credentials.h",
@ -241,6 +241,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/sync_cxx11.h",
"include/grpcpp/impl/sync_no_cxx11.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",

@ -3014,6 +3014,7 @@ foreach(_hdr
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/credentials.h
@ -3604,6 +3605,7 @@ foreach(_hdr
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/credentials.h
@ -4559,6 +4561,7 @@ foreach(_hdr
include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/credentials.h

@ -5438,6 +5438,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
@ -6037,6 +6038,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
@ -6949,6 +6951,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \

@ -1360,6 +1360,7 @@ filegroups:
- include/grpcpp/impl/server_initializer.h
- include/grpcpp/impl/service_type.h
- include/grpcpp/resource_quota.h
- include/grpcpp/resource_quota_impl.h
- include/grpcpp/security/auth_context.h
- include/grpcpp/security/auth_metadata_processor.h
- include/grpcpp/security/credentials.h

@ -105,6 +105,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/server_initializer.h',
'include/grpcpp/impl/service_type.h',
'include/grpcpp/resource_quota.h',
'include/grpcpp/resource_quota_impl.h',
'include/grpcpp/security/auth_context.h',
'include/grpcpp/security/auth_metadata_processor.h',
'include/grpcpp/security/credentials.h',

@ -1,6 +1,6 @@
/*
*
* Copyright 2016 gRPC authors.
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,50 +19,11 @@
#ifndef GRPCPP_RESOURCE_QUOTA_H
#define GRPCPP_RESOURCE_QUOTA_H
struct grpc_resource_quota;
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/resource_quota_impl.h>
namespace grpc {
/// ResourceQuota represents a bound on memory and thread usage by the gRPC
/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder),
/// or a client channel (via \a ChannelArguments).
/// gRPC will attempt to keep memory and threads used by all attached entities
/// below the ResourceQuota bound.
class ResourceQuota final : private GrpcLibraryCodegen {
public:
/// \param name - a unique name for this ResourceQuota.
explicit ResourceQuota(const grpc::string& name);
ResourceQuota();
~ResourceQuota();
/// Resize this \a ResourceQuota to a new size. If \a new_size is smaller
/// than the current size of the pool, memory usage will be monotonically
/// decreased until it falls under \a new_size.
/// No time bound is given for this to occur however.
ResourceQuota& Resize(size_t new_size);
/// Set the max number of threads that can be allocated from this
/// ResourceQuota object.
///
/// If the new_max_threads value is smaller than the current value, no new
/// threads are allocated until the number of active threads fall below
/// new_max_threads. There is no time bound on when this may happen i.e none
/// of the current threads are forcefully destroyed and all threads run their
/// normal course.
ResourceQuota& SetMaxThreads(int new_max_threads);
grpc_resource_quota* c_resource_quota() const { return impl_; }
private:
ResourceQuota(const ResourceQuota& rhs);
ResourceQuota& operator=(const ResourceQuota& rhs);
grpc_resource_quota* const impl_;
};
typedef ::grpc_impl::ResourceQuota ResourceQuota;
} // namespace grpc
#endif // GRPCPP_RESOURCE_QUOTA_H

@ -0,0 +1,68 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_RESOURCE_QUOTA_IMPL_H
#define GRPCPP_RESOURCE_QUOTA_IMPL_H
struct grpc_resource_quota;
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h>
namespace grpc_impl {
/// ResourceQuota represents a bound on memory and thread usage by the gRPC
/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder),
/// or a client channel (via \a ChannelArguments).
/// gRPC will attempt to keep memory and threads used by all attached entities
/// below the ResourceQuota bound.
class ResourceQuota final : private ::grpc::GrpcLibraryCodegen {
public:
/// \param name - a unique name for this ResourceQuota.
explicit ResourceQuota(const grpc::string& name);
ResourceQuota();
~ResourceQuota();
/// Resize this \a ResourceQuota to a new size. If \a new_size is smaller
/// than the current size of the pool, memory usage will be monotonically
/// decreased until it falls under \a new_size.
/// No time bound is given for this to occur however.
ResourceQuota& Resize(size_t new_size);
/// Set the max number of threads that can be allocated from this
/// ResourceQuota object.
///
/// If the new_max_threads value is smaller than the current value, no new
/// threads are allocated until the number of active threads fall below
/// new_max_threads. There is no time bound on when this may happen i.e none
/// of the current threads are forcefully destroyed and all threads run their
/// normal course.
ResourceQuota& SetMaxThreads(int new_max_threads);
grpc_resource_quota* c_resource_quota() const { return impl_; }
private:
ResourceQuota(const ResourceQuota& rhs);
ResourceQuota& operator=(const ResourceQuota& rhs);
grpc_resource_quota* const impl_;
};
} // namespace grpc_impl
#endif // GRPCPP_RESOURCE_QUOTA_IMPL_H

@ -35,10 +35,14 @@
struct grpc_resource_quota;
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
class AsyncGenericService;
class ResourceQuota;
class CompletionQueue;
class Server;
class ServerCompletionQueue;
@ -186,7 +190,8 @@ class ServerBuilder {
grpc_compression_algorithm algorithm);
/// Set the attached buffer pool for this server
ServerBuilder& SetResourceQuota(const ResourceQuota& resource_quota);
ServerBuilder& SetResourceQuota(
const ::grpc_impl::ResourceQuota& resource_quota);
ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option);

@ -26,13 +26,16 @@
#include <grpc/grpc.h>
#include <grpcpp/support/config.h>
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
namespace testing {
class ChannelArgumentsTest;
} // namespace testing
class ResourceQuota;
/// Options for channel creation. The user can use generic setters to pass
/// key value pairs down to C channel creation code. For gRPC related options,
/// concrete setters are provided.
@ -83,7 +86,7 @@ class ChannelArguments {
void SetUserAgentPrefix(const grpc::string& user_agent_prefix);
/// Set the buffer pool to be attached to the constructed channel.
void SetResourceQuota(const ResourceQuota& resource_quota);
void SetResourceQuota(const ::grpc_impl::ResourceQuota& resource_quota);
/// Set the max receive and send message sizes.
void SetMaxReceiveMessageSize(int size);

@ -143,7 +143,7 @@ void ChannelArguments::SetUserAgentPrefix(
}
void ChannelArguments::SetResourceQuota(
const grpc::ResourceQuota& resource_quota) {
const grpc_impl::ResourceQuota& resource_quota) {
SetPointerWithVtable(GRPC_ARG_RESOURCE_QUOTA,
resource_quota.c_resource_quota(),
grpc_resource_quota_arg_vtable());

@ -19,7 +19,7 @@
#include <grpc/grpc.h>
#include <grpcpp/resource_quota.h>
namespace grpc {
namespace grpc_impl {
ResourceQuota::ResourceQuota() : impl_(grpc_resource_quota_create(nullptr)) {}
@ -37,4 +37,4 @@ ResourceQuota& ResourceQuota::SetMaxThreads(int new_max_threads) {
grpc_resource_quota_set_max_threads(impl_, new_max_threads);
return *this;
}
} // namespace grpc
} // namespace grpc_impl

@ -29,6 +29,11 @@
#include "src/core/lib/gpr/useful.h"
#include "src/cpp/server/thread_pool_interface.h"
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>*
@ -164,7 +169,7 @@ ServerBuilder& ServerBuilder::SetDefaultCompressionAlgorithm(
}
ServerBuilder& ServerBuilder::SetResourceQuota(
const grpc::ResourceQuota& resource_quota) {
const grpc_impl::ResourceQuota& resource_quota) {
if (resource_quota_ != nullptr) {
grpc_resource_quota_unref(resource_quota_);
}

@ -64,6 +64,11 @@ using std::chrono::system_clock;
} \
} while (0)
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
namespace testing {
namespace {

@ -48,6 +48,11 @@ const int kNumAsyncReceiveThreads = 50;
const int kNumAsyncServerThreads = 50;
const int kNumRpcs = 1000; // Number of RPCs per thread
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
namespace testing {

@ -34,6 +34,11 @@
#include "test/cpp/qps/usage_timer.h"
#include "test/cpp/util/test_credentials_provider.h"
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc {
namespace testing {

@ -27,7 +27,6 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/generic/async_generic_service.h>
#include <grpcpp/resource_quota.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>

@ -995,6 +995,7 @@ include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \

@ -997,6 +997,7 @@ include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \

@ -11391,6 +11391,7 @@
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",
@ -11500,6 +11501,7 @@
"include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",

Loading…
Cancel
Save