1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 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 TENSORFLOW_C_EAGER_immediate_execution_distributed_manager_H_ 17 #define TENSORFLOW_C_EAGER_immediate_execution_distributed_manager_H_ 18 19 #include "tensorflow/core/platform/status.h" 20 21 namespace tensorflow { 22 class CoordinationServiceAgent; 23 class ImmediateExecutionContext; 24 class ServerDef; 25 class WorkerEnv; 26 class WorkerCacheInterface; 27 28 class ImmediateExecutionDistributedManager { 29 public: ~ImmediateExecutionDistributedManager()30 virtual ~ImmediateExecutionDistributedManager() {} 31 32 // Set up distributed execution environment on local and remote tasks. 33 // When `reset_context` is true, initialize new cluster context state based on 34 // cluster configurations provided in `server_def`; otherwise, update existing 35 // context state with the provided `server_def`. 36 // Contexts created on remote tasks will be considered stale and garbage 37 // collected after `keep_alive_secs` of inactivity. 38 virtual Status SetOrUpdateServerDef(const ServerDef& server_def, 39 bool reset_context, 40 int keep_alive_secs) = 0; 41 42 // Set up a multi-client distributed execution environment. Must be called on 43 // all tasks in the cluster. 44 // This call internally coordinates with other tasks to initialize the eager 45 // context and TF server for multi-client execution. 46 virtual Status EnableCollectiveOps(const ServerDef& server_def) = 0; 47 48 // Enable coordination service instance for the distributed cluster. The 49 // service is owned by the current distributed manager. 50 // See CoordinationServiceInterface for details. 51 virtual Status EnableCoordinationService( 52 const std::string& service_type, const WorkerEnv* worker_env, 53 const ServerDef& server_def, WorkerCacheInterface* worker_cache) = 0; 54 55 // Check if the remote task is alive. 56 virtual Status CheckRemoteAlive(const std::string& remote_task_name, 57 bool* is_alive) = 0; 58 59 // Get pointer to the coordination service agent instance. 60 virtual CoordinationServiceAgent* GetCoordinationServiceAgent() = 0; 61 }; 62 } // namespace tensorflow 63 64 #endif // TENSORFLOW_C_EAGER_immediate_execution_distributed_manager_H_ 65