• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
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 INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_H_
18 #define INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_H_
19 
20 #include <memory>
21 #include <vector>
22 
23 #include "perfetto/base/status.h"
24 #include "perfetto/ext/base/status_or.h"
25 #include "perfetto/ext/base/threading/future.h"
26 #include "perfetto/ext/base/threading/stream.h"
27 
28 namespace perfetto {
29 namespace protos {
30 class TracePoolCreateArgs;
31 class TracePoolCreateResponse;
32 
33 class TracePoolSetTracesArgs;
34 class TracePoolSetTracesResponse;
35 
36 class TracePoolQueryArgs;
37 class TracePoolQueryResponse;
38 
39 class TracePoolDestroyArgs;
40 class TracePoolDestroyResponse;
41 }  // namespace protos
42 }  // namespace perfetto
43 
44 namespace perfetto {
45 namespace cloud_trace_processor {
46 
47 class Worker;
48 
49 // Interface for a CloudTraceProcessor "Orchestrator".
50 //
51 // See CloudTraceProcessorOrchestrator RPC service for high-level documentation.
52 class Orchestrator {
53  public:
54   virtual ~Orchestrator();
55 
56   // Returns an in-process implementation of the Orchestrator, given a group of
57   // workers which can be delegated to.
58   //
59   // Note that the passed workers instances can be "remote" (i.e. in another
60   // process or even on another machine); the returned manager will gracefully
61   // handle this.
62   static std::unique_ptr<Orchestrator> CreateInProcess(
63       std::vector<std::unique_ptr<Worker>> workers);
64 
65   // Creates a TracePool with the specified arguments.
66   virtual base::StatusOrFuture<protos::TracePoolCreateResponse> TracePoolCreate(
67       const protos::TracePoolCreateArgs&) = 0;
68 
69   // Associates the provided list of traces to this TracePoolShard.
70   virtual base::StatusOrFuture<protos::TracePoolSetTracesResponse>
71   TracePoolSetTraces(const protos::TracePoolSetTracesArgs&) = 0;
72 
73   // Executes a SQL query on the specified TracePool.
74   virtual base::StatusOrStream<protos::TracePoolQueryResponse> TracePoolQuery(
75       const protos::TracePoolQueryArgs&) = 0;
76 
77   // Destroys the TracePool with the specified id.
78   virtual base::StatusOrFuture<protos::TracePoolDestroyResponse>
79   TracePoolDestroy(const protos::TracePoolDestroyArgs&) = 0;
80 };
81 
82 }  // namespace cloud_trace_processor
83 }  // namespace perfetto
84 
85 #endif  // INCLUDE_PERFETTO_EXT_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_H_
86