YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/operation_filter.h
Line
Count
Source
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_OPERATION_FILTER_H
15
#define YB_TABLET_OPERATION_FILTER_H
16
17
#include <boost/intrusive/list.hpp>
18
19
#include "yb/consensus/consensus_types.pb.h"
20
21
#include "yb/util/opid.h"
22
#include "yb/util/status.h"
23
24
namespace yb {
25
namespace tablet {
26
27
// Checks whether operation with specified id and type is allowed in some scenario defined
28
// by the user of this class.
29
// Please note that this class does not enforce any restrictions on its usage, and
30
// doesn't care about scenarios that use this class.
31
class OperationFilter : public boost::intrusive::list_base_hook<> {
32
 public:
33
  virtual CHECKED_STATUS CheckOperationAllowed(
34
      const OpId& id, consensus::OperationType op_type) const = 0;
35
36
2.11k
  virtual ~OperationFilter() = default;
37
};
38
39
template <class F>
40
class FunctorOperationFilter : public OperationFilter {
41
 public:
42
98
  explicit FunctorOperationFilter(const F& f) : f_(f) {}
tablet.cc:yb::tablet::FunctorOperationFilter<yb::tablet::Tablet::SplitDone()::$_12>::FunctorOperationFilter(yb::tablet::Tablet::SplitDone()::$_12 const&)
Line
Count
Source
42
68
  explicit FunctorOperationFilter(const F& f) : f_(f) {}
tablet.cc:yb::tablet::FunctorOperationFilter<yb::tablet::Tablet::SyncRestoringOperationFilter(yb::StronglyTypedBool<yb::tablet::ResetSplit_Tag>)::$_13>::FunctorOperationFilter(yb::tablet::Tablet::SyncRestoringOperationFilter(yb::StronglyTypedBool<yb::tablet::ResetSplit_Tag>)::$_13 const&)
Line
Count
Source
42
30
  explicit FunctorOperationFilter(const F& f) : f_(f) {}
43
44
  CHECKED_STATUS CheckOperationAllowed(
45
40
      const OpId& id, consensus::OperationType op_type) const override {
46
40
    return f_(id, op_type);
47
40
  }
tablet.cc:yb::tablet::FunctorOperationFilter<yb::tablet::Tablet::SplitDone()::$_12>::CheckOperationAllowed(yb::OpId const&, yb::consensus::OperationType) const
Line
Count
Source
45
25
      const OpId& id, consensus::OperationType op_type) const override {
46
25
    return f_(id, op_type);
47
25
  }
tablet.cc:yb::tablet::FunctorOperationFilter<yb::tablet::Tablet::SyncRestoringOperationFilter(yb::StronglyTypedBool<yb::tablet::ResetSplit_Tag>)::$_13>::CheckOperationAllowed(yb::OpId const&, yb::consensus::OperationType) const
Line
Count
Source
45
15
      const OpId& id, consensus::OperationType op_type) const override {
46
15
    return f_(id, op_type);
47
15
  }
48
49
 private:
50
  F f_;
51
};
52
53
template <class F>
54
98
std::unique_ptr<OperationFilter> MakeFunctorOperationFilter(const F& f) {
55
98
  return std::make_unique<FunctorOperationFilter<F>>(f);
56
98
}
tablet.cc:std::__1::unique_ptr<yb::tablet::OperationFilter, std::__1::default_delete<yb::tablet::OperationFilter> > yb::tablet::MakeFunctorOperationFilter<yb::tablet::Tablet::SplitDone()::$_12>(yb::tablet::Tablet::SplitDone()::$_12 const&)
Line
Count
Source
54
68
std::unique_ptr<OperationFilter> MakeFunctorOperationFilter(const F& f) {
55
68
  return std::make_unique<FunctorOperationFilter<F>>(f);
56
68
}
tablet.cc:std::__1::unique_ptr<yb::tablet::OperationFilter, std::__1::default_delete<yb::tablet::OperationFilter> > yb::tablet::MakeFunctorOperationFilter<yb::tablet::Tablet::SyncRestoringOperationFilter(yb::StronglyTypedBool<yb::tablet::ResetSplit_Tag>)::$_13>(yb::tablet::Tablet::SyncRestoringOperationFilter(yb::StronglyTypedBool<yb::tablet::ResetSplit_Tag>)::$_13 const&)
Line
Count
Source
54
30
std::unique_ptr<OperationFilter> MakeFunctorOperationFilter(const F& f) {
55
30
  return std::make_unique<FunctorOperationFilter<F>>(f);
56
30
}
57
58
}  // namespace tablet
59
}  // namespace yb
60
61
#endif  // YB_TABLET_OPERATION_FILTER_H