/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 | 942 | virtual ~OperationFilter() = default; |
37 | | }; |
38 | | |
39 | | template <class F> |
40 | | class FunctorOperationFilter : public OperationFilter { |
41 | | public: |
42 | 44 | explicit FunctorOperationFilter(const F& f) : f_(f) {} tablet.cc:_ZN2yb6tablet22FunctorOperationFilterIZNS0_6Tablet9SplitDoneEvE4$_12EC2ERKS3_ Line | Count | Source | 42 | 44 | explicit FunctorOperationFilter(const F& f) : f_(f) {} |
Unexecuted instantiation: tablet.cc:_ZN2yb6tablet22FunctorOperationFilterIZNS0_6Tablet28SyncRestoringOperationFilterENS_17StronglyTypedBoolINS0_14ResetSplit_TagEEEE4$_13EC2ERKS6_ |
43 | | |
44 | | CHECKED_STATUS CheckOperationAllowed( |
45 | 14 | const OpId& id, consensus::OperationType op_type) const override { |
46 | 14 | return f_(id, op_type); |
47 | 14 | } tablet.cc:_ZNK2yb6tablet22FunctorOperationFilterIZNS0_6Tablet9SplitDoneEvE4$_12E21CheckOperationAllowedERKNS_4OpIdENS_9consensus13OperationTypeE Line | Count | Source | 45 | 14 | const OpId& id, consensus::OperationType op_type) const override { | 46 | 14 | return f_(id, op_type); | 47 | 14 | } |
Unexecuted instantiation: tablet.cc:_ZNK2yb6tablet22FunctorOperationFilterIZNS0_6Tablet28SyncRestoringOperationFilterENS_17StronglyTypedBoolINS0_14ResetSplit_TagEEEE4$_13E21CheckOperationAllowedERKNS_4OpIdENS_9consensus13OperationTypeE |
48 | | |
49 | | private: |
50 | | F f_; |
51 | | }; |
52 | | |
53 | | template <class F> |
54 | 44 | std::unique_ptr<OperationFilter> MakeFunctorOperationFilter(const F& f) { |
55 | 44 | return std::make_unique<FunctorOperationFilter<F>>(f); |
56 | 44 | } tablet.cc:_ZN2yb6tablet26MakeFunctorOperationFilterIZNS0_6Tablet9SplitDoneEvE4$_12EENSt3__110unique_ptrINS0_15OperationFilterENS4_14default_deleteIS6_EEEERKT_ Line | Count | Source | 54 | 44 | std::unique_ptr<OperationFilter> MakeFunctorOperationFilter(const F& f) { | 55 | 44 | return std::make_unique<FunctorOperationFilter<F>>(f); | 56 | 44 | } |
Unexecuted instantiation: tablet.cc:_ZN2yb6tablet26MakeFunctorOperationFilterIZNS0_6Tablet28SyncRestoringOperationFilterENS_17StronglyTypedBoolINS0_14ResetSplit_TagEEEE4$_13EENSt3__110unique_ptrINS0_15OperationFilterENS7_14default_deleteIS9_EEEERKT_ |
57 | | |
58 | | } // namespace tablet |
59 | | } // namespace yb |
60 | | |
61 | | #endif // YB_TABLET_OPERATION_FILTER_H |