YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/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
334M
Status ConnectionContextBase::ReportPendingWriteBytes(size_t bytes_in_queue) {
30
334M
  return Status::OK();
31
334M
}
32
33
77.8M
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
77.8M
  connection->UpdateLastActivity();
38
77.8M
}
39
40
ConnectionContextFactory::ConnectionContextFactory(
41
    int64_t memory_limit, const std::string& name,
42
    const std::shared_ptr<MemTracker>& parent_mem_tracker)
43
61.8k
    : parent_tracker_(parent_mem_tracker) {
44
61.8k
  int64_t root_buffer_limit = AbsRelMemLimit(FLAGS_read_buffer_memory_limit, [] {
45
61.8k
    return MemTracker::GetRootTracker()->limit();
46
61.8k
  });
47
48
61.8k
  auto root_buffer_tracker = MemTracker::FindOrCreateTracker(
49
61.8k
      root_buffer_limit, "Read Buffer", parent_mem_tracker);
50
61.8k
  memory_limit = AbsRelMemLimit(memory_limit, [&root_buffer_tracker] {
51
0
    return root_buffer_tracker->limit();
52
0
  });
53
61.8k
  buffer_tracker_ = MemTracker::FindOrCreateTracker(memory_limit, name, root_buffer_tracker);
54
61.8k
  auto root_call_tracker = MemTracker::FindOrCreateTracker("Call", parent_mem_tracker);
55
61.8k
  call_tracker_ = MemTracker::FindOrCreateTracker(name, root_call_tracker);
56
61.8k
}
57
58
9.03k
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