| 1 |
# |
| 2 |
# Autogenerated by Thrift Compiler (0.9.3) |
| 3 |
# |
| 4 |
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 5 |
# |
| 6 |
# options string: py:new_style,tornado |
| 7 |
# |
| 8 |
|
| 9 |
from thrift.Thrift import TType, TMessageType, TException, TApplicationException |
| 10 |
import logging |
| 11 |
from .ttypes import * |
| 12 |
from thrift.Thrift import TProcessor |
| 13 |
from thrift.transport import TTransport |
| 14 |
from thrift.protocol import TBinaryProtocol, TProtocol |
| 15 |
try: |
| 16 |
from thrift.protocol import fastbinary |
| 17 |
except: |
| 18 |
fastbinary = None |
| 19 |
|
| 20 |
from tornado import gen |
| 21 |
from tornado import concurrent |
| 22 |
from thrift.transport import TTransport |
| 23 |
|
| 24 |
class Iface(object): |
| 25 |
def startTrace(self, request): |
| 26 |
""" |
| 27 |
Parameters: |
| 28 |
- request |
| 29 |
""" |
| 30 |
pass |
| 31 |
|
| 32 |
def joinTrace(self, request): |
| 33 |
""" |
| 34 |
Parameters: |
| 35 |
- request |
| 36 |
""" |
| 37 |
pass |
| 38 |
|
| 39 |
|
| 40 |
class Client(Iface): |
| 41 |
def __init__(self, transport, iprot_factory, oprot_factory=None): |
| 42 |
self._transport = transport |
| 43 |
self._iprot_factory = iprot_factory |
| 44 |
self._oprot_factory = (oprot_factory if oprot_factory is not None |
| 45 |
else iprot_factory) |
| 46 |
self._seqid = 0 |
| 47 |
self._reqs = {} |
| 48 |
self._transport.io_loop.spawn_callback(self._start_receiving) |
| 49 |
|
| 50 |
@gen.engine |
| 51 |
def _start_receiving(self): |
| 52 |
while True: |
| 53 |
try: |
| 54 |
frame = yield self._transport.readFrame() |
| 55 |
except TTransport.TTransportException as e: |
| 56 |
for future in self._reqs.itervalues(): |
| 57 |
future.set_exception(e) |
| 58 |
self._reqs = {} |
| 59 |
return |
| 60 |
tr = TTransport.TMemoryBuffer(frame) |
| 61 |
iprot = self._iprot_factory.getProtocol(tr) |
| 62 |
(fname, mtype, rseqid) = iprot.readMessageBegin() |
| 63 |
future = self._reqs.pop(rseqid, None) |
| 64 |
if not future: |
| 65 |
# future has already been discarded |
| 66 |
continue |
| 67 |
method = getattr(self, 'recv_' + fname) |
| 68 |
try: |
| 69 |
result = method(iprot, mtype, rseqid) |
| 70 |
except Exception as e: |
| 71 |
future.set_exception(e) |
| 72 |
else: |
| 73 |
future.set_result(result) |
| 74 |
|
| 75 |
def startTrace(self, request): |
| 76 |
""" |
| 77 |
Parameters: |
| 78 |
- request |
| 79 |
""" |
| 80 |
self._seqid += 1 |
| 81 |
future = self._reqs[self._seqid] = concurrent.Future() |
| 82 |
self.send_startTrace(request) |
| 83 |
return future |
| 84 |
|
| 85 |
def send_startTrace(self, request): |
| 86 |
oprot = self._oprot_factory.getProtocol(self._transport) |
| 87 |
oprot.writeMessageBegin('startTrace', TMessageType.CALL, self._seqid) |
| 88 |
args = startTrace_args() |
| 89 |
args.request = request |
| 90 |
args.write(oprot) |
| 91 |
oprot.writeMessageEnd() |
| 92 |
oprot.trans.flush() |
| 93 |
|
| 94 |
def recv_startTrace(self, iprot, mtype, rseqid): |
| 95 |
if mtype == TMessageType.EXCEPTION: |
| 96 |
x = TApplicationException() |
| 97 |
x.read(iprot) |
| 98 |
iprot.readMessageEnd() |
| 99 |
raise x |
| 100 |
result = startTrace_result() |
| 101 |
result.read(iprot) |
| 102 |
iprot.readMessageEnd() |
| 103 |
if result.success is not None: |
| 104 |
return result.success |
| 105 |
raise TApplicationException(TApplicationException.MISSING_RESULT, "startTrace failed: unknown result") |
| 106 |
|
| 107 |
def joinTrace(self, request): |
| 108 |
""" |
| 109 |
Parameters: |
| 110 |
- request |
| 111 |
""" |
| 112 |
self._seqid += 1 |
| 113 |
future = self._reqs[self._seqid] = concurrent.Future() |
| 114 |
self.send_joinTrace(request) |
| 115 |
return future |
| 116 |
|
| 117 |
def send_joinTrace(self, request): |
| 118 |
oprot = self._oprot_factory.getProtocol(self._transport) |
| 119 |
oprot.writeMessageBegin('joinTrace', TMessageType.CALL, self._seqid) |
| 120 |
args = joinTrace_args() |
| 121 |
args.request = request |
| 122 |
args.write(oprot) |
| 123 |
oprot.writeMessageEnd() |
| 124 |
oprot.trans.flush() |
| 125 |
|
| 126 |
def recv_joinTrace(self, iprot, mtype, rseqid): |
| 127 |
if mtype == TMessageType.EXCEPTION: |
| 128 |
x = TApplicationException() |
| 129 |
x.read(iprot) |
| 130 |
iprot.readMessageEnd() |
| 131 |
raise x |
| 132 |
result = joinTrace_result() |
| 133 |
result.read(iprot) |
| 134 |
iprot.readMessageEnd() |
| 135 |
if result.success is not None: |
| 136 |
return result.success |
| 137 |
raise TApplicationException(TApplicationException.MISSING_RESULT, "joinTrace failed: unknown result") |
| 138 |
|
| 139 |
|
| 140 |
class Processor(Iface, TProcessor): |
| 141 |
def __init__(self, handler): |
| 142 |
self._handler = handler |
| 143 |
self._processMap = {} |
| 144 |
self._processMap["startTrace"] = Processor.process_startTrace |
| 145 |
self._processMap["joinTrace"] = Processor.process_joinTrace |
| 146 |
|
| 147 |
def process(self, iprot, oprot): |
| 148 |
(name, type, seqid) = iprot.readMessageBegin() |
| 149 |
if name not in self._processMap: |
| 150 |
iprot.skip(TType.STRUCT) |
| 151 |
iprot.readMessageEnd() |
| 152 |
x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) |
| 153 |
oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) |
| 154 |
x.write(oprot) |
| 155 |
oprot.writeMessageEnd() |
| 156 |
oprot.trans.flush() |
| 157 |
return |
| 158 |
else: |
| 159 |
return self._processMap[name](self, seqid, iprot, oprot) |
| 160 |
|
| 161 |
@gen.coroutine |
| 162 |
def process_startTrace(self, seqid, iprot, oprot): |
| 163 |
args = startTrace_args() |
| 164 |
args.read(iprot) |
| 165 |
iprot.readMessageEnd() |
| 166 |
result = startTrace_result() |
| 167 |
result.success = yield gen.maybe_future(self._handler.startTrace(args.request)) |
| 168 |
oprot.writeMessageBegin("startTrace", TMessageType.REPLY, seqid) |
| 169 |
result.write(oprot) |
| 170 |
oprot.writeMessageEnd() |
| 171 |
oprot.trans.flush() |
| 172 |
|
| 173 |
@gen.coroutine |
| 174 |
def process_joinTrace(self, seqid, iprot, oprot): |
| 175 |
args = joinTrace_args() |
| 176 |
args.read(iprot) |
| 177 |
iprot.readMessageEnd() |
| 178 |
result = joinTrace_result() |
| 179 |
result.success = yield gen.maybe_future(self._handler.joinTrace(args.request)) |
| 180 |
oprot.writeMessageBegin("joinTrace", TMessageType.REPLY, seqid) |
| 181 |
result.write(oprot) |
| 182 |
oprot.writeMessageEnd() |
| 183 |
oprot.trans.flush() |
| 184 |
|
| 185 |
|
| 186 |
# HELPER FUNCTIONS AND STRUCTURES |
| 187 |
|
| 188 |
class startTrace_args(object): |
| 189 |
""" |
| 190 |
Attributes: |
| 191 |
- request |
| 192 |
""" |
| 193 |
|
| 194 |
thrift_spec = ( |
| 195 |
None, # 0 |
| 196 |
(1, TType.STRUCT, 'request', (StartTraceRequest, StartTraceRequest.thrift_spec), None, ), # 1 |
| 197 |
) |
| 198 |
|
| 199 |
def __init__(self, request=None,): |
| 200 |
self.request = request |
| 201 |
|
| 202 |
def read(self, iprot): |
| 203 |
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: |
| 204 |
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) |
| 205 |
return |
| 206 |
iprot.readStructBegin() |
| 207 |
while True: |
| 208 |
(fname, ftype, fid) = iprot.readFieldBegin() |
| 209 |
if ftype == TType.STOP: |
| 210 |
break |
| 211 |
if fid == 1: |
| 212 |
if ftype == TType.STRUCT: |
| 213 |
self.request = StartTraceRequest() |
| 214 |
self.request.read(iprot) |
| 215 |
else: |
| 216 |
iprot.skip(ftype) |
| 217 |
else: |
| 218 |
iprot.skip(ftype) |
| 219 |
iprot.readFieldEnd() |
| 220 |
iprot.readStructEnd() |
| 221 |
|
| 222 |
def write(self, oprot): |
| 223 |
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: |
| 224 |
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) |
| 225 |
return |
| 226 |
oprot.writeStructBegin('startTrace_args') |
| 227 |
if self.request is not None: |
| 228 |
oprot.writeFieldBegin('request', TType.STRUCT, 1) |
| 229 |
self.request.write(oprot) |
| 230 |
oprot.writeFieldEnd() |
| 231 |
oprot.writeFieldStop() |
| 232 |
oprot.writeStructEnd() |
| 233 |
|
| 234 |
def validate(self): |
| 235 |
return |
| 236 |
|
| 237 |
|
| 238 |
def __hash__(self): |
| 239 |
value = 17 |
| 240 |
value = (value * 31) ^ hash(self.request) |
| 241 |
return value |
| 242 |
|
| 243 |
def __repr__(self): |
| 244 |
L = ['%s=%r' % (key, value) |
| 245 |
for key, value in self.__dict__.iteritems()] |
| 246 |
return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) |
| 247 |
|
| 248 |
def __eq__(self, other): |
| 249 |
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ |
| 250 |
|
| 251 |
def __ne__(self, other): |
| 252 |
return not (self == other) |
| 253 |
|
| 254 |
class startTrace_result(object): |
| 255 |
""" |
| 256 |
Attributes: |
| 257 |
- success |
| 258 |
""" |
| 259 |
|
| 260 |
thrift_spec = ( |
| 261 |
(0, TType.STRUCT, 'success', (TraceResponse, TraceResponse.thrift_spec), None, ), # 0 |
| 262 |
) |
| 263 |
|
| 264 |
def __init__(self, success=None,): |
| 265 |
self.success = success |
| 266 |
|
| 267 |
def read(self, iprot): |
| 268 |
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: |
| 269 |
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) |
| 270 |
return |
| 271 |
iprot.readStructBegin() |
| 272 |
while True: |
| 273 |
(fname, ftype, fid) = iprot.readFieldBegin() |
| 274 |
if ftype == TType.STOP: |
| 275 |
break |
| 276 |
if fid == 0: |
| 277 |
if ftype == TType.STRUCT: |
| 278 |
self.success = TraceResponse() |
| 279 |
self.success.read(iprot) |
| 280 |
else: |
| 281 |
iprot.skip(ftype) |
| 282 |
else: |
| 283 |
iprot.skip(ftype) |
| 284 |
iprot.readFieldEnd() |
| 285 |
iprot.readStructEnd() |
| 286 |
|
| 287 |
def write(self, oprot): |
| 288 |
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: |
| 289 |
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) |
| 290 |
return |
| 291 |
oprot.writeStructBegin('startTrace_result') |
| 292 |
if self.success is not None: |
| 293 |
oprot.writeFieldBegin('success', TType.STRUCT, 0) |
| 294 |
self.success.write(oprot) |
| 295 |
oprot.writeFieldEnd() |
| 296 |
oprot.writeFieldStop() |
| 297 |
oprot.writeStructEnd() |
| 298 |
|
| 299 |
def validate(self): |
| 300 |
return |
| 301 |
|
| 302 |
|
| 303 |
def __hash__(self): |
| 304 |
value = 17 |
| 305 |
value = (value * 31) ^ hash(self.success) |
| 306 |
return value |
| 307 |
|
| 308 |
def __repr__(self): |
| 309 |
L = ['%s=%r' % (key, value) |
| 310 |
for key, value in self.__dict__.iteritems()] |
| 311 |
return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) |
| 312 |
|
| 313 |
def __eq__(self, other): |
| 314 |
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ |
| 315 |
|
| 316 |
def __ne__(self, other): |
| 317 |
return not (self == other) |
| 318 |
|
| 319 |
class joinTrace_args(object): |
| 320 |
""" |
| 321 |
Attributes: |
| 322 |
- request |
| 323 |
""" |
| 324 |
|
| 325 |
thrift_spec = ( |
| 326 |
None, # 0 |
| 327 |
(1, TType.STRUCT, 'request', (JoinTraceRequest, JoinTraceRequest.thrift_spec), None, ), # 1 |
| 328 |
) |
| 329 |
|
| 330 |
def __init__(self, request=None,): |
| 331 |
self.request = request |
| 332 |
|
| 333 |
def read(self, iprot): |
| 334 |
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: |
| 335 |
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) |
| 336 |
return |
| 337 |
iprot.readStructBegin() |
| 338 |
while True: |
| 339 |
(fname, ftype, fid) = iprot.readFieldBegin() |
| 340 |
if ftype == TType.STOP: |
| 341 |
break |
| 342 |
if fid == 1: |
| 343 |
if ftype == TType.STRUCT: |
| 344 |
self.request = JoinTraceRequest() |
| 345 |
self.request.read(iprot) |
| 346 |
else: |
| 347 |
iprot.skip(ftype) |
| 348 |
else: |
| 349 |
iprot.skip(ftype) |
| 350 |
iprot.readFieldEnd() |
| 351 |
iprot.readStructEnd() |
| 352 |
|
| 353 |
def write(self, oprot): |
| 354 |
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: |
| 355 |
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) |
| 356 |
return |
| 357 |
oprot.writeStructBegin('joinTrace_args') |
| 358 |
if self.request is not None: |
| 359 |
oprot.writeFieldBegin('request', TType.STRUCT, 1) |
| 360 |
self.request.write(oprot) |
| 361 |
oprot.writeFieldEnd() |
| 362 |
oprot.writeFieldStop() |
| 363 |
oprot.writeStructEnd() |
| 364 |
|
| 365 |
def validate(self): |
| 366 |
return |
| 367 |
|
| 368 |
|
| 369 |
def __hash__(self): |
| 370 |
value = 17 |
| 371 |
value = (value * 31) ^ hash(self.request) |
| 372 |
return value |
| 373 |
|
| 374 |
def __repr__(self): |
| 375 |
L = ['%s=%r' % (key, value) |
| 376 |
for key, value in self.__dict__.iteritems()] |
| 377 |
return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) |
| 378 |
|
| 379 |
def __eq__(self, other): |
| 380 |
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ |
| 381 |
|
| 382 |
def __ne__(self, other): |
| 383 |
return not (self == other) |
| 384 |
|
| 385 |
class joinTrace_result(object): |
| 386 |
""" |
| 387 |
Attributes: |
| 388 |
- success |
| 389 |
""" |
| 390 |
|
| 391 |
thrift_spec = ( |
| 392 |
(0, TType.STRUCT, 'success', (TraceResponse, TraceResponse.thrift_spec), None, ), # 0 |
| 393 |
) |
| 394 |
|
| 395 |
def __init__(self, success=None,): |
| 396 |
self.success = success |
| 397 |
|
| 398 |
def read(self, iprot): |
| 399 |
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: |
| 400 |
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) |
| 401 |
return |
| 402 |
iprot.readStructBegin() |
| 403 |
while True: |
| 404 |
(fname, ftype, fid) = iprot.readFieldBegin() |
| 405 |
if ftype == TType.STOP: |
| 406 |
break |
| 407 |
if fid == 0: |
| 408 |
if ftype == TType.STRUCT: |
| 409 |
self.success = TraceResponse() |
| 410 |
self.success.read(iprot) |
| 411 |
else: |
| 412 |
iprot.skip(ftype) |
| 413 |
else: |
| 414 |
iprot.skip(ftype) |
| 415 |
iprot.readFieldEnd() |
| 416 |
iprot.readStructEnd() |
| 417 |
|
| 418 |
def write(self, oprot): |
| 419 |
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: |
| 420 |
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) |
| 421 |
return |
| 422 |
oprot.writeStructBegin('joinTrace_result') |
| 423 |
if self.success is not None: |
| 424 |
oprot.writeFieldBegin('success', TType.STRUCT, 0) |
| 425 |
self.success.write(oprot) |
| 426 |
oprot.writeFieldEnd() |
| 427 |
oprot.writeFieldStop() |
| 428 |
oprot.writeStructEnd() |
| 429 |
|
| 430 |
def validate(self): |
| 431 |
return |
| 432 |
|
| 433 |
|
| 434 |
def __hash__(self): |
| 435 |
value = 17 |
| 436 |
value = (value * 31) ^ hash(self.success) |
| 437 |
return value |
| 438 |
|
| 439 |
def __repr__(self): |
| 440 |
L = ['%s=%r' % (key, value) |
| 441 |
for key, value in self.__dict__.iteritems()] |
| 442 |
return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) |
| 443 |
|
| 444 |
def __eq__(self, other): |
| 445 |
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ |
| 446 |
|
| 447 |
def __ne__(self, other): |
| 448 |
return not (self == other) |