YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/rpc/rpc_with_call_id.h
Line
Count
Source
1
//
2
// Copyright (c) YugaByte, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
// in compliance with the License.  You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software distributed under the License
10
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
// or implied.  See the License for the specific language governing permissions and limitations
12
// under the License.
13
//
14
//
15
16
#ifndef YB_RPC_RPC_WITH_CALL_ID_H
17
#define YB_RPC_RPC_WITH_CALL_ID_H
18
19
#include <stdint.h>
20
21
#include <functional>
22
#include <type_traits>
23
#include <unordered_map>
24
25
#include "yb/rpc/connection_context.h"
26
#include "yb/rpc/inbound_call.h"
27
28
#include "yb/util/size_literals.h"
29
30
namespace yb {
31
namespace rpc {
32
33
class ConnectionContextWithCallId : public ConnectionContextBase {
34
 protected:
35
  ConnectionContextWithCallId();
36
37
79.7M
  InboundCall::CallProcessedListener call_processed_listener() {
38
79.7M
    return std::bind(&ConnectionContextWithCallId::CallProcessed, this, std::placeholders::_1);
39
79.7M
  }
40
41
  CHECKED_STATUS Store(InboundCall* call);
42
  void DumpPB(const DumpRunningRpcsRequestPB& req, RpcConnectionPB* resp) override;
43
44
11
  uint64_t ProcessedCallCount() override {
45
11
    return processed_call_count_.load(std::memory_order_acquire);
46
11
  }
47
48
 private:
49
  virtual uint64_t ExtractCallId(InboundCall* call) = 0;
50
3.01k
  void ListenIdle(IdleListener listener) override { idle_listener_ = std::move(listener); }
51
  void Shutdown(const Status& status) override;
52
53
  bool Idle(std::string* reason_not_idle = nullptr) override;
54
55
  void CallProcessed(InboundCall* call);
56
  void QueueResponse(const ConnectionPtr& conn, InboundCallPtr call) override;
57
58
  // Calls which have been received on the server and are currently
59
  // being handled.
60
  std::unordered_map<uint64_t, InboundCall*> calls_being_handled_;
61
  std::atomic<uint64_t> processed_call_count_{0};
62
  IdleListener idle_listener_;
63
};
64
65
} // namespace rpc
66
} // namespace yb
67
68
#endif // YB_RPC_RPC_WITH_CALL_ID_H