orca_service.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPCPP_EXT_ORCA_SERVICE_H
18 #define GRPCPP_EXT_ORCA_SERVICE_H
19 
20 #include <map>
21 #include <string>
22 
23 #include "absl/time/time.h"
24 #include "absl/types/optional.h"
25 
29 #include <grpcpp/server_builder.h>
30 #include <grpcpp/support/slice.h>
31 
32 namespace grpc {
33 namespace experimental {
34 
35 // RPC service implementation for supplying out-of-band backend
36 // utilization metrics to clients.
37 class OrcaService : public Service {
38  public:
39  struct Options {
40  // Minimum report interval. If a client requests an interval lower
41  // than this value, this value will be used instead.
43 
44  Options() = default;
46  min_report_duration = duration;
47  return *this;
48  }
49  };
50 
51  explicit OrcaService(Options options);
52 
53  // Sets or removes the CPU utilization value to be reported to clients.
54  void SetCpuUtilization(double cpu_utilization);
55  void DeleteCpuUtilization();
56 
57  // Sets of removes the memory utilization value to be reported to clients.
58  void SetMemoryUtilization(double memory_utilization);
60 
61  // Sets or removed named utilization values to be reported to clients.
62  void SetNamedUtilization(std::string name, double utilization);
64  void SetAllNamedUtilization(std::map<std::string, double> named_utilization);
65 
66  private:
67  class Reactor;
68 
70 
72 
74  double cpu_utilization_ ABSL_GUARDED_BY(&mu_) = -1;
75  double memory_utilization_ ABSL_GUARDED_BY(&mu_) = -1;
76  std::map<std::string, double> named_utilization_ ABSL_GUARDED_BY(&mu_);
78 };
79 
80 } // namespace experimental
81 } // namespace grpc
82 
83 #endif // GRPCPP_EXT_ORCA_SERVICE_H
grpc::experimental::OrcaService::Options
Definition: orca_service.h:39
grpc::experimental::OrcaService
Definition: orca_service.h:37
grpc::experimental::OrcaService::DeleteCpuUtilization
void DeleteCpuUtilization()
Definition: orca_service.cc:188
grpc::internal::Mutex
Definition: include/grpcpp/impl/codegen/sync.h:59
grpc
Definition: grpcpp/alarm.h:33
grpc::experimental::OrcaService::min_report_duration_
const absl::Duration min_report_duration_
Definition: orca_service.h:71
grpc::experimental::OrcaService::DeleteNamedUtilization
void DeleteNamedUtilization(const std::string &name)
Definition: orca_service.cc:212
service_type.h
options
double_dict options[]
Definition: capstone_test.c:55
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
slice.h
ABSL_GUARDED_BY
#define ABSL_GUARDED_BY(x)
Definition: abseil-cpp/absl/base/thread_annotations.h:62
setup.name
name
Definition: setup.py:542
grpc::experimental::OrcaService::Options::Options
Options()=default
server_callback.h
grpc::experimental::OrcaService::SetAllNamedUtilization
void SetAllNamedUtilization(std::map< std::string, double > named_utilization)
Definition: orca_service.cc:218
grpc::experimental::OrcaService::SetNamedUtilization
void SetNamedUtilization(std::string name, double utilization)
Definition: orca_service.cc:206
grpc::Service
Desriptor of an RPC service and its various RPC methods.
Definition: grpcpp/impl/codegen/service_type.h:58
grpc::experimental::OrcaService::DeleteMemoryUtilization
void DeleteMemoryUtilization()
Definition: orca_service.cc:200
sync.h
grpc::experimental::OrcaService::SetMemoryUtilization
void SetMemoryUtilization(double memory_utilization)
Definition: orca_service.cc:194
grpc::experimental::OrcaService::SetCpuUtilization
void SetCpuUtilization(double cpu_utilization)
Definition: orca_service.cc:182
absl::optional
Definition: abseil-cpp/absl/types/internal/optional.h:61
grpc::experimental::OrcaService::GetOrCreateSerializedResponse
Slice GetOrCreateSerializedResponse()
Definition: orca_service.cc:225
absl::Duration
Definition: third_party/abseil-cpp/absl/time/time.h:159
grpc::experimental::OrcaService::Options::set_min_report_duration
Options & set_min_report_duration(absl::Duration duration)
Definition: orca_service.h:45
grpc::experimental::OrcaService::mu_
grpc::internal::Mutex mu_
Definition: orca_service.h:73
grpc::experimental::OrcaService::OrcaService
OrcaService(Options options)
Definition: orca_service.cc:170
absl::Seconds
constexpr Duration Seconds(T n)
Definition: third_party/abseil-cpp/absl/time/time.h:419
grpc::experimental::OrcaService::Options::min_report_duration
absl::Duration min_report_duration
Definition: orca_service.h:42
grpc::Slice
Definition: include/grpcpp/impl/codegen/slice.h:36
server_builder.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:46