YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/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
876
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
876
  }
_ZN2yb6tablet17SnapshotOperationC2IJPNS0_6TabletEPNS_7tserver25TabletSnapshotOpRequestPBEEEEDpOT_
Line
Count
Source
39
373
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
373
  }
Unexecuted instantiation: _ZN2yb6tablet17SnapshotOperationC2IJDnEEEDpOT_
Unexecuted instantiation: _ZN2yb6tablet17SnapshotOperationC2IJPNS0_6TabletERKPNS_7tserver25TabletSnapshotOpRequestPBEEEEDpOT_
_ZN2yb6tablet17SnapshotOperationC2IJPNS0_6TabletEEEEDpOT_
Line
Count
Source
39
500
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
500
  }
_ZN2yb6tablet17SnapshotOperationC2IJPNS0_6TabletERPKNS_7tserver25TabletSnapshotOpRequestPBEEEEDpOT_
Line
Count
Source
39
3
      : ExclusiveSchemaOperation(std::forward<Args>(args)...) {
40
3
  }
41
42
3
  tserver::TabletSnapshotOpRequestPB::Operation operation() const {
43
3
    return request() == nullptr ?
44
3
        tserver::TabletSnapshotOpRequestPB::UNKNOWN : request()->operation();
45
3
  }
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