• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef STORAGE_EXECUTOR_H
17 #define STORAGE_EXECUTOR_H
18 
19 #include "macro_utils.h"
20 
21 namespace DistributedDB {
22 enum EngineState {
23     INVALID = -1, // default value, representative database is not generated
24     CACHEDB,
25     ATTACHING, // main db and cache db attach together
26     MIGRATING, // begine to Migrate data
27     MAINDB,
28     ENGINE_BUSY, // In order to change handle during the migration process, it is temporarily unavailable
29 };
30 
31 class StorageExecutor {
32 public:
33     explicit StorageExecutor(bool writable);
34     virtual ~StorageExecutor();
35 
36     // Delete the copy and assign constructors
37     DISABLE_COPY_ASSIGN_MOVE(StorageExecutor);
38 
39     virtual bool GetWritable() const;
40 
41     virtual int CheckCorruptedStatus(int errCode) const;
42 
43     virtual bool GetCorruptedStatus() const;
44 
45     virtual void SetCorruptedStatus() const;
46 
47     virtual int Reset() = 0;
48 
49 protected:
50     bool writable_;
51     mutable bool isCorrupted_;
52 };
53 } // namespace DistributedDB
54 
55 #endif // STORAGE_EXECUTOR_H
56