YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/operations/snapshot_operation.h
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
#ifndef YB_TABLET_OPERATIONS_SNAPSHOT_OPERATION_H
15
#define YB_TABLET_OPERATIONS_SNAPSHOT_OPERATION_H
16
17
#include <mutex>
18
#include <string>
19
20
#include "yb/tablet/tablet_fwd.h"
21
#include "yb/gutil/macros.h"
22
#include "yb/tablet/operation_filter.h"
23
#include "yb/tablet/operations/operation.h"
24
#include "yb/tserver/backup.pb.h"
25
#include "yb/util/locks.h"
26
27
namespace yb {
28
namespace tablet {
29
30
// Operation Context for the TabletSnapshot operation.
31
// Keeps track of the Operation states (request, result, ...)
32
// Executes the TabletSnapshotOp operation.
33
class SnapshotOperation :
34
    public ExclusiveSchemaOperation<OperationType::kSnapshot, tserver::TabletSnapshotOpRequestPB>,
35
    public OperationFilter {
36
 public:
37
  template <class... Args>
38
  explicit SnapshotOperation(Args&&... args)
39
1.98k
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
1.98k
  }
yb::tablet::SnapshotOperation::SnapshotOperation<yb::tablet::Tablet*, yb::tserver::TabletSnapshotOpRequestPB const*&>(yb::tablet::Tablet*&&, yb::tserver::TabletSnapshotOpRequestPB const*&)
Line
Count
Source
39
48
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
48
  }
Unexecuted instantiation: yb::tablet::SnapshotOperation::SnapshotOperation<yb::tablet::Tablet*, yb::tserver::TabletSnapshotOpRequestPB* const&>(yb::tablet::Tablet*&&, yb::tserver::TabletSnapshotOpRequestPB* const&)
yb::tablet::SnapshotOperation::SnapshotOperation<yb::tablet::Tablet*>(yb::tablet::Tablet*&&)
Line
Count
Source
39
1.15k
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
1.15k
  }
yb::tablet::SnapshotOperation::SnapshotOperation<std::nullptr_t>(std::nullptr_t&&)
Line
Count
Source
39
24
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
24
  }
yb::tablet::SnapshotOperation::SnapshotOperation<yb::tablet::Tablet*, yb::tserver::TabletSnapshotOpRequestPB*>(yb::tablet::Tablet*&&, yb::tserver::TabletSnapshotOpRequestPB*&&)
Line
Count
Source
39
758
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
758
  }
41
42
48
  tserver::TabletSnapshotOpRequestPB::Operation operation() const {
43
48
    return request() == nullptr ?
44
48
        
tserver::TabletSnapshotOpRequestPB::UNKNOWN0
: request()->operation();
45
48
  }
46
47
  // Returns the snapshot directory, based on the tablet's top directory for all snapshots, and any
48
  // overrides for the snapshot directory this operation might have.
49
  Result<std::string> GetSnapshotDir() const;
50
51
  bool CheckOperationRequirements();
52
53
  static bool ShouldAllowOpDuringRestore(consensus::OperationType op_type);
54
55
  static CHECKED_STATUS RejectionStatus(OpId rejected_op_id, consensus::OperationType op_type);
56
57
  CHECKED_STATUS Prepare() override;
58
59
 private:
60
  // Starts the TabletSnapshotOp operation by assigning it a timestamp.
61
  CHECKED_STATUS DoReplicated(int64_t leader_term, Status* complete_status) override;
62
  CHECKED_STATUS DoAborted(const Status& status) override;
63
  CHECKED_STATUS Apply(int64_t leader_term, Status* complete_status);
64
65
  void AddedAsPending() override;
66
  void RemovedFromPending() override;
67
68
  bool NeedOperationFilter() const;
69
70
  CHECKED_STATUS CheckOperationAllowed(
71
      const OpId& id, consensus::OperationType op_type) const override;
72
73
  CHECKED_STATUS DoCheckOperationRequirements();
74
};
75
76
}  // namespace tablet
77
}  // namespace yb
78
79
#endif  // YB_TABLET_OPERATIONS_SNAPSHOT_OPERATION_H