@@ -77,6 +77,7 @@ pub struct ExecutorMeta {
7777 pub id : String ,
7878 pub host : String ,
7979 pub port : u16 ,
80+ pub grpc_port : u16 ,
8081}
8182
8283#[ allow( clippy:: from_over_into) ]
@@ -86,6 +87,7 @@ impl Into<protobuf::ExecutorMetadata> for ExecutorMeta {
8687 id : self . id ,
8788 host : self . host ,
8889 port : self . port as u32 ,
90+ grpc_port : self . grpc_port as u32 ,
8991 }
9092 }
9193}
@@ -96,10 +98,149 @@ impl From<protobuf::ExecutorMetadata> for ExecutorMeta {
9698 id : meta. id ,
9799 host : meta. host ,
98100 port : meta. port as u16 ,
101+ grpc_port : meta. grpc_port as u16 ,
99102 }
100103 }
101104}
102105
106+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Serialize ) ]
107+ pub struct ExecutorSpecification {
108+ pub task_slots : u32 ,
109+ }
110+
111+ #[ allow( clippy:: from_over_into) ]
112+ impl Into < protobuf:: ExecutorSpecification > for ExecutorSpecification {
113+ fn into ( self ) -> protobuf:: ExecutorSpecification {
114+ protobuf:: ExecutorSpecification {
115+ resources : vec ! [ protobuf:: executor_resource:: Resource :: TaskSlots (
116+ self . task_slots,
117+ ) ]
118+ . into_iter ( )
119+ . map ( |r| protobuf:: ExecutorResource { resource : Some ( r) } )
120+ . collect ( ) ,
121+ }
122+ }
123+ }
124+
125+ impl From < protobuf:: ExecutorSpecification > for ExecutorSpecification {
126+ fn from ( input : protobuf:: ExecutorSpecification ) -> Self {
127+ let mut ret = Self { task_slots : 0 } ;
128+ for resource in input. resources {
129+ if let Some ( protobuf:: executor_resource:: Resource :: TaskSlots ( task_slots) ) =
130+ resource. resource
131+ {
132+ ret. task_slots = task_slots
133+ }
134+ }
135+ ret
136+ }
137+ }
138+
139+ #[ derive( Debug , Clone , Serialize ) ]
140+ pub struct ExecutorData {
141+ pub executor_id : String ,
142+ pub total_task_slots : u32 ,
143+ pub available_task_slots : u32 ,
144+ }
145+
146+ struct ExecutorResourcePair {
147+ total : protobuf:: executor_resource:: Resource ,
148+ available : protobuf:: executor_resource:: Resource ,
149+ }
150+
151+ #[ allow( clippy:: from_over_into) ]
152+ impl Into < protobuf:: ExecutorData > for ExecutorData {
153+ fn into ( self ) -> protobuf:: ExecutorData {
154+ protobuf:: ExecutorData {
155+ executor_id : self . executor_id ,
156+ resources : vec ! [ ExecutorResourcePair {
157+ total: protobuf:: executor_resource:: Resource :: TaskSlots (
158+ self . total_task_slots,
159+ ) ,
160+ available: protobuf:: executor_resource:: Resource :: TaskSlots (
161+ self . available_task_slots,
162+ ) ,
163+ } ]
164+ . into_iter ( )
165+ . map ( |r| protobuf:: ExecutorResourcePair {
166+ total : Some ( protobuf:: ExecutorResource {
167+ resource : Some ( r. total ) ,
168+ } ) ,
169+ available : Some ( protobuf:: ExecutorResource {
170+ resource : Some ( r. available ) ,
171+ } ) ,
172+ } )
173+ . collect ( ) ,
174+ }
175+ }
176+ }
177+
178+ impl From < protobuf:: ExecutorData > for ExecutorData {
179+ fn from ( input : protobuf:: ExecutorData ) -> Self {
180+ let mut ret = Self {
181+ executor_id : input. executor_id ,
182+ total_task_slots : 0 ,
183+ available_task_slots : 0 ,
184+ } ;
185+ for resource in input. resources {
186+ if let Some ( task_slots) = resource. total {
187+ if let Some ( protobuf:: executor_resource:: Resource :: TaskSlots (
188+ task_slots,
189+ ) ) = task_slots. resource
190+ {
191+ ret. total_task_slots = task_slots
192+ }
193+ } ;
194+ if let Some ( task_slots) = resource. available {
195+ if let Some ( protobuf:: executor_resource:: Resource :: TaskSlots (
196+ task_slots,
197+ ) ) = task_slots. resource
198+ {
199+ ret. available_task_slots = task_slots
200+ }
201+ } ;
202+ }
203+ ret
204+ }
205+ }
206+
207+ #[ derive( Debug , Clone , Copy , Serialize ) ]
208+ pub struct ExecutorState {
209+ // in bytes
210+ pub available_memory_size : u64 ,
211+ }
212+
213+ #[ allow( clippy:: from_over_into) ]
214+ impl Into < protobuf:: ExecutorState > for ExecutorState {
215+ fn into ( self ) -> protobuf:: ExecutorState {
216+ protobuf:: ExecutorState {
217+ metrics : vec ! [ protobuf:: executor_metric:: Metric :: AvailableMemory (
218+ self . available_memory_size,
219+ ) ]
220+ . into_iter ( )
221+ . map ( |m| protobuf:: ExecutorMetric { metric : Some ( m) } )
222+ . collect ( ) ,
223+ }
224+ }
225+ }
226+
227+ impl From < protobuf:: ExecutorState > for ExecutorState {
228+ fn from ( input : protobuf:: ExecutorState ) -> Self {
229+ let mut ret = Self {
230+ available_memory_size : u64:: MAX ,
231+ } ;
232+ for metric in input. metrics {
233+ if let Some ( protobuf:: executor_metric:: Metric :: AvailableMemory (
234+ available_memory_size,
235+ ) ) = metric. metric
236+ {
237+ ret. available_memory_size = available_memory_size
238+ }
239+ }
240+ ret
241+ }
242+ }
243+
103244/// Summary of executed partition
104245#[ derive( Debug , Copy , Clone , Default ) ]
105246pub struct PartitionStats {
0 commit comments