YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/tablet_bootstrap_if.cc
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
33
#include "yb/tablet/tablet_bootstrap_if.h"
34
35
#include <atomic>
36
#include <future>
37
#include <map>
38
#include <memory>
39
#include <mutex>
40
#include <string>
41
#include <vector>
42
43
#include "yb/consensus/consensus_fwd.h"
44
#include "yb/consensus/log.h"
45
46
#include "yb/gutil/callback.h"
47
#include "yb/gutil/ref_counted.h"
48
#include "yb/gutil/thread_annotations.h"
49
50
#include "yb/tablet/tablet_fwd.h"
51
#include "yb/tablet/tablet_bootstrap.h"
52
#include "yb/tablet/tablet_metadata.h"
53
#include "yb/tablet/tablet_options.h"
54
55
#include "yb/util/debug/trace_event.h"
56
57
namespace yb {
58
namespace tablet {
59
60
using std::shared_ptr;
61
62
using consensus::ConsensusBootstrapInfo;
63
64
TabletStatusListener::TabletStatusListener(const RaftGroupMetadataPtr& meta)
65
150k
    : meta_(meta) {
66
150k
}
67
68
399k
const string TabletStatusListener::tablet_id() const {
69
399k
  return meta_->raft_group_id();
70
399k
}
71
72
8.14k
const string TabletStatusListener::namespace_name() const {
73
8.14k
  return meta_->namespace_name();
74
8.14k
}
75
76
8.14k
const string TabletStatusListener::table_name() const {
77
8.14k
  return meta_->table_name();
78
8.14k
}
79
80
8.14k
const string TabletStatusListener::table_id() const {
81
8.14k
  return meta_->table_id();
82
8.14k
}
83
84
8.15k
std::shared_ptr<Partition> TabletStatusListener::partition() const {
85
8.15k
  return meta_->partition();
86
8.15k
}
87
88
3.19k
SchemaPtr TabletStatusListener::schema() const {
89
3.19k
  return meta_->schema();
90
3.19k
}
91
92
74.5k
TabletStatusListener::~TabletStatusListener() {
93
74.5k
}
94
95
390k
void TabletStatusListener::StatusMessage(const string& status) {
96
390k
  LOG(INFO) << "T " << tablet_id() << " P " << meta_->fs_manager()->uuid() << ": "
97
390k
            << status;
98
390k
  std::lock_guard<std::shared_timed_mutex> l(lock_);
99
390k
  last_status_ = status;
100
390k
}
101
102
Status BootstrapTablet(
103
    const BootstrapTabletData& data,
104
    TabletPtr* rebuilt_tablet,
105
    scoped_refptr<log::Log>* rebuilt_log,
106
150k
    ConsensusBootstrapInfo* consensus_info) {
107
150k
  const auto& meta = *data.tablet_init_data.metadata;
108
150k
  TRACE_EVENT1("tablet", "BootstrapTablet", "tablet_id", meta.raft_group_id());
109
150k
  RETURN_NOT_OK(BootstrapTabletImpl(data, rebuilt_tablet, rebuilt_log, consensus_info));
110
111
  // Set WAL retention time from the metadata.
112
150k
  (*rebuilt_log)->set_wal_retention_secs(meta.wal_retention_secs());
113
150k
  (*rebuilt_log)->set_cdc_min_replicated_index(meta.cdc_min_replicated_index());
114
115
  // This is necessary since OpenNewLog() initially disables sync.
116
150k
  RETURN_NOT_OK((*rebuilt_log)->ReEnableSyncIfRequired());
117
150k
  return Status::OK();
118
150k
}
119
120
3.19k
string DocDbOpIds::ToString() const {
121
3.19k
  return Format("{ regular: $0 intents: $1 }", regular, intents);
122
3.19k
}
123
124
} // namespace tablet
125
} // namespace yb