Coverage Report

Created: 2025-03-11 12:30

/root/doris/be/src/agent/agent_server.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <butil/macros.h>
21
22
#include <memory>
23
#include <string>
24
#include <unordered_map>
25
#include <vector>
26
27
namespace doris {
28
29
class TaskWorkerPoolIf;
30
class TaskWorkerPool;
31
class PriorTaskWorkerPool;
32
class ReportWorker;
33
class TopicSubscriber;
34
class ExecEnv;
35
class TAgentPublishRequest;
36
class TAgentResult;
37
class TAgentTaskRequest;
38
class ClusterInfo;
39
class TSnapshotRequest;
40
class StorageEngine;
41
class CloudStorageEngine;
42
43
// Each method corresponds to one RPC from FE Master, see BackendService.
44
class AgentServer {
45
public:
46
    explicit AgentServer(ExecEnv* exec_env, const ClusterInfo* cluster_info);
47
    ~AgentServer();
48
49
    void start_workers(StorageEngine& engine, ExecEnv* exec_env);
50
51
    void cloud_start_workers(CloudStorageEngine& engine, ExecEnv* exec_env);
52
53
    // Receive agent task from FE master
54
    void submit_tasks(TAgentResult& agent_result, const std::vector<TAgentTaskRequest>& tasks);
55
56
    // Deprecated
57
    // TODO(lingbin): This method is deprecated, should be removed later.
58
    // [[deprecated]]
59
    void publish_cluster_state(TAgentResult& agent_result, const TAgentPublishRequest& request);
60
61
0
    TopicSubscriber* get_topic_subscriber() { return _topic_subscriber.get(); }
62
63
    void stop_report_workers();
64
65
private:
66
    // Reference to the ExecEnv::_cluster_info
67
    const ClusterInfo* _cluster_info;
68
69
    std::unordered_map<int64_t /* TTaskType */, std::unique_ptr<TaskWorkerPoolIf>> _workers;
70
71
    // These workers do not accept tasks from FE.
72
    // It is self triggered periodically and reports to FE master
73
    std::vector<std::unique_ptr<ReportWorker>> _report_workers;
74
75
    std::unique_ptr<TopicSubscriber> _topic_subscriber;
76
};
77
78
} // end namespace doris