http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py new file mode 100644 index 0000000..b8c13c1 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py @@ -0,0 +1,1495 @@ +# +# Autogenerated by Thrift Compiler (0.9.1) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from ttypes import * +from ...thrift.Thrift import TProcessor +from ...thrift.transport import TTransport +from ..Exception import ttypes +from .. import Data + +try: + from ...thrift.protocol import fastbinary +except: + fastbinary = None + + +class Iface: + def connect(self, userName, password): + """ + Parameters: + - userName + - password + """ + pass + + def disconnect(self, sessionId): + """ + Parameters: + - sessionId + """ + pass + + def defineStream(self, sessionId, streamDefinition): + """ + Parameters: + - sessionId + - streamDefinition + """ + pass + + def findStreamId(self, sessionId, streamName, streamVersion): + """ + Parameters: + - sessionId + - streamName + - streamVersion + """ + pass + + def publish(self, eventBundle): + """ + Parameters: + - eventBundle + """ + pass + + def deleteStreamById(self, sessionId, streamId): + """ + Parameters: + - sessionId + - streamId + """ + pass + + def deleteStreamByNameVersion(self, sessionId, streamName, streamVersion): + """ + Parameters: + - sessionId + - streamName + - streamVersion + """ + pass + + +class Client(Iface): + def __init__(self, iprot, oprot=None): + self._iprot = self._oprot = iprot + if oprot is not None: + self._oprot = oprot + self._seqid = 0 + + def connect(self, userName, password): + """ + Parameters: + - userName + - password + """ + self.send_connect(userName, password) + return self.recv_connect() + + def send_connect(self, userName, password): + self._oprot.writeMessageBegin('connect', TMessageType.CALL, self._seqid) + args = connect_args() + args.userName = userName + args.password = password + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_connect(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = connect_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ae is not None: + raise result.ae + raise TApplicationException(TApplicationException.MISSING_RESULT, "connect failed: unknown result"); + + def disconnect(self, sessionId): + """ + Parameters: + - sessionId + """ + self.send_disconnect(sessionId) + self.recv_disconnect() + + def send_disconnect(self, sessionId): + self._oprot.writeMessageBegin('disconnect', TMessageType.CALL, self._seqid) + args = disconnect_args() + args.sessionId = sessionId + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_disconnect(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = disconnect_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + return + + def defineStream(self, sessionId, streamDefinition): + """ + Parameters: + - sessionId + - streamDefinition + """ + self.send_defineStream(sessionId, streamDefinition) + return self.recv_defineStream() + + def send_defineStream(self, sessionId, streamDefinition): + self._oprot.writeMessageBegin('defineStream', TMessageType.CALL, self._seqid) + args = defineStream_args() + args.sessionId = sessionId + args.streamDefinition = streamDefinition + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_defineStream(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = defineStream_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ade is not None: + raise result.ade + if result.mtd is not None: + raise result.mtd + if result.tde is not None: + raise result.tde + if result.se is not None: + raise result.se + raise TApplicationException(TApplicationException.MISSING_RESULT, "defineStream failed: unknown result"); + + def findStreamId(self, sessionId, streamName, streamVersion): + """ + Parameters: + - sessionId + - streamName + - streamVersion + """ + self.send_findStreamId(sessionId, streamName, streamVersion) + return self.recv_findStreamId() + + def send_findStreamId(self, sessionId, streamName, streamVersion): + self._oprot.writeMessageBegin('findStreamId', TMessageType.CALL, self._seqid) + args = findStreamId_args() + args.sessionId = sessionId + args.streamName = streamName + args.streamVersion = streamVersion + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_findStreamId(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = findStreamId_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.tnde is not None: + raise result.tnde + if result.se is not None: + raise result.se + raise TApplicationException(TApplicationException.MISSING_RESULT, "findStreamId failed: unknown result"); + + def publish(self, eventBundle): + """ + Parameters: + - eventBundle + """ + self.send_publish(eventBundle) + self.recv_publish() + + def send_publish(self, eventBundle): + self._oprot.writeMessageBegin('publish', TMessageType.CALL, self._seqid) + args = publish_args() + args.eventBundle = eventBundle + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_publish(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = publish_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.ue is not None: + raise result.ue + if result.se is not None: + raise result.se + return + + def deleteStreamById(self, sessionId, streamId): + """ + Parameters: + - sessionId + - streamId + """ + self.send_deleteStreamById(sessionId, streamId) + return self.recv_deleteStreamById() + + def send_deleteStreamById(self, sessionId, streamId): + self._oprot.writeMessageBegin('deleteStreamById', TMessageType.CALL, self._seqid) + args = deleteStreamById_args() + args.sessionId = sessionId + args.streamId = streamId + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_deleteStreamById(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = deleteStreamById_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.se is not None: + raise result.se + raise TApplicationException(TApplicationException.MISSING_RESULT, "deleteStreamById failed: unknown result"); + + def deleteStreamByNameVersion(self, sessionId, streamName, streamVersion): + """ + Parameters: + - sessionId + - streamName + - streamVersion + """ + self.send_deleteStreamByNameVersion(sessionId, streamName, streamVersion) + return self.recv_deleteStreamByNameVersion() + + def send_deleteStreamByNameVersion(self, sessionId, streamName, streamVersion): + self._oprot.writeMessageBegin('deleteStreamByNameVersion', TMessageType.CALL, self._seqid) + args = deleteStreamByNameVersion_args() + args.sessionId = sessionId + args.streamName = streamName + args.streamVersion = streamVersion + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_deleteStreamByNameVersion(self): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = deleteStreamByNameVersion_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.se is not None: + raise result.se + raise TApplicationException(TApplicationException.MISSING_RESULT, "deleteStreamByNameVersion failed: unknown result"); + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["connect"] = Processor.process_connect + self._processMap["disconnect"] = Processor.process_disconnect + self._processMap["defineStream"] = Processor.process_defineStream + self._processMap["findStreamId"] = Processor.process_findStreamId + self._processMap["publish"] = Processor.process_publish + self._processMap["deleteStreamById"] = Processor.process_deleteStreamById + self._processMap["deleteStreamByNameVersion"] = Processor.process_deleteStreamByNameVersion + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + self._processMap[name](self, seqid, iprot, oprot) + return True + + def process_connect(self, seqid, iprot, oprot): + args = connect_args() + args.read(iprot) + iprot.readMessageEnd() + result = connect_result() + try: + result.success = self._handler.connect(args.userName, args.password) + except ttypes.ThriftAuthenticationException, ae: + result.ae = ae + oprot.writeMessageBegin("connect", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_disconnect(self, seqid, iprot, oprot): + args = disconnect_args() + args.read(iprot) + iprot.readMessageEnd() + result = disconnect_result() + self._handler.disconnect(args.sessionId) + oprot.writeMessageBegin("disconnect", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_defineStream(self, seqid, iprot, oprot): + args = defineStream_args() + args.read(iprot) + iprot.readMessageEnd() + result = defineStream_result() + try: + result.success = self._handler.defineStream(args.sessionId, args.streamDefinition) + except ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade: + result.ade = ade + except ttypes.ThriftMalformedStreamDefinitionException, mtd: + result.mtd = mtd + except ttypes.ThriftStreamDefinitionException, tde: + result.tde = tde + except ttypes.ThriftSessionExpiredException, se: + result.se = se + oprot.writeMessageBegin("defineStream", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_findStreamId(self, seqid, iprot, oprot): + args = findStreamId_args() + args.read(iprot) + iprot.readMessageEnd() + result = findStreamId_result() + try: + result.success = self._handler.findStreamId(args.sessionId, args.streamName, args.streamVersion) + except ttypes.ThriftNoStreamDefinitionExistException, tnde: + result.tnde = tnde + except ttypes.ThriftSessionExpiredException, se: + result.se = se + oprot.writeMessageBegin("findStreamId", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_publish(self, seqid, iprot, oprot): + args = publish_args() + args.read(iprot) + iprot.readMessageEnd() + result = publish_result() + try: + self._handler.publish(args.eventBundle) + except ttypes.ThriftUndefinedEventTypeException, ue: + result.ue = ue + except ttypes.ThriftSessionExpiredException, se: + result.se = se + oprot.writeMessageBegin("publish", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_deleteStreamById(self, seqid, iprot, oprot): + args = deleteStreamById_args() + args.read(iprot) + iprot.readMessageEnd() + result = deleteStreamById_result() + try: + result.success = self._handler.deleteStreamById(args.sessionId, args.streamId) + except ttypes.ThriftSessionExpiredException, se: + result.se = se + oprot.writeMessageBegin("deleteStreamById", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_deleteStreamByNameVersion(self, seqid, iprot, oprot): + args = deleteStreamByNameVersion_args() + args.read(iprot) + iprot.readMessageEnd() + result = deleteStreamByNameVersion_result() + try: + result.success = self._handler.deleteStreamByNameVersion(args.sessionId, args.streamName, args.streamVersion) + except ttypes.ThriftSessionExpiredException, se: + result.se = se + oprot.writeMessageBegin("deleteStreamByNameVersion", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + +# HELPER FUNCTIONS AND STRUCTURES + +class connect_args: + """ + Attributes: + - userName + - password + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'userName', None, None, ), # 1 + (2, TType.STRING, 'password', None, None, ), # 2 + ) + + def __init__(self, userName=None, password=None,): + self.userName = userName + self.password = password + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.userName = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.password = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('connect_args') + if self.userName is not None: + oprot.writeFieldBegin('userName', TType.STRING, 1) + oprot.writeString(self.userName) + oprot.writeFieldEnd() + if self.password is not None: + oprot.writeFieldBegin('password', TType.STRING, 2) + oprot.writeString(self.password) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class connect_result: + """ + Attributes: + - success + - ae + """ + + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ae', (ttypes.ThriftAuthenticationException, ttypes.ThriftAuthenticationException.thrift_spec), None, ), # 1 + ) + + def __init__(self, success=None, ae=None,): + self.success = success + self.ae = ae + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ae = ttypes.ThriftAuthenticationException() + self.ae.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('connect_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.ae is not None: + oprot.writeFieldBegin('ae', TType.STRUCT, 1) + self.ae.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class disconnect_args: + """ + Attributes: + - sessionId + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', None, None, ), # 1 + ) + + def __init__(self, sessionId=None,): + self.sessionId = sessionId + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('disconnect_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class disconnect_result: + + thrift_spec = ( + ) + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('disconnect_result') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class defineStream_args: + """ + Attributes: + - sessionId + - streamDefinition + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', None, None, ), # 1 + (2, TType.STRING, 'streamDefinition', None, None, ), # 2 + ) + + def __init__(self, sessionId=None, streamDefinition=None,): + self.sessionId = sessionId + self.streamDefinition = streamDefinition + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.streamDefinition = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('defineStream_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId) + oprot.writeFieldEnd() + if self.streamDefinition is not None: + oprot.writeFieldBegin('streamDefinition', TType.STRING, 2) + oprot.writeString(self.streamDefinition) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class defineStream_result: + """ + Attributes: + - success + - ade + - mtd + - tde + - se + """ + + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ade', (ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'mtd', (ttypes.ThriftMalformedStreamDefinitionException, ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'tde', (ttypes.ThriftStreamDefinitionException, ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3 + (4, TType.STRUCT, 'se', (ttypes.ThriftSessionExpiredException, ttypes.ThriftSessionExpiredException.thrift_spec), None, ), # 4 + ) + + def __init__(self, success=None, ade=None, mtd=None, tde=None, se=None,): + self.success = success + self.ade = ade + self.mtd = mtd + self.tde = tde + self.se = se + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ade = ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException() + self.ade.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.mtd = ttypes.ThriftMalformedStreamDefinitionException() + self.mtd.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tde = ttypes.ThriftStreamDefinitionException() + self.tde.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.se = ttypes.ThriftSessionExpiredException() + self.se.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('defineStream_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.ade is not None: + oprot.writeFieldBegin('ade', TType.STRUCT, 1) + self.ade.write(oprot) + oprot.writeFieldEnd() + if self.mtd is not None: + oprot.writeFieldBegin('mtd', TType.STRUCT, 2) + self.mtd.write(oprot) + oprot.writeFieldEnd() + if self.tde is not None: + oprot.writeFieldBegin('tde', TType.STRUCT, 3) + self.tde.write(oprot) + oprot.writeFieldEnd() + if self.se is not None: + oprot.writeFieldBegin('se', TType.STRUCT, 4) + self.se.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class findStreamId_args: + """ + Attributes: + - sessionId + - streamName + - streamVersion + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', None, None, ), # 1 + (2, TType.STRING, 'streamName', None, None, ), # 2 + (3, TType.STRING, 'streamVersion', None, None, ), # 3 + ) + + def __init__(self, sessionId=None, streamName=None, streamVersion=None,): + self.sessionId = sessionId + self.streamName = streamName + self.streamVersion = streamVersion + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.streamName = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.streamVersion = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('findStreamId_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId) + oprot.writeFieldEnd() + if self.streamName is not None: + oprot.writeFieldBegin('streamName', TType.STRING, 2) + oprot.writeString(self.streamName) + oprot.writeFieldEnd() + if self.streamVersion is not None: + oprot.writeFieldBegin('streamVersion', TType.STRING, 3) + oprot.writeString(self.streamVersion) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class findStreamId_result: + """ + Attributes: + - success + - tnde + - se + """ + + thrift_spec = ( + (0, TType.STRING, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'tnde', (ttypes.ThriftNoStreamDefinitionExistException, ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'se', (ttypes.ThriftSessionExpiredException, ttypes.ThriftSessionExpiredException.thrift_spec), None, ), # 2 + ) + + def __init__(self, success=None, tnde=None, se=None,): + self.success = success + self.tnde = tnde + self.se = se + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.tnde = ttypes.ThriftNoStreamDefinitionExistException() + self.tnde.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.se = ttypes.ThriftSessionExpiredException() + self.se.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('findStreamId_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success) + oprot.writeFieldEnd() + if self.tnde is not None: + oprot.writeFieldBegin('tnde', TType.STRUCT, 1) + self.tnde.write(oprot) + oprot.writeFieldEnd() + if self.se is not None: + oprot.writeFieldBegin('se', TType.STRUCT, 2) + self.se.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class publish_args: + """ + Attributes: + - eventBundle + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'eventBundle', (Data.ttypes.ThriftEventBundle, Data.ttypes.ThriftEventBundle.thrift_spec), None, ), # 1 + ) + + def __init__(self, eventBundle=None,): + self.eventBundle = eventBundle + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.eventBundle = Data.ttypes.ThriftEventBundle() + self.eventBundle.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('publish_args') + if self.eventBundle is not None: + oprot.writeFieldBegin('eventBundle', TType.STRUCT, 1) + self.eventBundle.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class publish_result: + """ + Attributes: + - ue + - se + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'ue', (ttypes.ThriftUndefinedEventTypeException, ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'se', (ttypes.ThriftSessionExpiredException, ttypes.ThriftSessionExpiredException.thrift_spec), None, ), # 2 + ) + + def __init__(self, ue=None, se=None,): + self.ue = ue + self.se = se + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.ue = ttypes.ThriftUndefinedEventTypeException() + self.ue.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.se = ttypes.ThriftSessionExpiredException() + self.se.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('publish_result') + if self.ue is not None: + oprot.writeFieldBegin('ue', TType.STRUCT, 1) + self.ue.write(oprot) + oprot.writeFieldEnd() + if self.se is not None: + oprot.writeFieldBegin('se', TType.STRUCT, 2) + self.se.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class deleteStreamById_args: + """ + Attributes: + - sessionId + - streamId + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', None, None, ), # 1 + (2, TType.STRING, 'streamId', None, None, ), # 2 + ) + + def __init__(self, sessionId=None, streamId=None,): + self.sessionId = sessionId + self.streamId = streamId + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.streamId = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('deleteStreamById_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId) + oprot.writeFieldEnd() + if self.streamId is not None: + oprot.writeFieldBegin('streamId', TType.STRING, 2) + oprot.writeString(self.streamId) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class deleteStreamById_result: + """ + Attributes: + - success + - se + """ + + thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'se', (ttypes.ThriftSessionExpiredException, ttypes.ThriftSessionExpiredException.thrift_spec), None, ), # 1 + ) + + def __init__(self, success=None, se=None,): + self.success = success + self.se = se + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.se = ttypes.ThriftSessionExpiredException() + self.se.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('deleteStreamById_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.se is not None: + oprot.writeFieldBegin('se', TType.STRUCT, 1) + self.se.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class deleteStreamByNameVersion_args: + """ + Attributes: + - sessionId + - streamName + - streamVersion + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'sessionId', None, None, ), # 1 + (2, TType.STRING, 'streamName', None, None, ), # 2 + (3, TType.STRING, 'streamVersion', None, None, ), # 3 + ) + + def __init__(self, sessionId=None, streamName=None, streamVersion=None,): + self.sessionId = sessionId + self.streamName = streamName + self.streamVersion = streamVersion + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.sessionId = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.streamName = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRING: + self.streamVersion = iprot.readString(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('deleteStreamByNameVersion_args') + if self.sessionId is not None: + oprot.writeFieldBegin('sessionId', TType.STRING, 1) + oprot.writeString(self.sessionId) + oprot.writeFieldEnd() + if self.streamName is not None: + oprot.writeFieldBegin('streamName', TType.STRING, 2) + oprot.writeString(self.streamName) + oprot.writeFieldEnd() + if self.streamVersion is not None: + oprot.writeFieldBegin('streamVersion', TType.STRING, 3) + oprot.writeString(self.streamVersion) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class deleteStreamByNameVersion_result: + """ + Attributes: + - success + - se + """ + + thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'se', (ttypes.ThriftSessionExpiredException, ttypes.ThriftSessionExpiredException.thrift_spec), None, ), # 1 + ) + + def __init__(self, success=None, se=None,): + self.success = success + self.se = se + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool(); + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.se = ttypes.ThriftSessionExpiredException() + self.se.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('deleteStreamByNameVersion_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.se is not None: + oprot.writeFieldBegin('se', TType.STRUCT, 1) + self.se.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other)
http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py new file mode 100644 index 0000000..c321ae1 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py @@ -0,0 +1 @@ +__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService'] http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py new file mode 100644 index 0000000..36943ba --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py @@ -0,0 +1,8 @@ +# +# Autogenerated by Thrift Compiler (0.9.1) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py new file mode 100644 index 0000000..37ac241 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py @@ -0,0 +1,21 @@ +# +# Autogenerated by Thrift Compiler (0.9.1) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from ...thrift.Thrift import TType, TMessageType, TException, TApplicationException +from ..Data import ttypes +from ..Exception import ttypes + + +from ...thrift.transport import TTransport +from ...thrift.protocol import TBinaryProtocol, TProtocol +try: + from thrift.protocol import fastbinary +except: + fastbinary = None + + http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/__init__.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/__init__.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/gen/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/publisher.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/publisher.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/publisher.py new file mode 100644 index 0000000..325b05d --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/publisher.py @@ -0,0 +1,111 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import time +import sys + +sys.path.append("gen") + +from gen.ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService +from gen.Data.ttypes import ThriftEventBundle + +from thrift.transport import TSSLSocket +from thrift.transport import TTransport +from thrift.protocol import TBinaryProtocol + + +# Define publisher class +class Publisher: + client = None + + def __init__(self, ip, port): + # Make SSL socket + self.socket = TSSLSocket.TSSLSocket(ip, port, False) + # Buffering is critical. Raw sockets are very slow + self.transport = TTransport.TBufferedTransport(self.socket) + # Wrap in a protocol + self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) + self.sessionId = None + self.streamId = None + + def connect(self, username, password): + # Create a client to use the protocol encoder + Publisher.client = ThriftSecureEventTransmissionService.Client(self.protocol) + + # Make connection + self.socket.open() + self.transport.open() + self.sessionId = Publisher.client.connect(username, password) + + def defineStream(self, streamDef): + # Create Stream Definition + self.streamId = Publisher.client.defineStream(self.sessionId, streamDef) + + def publish(self, event): + # Build thrift event bundle + #event = EventBundle() + event.setSessionId(self.sessionId) + event.setEventNum(0) + event.addStringAttribute(self.streamId) + event.addLongAttribute(time.time() * 1000) + #event.addStringAttribute(msg) + # Publish + Publisher.client.publish(event.getEventBundle()) + + def disconnect(self): + # Disconnect + Publisher.client.disconnect(self.sessionId) + self.transport.close() + self.socket.close() + + +class EventBundle: + __sessionId = "" + __eventNum = 0 + __intAttributeList = [] + __longAttributeList = [] + __doubleAttributeList = [] + __boolAttributeList = [] + __stringAttributeList = [] + __arbitraryDataMapMap = None + + def setSessionId(self, sessionId): + self.__sessionId = sessionId + + def setEventNum(self, num): + self.__eventNum = num + + def addIntAttribute(self, attr): + self.__intAttributeList.append(attr) + + def addLongAttribute(self, attr): + self.__longAttributeList.append(attr) + + def addDoubleAttribute(self, attr): + self.__doubleAttributeList.append(attr) + + def addBoolAttribute(self, attr): + self.__boolAttributeList.append(attr) + + def addStringAttribute(self, attr): + self.__stringAttributeList.append(attr) + + def getEventBundle(self): + return ThriftEventBundle(self.__sessionId, self.__eventNum, self.__intAttributeList, + self.__longAttributeList, self.__doubleAttributeList, + self.__boolAttributeList, self.__stringAttributeList, + self.__arbitraryDataMapMap) http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSCons.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSCons.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSCons.py new file mode 100644 index 0000000..da8d283 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSCons.py @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from os import path +from SCons.Builder import Builder + + +def scons_env(env, add=''): + opath = path.dirname(path.abspath('$TARGET')) + lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' + cppbuild = Builder(action=lstr) + env.Append(BUILDERS={'ThriftCpp': cppbuild}) + + +def gen_cpp(env, dir, file): + scons_env(env) + suffixes = ['_types.h', '_types.cpp'] + targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) + return env.ThriftCpp(targets, dir + file + '.thrift') http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSerialization.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSerialization.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSerialization.py new file mode 100644 index 0000000..8a58d89 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TSerialization.py @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from protocol import TBinaryProtocol +from transport import TTransport + + +def serialize(thrift_object, + protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): + transport = TTransport.TMemoryBuffer() + protocol = protocol_factory.getProtocol(transport) + thrift_object.write(protocol) + return transport.getvalue() + + +def deserialize(base, + buf, + protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): + transport = TTransport.TMemoryBuffer(buf) + protocol = protocol_factory.getProtocol(transport) + base.read(protocol) + return base http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TTornado.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TTornado.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TTornado.py new file mode 100644 index 0000000..8d9f5ed --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/TTornado.py @@ -0,0 +1,153 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from cStringIO import StringIO +import logging +import socket +import struct + +from .transport import TTransport +from .transport.TTransport import TTransportException + +from tornado import gen +from tornado import iostream +from tornado import netutil + + +class TTornadoStreamTransport(TTransport.TTransportBase): + """a framed, buffered transport over a Tornado stream""" + def __init__(self, host, port, stream=None): + self.host = host + self.port = port + self.is_queuing_reads = False + self.read_queue = [] + self.__wbuf = StringIO() + + # servers provide a ready-to-go stream + self.stream = stream + if self.stream is not None: + self._set_close_callback() + + # not the same number of parameters as TTransportBase.open + def open(self, callback): + logging.debug('socket connecting') + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) + self.stream = iostream.IOStream(sock) + + def on_close_in_connect(*_): + message = 'could not connect to {}:{}'.format(self.host, self.port) + raise TTransportException( + type=TTransportException.NOT_OPEN, + message=message) + self.stream.set_close_callback(on_close_in_connect) + + def finish(*_): + self._set_close_callback() + callback() + + self.stream.connect((self.host, self.port), callback=finish) + + def _set_close_callback(self): + def on_close(): + raise TTransportException( + type=TTransportException.END_OF_FILE, + message='socket closed') + self.stream.set_close_callback(self.close) + + def close(self): + # don't raise if we intend to close + self.stream.set_close_callback(None) + self.stream.close() + + def read(self, _): + # The generated code for Tornado shouldn't do individual reads -- only + # frames at a time + assert "you're doing it wrong" is True + + @gen.engine + def readFrame(self, callback): + self.read_queue.append(callback) + logging.debug('read queue: %s', self.read_queue) + + if self.is_queuing_reads: + # If a read is already in flight, then the while loop below should + # pull it from self.read_queue + return + + self.is_queuing_reads = True + while self.read_queue: + next_callback = self.read_queue.pop() + result = yield gen.Task(self._readFrameFromStream) + next_callback(result) + self.is_queuing_reads = False + + @gen.engine + def _readFrameFromStream(self, callback): + logging.debug('_readFrameFromStream') + frame_header = yield gen.Task(self.stream.read_bytes, 4) + frame_length, = struct.unpack('!i', frame_header) + logging.debug('received frame header, frame length = %i', frame_length) + frame = yield gen.Task(self.stream.read_bytes, frame_length) + logging.debug('received frame payload') + callback(frame) + + def write(self, buf): + self.__wbuf.write(buf) + + def flush(self, callback=None): + wout = self.__wbuf.getvalue() + wsz = len(wout) + # reset wbuf before write/flush to preserve state on underlying failure + self.__wbuf = StringIO() + # N.B.: Doing this string concatenation is WAY cheaper than making + # two separate calls to the underlying socket object. Socket writes in + # Python turn out to be REALLY expensive, but it seems to do a pretty + # good job of managing string buffer operations without excessive copies + buf = struct.pack("!i", wsz) + wout + + logging.debug('writing frame length = %i', wsz) + self.stream.write(buf, callback) + + +class TTornadoServer(netutil.TCPServer): + def __init__(self, processor, iprot_factory, oprot_factory=None, + *args, **kwargs): + super(TTornadoServer, self).__init__(*args, **kwargs) + + self._processor = processor + self._iprot_factory = iprot_factory + self._oprot_factory = (oprot_factory if oprot_factory is not None + else iprot_factory) + + def handle_stream(self, stream, address): + try: + host, port = address + trans = TTornadoStreamTransport(host=host, port=port, stream=stream) + oprot = self._oprot_factory.getProtocol(trans) + + def next_pass(): + if not trans.stream.closed(): + self._processor.process(trans, self._iprot_factory, oprot, + callback=next_pass) + + next_pass() + + except Exception: + logging.exception('thrift exception in handle_stream') + trans.close() http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/Thrift.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/Thrift.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/Thrift.py new file mode 100644 index 0000000..9890af7 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/Thrift.py @@ -0,0 +1,170 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import sys + + +class TType: + STOP = 0 + VOID = 1 + BOOL = 2 + BYTE = 3 + I08 = 3 + DOUBLE = 4 + I16 = 6 + I32 = 8 + I64 = 10 + STRING = 11 + UTF7 = 11 + STRUCT = 12 + MAP = 13 + SET = 14 + LIST = 15 + UTF8 = 16 + UTF16 = 17 + + _VALUES_TO_NAMES = ('STOP', + 'VOID', + 'BOOL', + 'BYTE', + 'DOUBLE', + None, + 'I16', + None, + 'I32', + None, + 'I64', + 'STRING', + 'STRUCT', + 'MAP', + 'SET', + 'LIST', + 'UTF8', + 'UTF16') + + +class TMessageType: + CALL = 1 + REPLY = 2 + EXCEPTION = 3 + ONEWAY = 4 + + +class TProcessor: + """Base class for procsessor, which works on two streams.""" + + def process(iprot, oprot): + pass + + +class TException(Exception): + """Base class for all thrift exceptions.""" + + # BaseException.message is deprecated in Python v[2.6,3.0) + if (2, 6, 0) <= sys.version_info < (3, 0): + def _get_message(self): + return self._message + + def _set_message(self, message): + self._message = message + message = property(_get_message, _set_message) + + def __init__(self, message=None): + Exception.__init__(self, message) + self.message = message + + +class TApplicationException(TException): + """Application level thrift exceptions.""" + + UNKNOWN = 0 + UNKNOWN_METHOD = 1 + INVALID_MESSAGE_TYPE = 2 + WRONG_METHOD_NAME = 3 + BAD_SEQUENCE_ID = 4 + MISSING_RESULT = 5 + INTERNAL_ERROR = 6 + PROTOCOL_ERROR = 7 + INVALID_TRANSFORM = 8 + INVALID_PROTOCOL = 9 + UNSUPPORTED_CLIENT_TYPE = 10 + + def __init__(self, type=UNKNOWN, message=None): + TException.__init__(self, message) + self.type = type + + def __str__(self): + if self.message: + return self.message + elif self.type == self.UNKNOWN_METHOD: + return 'Unknown method' + elif self.type == self.INVALID_MESSAGE_TYPE: + return 'Invalid message type' + elif self.type == self.WRONG_METHOD_NAME: + return 'Wrong method name' + elif self.type == self.BAD_SEQUENCE_ID: + return 'Bad sequence ID' + elif self.type == self.MISSING_RESULT: + return 'Missing result' + elif self.type == self.INTERNAL_ERROR: + return 'Internal error' + elif self.type == self.PROTOCOL_ERROR: + return 'Protocol error' + elif self.type == self.INVALID_TRANSFORM: + return 'Invalid transform' + elif self.type == self.INVALID_PROTOCOL: + return 'Invalid protocol' + elif self.type == self.UNSUPPORTED_CLIENT_TYPE: + return 'Unsupported client type' + else: + return 'Default (unknown) TApplicationException' + + def read(self, iprot): + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.message = iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.type = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + oprot.writeStructBegin('TApplicationException') + if self.message is not None: + oprot.writeFieldBegin('message', TType.STRING, 1) + oprot.writeString(self.message) + oprot.writeFieldEnd() + if self.type is not None: + oprot.writeFieldBegin('type', TType.I32, 2) + oprot.writeI32(self.type) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/__init__.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/__init__.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/__init__.py new file mode 100644 index 0000000..48d659c --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/__init__.py @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +__all__ = ['Thrift', 'TSCons'] http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBase.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBase.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBase.py new file mode 100644 index 0000000..61b469b --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBase.py @@ -0,0 +1,81 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from ..Thrift import * +import TBinaryProtocol +from ..transport import TTransport + +try: + import fastbinary +except: + fastbinary = None + + +class TBase(object): + __slots__ = [] + + def __repr__(self): + L = ['%s=%r' % (key, getattr(self, key)) + for key in self.__slots__] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + for attr in self.__slots__: + my_val = getattr(self, attr) + other_val = getattr(other, attr) + if my_val != other_val: + return False + return True + + def __ne__(self, other): + return not (self == other) + + def read(self, iprot): + if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and + isinstance(iprot.trans, TTransport.CReadableTransport) and + self.thrift_spec is not None and + fastbinary is not None): + fastbinary.decode_binary(self, + iprot.trans, + (self.__class__, self.thrift_spec)) + return + iprot.readStruct(self, self.thrift_spec) + + def write(self, oprot): + if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and + self.thrift_spec is not None and + fastbinary is not None): + oprot.trans.write( + fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStruct(self, self.thrift_spec) + + +class TExceptionBase(Exception): + # old style class so python2.4 can raise exceptions derived from this + # This can't inherit from TBase because of that limitation. + __slots__ = [] + + __repr__ = TBase.__repr__.im_func + __eq__ = TBase.__eq__.im_func + __ne__ = TBase.__ne__.im_func + read = TBase.read.im_func + write = TBase.write.im_func http://git-wip-us.apache.org/repos/asf/stratos/blob/a11df3ed/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py ---------------------------------------------------------------------- diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py new file mode 100644 index 0000000..2cdc6b5 --- /dev/null +++ b/tools/python_cartridgeagent/cartridgeagent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py @@ -0,0 +1,261 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from struct import pack, unpack + +from TProtocol import * + + +class TBinaryProtocol(TProtocolBase): + """Binary implementation of the Thrift protocol driver.""" + + # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be + # positive, converting this into a long. If we hardcode the int value + # instead it'll stay in 32 bit-land. + + # VERSION_MASK = 0xffff0000 + VERSION_MASK = -65536 + + # VERSION_1 = 0x80010000 + VERSION_1 = -2147418112 + + TYPE_MASK = 0x000000ff + + def __init__(self, trans, strictRead=False, strictWrite=True): + TProtocolBase.__init__(self, trans) + self.strictRead = strictRead + self.strictWrite = strictWrite + + def writeMessageBegin(self, name, type, seqid): + if self.strictWrite: + self.writeI32(TBinaryProtocol.VERSION_1 | type) + self.writeString(name) + self.writeI32(seqid) + else: + self.writeString(name) + self.writeByte(type) + self.writeI32(seqid) + + def writeMessageEnd(self): + pass + + def writeStructBegin(self, name): + pass + + def writeStructEnd(self): + pass + + def writeFieldBegin(self, name, type, id): + self.writeByte(type) + self.writeI16(id) + + def writeFieldEnd(self): + pass + + def writeFieldStop(self): + self.writeByte(TType.STOP) + + def writeMapBegin(self, ktype, vtype, size): + self.writeByte(ktype) + self.writeByte(vtype) + self.writeI32(size) + + def writeMapEnd(self): + pass + + def writeListBegin(self, etype, size): + self.writeByte(etype) + self.writeI32(size) + + def writeListEnd(self): + pass + + def writeSetBegin(self, etype, size): + self.writeByte(etype) + self.writeI32(size) + + def writeSetEnd(self): + pass + + def writeBool(self, bool): + if bool: + self.writeByte(1) + else: + self.writeByte(0) + + def writeByte(self, byte): + buff = pack("!b", byte) + self.trans.write(buff) + + def writeI16(self, i16): + buff = pack("!h", i16) + self.trans.write(buff) + + def writeI32(self, i32): + buff = pack("!i", i32) + self.trans.write(buff) + + def writeI64(self, i64): + buff = pack("!q", i64) + self.trans.write(buff) + + def writeDouble(self, dub): + buff = pack("!d", dub) + self.trans.write(buff) + + def writeString(self, str): + self.writeI32(len(str)) + self.trans.write(str) + + def readMessageBegin(self): + sz = self.readI32() + if sz < 0: + version = sz & TBinaryProtocol.VERSION_MASK + if version != TBinaryProtocol.VERSION_1: + raise TProtocolException( + type=TProtocolException.BAD_VERSION, + message='Bad version in readMessageBegin: %d' % (sz)) + type = sz & TBinaryProtocol.TYPE_MASK + name = self.readString() + seqid = self.readI32() + else: + if self.strictRead: + raise TProtocolException(type=TProtocolException.BAD_VERSION, + message='No protocol version header') + name = self.trans.readAll(sz) + type = self.readByte() + seqid = self.readI32() + return (name, type, seqid) + + def readMessageEnd(self): + pass + + def readStructBegin(self): + pass + + def readStructEnd(self): + pass + + def readFieldBegin(self): + type = self.readByte() + if type == TType.STOP: + return (None, type, 0) + id = self.readI16() + return (None, type, id) + + def readFieldEnd(self): + pass + + def readMapBegin(self): + ktype = self.readByte() + vtype = self.readByte() + size = self.readI32() + return (ktype, vtype, size) + + def readMapEnd(self): + pass + + def readListBegin(self): + etype = self.readByte() + size = self.readI32() + return (etype, size) + + def readListEnd(self): + pass + + def readSetBegin(self): + etype = self.readByte() + size = self.readI32() + return (etype, size) + + def readSetEnd(self): + pass + + def readBool(self): + byte = self.readByte() + if byte == 0: + return False + return True + + def readByte(self): + buff = self.trans.readAll(1) + val, = unpack('!b', buff) + return val + + def readI16(self): + buff = self.trans.readAll(2) + val, = unpack('!h', buff) + return val + + def readI32(self): + buff = self.trans.readAll(4) + val, = unpack('!i', buff) + return val + + def readI64(self): + buff = self.trans.readAll(8) + val, = unpack('!q', buff) + return val + + def readDouble(self): + buff = self.trans.readAll(8) + val, = unpack('!d', buff) + return val + + def readString(self): + len = self.readI32() + str = self.trans.readAll(len) + return str + + +class TBinaryProtocolFactory: + def __init__(self, strictRead=False, strictWrite=True): + self.strictRead = strictRead + self.strictWrite = strictWrite + + def getProtocol(self, trans): + prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite) + return prot + + +class TBinaryProtocolAccelerated(TBinaryProtocol): + """C-Accelerated version of TBinaryProtocol. + + This class does not override any of TBinaryProtocol's methods, + but the generated code recognizes it directly and will call into + our C module to do the encoding, bypassing this object entirely. + We inherit from TBinaryProtocol so that the normal TBinaryProtocol + encoding can happen if the fastbinary module doesn't work for some + reason. (TODO(dreiss): Make this happen sanely in more cases.) + + In order to take advantage of the C module, just use + TBinaryProtocolAccelerated instead of TBinaryProtocol. + + NOTE: This code was contributed by an external developer. + The internal Thrift team has reviewed and tested it, + but we cannot guarantee that it is production-ready. + Please feel free to report bugs and/or success stories + to the public mailing list. + """ + pass + + +class TBinaryProtocolAcceleratedFactory: + def getProtocol(self, trans): + return TBinaryProtocolAccelerated(trans)
