YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rpc/connection_context.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#include "yb/rpc/connection_context.h"
15
16
#include "yb/rpc/connection.h"
17
18
#include "yb/util/mem_tracker.h"
19
20
DEFINE_int64(read_buffer_memory_limit, -5,
21
             "Overall limit for read buffers. "
22
             "Positive value - limit in bytes. "
23
             "Negative value - percent of root process memory. "
24
             "Zero - unlimited.");
25
26
namespace yb {
27
namespace rpc {
28
29
90.1M
Status ConnectionContextBase::ReportPendingWriteBytes(size_t bytes_in_queue) {
30
90.1M
  return Status::OK();
31
90.1M
}
32
33
23.0M
void ConnectionContext::UpdateLastRead(const ConnectionPtr& connection) {
34
  // By default any read events on connection updates it's last activity. This could be
35
  // overriden in subclasses for example in order to not treat application-level heartbeats as
36
  // activity preventing connection from being GCed.
37
23.0M
  connection->UpdateLastActivity();
38
23.0M
}
39
40
ConnectionContextFactory::ConnectionContextFactory(
41
    int64_t memory_limit, const std::string& name,
42
    const std::shared_ptr<MemTracker>& parent_mem_tracker)
43
38.9k
    : parent_tracker_(parent_mem_tracker) {
44
38.9k
  int64_t root_buffer_limit = AbsRelMemLimit(FLAGS_read_buffer_memory_limit, [] {
45
38.9k
    return MemTracker::GetRootTracker()->limit();
46
38.9k
  });
47
48
38.9k
  auto root_buffer_tracker = MemTracker::FindOrCreateTracker(
49
38.9k
      root_buffer_limit, "Read Buffer", parent_mem_tracker);
50
0
  memory_limit = AbsRelMemLimit(memory_limit, [&root_buffer_tracker] {
51
0
    return root_buffer_tracker->limit();
52
0
  });
53
38.9k
  buffer_tracker_ = MemTracker::FindOrCreateTracker(memory_limit, name, root_buffer_tracker);
54
38.9k
  auto root_call_tracker = MemTracker::FindOrCreateTracker("Call", parent_mem_tracker);
55
38.9k
  call_tracker_ = MemTracker::FindOrCreateTracker(name, root_call_tracker);
56
38.9k
}
57
58
4.11k
ConnectionContextFactory::~ConnectionContextFactory() = default;
59
60
0
std::string ProcessCallsResult::ToString() const {
61
0
  return Format(
62
0
      "{ consumed: $0 buffer.size(): $1 bytes_to_skip: $2 }",
63
0
      consumed, buffer.size(), bytes_to_skip);
64
0
}
65
66
} // namespace rpc
67
} // namespace yb