]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /** |
2 | * Autogenerated by Thrift Compiler (0.11.0) | |
3 | * | |
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
5 | * @generated | |
6 | */ | |
7 | #include "ZipkinCollector.h" | |
8 | ||
9 | namespace twitter { namespace zipkin { namespace thrift { | |
10 | ||
11 | ||
12 | ZipkinCollector_submitZipkinBatch_args::~ZipkinCollector_submitZipkinBatch_args() throw() { | |
13 | } | |
14 | ||
15 | ||
16 | uint32_t ZipkinCollector_submitZipkinBatch_args::read(::apache::thrift::protocol::TProtocol* iprot) { | |
17 | ||
18 | ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); | |
19 | uint32_t xfer = 0; | |
20 | std::string fname; | |
21 | ::apache::thrift::protocol::TType ftype; | |
22 | int16_t fid; | |
23 | ||
24 | xfer += iprot->readStructBegin(fname); | |
25 | ||
26 | using ::apache::thrift::protocol::TProtocolException; | |
27 | ||
28 | ||
29 | while (true) | |
30 | { | |
31 | xfer += iprot->readFieldBegin(fname, ftype, fid); | |
32 | if (ftype == ::apache::thrift::protocol::T_STOP) { | |
33 | break; | |
34 | } | |
35 | switch (fid) | |
36 | { | |
37 | case 1: | |
38 | if (ftype == ::apache::thrift::protocol::T_LIST) { | |
39 | { | |
40 | this->spans.clear(); | |
41 | uint32_t _size23; | |
42 | ::apache::thrift::protocol::TType _etype26; | |
43 | xfer += iprot->readListBegin(_etype26, _size23); | |
44 | this->spans.resize(_size23); | |
45 | uint32_t _i27; | |
46 | for (_i27 = 0; _i27 < _size23; ++_i27) | |
47 | { | |
48 | xfer += this->spans[_i27].read(iprot); | |
49 | } | |
50 | xfer += iprot->readListEnd(); | |
51 | } | |
52 | this->__isset.spans = true; | |
53 | } else { | |
54 | xfer += iprot->skip(ftype); | |
55 | } | |
56 | break; | |
57 | default: | |
58 | xfer += iprot->skip(ftype); | |
59 | break; | |
60 | } | |
61 | xfer += iprot->readFieldEnd(); | |
62 | } | |
63 | ||
64 | xfer += iprot->readStructEnd(); | |
65 | ||
66 | return xfer; | |
67 | } | |
68 | ||
69 | uint32_t ZipkinCollector_submitZipkinBatch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { | |
70 | uint32_t xfer = 0; | |
71 | ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); | |
72 | xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_args"); | |
73 | ||
74 | xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); | |
75 | { | |
76 | xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->spans.size())); | |
77 | std::vector<Span> ::const_iterator _iter28; | |
78 | for (_iter28 = this->spans.begin(); _iter28 != this->spans.end(); ++_iter28) | |
79 | { | |
80 | xfer += (*_iter28).write(oprot); | |
81 | } | |
82 | xfer += oprot->writeListEnd(); | |
83 | } | |
84 | xfer += oprot->writeFieldEnd(); | |
85 | ||
86 | xfer += oprot->writeFieldStop(); | |
87 | xfer += oprot->writeStructEnd(); | |
88 | return xfer; | |
89 | } | |
90 | ||
91 | ||
92 | ZipkinCollector_submitZipkinBatch_pargs::~ZipkinCollector_submitZipkinBatch_pargs() throw() { | |
93 | } | |
94 | ||
95 | ||
96 | uint32_t ZipkinCollector_submitZipkinBatch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { | |
97 | uint32_t xfer = 0; | |
98 | ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); | |
99 | xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_pargs"); | |
100 | ||
101 | xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); | |
102 | { | |
103 | xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>((*(this->spans)).size())); | |
104 | std::vector<Span> ::const_iterator _iter29; | |
105 | for (_iter29 = (*(this->spans)).begin(); _iter29 != (*(this->spans)).end(); ++_iter29) | |
106 | { | |
107 | xfer += (*_iter29).write(oprot); | |
108 | } | |
109 | xfer += oprot->writeListEnd(); | |
110 | } | |
111 | xfer += oprot->writeFieldEnd(); | |
112 | ||
113 | xfer += oprot->writeFieldStop(); | |
114 | xfer += oprot->writeStructEnd(); | |
115 | return xfer; | |
116 | } | |
117 | ||
118 | ||
119 | ZipkinCollector_submitZipkinBatch_result::~ZipkinCollector_submitZipkinBatch_result() throw() { | |
120 | } | |
121 | ||
122 | ||
123 | uint32_t ZipkinCollector_submitZipkinBatch_result::read(::apache::thrift::protocol::TProtocol* iprot) { | |
124 | ||
125 | ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); | |
126 | uint32_t xfer = 0; | |
127 | std::string fname; | |
128 | ::apache::thrift::protocol::TType ftype; | |
129 | int16_t fid; | |
130 | ||
131 | xfer += iprot->readStructBegin(fname); | |
132 | ||
133 | using ::apache::thrift::protocol::TProtocolException; | |
134 | ||
135 | ||
136 | while (true) | |
137 | { | |
138 | xfer += iprot->readFieldBegin(fname, ftype, fid); | |
139 | if (ftype == ::apache::thrift::protocol::T_STOP) { | |
140 | break; | |
141 | } | |
142 | switch (fid) | |
143 | { | |
144 | case 0: | |
145 | if (ftype == ::apache::thrift::protocol::T_LIST) { | |
146 | { | |
147 | this->success.clear(); | |
148 | uint32_t _size30; | |
149 | ::apache::thrift::protocol::TType _etype33; | |
150 | xfer += iprot->readListBegin(_etype33, _size30); | |
151 | this->success.resize(_size30); | |
152 | uint32_t _i34; | |
153 | for (_i34 = 0; _i34 < _size30; ++_i34) | |
154 | { | |
155 | xfer += this->success[_i34].read(iprot); | |
156 | } | |
157 | xfer += iprot->readListEnd(); | |
158 | } | |
159 | this->__isset.success = true; | |
160 | } else { | |
161 | xfer += iprot->skip(ftype); | |
162 | } | |
163 | break; | |
164 | default: | |
165 | xfer += iprot->skip(ftype); | |
166 | break; | |
167 | } | |
168 | xfer += iprot->readFieldEnd(); | |
169 | } | |
170 | ||
171 | xfer += iprot->readStructEnd(); | |
172 | ||
173 | return xfer; | |
174 | } | |
175 | ||
176 | uint32_t ZipkinCollector_submitZipkinBatch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { | |
177 | ||
178 | uint32_t xfer = 0; | |
179 | ||
180 | xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_result"); | |
181 | ||
182 | if (this->__isset.success) { | |
183 | xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); | |
184 | { | |
185 | xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->success.size())); | |
186 | std::vector<Response> ::const_iterator _iter35; | |
187 | for (_iter35 = this->success.begin(); _iter35 != this->success.end(); ++_iter35) | |
188 | { | |
189 | xfer += (*_iter35).write(oprot); | |
190 | } | |
191 | xfer += oprot->writeListEnd(); | |
192 | } | |
193 | xfer += oprot->writeFieldEnd(); | |
194 | } | |
195 | xfer += oprot->writeFieldStop(); | |
196 | xfer += oprot->writeStructEnd(); | |
197 | return xfer; | |
198 | } | |
199 | ||
200 | ||
201 | ZipkinCollector_submitZipkinBatch_presult::~ZipkinCollector_submitZipkinBatch_presult() throw() { | |
202 | } | |
203 | ||
204 | ||
205 | uint32_t ZipkinCollector_submitZipkinBatch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { | |
206 | ||
207 | ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); | |
208 | uint32_t xfer = 0; | |
209 | std::string fname; | |
210 | ::apache::thrift::protocol::TType ftype; | |
211 | int16_t fid; | |
212 | ||
213 | xfer += iprot->readStructBegin(fname); | |
214 | ||
215 | using ::apache::thrift::protocol::TProtocolException; | |
216 | ||
217 | ||
218 | while (true) | |
219 | { | |
220 | xfer += iprot->readFieldBegin(fname, ftype, fid); | |
221 | if (ftype == ::apache::thrift::protocol::T_STOP) { | |
222 | break; | |
223 | } | |
224 | switch (fid) | |
225 | { | |
226 | case 0: | |
227 | if (ftype == ::apache::thrift::protocol::T_LIST) { | |
228 | { | |
229 | (*(this->success)).clear(); | |
230 | uint32_t _size36; | |
231 | ::apache::thrift::protocol::TType _etype39; | |
232 | xfer += iprot->readListBegin(_etype39, _size36); | |
233 | (*(this->success)).resize(_size36); | |
234 | uint32_t _i40; | |
235 | for (_i40 = 0; _i40 < _size36; ++_i40) | |
236 | { | |
237 | xfer += (*(this->success))[_i40].read(iprot); | |
238 | } | |
239 | xfer += iprot->readListEnd(); | |
240 | } | |
241 | this->__isset.success = true; | |
242 | } else { | |
243 | xfer += iprot->skip(ftype); | |
244 | } | |
245 | break; | |
246 | default: | |
247 | xfer += iprot->skip(ftype); | |
248 | break; | |
249 | } | |
250 | xfer += iprot->readFieldEnd(); | |
251 | } | |
252 | ||
253 | xfer += iprot->readStructEnd(); | |
254 | ||
255 | return xfer; | |
256 | } | |
257 | ||
258 | void ZipkinCollectorClient::submitZipkinBatch(std::vector<Response> & _return, const std::vector<Span> & spans) | |
259 | { | |
260 | send_submitZipkinBatch(spans); | |
261 | recv_submitZipkinBatch(_return); | |
262 | } | |
263 | ||
264 | void ZipkinCollectorClient::send_submitZipkinBatch(const std::vector<Span> & spans) | |
265 | { | |
266 | int32_t cseqid = 0; | |
267 | oprot_->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_CALL, cseqid); | |
268 | ||
269 | ZipkinCollector_submitZipkinBatch_pargs args; | |
270 | args.spans = &spans; | |
271 | args.write(oprot_); | |
272 | ||
273 | oprot_->writeMessageEnd(); | |
274 | oprot_->getTransport()->writeEnd(); | |
275 | oprot_->getTransport()->flush(); | |
276 | } | |
277 | ||
278 | void ZipkinCollectorClient::recv_submitZipkinBatch(std::vector<Response> & _return) | |
279 | { | |
280 | ||
281 | int32_t rseqid = 0; | |
282 | std::string fname; | |
283 | ::apache::thrift::protocol::TMessageType mtype; | |
284 | ||
285 | iprot_->readMessageBegin(fname, mtype, rseqid); | |
286 | if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { | |
287 | ::apache::thrift::TApplicationException x; | |
288 | x.read(iprot_); | |
289 | iprot_->readMessageEnd(); | |
290 | iprot_->getTransport()->readEnd(); | |
291 | throw x; | |
292 | } | |
293 | if (mtype != ::apache::thrift::protocol::T_REPLY) { | |
294 | iprot_->skip(::apache::thrift::protocol::T_STRUCT); | |
295 | iprot_->readMessageEnd(); | |
296 | iprot_->getTransport()->readEnd(); | |
297 | } | |
298 | if (fname.compare("submitZipkinBatch") != 0) { | |
299 | iprot_->skip(::apache::thrift::protocol::T_STRUCT); | |
300 | iprot_->readMessageEnd(); | |
301 | iprot_->getTransport()->readEnd(); | |
302 | } | |
303 | ZipkinCollector_submitZipkinBatch_presult result; | |
304 | result.success = &_return; | |
305 | result.read(iprot_); | |
306 | iprot_->readMessageEnd(); | |
307 | iprot_->getTransport()->readEnd(); | |
308 | ||
309 | if (result.__isset.success) { | |
310 | // _return pointer has now been filled | |
311 | return; | |
312 | } | |
313 | throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitZipkinBatch failed: unknown result"); | |
314 | } | |
315 | ||
316 | bool ZipkinCollectorProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { | |
317 | ProcessMap::iterator pfn; | |
318 | pfn = processMap_.find(fname); | |
319 | if (pfn == processMap_.end()) { | |
320 | iprot->skip(::apache::thrift::protocol::T_STRUCT); | |
321 | iprot->readMessageEnd(); | |
322 | iprot->getTransport()->readEnd(); | |
323 | ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); | |
324 | oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); | |
325 | x.write(oprot); | |
326 | oprot->writeMessageEnd(); | |
327 | oprot->getTransport()->writeEnd(); | |
328 | oprot->getTransport()->flush(); | |
329 | return true; | |
330 | } | |
331 | (this->*(pfn->second))(seqid, iprot, oprot, callContext); | |
332 | return true; | |
333 | } | |
334 | ||
335 | void ZipkinCollectorProcessor::process_submitZipkinBatch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) | |
336 | { | |
337 | void* ctx = NULL; | |
338 | if (this->eventHandler_.get() != NULL) { | |
339 | ctx = this->eventHandler_->getContext("ZipkinCollector.submitZipkinBatch", callContext); | |
340 | } | |
341 | ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ZipkinCollector.submitZipkinBatch"); | |
342 | ||
343 | if (this->eventHandler_.get() != NULL) { | |
344 | this->eventHandler_->preRead(ctx, "ZipkinCollector.submitZipkinBatch"); | |
345 | } | |
346 | ||
347 | ZipkinCollector_submitZipkinBatch_args args; | |
348 | args.read(iprot); | |
349 | iprot->readMessageEnd(); | |
350 | uint32_t bytes = iprot->getTransport()->readEnd(); | |
351 | ||
352 | if (this->eventHandler_.get() != NULL) { | |
353 | this->eventHandler_->postRead(ctx, "ZipkinCollector.submitZipkinBatch", bytes); | |
354 | } | |
355 | ||
356 | ZipkinCollector_submitZipkinBatch_result result; | |
357 | try { | |
358 | iface_->submitZipkinBatch(result.success, args.spans); | |
359 | result.__isset.success = true; | |
360 | } catch (const std::exception& e) { | |
361 | if (this->eventHandler_.get() != NULL) { | |
362 | this->eventHandler_->handlerError(ctx, "ZipkinCollector.submitZipkinBatch"); | |
363 | } | |
364 | ||
365 | ::apache::thrift::TApplicationException x(e.what()); | |
366 | oprot->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_EXCEPTION, seqid); | |
367 | x.write(oprot); | |
368 | oprot->writeMessageEnd(); | |
369 | oprot->getTransport()->writeEnd(); | |
370 | oprot->getTransport()->flush(); | |
371 | return; | |
372 | } | |
373 | ||
374 | if (this->eventHandler_.get() != NULL) { | |
375 | this->eventHandler_->preWrite(ctx, "ZipkinCollector.submitZipkinBatch"); | |
376 | } | |
377 | ||
378 | oprot->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_REPLY, seqid); | |
379 | result.write(oprot); | |
380 | oprot->writeMessageEnd(); | |
381 | bytes = oprot->getTransport()->writeEnd(); | |
382 | oprot->getTransport()->flush(); | |
383 | ||
384 | if (this->eventHandler_.get() != NULL) { | |
385 | this->eventHandler_->postWrite(ctx, "ZipkinCollector.submitZipkinBatch", bytes); | |
386 | } | |
387 | } | |
388 | ||
389 | ::std::shared_ptr< ::apache::thrift::TProcessor > ZipkinCollectorProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { | |
390 | ::apache::thrift::ReleaseHandler< ZipkinCollectorIfFactory > cleanup(handlerFactory_); | |
391 | ::std::shared_ptr< ZipkinCollectorIf > handler(handlerFactory_->getHandler(connInfo), cleanup); | |
392 | ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new ZipkinCollectorProcessor(handler)); | |
393 | return processor; | |
394 | } | |
395 | ||
396 | void ZipkinCollectorConcurrentClient::submitZipkinBatch(std::vector<Response> & _return, const std::vector<Span> & spans) | |
397 | { | |
398 | int32_t seqid = send_submitZipkinBatch(spans); | |
399 | recv_submitZipkinBatch(_return, seqid); | |
400 | } | |
401 | ||
402 | int32_t ZipkinCollectorConcurrentClient::send_submitZipkinBatch(const std::vector<Span> & spans) | |
403 | { | |
404 | int32_t cseqid = this->sync_.generateSeqId(); | |
405 | ::apache::thrift::async::TConcurrentSendSentry sentry(&this->sync_); | |
406 | oprot_->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_CALL, cseqid); | |
407 | ||
408 | ZipkinCollector_submitZipkinBatch_pargs args; | |
409 | args.spans = &spans; | |
410 | args.write(oprot_); | |
411 | ||
412 | oprot_->writeMessageEnd(); | |
413 | oprot_->getTransport()->writeEnd(); | |
414 | oprot_->getTransport()->flush(); | |
415 | ||
416 | sentry.commit(); | |
417 | return cseqid; | |
418 | } | |
419 | ||
420 | void ZipkinCollectorConcurrentClient::recv_submitZipkinBatch(std::vector<Response> & _return, const int32_t seqid) | |
421 | { | |
422 | ||
423 | int32_t rseqid = 0; | |
424 | std::string fname; | |
425 | ::apache::thrift::protocol::TMessageType mtype; | |
426 | ||
427 | // the read mutex gets dropped and reacquired as part of waitForWork() | |
428 | // The destructor of this sentry wakes up other clients | |
429 | ::apache::thrift::async::TConcurrentRecvSentry sentry(&this->sync_, seqid); | |
430 | ||
431 | while(true) { | |
432 | if(!this->sync_.getPending(fname, mtype, rseqid)) { | |
433 | iprot_->readMessageBegin(fname, mtype, rseqid); | |
434 | } | |
435 | if(seqid == rseqid) { | |
436 | if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { | |
437 | ::apache::thrift::TApplicationException x; | |
438 | x.read(iprot_); | |
439 | iprot_->readMessageEnd(); | |
440 | iprot_->getTransport()->readEnd(); | |
441 | sentry.commit(); | |
442 | throw x; | |
443 | } | |
444 | if (mtype != ::apache::thrift::protocol::T_REPLY) { | |
445 | iprot_->skip(::apache::thrift::protocol::T_STRUCT); | |
446 | iprot_->readMessageEnd(); | |
447 | iprot_->getTransport()->readEnd(); | |
448 | } | |
449 | if (fname.compare("submitZipkinBatch") != 0) { | |
450 | iprot_->skip(::apache::thrift::protocol::T_STRUCT); | |
451 | iprot_->readMessageEnd(); | |
452 | iprot_->getTransport()->readEnd(); | |
453 | ||
454 | // in a bad state, don't commit | |
455 | using ::apache::thrift::protocol::TProtocolException; | |
456 | throw TProtocolException(TProtocolException::INVALID_DATA); | |
457 | } | |
458 | ZipkinCollector_submitZipkinBatch_presult result; | |
459 | result.success = &_return; | |
460 | result.read(iprot_); | |
461 | iprot_->readMessageEnd(); | |
462 | iprot_->getTransport()->readEnd(); | |
463 | ||
464 | if (result.__isset.success) { | |
465 | // _return pointer has now been filled | |
466 | sentry.commit(); | |
467 | return; | |
468 | } | |
469 | // in a bad state, don't commit | |
470 | throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitZipkinBatch failed: unknown result"); | |
471 | } | |
472 | // seqid != rseqid | |
473 | this->sync_.updatePending(fname, mtype, rseqid); | |
474 | ||
475 | // this will temporarily unlock the readMutex, and let other clients get work done | |
476 | this->sync_.waitForWork(seqid); | |
477 | } // end while(true) | |
478 | } | |
479 | ||
480 | }}} // namespace | |
481 |