/Users/deen/code/yugabyte-db/src/yb/tablet/tablet_component.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_TABLET_COMPONENT_H |
15 | | #define YB_TABLET_TABLET_COMPONENT_H |
16 | | |
17 | | #include <mutex> |
18 | | |
19 | | #include "yb/rocksdb/rocksdb_fwd.h" |
20 | | |
21 | | #include "yb/tablet/tablet_fwd.h" |
22 | | |
23 | | #include "yb/util/status_fwd.h" |
24 | | |
25 | | namespace yb { |
26 | | |
27 | | class RWOperationCounter; |
28 | | |
29 | | namespace tablet { |
30 | | |
31 | | struct TabletScopedRWOperationPauses; |
32 | | |
33 | | // Base class for Tablet components, has access to private Tablet fields. |
34 | | // For methods descriptions see comments for appropriate field or method in Tablet class. |
35 | | class TabletComponent { |
36 | | public: |
37 | 150k | explicit TabletComponent(Tablet* tablet) : tablet_(*tablet) {} |
38 | | |
39 | 4.00k | Tablet& tablet() const { |
40 | 4.00k | return tablet_; |
41 | 4.00k | } |
42 | | |
43 | | protected: |
44 | | Result<TabletScopedRWOperationPauses> StartShutdownRocksDBs( |
45 | | DisableFlushOnShutdown disable_flush_on_shutdown); |
46 | | |
47 | | CHECKED_STATUS CompleteShutdownRocksDBs( |
48 | | Destroy destroy, TabletScopedRWOperationPauses* ops_pauses); |
49 | | |
50 | | CHECKED_STATUS OpenRocksDBs(); |
51 | | |
52 | | std::string LogPrefix() const; |
53 | | |
54 | | RaftGroupMetadata& metadata() const; |
55 | | |
56 | | RWOperationCounter& pending_op_counter() const; |
57 | | |
58 | | rocksdb::DB& regular_db() const; |
59 | | |
60 | | bool has_regular_db() const; |
61 | | |
62 | | rocksdb::DB& intents_db() const; |
63 | | |
64 | | bool has_intents_db() const; |
65 | | |
66 | | std::mutex& create_checkpoint_lock() const; |
67 | | |
68 | | rocksdb::Env& rocksdb_env() const; |
69 | | |
70 | | void RefreshYBMetaDataCache(); |
71 | | |
72 | | private: |
73 | | Tablet& tablet_; |
74 | | }; |
75 | | |
76 | | } // namespace tablet |
77 | | } // namespace yb |
78 | | |
79 | | #endif // YB_TABLET_TABLET_COMPONENT_H |