1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_PS_CORE_RECOVERY_BASE_H_ 18 #define MINDSPORE_CCSRC_PS_CORE_RECOVERY_BASE_H_ 19 20 #include <cstdlib> 21 #include <iostream> 22 #include <memory> 23 #include <string> 24 #include <vector> 25 26 #include "ps/constants.h" 27 #include "utils/log_adapter.h" 28 #include "ps/core/file_configuration.h" 29 #include "ps/ps_context.h" 30 31 namespace mindspore { 32 namespace ps { 33 namespace core { 34 enum class StorageType : int { kFileStorage = 1 }; 35 // RecoveryBase is used to parse configuration items related to recovery. 36 // It is the base class of SchedulerRecovery and NodeRecovery. 37 class RecoveryBase { 38 public: RecoveryBase()39 RecoveryBase() : recovery_storage_(nullptr), storage_type_(StorageType::kFileStorage) {} 40 41 virtual ~RecoveryBase() = default; 42 43 // Initialize the recovery configuration item and get the storage type of recovery. 44 virtual void Initialize(const std::string &json_config); 45 46 // The node needs to recover metadata information when it starts. 47 virtual bool Recover() = 0; 48 49 protected: 50 // Persistent storage used to save metadata. 51 std::unique_ptr<Configuration> recovery_storage_; 52 53 // Storage type for recovery,Currently only supports storage of file types 54 StorageType storage_type_; 55 }; 56 } // namespace core 57 } // namespace ps 58 } // namespace mindspore 59 #endif // MINDSPORE_CCSRC_PS_CORE_RECOVERY_BASE_H_ 60