• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CLUSTER_CONFIG_H_
18 #define MINDSPORE_CCSRC_PS_CORE_CLUSTER_CONFIG_H_
19 
20 #include <string>
21 #include <iostream>
22 #include <memory>
23 #include <utility>
24 
25 #include "utils/log_adapter.h"
26 
27 namespace mindspore {
28 namespace ps {
29 namespace core {
30 /*
31  * Configuration information read through environment variables and configuration files, generally immutable
32  */
33 struct ClusterConfig {
ClusterConfigClusterConfig34   explicit ClusterConfig(const uint32_t &worker_num, const uint32_t &server_num, std::string host, const uint16_t &port)
35       : initial_worker_num(worker_num),
36         initial_server_num(server_num),
37         heartbeat_interval(3),
38         scheduler_host(host),
39         scheduler_port(port),
40         heartbeat_timeout(30),
41         cluster_available_timeout(300),
42         connect_interval(3000),
43         scheduler_timeout(30) {}
44 
45   // Configure through environment variables:MS_WORKER_NUM
46   uint32_t initial_worker_num;
47   // Configure through environment variables:MS_SERVER_NUM
48   uint32_t initial_server_num;
49 
50   // The interval for sending heartbeat packets between worker node,server node and scheduler node is 3 seconds.
51   uint32_t heartbeat_interval;
52   std::string scheduler_host;
53   uint16_t scheduler_port;
54   // The timeout for worker node and server node sending heartbeat packets to scheduler node is 30 seconds.
55   uint32_t heartbeat_timeout;
56   // Timeout period for cluster preparation is 300 seconds.
57   uint32_t cluster_available_timeout;
58   // The timeout period for the client to connect to the server is 3000ms.
59   uint32_t connect_interval;
60   // When the scheduler exits, the worker and server can continue to work for 5 hours
61   int64_t scheduler_timeout;
62 };
63 }  // namespace core
64 }  // namespace ps
65 }  // namespace mindspore
66 #endif  // MINDSPORE_CCSRC_PS_CORE_CLUSTER_CONFIG_H_
67