2 * Autogenerated by Thrift Compiler (0.11.0)
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
7 #include "ZipkinCollector.h"
9 namespace twitter
{ namespace zipkin
{ namespace thrift
{
12 ZipkinCollector_submitZipkinBatch_args::~ZipkinCollector_submitZipkinBatch_args() throw() {
16 uint32_t ZipkinCollector_submitZipkinBatch_args::read(::apache::thrift::protocol::TProtocol
* iprot
) {
18 ::apache::thrift::protocol::TInputRecursionTracker
tracker(*iprot
);
21 ::apache::thrift::protocol::TType ftype
;
24 xfer
+= iprot
->readStructBegin(fname
);
26 using ::apache::thrift::protocol::TProtocolException
;
31 xfer
+= iprot
->readFieldBegin(fname
, ftype
, fid
);
32 if (ftype
== ::apache::thrift::protocol::T_STOP
) {
38 if (ftype
== ::apache::thrift::protocol::T_LIST
) {
42 ::apache::thrift::protocol::TType _etype26
;
43 xfer
+= iprot
->readListBegin(_etype26
, _size23
);
44 this->spans
.resize(_size23
);
46 for (_i27
= 0; _i27
< _size23
; ++_i27
)
48 xfer
+= this->spans
[_i27
].read(iprot
);
50 xfer
+= iprot
->readListEnd();
52 this->__isset
.spans
= true;
54 xfer
+= iprot
->skip(ftype
);
58 xfer
+= iprot
->skip(ftype
);
61 xfer
+= iprot
->readFieldEnd();
64 xfer
+= iprot
->readStructEnd();
69 uint32_t ZipkinCollector_submitZipkinBatch_args::write(::apache::thrift::protocol::TProtocol
* oprot
) const {
71 ::apache::thrift::protocol::TOutputRecursionTracker
tracker(*oprot
);
72 xfer
+= oprot
->writeStructBegin("ZipkinCollector_submitZipkinBatch_args");
74 xfer
+= oprot
->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST
, 1);
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
)
80 xfer
+= (*_iter28
).write(oprot
);
82 xfer
+= oprot
->writeListEnd();
84 xfer
+= oprot
->writeFieldEnd();
86 xfer
+= oprot
->writeFieldStop();
87 xfer
+= oprot
->writeStructEnd();
92 ZipkinCollector_submitZipkinBatch_pargs::~ZipkinCollector_submitZipkinBatch_pargs() throw() {
96 uint32_t ZipkinCollector_submitZipkinBatch_pargs::write(::apache::thrift::protocol::TProtocol
* oprot
) const {
98 ::apache::thrift::protocol::TOutputRecursionTracker
tracker(*oprot
);
99 xfer
+= oprot
->writeStructBegin("ZipkinCollector_submitZipkinBatch_pargs");
101 xfer
+= oprot
->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST
, 1);
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
)
107 xfer
+= (*_iter29
).write(oprot
);
109 xfer
+= oprot
->writeListEnd();
111 xfer
+= oprot
->writeFieldEnd();
113 xfer
+= oprot
->writeFieldStop();
114 xfer
+= oprot
->writeStructEnd();
119 ZipkinCollector_submitZipkinBatch_result::~ZipkinCollector_submitZipkinBatch_result() throw() {
123 uint32_t ZipkinCollector_submitZipkinBatch_result::read(::apache::thrift::protocol::TProtocol
* iprot
) {
125 ::apache::thrift::protocol::TInputRecursionTracker
tracker(*iprot
);
128 ::apache::thrift::protocol::TType ftype
;
131 xfer
+= iprot
->readStructBegin(fname
);
133 using ::apache::thrift::protocol::TProtocolException
;
138 xfer
+= iprot
->readFieldBegin(fname
, ftype
, fid
);
139 if (ftype
== ::apache::thrift::protocol::T_STOP
) {
145 if (ftype
== ::apache::thrift::protocol::T_LIST
) {
147 this->success
.clear();
149 ::apache::thrift::protocol::TType _etype33
;
150 xfer
+= iprot
->readListBegin(_etype33
, _size30
);
151 this->success
.resize(_size30
);
153 for (_i34
= 0; _i34
< _size30
; ++_i34
)
155 xfer
+= this->success
[_i34
].read(iprot
);
157 xfer
+= iprot
->readListEnd();
159 this->__isset
.success
= true;
161 xfer
+= iprot
->skip(ftype
);
165 xfer
+= iprot
->skip(ftype
);
168 xfer
+= iprot
->readFieldEnd();
171 xfer
+= iprot
->readStructEnd();
176 uint32_t ZipkinCollector_submitZipkinBatch_result::write(::apache::thrift::protocol::TProtocol
* oprot
) const {
180 xfer
+= oprot
->writeStructBegin("ZipkinCollector_submitZipkinBatch_result");
182 if (this->__isset
.success
) {
183 xfer
+= oprot
->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST
, 0);
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
)
189 xfer
+= (*_iter35
).write(oprot
);
191 xfer
+= oprot
->writeListEnd();
193 xfer
+= oprot
->writeFieldEnd();
195 xfer
+= oprot
->writeFieldStop();
196 xfer
+= oprot
->writeStructEnd();
201 ZipkinCollector_submitZipkinBatch_presult::~ZipkinCollector_submitZipkinBatch_presult() throw() {
205 uint32_t ZipkinCollector_submitZipkinBatch_presult::read(::apache::thrift::protocol::TProtocol
* iprot
) {
207 ::apache::thrift::protocol::TInputRecursionTracker
tracker(*iprot
);
210 ::apache::thrift::protocol::TType ftype
;
213 xfer
+= iprot
->readStructBegin(fname
);
215 using ::apache::thrift::protocol::TProtocolException
;
220 xfer
+= iprot
->readFieldBegin(fname
, ftype
, fid
);
221 if (ftype
== ::apache::thrift::protocol::T_STOP
) {
227 if (ftype
== ::apache::thrift::protocol::T_LIST
) {
229 (*(this->success
)).clear();
231 ::apache::thrift::protocol::TType _etype39
;
232 xfer
+= iprot
->readListBegin(_etype39
, _size36
);
233 (*(this->success
)).resize(_size36
);
235 for (_i40
= 0; _i40
< _size36
; ++_i40
)
237 xfer
+= (*(this->success
))[_i40
].read(iprot
);
239 xfer
+= iprot
->readListEnd();
241 this->__isset
.success
= true;
243 xfer
+= iprot
->skip(ftype
);
247 xfer
+= iprot
->skip(ftype
);
250 xfer
+= iprot
->readFieldEnd();
253 xfer
+= iprot
->readStructEnd();
258 void ZipkinCollectorClient::submitZipkinBatch(std::vector
<Response
> & _return
, const std::vector
<Span
> & spans
)
260 send_submitZipkinBatch(spans
);
261 recv_submitZipkinBatch(_return
);
264 void ZipkinCollectorClient::send_submitZipkinBatch(const std::vector
<Span
> & spans
)
267 oprot_
->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_CALL
, cseqid
);
269 ZipkinCollector_submitZipkinBatch_pargs args
;
273 oprot_
->writeMessageEnd();
274 oprot_
->getTransport()->writeEnd();
275 oprot_
->getTransport()->flush();
278 void ZipkinCollectorClient::recv_submitZipkinBatch(std::vector
<Response
> & _return
)
283 ::apache::thrift::protocol::TMessageType mtype
;
285 iprot_
->readMessageBegin(fname
, mtype
, rseqid
);
286 if (mtype
== ::apache::thrift::protocol::T_EXCEPTION
) {
287 ::apache::thrift::TApplicationException x
;
289 iprot_
->readMessageEnd();
290 iprot_
->getTransport()->readEnd();
293 if (mtype
!= ::apache::thrift::protocol::T_REPLY
) {
294 iprot_
->skip(::apache::thrift::protocol::T_STRUCT
);
295 iprot_
->readMessageEnd();
296 iprot_
->getTransport()->readEnd();
298 if (fname
.compare("submitZipkinBatch") != 0) {
299 iprot_
->skip(::apache::thrift::protocol::T_STRUCT
);
300 iprot_
->readMessageEnd();
301 iprot_
->getTransport()->readEnd();
303 ZipkinCollector_submitZipkinBatch_presult result
;
304 result
.success
= &_return
;
306 iprot_
->readMessageEnd();
307 iprot_
->getTransport()->readEnd();
309 if (result
.__isset
.success
) {
310 // _return pointer has now been filled
313 throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT
, "submitZipkinBatch failed: unknown result");
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
);
326 oprot
->writeMessageEnd();
327 oprot
->getTransport()->writeEnd();
328 oprot
->getTransport()->flush();
331 (this->*(pfn
->second
))(seqid
, iprot
, oprot
, callContext
);
335 void ZipkinCollectorProcessor::process_submitZipkinBatch(int32_t seqid
, ::apache::thrift::protocol::TProtocol
* iprot
, ::apache::thrift::protocol::TProtocol
* oprot
, void* callContext
)
338 if (this->eventHandler_
.get() != NULL
) {
339 ctx
= this->eventHandler_
->getContext("ZipkinCollector.submitZipkinBatch", callContext
);
341 ::apache::thrift::TProcessorContextFreer
freer(this->eventHandler_
.get(), ctx
, "ZipkinCollector.submitZipkinBatch");
343 if (this->eventHandler_
.get() != NULL
) {
344 this->eventHandler_
->preRead(ctx
, "ZipkinCollector.submitZipkinBatch");
347 ZipkinCollector_submitZipkinBatch_args args
;
349 iprot
->readMessageEnd();
350 uint32_t bytes
= iprot
->getTransport()->readEnd();
352 if (this->eventHandler_
.get() != NULL
) {
353 this->eventHandler_
->postRead(ctx
, "ZipkinCollector.submitZipkinBatch", bytes
);
356 ZipkinCollector_submitZipkinBatch_result result
;
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");
365 ::apache::thrift::TApplicationException
x(e
.what());
366 oprot
->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_EXCEPTION
, seqid
);
368 oprot
->writeMessageEnd();
369 oprot
->getTransport()->writeEnd();
370 oprot
->getTransport()->flush();
374 if (this->eventHandler_
.get() != NULL
) {
375 this->eventHandler_
->preWrite(ctx
, "ZipkinCollector.submitZipkinBatch");
378 oprot
->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_REPLY
, seqid
);
380 oprot
->writeMessageEnd();
381 bytes
= oprot
->getTransport()->writeEnd();
382 oprot
->getTransport()->flush();
384 if (this->eventHandler_
.get() != NULL
) {
385 this->eventHandler_
->postWrite(ctx
, "ZipkinCollector.submitZipkinBatch", bytes
);
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
));
396 void ZipkinCollectorConcurrentClient::submitZipkinBatch(std::vector
<Response
> & _return
, const std::vector
<Span
> & spans
)
398 int32_t seqid
= send_submitZipkinBatch(spans
);
399 recv_submitZipkinBatch(_return
, seqid
);
402 int32_t ZipkinCollectorConcurrentClient::send_submitZipkinBatch(const std::vector
<Span
> & spans
)
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
);
408 ZipkinCollector_submitZipkinBatch_pargs args
;
412 oprot_
->writeMessageEnd();
413 oprot_
->getTransport()->writeEnd();
414 oprot_
->getTransport()->flush();
420 void ZipkinCollectorConcurrentClient::recv_submitZipkinBatch(std::vector
<Response
> & _return
, const int32_t seqid
)
425 ::apache::thrift::protocol::TMessageType mtype
;
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
);
432 if(!this->sync_
.getPending(fname
, mtype
, rseqid
)) {
433 iprot_
->readMessageBegin(fname
, mtype
, rseqid
);
435 if(seqid
== rseqid
) {
436 if (mtype
== ::apache::thrift::protocol::T_EXCEPTION
) {
437 ::apache::thrift::TApplicationException x
;
439 iprot_
->readMessageEnd();
440 iprot_
->getTransport()->readEnd();
444 if (mtype
!= ::apache::thrift::protocol::T_REPLY
) {
445 iprot_
->skip(::apache::thrift::protocol::T_STRUCT
);
446 iprot_
->readMessageEnd();
447 iprot_
->getTransport()->readEnd();
449 if (fname
.compare("submitZipkinBatch") != 0) {
450 iprot_
->skip(::apache::thrift::protocol::T_STRUCT
);
451 iprot_
->readMessageEnd();
452 iprot_
->getTransport()->readEnd();
454 // in a bad state, don't commit
455 using ::apache::thrift::protocol::TProtocolException
;
456 throw TProtocolException(TProtocolException::INVALID_DATA
);
458 ZipkinCollector_submitZipkinBatch_presult result
;
459 result
.success
= &_return
;
461 iprot_
->readMessageEnd();
462 iprot_
->getTransport()->readEnd();
464 if (result
.__isset
.success
) {
465 // _return pointer has now been filled
469 // in a bad state, don't commit
470 throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT
, "submitZipkinBatch failed: unknown result");
473 this->sync_
.updatePending(fname
, mtype
, rseqid
);
475 // this will temporarily unlock the readMutex, and let other clients get work done
476 this->sync_
.waitForWork(seqid
);