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_INSTANCE_MANAGER_H_ 18 #define MINDSPORE_CCSRC_PS_CORE_INSTANCE_MANAGER_H_ 19 20 #include <cstdlib> 21 #include <iostream> 22 #include <memory> 23 #include <string> 24 #include <vector> 25 26 #include "ps/core/communicator/tcp_client.h" 27 #include "ps/core/node_manager.h" 28 #include "ps/core/node.h" 29 #include "ps/core/communicator/request_process_result_code.h" 30 #include "ps/constants.h" 31 #include "utils/log_adapter.h" 32 #include "ps/core/communicator/communicator_base.h" 33 34 namespace mindspore { 35 namespace ps { 36 namespace core { 37 // The class helps scheduler node to do new instance or query instance operation for the cluster. 38 class InstanceManager { 39 public: InstanceManager(Node * const node)40 explicit InstanceManager(Node *const node) : node_(node) {} 41 ~InstanceManager() = default; 42 43 // When the scheduler receives the new instance message, it will send this message to the workers and servers. 44 void NewInstanceAsync(const std::shared_ptr<TcpClient> &client, const NodeManager &manager, const std::string &body, 45 const uint64_t &request_id, const NodeInfo &node_info); 46 // When the scheduler receives the query instance message, it will send this message to the server0. 47 void QueryInstanceAsync(const std::shared_ptr<TcpClient> &client, const NodeManager &manager, 48 const uint64_t &request_id, const NodeInfo &node_info); 49 // When the scheduler receives the enable instance message, it will send this message to the server0. 50 void EnableFLSAsync(const std::shared_ptr<TcpClient> &client, const NodeManager &manager, const uint64_t &request_id, 51 const NodeInfo &node_info); 52 // When the scheduler receives the disable instance message, it will send this message to the server0. 53 void DisableFLSAsync(const std::shared_ptr<TcpClient> &client, const NodeManager &manager, const uint64_t &request_id, 54 const NodeInfo &node_info); 55 56 private: 57 // The node_ will only be instantiated with scheduler node. 58 Node *const node_; 59 }; 60 } // namespace core 61 } // namespace ps 62 } // namespace mindspore 63 #endif // MINDSPORE_CCSRC_PS_CORE_INSTANCE_MANAGER_H_ 64