You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/10/11 20:46:25 UTC

[01/50] [abbrv] git commit: Fixed minor issues in cartridge agent and cartridge agent configuration

Repository: stratos
Updated Branches:
  refs/heads/master 5d24241a4 -> 882e92a86


Fixed minor issues in cartridge agent and cartridge agent configuration


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/0b63370d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0b63370d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0b63370d

Branch: refs/heads/master
Commit: 0b63370d9198ffa156049f0d8aadccfa11ee24cb
Parents: 11231b3
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sun Sep 28 14:06:48 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:38:47 2014 +0530

----------------------------------------------------------------------
 tools/python-cartridge-agent/cartridge-agent/agent.py           | 5 ++++-
 .../modules/config/cartridgeagentconfiguration.py               | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0b63370d/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index ad063c8..ff5eaf5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -91,19 +91,22 @@ class CartridgeAgent(threading.Thread):
             CartridgeAgentConfiguration.read_property(cartridgeagentconstants.JNDI_PROPERTIES_DIR)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.JNDI_PROPERTIES_DIR)
+            return
 
         #PARAM_FILE_PATH
         try:
             CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.PARAM_FILE_PATH)
+            return
 
         #EXTENSIONS_DIR
         try:
             CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.EXTENSIONS_DIR)
-
+            return
+        
     def subscribe_to_topics_and_register_listeners(self):
         self.log.debug("Starting instance notifier event message receiver thread")
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b63370d/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index bb26569..43a4e5e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -37,9 +37,9 @@ class CartridgeAgentConfiguration:
     """ :type : str  """
     repo_url = None
     """ :type : str  """
-    ports = {}
+    ports = []
     """ :type : list[str]  """
-    log_file_paths = {}
+    log_file_paths = []
     """ :type : list[str]  """
     is_multitenant = False
     """ :type : bool  """


[14/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
new file mode 100644
index 0000000..38575a6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..a0727f8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/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
+import Data.ttypes
+import Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
new file mode 100755
index 0000000..46757bf
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from ThriftSecureEventTransmissionService.ttypes import *
+
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string connect(string userName, string password)'
+  print '  void disconnect(string sessionId)'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftSecureEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'connect':
+  if len(args) != 2:
+    print 'connect requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.connect(args[0],args[1],))
+
+elif cmd == 'disconnect':
+  if len(args) != 1:
+    print 'disconnect requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.disconnect(args[0],))
+
+elif cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
new file mode 100644
index 0000000..560ea38
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
@@ -0,0 +1,1493 @@
+#
+# 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
+
+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 Exception.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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
+      result.ade = ade
+    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
+      result.mtd = mtd
+    except Exception.ttypes.ThriftStreamDefinitionException, tde:
+      result.tde = tde
+    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
+      result.tnde = tnde
+    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
+      result.ue = ue
+    except Exception.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 Exception.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 Exception.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', (Exception.ttypes.ThriftAuthenticationException, Exception.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 = Exception.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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
+    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
+          self.ade.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
+          self.mtd.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
+          self.tde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
+          self.tnde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
+          self.ue.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
new file mode 100644
index 0000000..c321ae1
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..a0727f8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/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
+import Data.ttypes
+import Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
new file mode 100644
index 0000000..fa0a636
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
@@ -0,0 +1,94 @@
+import time
+import sys
+
+sys.path.append("databridge/thrift/gen-py")
+
+from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from ThriftSecureEventTransmissionService.ttypes import *
+
+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(1)
+        event.addLongAttribute(time.time() * 1000)
+        event.addStringAttribute(self.streamId)
+        #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 Data.ttypes.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSCons.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSCons.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSCons.py
new file mode 100644
index 0000000..da8d283
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSerialization.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSerialization.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TSerialization.py
new file mode 100644
index 0000000..8a58d89
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
new file mode 100644
index 0000000..af309c3
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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 thrift.transport import TTransport
+from thrift.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/Thrift.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/Thrift.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/Thrift.py
new file mode 100644
index 0000000..9890af7
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/__init__.py
new file mode 100644
index 0000000..48d659c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
new file mode 100644
index 0000000..6cbd5f3
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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.Thrift import *
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+try:
+  from thrift.protocol 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


[33/50] [abbrv] git commit: Changed the logic to retrieve member ID in the configuration

Posted by ni...@apache.org.
Changed the logic to retrieve member ID in the configuration


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1c69a9aa
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1c69a9aa
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1c69a9aa

Branch: refs/heads/master
Commit: 1c69a9aa76986093970d01e0a22ef6218e483735
Parents: 19f9227
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 13:17:39 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Fri Oct 10 13:17:39 2014 +0530

----------------------------------------------------------------------
 .../config/cartridgeagentconfiguration.py       | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/1c69a9aa/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 17b6c78..fde28e8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -16,8 +16,8 @@
 # under the License.
 
 import ConfigParser
-import logging
 import os
+import socket
 
 from ..util.log import LogFactory
 
@@ -114,7 +114,7 @@ class CartridgeAgentConfiguration:
                 self.cluster_id = self.read_property(cartridgeagentconstants.CLUSTER_ID)
                 self.network_partition_id = self.read_property(cartridgeagentconstants.NETWORK_PARTITION_ID)
                 self.partition_id = self.read_property(cartridgeagentconstants.PARTITION_ID)
-                self.member_id = self.read_property(cartridgeagentconstants.MEMBER_ID)
+                self.member_id = self.get_member_id(cartridgeagentconstants.MEMBER_ID, self.cluster_id)
                 self.cartridge_key = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
                 self.app_path = self.read_property(cartridgeagentconstants.APP_PATH)
                 self.repo_url = self.read_property(cartridgeagentconstants.REPO_URL)
@@ -231,6 +231,27 @@ class CartridgeAgentConfiguration:
             self.log.debug("lb-private-ip: %r" % self.lb_private_ip)
             self.log.debug("lb-public-ip: %r" % self.lb_public_ip)
 
+        def get_member_id(self, member_id_field):
+            """
+            Reads the member id from the payload file or configuration file. If neither of
+            these sources contain the member id, the hostname is assigned to it and returned.
+            :param str member_id_field: the key of the member id to lookup
+            :return: The member id
+            :rtype : str
+            """
+            try:
+                member_id = self.read_property(member_id_field)
+            except ParameterNotFoundException:
+                try:
+                    self.log.info("Reading hostname from container")
+                    member_id = socket.gethostname()
+                except:
+                    self.log.exception("Hostname can not be resolved")
+                    member_id = "unknown"
+
+            self.log.debug("MemberId  is taking the value of hostname : [" + member_id + "] ")
+            return member_id
+
         def __read_conf_file(self):
             """
             Reads and stores the agent's configuration file


[21/50] [abbrv] git commit: Removed circular dependancy between AgentGitHandler and DefaultExtensionHandler

Posted by ni...@apache.org.
Removed circular dependancy between AgentGitHandler and DefaultExtensionHandler


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b5ed6f0b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b5ed6f0b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b5ed6f0b

Branch: refs/heads/master
Commit: b5ed6f0b0650f7b83d382211c543ae62fc7dc8a5
Parents: b1c5d36
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 2 14:59:38 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:41:03 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    | 56 ++++++++++++--------
 .../modules/artifactmgt/git/agentgithandler.py  |  5 +-
 .../extensions/abstractextensionhandler.py      |  3 --
 .../modules/subscriber/eventsubscriber.py       |  2 +-
 4 files changed, 38 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b5ed6f0b/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index bf47397..ecc8c45 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -14,10 +14,11 @@ from modules.event.topology.events import *
 from modules.tenant.tenantcontext import *
 from modules.topology.topologycontext import *
 from modules.datapublisher.logpublisher import *
+from modules.extensions.abstractextensionhandler import *
 
 
 class CartridgeAgent(threading.Thread):
-    log = LogFactory().get_log(__name__)
+    extension_handler = None
 
     def __init__(self):
         threading.Thread.__init__(self)
@@ -27,8 +28,6 @@ class CartridgeAgent(threading.Thread):
         self.__tenant_event_subscriber = EventSubscriber(cartridgeagentconstants.TENANT_TOPIC)
         self.__topology_event_subscriber = EventSubscriber(cartridgeagentconstants.TOPOLOGY_TOPIC)
 
-        self.extension_handler = DefaultExtensionHandler()
-
         self.__tenant_context_initialized = False
         self.__topology_context_initialized = False
 
@@ -36,6 +35,8 @@ class CartridgeAgent(threading.Thread):
 
         self.terminated = False
 
+        self.log = LogFactory().get_log(__name__)
+
     def run(self):
         self.log.info("Starting Cartridge Agent...")
 
@@ -52,14 +53,14 @@ class CartridgeAgent(threading.Thread):
         self.register_tenant_event_listeners()
 
         #Execute instance started shell script
-        self.extension_handler.on_instance_started_event()
+        CartridgeAgent.extension_handler.on_instance_started_event()
 
         #Publish instance started event
         cartridgeagentpublisher.publish_instance_started_event()
 
         #Execute start servers extension
         try:
-            self.extension_handler.start_server_extension()
+            CartridgeAgent.extension_handler.start_server_extension()
         except:
             self.log.exception("Error processing start servers event")
 
@@ -73,13 +74,13 @@ class CartridgeAgent(threading.Thread):
         repo_url = CartridgeAgentConfiguration.repo_url
         if repo_url is None or str(repo_url).strip() == "":
             self.log.info("No artifact repository found")
-            self.extension_handler.on_instance_activated_event()
+            CartridgeAgent.extension_handler.on_instance_activated_event()
 
             cartridgeagentpublisher.publish_instance_activated_event()
 
         persistence_mappping_payload = CartridgeAgentConfiguration.persistence_mappings
         if persistence_mappping_payload is not None:
-            self.extension_handler.volume_mount_extension(persistence_mappping_payload)
+            CartridgeAgent.extension_handler.volume_mount_extension(persistence_mappping_payload)
 
         # start log publishing thread
         if DataPublisherConfiguration.get_instance().enabled:
@@ -146,14 +147,14 @@ class CartridgeAgent(threading.Thread):
 
     def on_artifact_updated(self, msg):
         event_obj = ArtifactUpdatedEvent.create_from_json(msg.payload)
-        self.extension_handler.on_artifact_updated_event(event_obj)
+        CartridgeAgent.extension_handler.on_artifact_updated_event(event_obj)
 
     def on_instance_cleanup_member(self, msg):
         member_in_payload = CartridgeAgentConfiguration.member_id
         event_obj = InstanceCleanupMemberEvent.create_from_json(msg.payload)
         member_in_event = event_obj.member_id
         if member_in_payload == member_in_event:
-            self.extension_handler.on_instance_cleanup_member_event(event_obj)
+            CartridgeAgent.extension_handler.on_instance_cleanup_member_event(event_obj)
 
     def on_instance_cleanup_cluster(self, msg):
         event_obj = InstanceCleanupClusterEvent.create_from_json(msg.payload)
@@ -161,7 +162,7 @@ class CartridgeAgent(threading.Thread):
         cluster_in_event = event_obj.cluster_id
 
         if cluster_in_event == cluster_in_payload:
-            self.extension_handler.on_instance_cleanup_cluster_event(event_obj)
+            CartridgeAgent.extension_handler.on_instance_cleanup_cluster_event(event_obj)
 
     def register_topology_event_listeners(self):
         self.log.debug("Starting topology event message receiver thread")
@@ -179,7 +180,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Member activated event received: %r" % msg.payload)
         event_obj = MemberActivatedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_member_activated_event(event_obj)
+            CartridgeAgent.extension_handler.on_member_activated_event(event_obj)
         except:
             self.log.exception("Error processing member terminated event")
 
@@ -187,7 +188,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Member terminated event received: %r" % msg.payload)
         event_obj = MemberTerminatedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_member_terminated_event(event_obj)
+            CartridgeAgent.extension_handler.on_member_terminated_event(event_obj)
         except:
             self.log.exception("Error processing member terminated event")
 
@@ -195,7 +196,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Member suspended event received: %r" % msg.payload)
         event_obj = MemberSuspendedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_member_suspended_event(event_obj)
+            CartridgeAgent.extension_handler.on_member_suspended_event(event_obj)
         except:
             self.log.exception("Error processing member suspended event")
 
@@ -206,7 +207,7 @@ class CartridgeAgent(threading.Thread):
             TopologyContext.update(event_obj.topology)
             self.__topology_context_initialized = True
             try:
-                self.extension_handler.on_complete_topology_event(event_obj)
+                CartridgeAgent.extension_handler.on_complete_topology_event(event_obj)
             except:
                 self.log.exception("Error processing complete topology event")
         else:
@@ -216,7 +217,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Member started event received: %r" % msg.payload)
         event_obj = MemberStartedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_member_started_event(event_obj)
+            CartridgeAgent.extension_handler.on_member_started_event(event_obj)
         except:
             self.log.exception("Error processing member started event")
 
@@ -235,7 +236,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Subscription domain added event received : %r" % msg.payload)
         event_obj = SubscriptionDomainAddedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_subscription_domain_added_event(event_obj)
+            CartridgeAgent.extension_handler.on_subscription_domain_added_event(event_obj)
         except:
             self.log.exception("Error processing subscription domains added event")
 
@@ -243,7 +244,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Subscription domain removed event received : %r" % msg.payload)
         event_obj = SubscriptionDomainRemovedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_subscription_domain_removed_event(event_obj)
+            CartridgeAgent.extension_handler.on_subscription_domain_removed_event(event_obj)
         except:
             self.log.exception("Error processing subscription domains removed event")
 
@@ -254,7 +255,7 @@ class CartridgeAgent(threading.Thread):
             TenantContext.update(event_obj.tenants)
 
             try:
-                self.extension_handler.on_complete_tenant_event(event_obj)
+                CartridgeAgent.extension_handler.on_complete_tenant_event(event_obj)
                 self.__tenant_context_initialized = True
             except:
                 self.log.exception("Error processing complete tenant event")
@@ -265,7 +266,7 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Tenant subscribed event received: %r" % msg.payload)
         event_obj = TenantSubscribedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_tenant_subscribed_event(event_obj)
+            CartridgeAgent.extension_handler.on_tenant_subscribed_event(event_obj)
         except:
             self.log.exception("Error processing tenant subscribed event")
 
@@ -273,14 +274,27 @@ class CartridgeAgent(threading.Thread):
         self.log.debug("Tenant unSubscribed event received: %r" % msg.payload)
         event_obj = TenantUnsubscribedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.on_tenant_unsubscribed_event(event_obj)
+            CartridgeAgent.extension_handler.on_tenant_unsubscribed_event(event_obj)
         except:
             self.log.exception("Error processing tenant unSubscribed event")
+            
+    @staticmethod
+    def get_extension_handler():
+        """
+        Returns the Extension handler implementation
+        :return: An implmentation of AbstractExtensionHandler
+        :rtype : AbstractExtensionHandler
+        """
+        if CartridgeAgent.extension_handler is None:
+            CartridgeAgent.extension_handler = DefaultExtensionHandler()
+            
+        return CartridgeAgent.extension_handler
 
 
 def main():
+    cartridge_agent = CartridgeAgent()
+
     try:
-        cartridge_agent = CartridgeAgent()
         cartridge_agent.start()
     except:
         cartridge_agent.terminate()

http://git-wip-us.apache.org/repos/asf/stratos/blob/b5ed6f0b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index e6fd98e..d192e75 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -10,9 +10,8 @@ from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
 from ... util.asyncscheduledtask import AsyncScheduledTask
 from ... artifactmgt.repositoryinformation import RepositoryInformation
-from ... extensions.abstractextensionhandler import AbstractExtensionHandler
 from ... util.log import LogFactory
-
+from ....agent import CartridgeAgent
 
 
 class AgentGitHandler:
@@ -26,7 +25,7 @@ class AgentGitHandler:
     SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
     TENANT_REPO_PATH = "/repository/tenants/"
 
-    extension_handler = AbstractExtensionHandler()  # TODO: remove dependancy
+    extension_handler = CartridgeAgent.get_extension_handler()
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)

http://git-wip-us.apache.org/repos/asf/stratos/blob/b5ed6f0b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
index 1a2bfaf..f57a1cf 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
@@ -1,6 +1,3 @@
-import abc
-
-
 class AbstractExtensionHandler:
 
     def on_instance_started_event(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/b5ed6f0b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index a8209a5..46fe18a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -44,7 +44,7 @@ class EventSubscriber(threading.Thread):
         """
         Adds an event handler function mapped to the provided event.
         :param str event: Name of the event to attach the provided handler
-        :param (str)->void handler: The handler function
+        :param handler: The handler function
         :return: void
         :rtype: void
         """


[02/50] [abbrv] git commit: Abstracted extension handler functionality to avoid circular dependancy Added logging to file '/tmp/cartridge-agent.log'

Posted by ni...@apache.org.
Abstracted extension handler functionality to avoid circular dependancy
Added logging to file '/tmp/cartridge-agent.log'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b7c8985a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b7c8985a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b7c8985a

Branch: refs/heads/master
Commit: b7c8985aa666aa508387cd665905b076bfe41fcb
Parents: 0b63370
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Sep 29 15:13:49 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:39:35 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  2 +-
 .../modules/artifactmgt/git/agentgithandler.py  |  8 +--
 .../config/cartridgeagentconfiguration.py       | 30 ++++++----
 .../extensions/abstractextensionhandler.py      | 61 ++++++++++++++++++++
 .../extensions/defaultextensionhandler.py       |  5 +-
 .../publisher/cartridgeagentpublisher.py        |  2 +-
 .../modules/subscriber/eventsubscriber.py       |  2 +-
 .../modules/util/cartridgeagentutils.py         |  2 +-
 .../modules/util/extensionutils.py              |  2 +-
 9 files changed, 91 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index ff5eaf5..ae85a5d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -16,7 +16,7 @@ from modules.topology.topologycontext import *
 
 
 class CartridgeAgent(threading.Thread):
-    logging.basicConfig(level=logging.DEBUG)
+    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
     log = logging.getLogger(__name__)
 
     def __init__(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index fb8100b..e433e0b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -8,18 +8,18 @@ from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
 from ... util.asyncscheduledtask import AsyncScheduledTask
 from ... artifactmgt.repositoryinformation import RepositoryInformation
-from ... extensions.defaultextensionhandler import DefaultExtensionHandler
+from ... extensions.abstractextensionhandler import AbstractExtensionHandler
 
 
 class AgentGitHandler:
-    logging.basicConfig(level=logging.DEBUG)
+    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
     log = logging.getLogger(__name__)
 
     SUPER_TENANT_ID = -1234
     SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
     TENANT_REPO_PATH = "/repository/tenants/"
 
-    extension_handler = DefaultExtensionHandler()
+    extension_handler = AbstractExtensionHandler()
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)
@@ -326,7 +326,7 @@ class AgentGitHandler:
 class ArtifactUpdateTask(Thread):
 
     def __init__(self, repo_info, auto_checkout, auto_commit):
-        logging.basicConfig(level=logging.DEBUG)
+        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
         self.log = logging.getLogger(__name__)
         Thread.__init__(self)
         self.repo_info = repo_info

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 43a4e5e..32ff23f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -11,7 +11,7 @@ class CartridgeAgentConfiguration:
     Handles the configuration information of the particular Cartridge Agent
     """
     # set log level
-    logging.basicConfig(level=logging.DEBUG)
+    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
     log = logging.getLogger(__name__)
 
     payload_params = {}
@@ -154,12 +154,12 @@ class CartridgeAgentConfiguration:
                         "%r is not found and setting it to false" % cartridgeagentconstants.COMMIT_ENABLED)
                     CartridgeAgentConfiguration.is_commits_enabled = False
 
-            auto_checkout_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.AUTO_CHECKOUT)
+            auto_checkout_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.AUTO_CHECKOUT, False)
             CartridgeAgentConfiguration.is_checkout_enabled = True if str(
                 auto_checkout_str).lower().strip() == "true" else False
 
             CartridgeAgentConfiguration.listen_address = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LISTEN_ADDRESS)
+                cartridgeagentconstants.LISTEN_ADDRESS, False)
 
             try:
                 int_repo_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PROVIDER)
@@ -176,13 +176,13 @@ class CartridgeAgentConfiguration:
             CartridgeAgentConfiguration.min_count = CartridgeAgentConfiguration.read_property(
                 cartridgeagentconstants.MIN_INSTANCE_COUNT)
             CartridgeAgentConfiguration.lb_private_ip = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LB_PRIVATE_IP)
+                cartridgeagentconstants.LB_PRIVATE_IP, False)
             CartridgeAgentConfiguration.lb_public_ip = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LB_PUBLIC_IP)
+                cartridgeagentconstants.LB_PUBLIC_IP, False)
             CartridgeAgentConfiguration.tenant_repository_path = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.TENANT_REPO_PATH)
+                cartridgeagentconstants.TENANT_REPO_PATH, False)
             CartridgeAgentConfiguration.super_tenant_repository_path = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.SUPER_TENANT_REPO_PATH)
+                cartridgeagentconstants.SUPER_TENANT_REPO_PATH, False)
 
             try:
                 CartridgeAgentConfiguration.deployment = CartridgeAgentConfiguration.read_property(
@@ -277,17 +277,22 @@ class CartridgeAgentConfiguration:
             if param_file is not None:
                 metadata_file = open(param_file)
                 metadata_payload_content = metadata_file.read()
-                CartridgeAgentConfiguration.payload_params = dict(
-                    param.split("=") for param in metadata_payload_content.split(","))
+                for param in metadata_payload_content.split(","):
+                    if param.strip() != "":
+                        param_value = param.strip().split("=")
+                        CartridgeAgentConfiguration.payload_params[param_value[0]] = param_value[1]
+
+                # CartridgeAgentConfiguration.payload_params = dict(
+                #     param.split("=") for param in metadata_payload_content.split(","))
                 metadata_file.close()
             else:
                 CartridgeAgentConfiguration.log.error("File not found: %r" % param_file)
         except:
-            CartridgeAgentConfiguration.log.error(
+            CartridgeAgentConfiguration.log.exception(
                 "Could not read launch parameter file, hence trying to read from System properties.")
 
     @staticmethod
-    def read_property(property_key):
+    def read_property(property_key, critical=True):
         """
         Returns the value of the provided property
         :param str property_key: the name of the property to be read
@@ -307,4 +312,5 @@ class CartridgeAgentConfiguration:
             if temp_str != "" and temp_str is not None:
                 return temp_str
 
-        raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
\ No newline at end of file
+        if critical:
+            raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
new file mode 100644
index 0000000..1a2bfaf
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
@@ -0,0 +1,61 @@
+import abc
+
+
+class AbstractExtensionHandler:
+
+    def on_instance_started_event(self):
+        raise NotImplementedError
+
+    def on_instance_activated_event(self):
+        raise NotImplementedError
+
+    def on_artifact_updated_event(self, artifacts_updated_event):
+        raise NotImplementedError
+
+    def on_artifact_update_scheduler_event(self, tenant_id):
+        raise NotImplementedError
+
+    def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
+        raise NotImplementedError
+
+    def on_instance_cleanup_member_event(self, instanceCleanupMemberEvent):
+        raise NotImplementedError
+
+    def on_member_activated_event(self, member_activated_event):
+        raise NotImplementedError
+
+    def on_complete_topology_event(self, complete_topology_event):
+        raise NotImplementedError
+
+    def on_complete_tenant_event(self, complete_tenant_event):
+        raise NotImplementedError
+
+    def on_member_terminated_event(self, member_terminated_event):
+        raise NotImplementedError
+
+    def on_member_suspended_event(self, member_suspended_event):
+        raise NotImplementedError
+
+    def on_member_started_event(self, member_started_event):
+        raise NotImplementedError
+
+    def start_server_extension(self):
+        raise NotImplementedError
+
+    def volume_mount_extension(self, persistence_mappings_payload):
+        raise NotImplementedError
+
+    def on_subscription_domain_added_event(self, subscription_domain_added_event):
+        raise NotImplementedError
+
+    def on_subscription_domain_removed_event(self, subscriptionDomainRemovedEvent):
+        raise NotImplementedError
+
+    def on_copy_artifacts_extension(self, src, des):
+        raise NotImplementedError
+
+    def on_tenant_subscribed_event(self, tenant_subscribed_event):
+            raise NotImplementedError
+
+    def on_tenant_unsubscribed_event(self, tenant_unsubscribed_event):
+            raise NotImplementedError

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index a93130f..96b6fd5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -9,16 +9,17 @@ from ..publisher import cartridgeagentpublisher
 from ..exception.parameternotfoundexception import ParameterNotFoundException
 from ..topology.topologycontext import *
 from ..tenant.tenantcontext import *
+from abstractextensionhandler import AbstractExtensionHandler
 
 
-class DefaultExtensionHandler:
+class DefaultExtensionHandler(AbstractExtensionHandler):
     """
     TODO : Provide abstraction
     """
     log = None
 
     def __init__(self):
-        logging.basicConfig(level=logging.DEBUG)
+        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
         self.log = logging.getLogger(__name__)
         self.wk_members = []
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 84ee43a..1ad437b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -7,7 +7,7 @@ from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. util import cartridgeagentconstants
 
 
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
 log = logging.getLogger(__name__)
 
 started = False

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index 44ed8d8..6d29a68 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -18,7 +18,7 @@ class EventSubscriber(threading.Thread):
         #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
         self.__event_handlers = {}
 
-        logging.basicConfig(level=logging.DEBUG)
+        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
         self.log = logging.getLogger(__name__)
 
         self.__mb_client = None

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index 89e7961..8e47a37 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -11,7 +11,7 @@ import cartridgeagentconstants
 
 unpad = lambda s: s[0:-ord(s[-1])]
 
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
 log = logging.getLogger(__name__)
 
 current_milli_time = lambda: int(round(time.time() * 1000))

http://git-wip-us.apache.org/repos/asf/stratos/blob/b7c8985a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 60a1558..53b6ea8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -6,7 +6,7 @@ import time
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. topology.topologycontext import *
 
-logging.basicConfig(level=logging.DEBUG)
+logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
 log = logging.getLogger(__name__)
 
 


[30/50] [abbrv] git commit: Reverted accidently committed mistake

Posted by ni...@apache.org.
Reverted accidently committed mistake


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/29f35bde
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/29f35bde
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/29f35bde

Branch: refs/heads/master
Commit: 29f35bdee598a3f007228a8b4cb104a245828344
Parents: 0b73a8f
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 16:12:54 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 16:12:54 2014 +0530

----------------------------------------------------------------------
 .../apache/stratos/messaging/broker/publish/EventPublisher.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/29f35bde/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
index 92ae4da..2ba4df4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
- */INSTANCE_STATUS_TOPIC
+ */
 
 package org.apache.stratos.messaging.broker.publish;
 


[29/50] [abbrv] git commit: Fixed issues observed in testing in an OpenStack environment in cartridge agent

Posted by ni...@apache.org.
Fixed issues observed in testing in an OpenStack environment in cartridge agent


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/0b73a8f7
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0b73a8f7
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0b73a8f7

Branch: refs/heads/master
Commit: 0b73a8f7d432bec9b8b725f56ed5ddf5a3ff6361
Parents: 2261bbe
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 12:25:04 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:41:35 2014 +0530

----------------------------------------------------------------------
 tools/python-cartridge-agent/cartridge-agent/agent.py        | 7 -------
 tools/python-cartridge-agent/cartridge-agent/logging.ini     | 4 ++--
 .../cartridge-agent/modules/datapublisher/logpublisher.py    | 3 ++-
 .../cartridge-agent/modules/event/topology/events.py         | 3 +++
 .../modules/extensions/defaultextensionhandler.py            | 4 ++--
 .../cartridge-agent/modules/topology/topologycontext.py      | 8 +++++---
 .../cartridge-agent/modules/util/log.py                      | 2 +-
 7 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index 8ba2740..1d16c99 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -121,13 +121,6 @@ class CartridgeAgent(threading.Thread):
         Checks if required properties are set
         :return: void
         """
-        # JNDI_PROPERTIES_DIR
-        try:
-            self.cartridge_agent_config.read_property(cartridgeagentconstants.JNDI_PROPERTIES_DIR)
-        except ParameterNotFoundException:
-            self.log.error("System property not found: %r" % cartridgeagentconstants.JNDI_PROPERTIES_DIR)
-            return
-
         #PARAM_FILE_PATH
         try:
             self.cartridge_agent_config.read_property(cartridgeagentconstants.PARAM_FILE_PATH)

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
index 3fd9381..c3e9e2c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/logging.ini
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -6,7 +6,7 @@ format=%(asctime)s:%(levelname)s:%(message)s
 class=logging.Formatter
 
 [handlers]
-keys=console, error_file
+keys=console, error_file, log_file
 
 [handler_console]
 class=logging.StreamHandler
@@ -31,4 +31,4 @@ keys=root
 [logger_root]
 level=DEBUG
 formatter=default
-handlers=console,error_file
\ No newline at end of file
+handlers=console,error_file,log_file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index ea30c85..f58b6eb 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -221,9 +221,10 @@ class DataPublisherConfiguration:
         self.monitoring_server_secure_port = None
         self.admin_username = None
         self.admin_password = None
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
         self.read_config()
 
-        self.cartridge_agent_config = CartridgeAgentConfiguration()
 
     def read_config(self):
         self.enabled = True if self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_PUBLISHER_ENABLED, False).strip().lower() == "true" else False

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 5f37784..2886099 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -181,6 +181,9 @@ class CompleteTopologyEvent:
 
         return instance
 
+    def get_topology(self):
+        return self.topology
+
 
 class MemberStartedEvent:
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 58a5aa7..c91a559 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -209,9 +209,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         self.log.debug("Complete tenant event received")
 
         tenant_list_json = complete_tenant_event.tenant_list_json
-        self.log.debug("Complete tenants:" + tenant_list_json)
+        self.log.debug("Complete tenants:" + ','.join(tenant_list_json))
 
-        env_params = {"STRATOS_TENANT_LIST_JSON": tenant_list_json}
+        env_params = {"STRATOS_TENANT_LIST_JSON": ','.join(tenant_list_json)}
 
         extensionutils.execute_complete_tenant_extension(env_params)
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 21972ef..81314d2 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -176,7 +176,7 @@ class Cluster:
     Represents a cluster for a service
     """
 
-    def __init__(self, service_name, cluster_id, deployment_policy_name, autoscale_policy_name):
+    def __init__(self, service_name="", cluster_id="", deployment_policy_name="", autoscale_policy_name=""):
         self.service_name = service_name
         """ :type : str  """
         self.cluster_id = cluster_id
@@ -298,12 +298,13 @@ class Cluster:
         if not valid:
             raise RuntimeError("Tenant range %r is not valid" % tenant_range)
 
+
 class Member:
     """
     Represents a member on a particular cluster
     """
 
-    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
+    def __init__(self, service_name="", cluster_id="", network_partition_id="", parition_id="", member_id=""):
         self.service_name = service_name
         """ :type : str  """
         self.cluster_id = cluster_id
@@ -430,4 +431,5 @@ class TopologyContext:
 
     @staticmethod
     def update(topology):
-        TopologyContext.topology = topology
\ No newline at end of file
+        TopologyContext.topology = topology
+        TopologyContext.topology.initialized = True
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/0b73a8f7/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
index b6fec95..ff8e9d4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
@@ -35,4 +35,4 @@ class LogFactory(object):
         :return: The logger class
         :rtype: RootLogger
         """
-        self.instance.get_log(name)
\ No newline at end of file
+        return self.instance.get_log(name)
\ No newline at end of file


[44/50] [abbrv] git commit: Fixed missing null checks Added health stats publishing username and password to the configuration Fixed topology events not returning the deserialized objects

Posted by ni...@apache.org.
Fixed missing null checks
Added health stats publishing username and password to the configuration
Fixed topology events not returning the deserialized objects


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/dc4d2ad1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/dc4d2ad1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/dc4d2ad1

Branch: refs/heads/master
Commit: dc4d2ad1d3cb98e9c39f2859e9f3291672e5a720
Parents: b6a871d
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 21:43:35 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 21:43:35 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.conf                       |  2 ++
 .../python-cartridge-agent/cartridge-agent/agent.py  |  2 +-
 .../modules/datapublisher/logpublisher.py            | 15 +++++++--------
 .../cartridge-agent/modules/event/topology/events.py |  7 +++++++
 .../modules/extensions/defaultextensionhandler.py    |  2 +-
 .../modules/healthstatspublisher/healthstats.py      |  8 ++++----
 6 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.conf b/tools/python-cartridge-agent/cartridge-agent/agent.conf
index 1bb65d8..5c087e9 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.conf
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.conf
@@ -21,6 +21,8 @@ mb.port                               =MB-PORT
 listen.address                        =LISTEN_ADDR
 thrift.receiver.ip                    =CEP-IP
 thrift.receiver.port                  =CEP-PORT
+thrift.server.admin.username          =CEP-ADMIN-USERNAME
+thrift.server.admin.password          =CEP-ADMIN-PASSWORD
 param.file.path                       =/mnt/cartridge-agent/payload/launch-params
 extensions.dir                        =/mnt/cartridge-agent/extensions
 cep.stats.publisher.enabled           =ENABLE_HEALTH_PUBLISHER

http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index c2976a8..aacfb2e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -203,7 +203,7 @@ class CartridgeAgent(threading.Thread):
         try:
             CartridgeAgent.extension_handler.on_member_activated_event(event_obj)
         except:
-            self.log.exception("Error processing member terminated event")
+            self.log.exception("Error processing member activated event")
 
     def on_member_terminated(self, msg):
         self.log.debug("Member terminated event received: %r" % msg.payload)

http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index cf91736..050dd9e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -242,7 +242,6 @@ class DataPublisherConfiguration:
 
         self.read_config()
 
-
     def read_config(self):
         self.enabled = True if self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_PUBLISHER_ENABLED, False).strip().lower() == "true" else False
         if not self.enabled:
@@ -252,23 +251,23 @@ class DataPublisherConfiguration:
         DataPublisherConfiguration.log.info("Data Publisher enabled")
 
         self.monitoring_server_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_RECEIVER_IP, False)
-        if self.monitoring_server_ip.strip() == "":
+        if self.monitoring_server_ip is None or self.monitoring_server_ip.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_RECEIVER_IP)
 
         self.monitoring_server_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_RECEIVER_PORT, False)
-        if self.monitoring_server_port.strip() == "":
+        if self.monitoring_server_port is None or self.monitoring_server_port.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_RECEIVER_PORT)
 
-        # self.monitoring_server_secure_port = self.cartridge_agent_config.read_property("monitoring.server.secure.port", False)
-        # if self.monitoring_server_secure_port.strip() == "":
-        #     raise RuntimeError("System property not found: monitoring.server.secure.port")
+        self.monitoring_server_secure_port = self.cartridge_agent_config.read_property("monitoring.server.secure.port", False)
+        if self.monitoring_server_secure_port is None or self.monitoring_server_secure_port.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.secure.port")
 
         self.admin_username = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_SERVER_ADMIN_USERNAME, False)
-        if self.admin_username.strip() == "":
+        if self.admin_username is None or self.admin_username.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_SERVER_ADMIN_USERNAME)
 
         self.admin_password = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_SERVER_ADMIN_PASSWORD, False)
-        if self.admin_password.strip() == "":
+        if self.admin_password is None or self.admin_password.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_SERVER_ADMIN_PASSWORD)
 
         DataPublisherConfiguration.log.info("Data Publisher configuration initialized")

http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 72c4a99..8a89c98 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -68,6 +68,8 @@ class MemberActivatedEvent:
             port_obj = Port(port_str["protocol"], port_str["value"], port_proxy)
             instance.port_map[port_proxy] = port_obj
 
+        return instance
+
 
 class MemberTerminatedEvent:
 
@@ -96,6 +98,8 @@ class MemberTerminatedEvent:
         instance.partition_id = json_obj["partitionId"] if "partitionId" in json_obj else None
         instance.member_id = json_obj["memberId"] if "memberId" in json_obj else None
 
+        return instance
+
 
 class MemberSuspendedEvent:
 
@@ -122,6 +126,8 @@ class MemberSuspendedEvent:
         instance.partition_id = json_obj["partitionId"] if "partitionId" in json_obj else None
         instance.member_id = json_obj["memberId"] if "memberId" in json_obj else None
 
+        return instance
+
 
 class CompleteTopologyEvent:
 
@@ -229,3 +235,4 @@ class MemberStartedEvent:
         instance.partition_id = json_obj["partitionId"] if "partitionId" in json_obj else None
         instance.member_id = json_obj["memberId"] if "memberId" in json_obj else None
 
+        return instance
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 8ee3cd6..f2ec818 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -159,7 +159,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
             ports = member_activated_event.port_map.values()
             ports_str = ""
             for port in ports:
-                ports_str += port.protocol + "," + port.value + "," + port.proxy + "|"
+                ports_str += port.protocol + "," + str(port.value) + "," + str(port.proxy) + "|"
 
             env_params["STRATOS_MEMBER_ACTIVATED_PORTS"] = ports_str
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/dc4d2ad1/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index aafe4db..fd833c4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -214,22 +214,22 @@ class CEPPublisherConfiguration:
 
         self.server_ip = self.cartridge_agent_config.read_property(
             cartridgeagentconstants.CEP_RECEIVER_IP, False)
-        if self.server_ip.strip() == "":
+        if self.server_ip is None or self.server_ip.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_RECEIVER_IP)
 
         self.server_port = self.cartridge_agent_config.read_property(
             cartridgeagentconstants.CEP_RECEIVER_PORT, False)
-        if self.server_port.strip() == "":
+        if self.server_port is None or self.server_port.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_RECEIVER_PORT)
 
         self.admin_username = self.cartridge_agent_config.read_property(
             cartridgeagentconstants.CEP_SERVER_ADMIN_USERNAME, False)
-        if self.admin_username.strip() == "":
+        if self.admin_username is None or self.admin_username.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_SERVER_ADMIN_USERNAME)
 
         self.admin_password = self.cartridge_agent_config.read_property(
             cartridgeagentconstants.CEP_SERVER_ADMIN_PASSWORD, False)
-        if self.admin_password.strip() == "":
+        if self.admin_password is None or self.admin_password.strip() == "":
             raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_SERVER_ADMIN_PASSWORD)
 
         CEPPublisherConfiguration.log.info("CEP Publisher configuration initialized")


[28/50] [abbrv] git commit: Fixed singleton impl of the configuration class Fixed minor issues in dependancies

Posted by ni...@apache.org.
Fixed singleton impl of the configuration class
Fixed minor issues in dependancies


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2261bbec
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2261bbec
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2261bbec

Branch: refs/heads/master
Commit: 2261bbec4bbabd36aace3b4dbeae860007d54ed8
Parents: 105a09e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 04:22:56 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:41:22 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  3 +-
 .../modules/artifactmgt/git/agentgithandler.py  | 17 +++---
 .../config/cartridgeagentconfiguration.py       | 58 +++++++++-----------
 .../modules/topology/topologycontext.py         | 24 +++++++-
 .../modules/util/cartridgeagentutils.py         | 39 +------------
 .../modules/util/extensionutils.py              |  2 +
 6 files changed, 60 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index 4858b9d..8ba2740 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -11,10 +11,11 @@ from modules.tenant.tenantcontext import *
 from modules.topology.topologycontext import *
 from modules.datapublisher.logpublisher import *
 from modules.config import cartridgeagentconfiguration
+from modules.extensions import defaultextensionhandler
 
 
 class CartridgeAgent(threading.Thread):
-    extension_handler = None
+    extension_handler = defaultextensionhandler.DefaultExtensionHandler()
 
     def __init__(self):
         threading.Thread.__init__(self)

http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index be46c5d..5353b8f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -5,7 +5,10 @@ import urllib2
 
 from ... util.log import LogFactory
 from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
-
+from gitrepository import GitRepository
+from ... config import cartridgeagentconfiguration
+from ... util.asyncscheduledtask import AsyncScheduledTask
+from ... artifactmgt.repositoryinformation import RepositoryInformation
 
 class AgentGitHandler:
     """
@@ -18,7 +21,7 @@ class AgentGitHandler:
     SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
     TENANT_REPO_PATH = "/repository/tenants/"
 
-    extension_handler = cartridgeagentutils.get_extension_handler()
+    extension_handler = None
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)
@@ -113,6 +116,8 @@ class AgentGitHandler:
     @staticmethod
     def pull(repo_context):
         repo = Repo(repo_context.local_repo_path)
+        from ....agent import CartridgeAgent
+        AgentGitHandler.extension_handler = CartridgeAgent.extension_handler
         try:
             repo.git.checkout("master")
             pull_output = repo.git.pull()
@@ -476,10 +481,4 @@ class ArtifactUpdateTask(Thread):
             self.log.exception("Auto checkout task failed")
 
         if self.auto_commit:
-            AgentGitHandler.commit(self.repo_info)
-
-
-from gitrepository import GitRepository
-from ... config import cartridgeagentconfiguration
-from ... util.asyncscheduledtask import AsyncScheduledTask
-from ... artifactmgt.repositoryinformation import RepositoryInformation
\ No newline at end of file
+            AgentGitHandler.commit(self.repo_info)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 27c9a89..415a54e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -111,8 +111,7 @@ class CartridgeAgentConfiguration:
                     self.log_file_paths = None
 
                 is_multi_str = self.read_property(cartridgeagentconstants.CLUSTER_ID)
-                self.is_multitenant = True if str(
-                    is_multi_str).lower().strip() == "true" else False
+                self.is_multitenant = True if str(is_multi_str).lower().strip() == "true" else False
 
                 try:
                     self.persistence_mappings = self.read_property(
@@ -123,47 +122,36 @@ class CartridgeAgentConfiguration:
 
                 try:
                     is_commit_str = self.read_property(cartridgeagentconstants.COMMIT_ENABLED)
-                    self.is_commits_enabled = True if str(
-                        is_commit_str).lower().strip() == "true" else False
+                    self.is_commits_enabled = True if str(is_commit_str).lower().strip() == "true" else False
                 except ParameterNotFoundException:
                     try:
                         is_commit_str = self.read_property(cartridgeagentconstants.AUTO_COMMIT)
-                        self.is_commits_enabled = True if str(
-                            is_commit_str).lower().strip() == "true" else False
+                        self.is_commits_enabled = True if str(is_commit_str).lower().strip() == "true" else False
                     except ParameterNotFoundException:
                         self.log.info(
                             "%r is not found and setting it to false" % cartridgeagentconstants.COMMIT_ENABLED)
                         self.is_commits_enabled = False
 
                 auto_checkout_str = self.read_property(cartridgeagentconstants.AUTO_CHECKOUT, False)
-                self.is_checkout_enabled = True if str(
-                    auto_checkout_str).lower().strip() == "true" else False
+                self.is_checkout_enabled = True if str(auto_checkout_str).lower().strip() == "true" else False
 
                 self.listen_address = self.read_property(
                     cartridgeagentconstants.LISTEN_ADDRESS, False)
 
                 try:
                     int_repo_str = self.read_property(cartridgeagentconstants.PROVIDER)
-                    self.is_internal_repo = True if str(
-                        int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
+                    self.is_internal_repo = True if str(int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
                 except ParameterNotFoundException:
                     self.log.info(" INTERNAL payload parameter is not found")
                     self.is_internal_repo = False
 
-                self.tenant_id = self.read_property(
-                    cartridgeagentconstants.TENANT_ID)
-                self.lb_cluster_id = self.read_property(
-                    cartridgeagentconstants.LB_CLUSTER_ID)
-                self.min_count = self.read_property(
-                    cartridgeagentconstants.MIN_INSTANCE_COUNT)
-                self.lb_private_ip = self.read_property(
-                    cartridgeagentconstants.LB_PRIVATE_IP, False)
-                self.lb_public_ip = self.read_property(
-                    cartridgeagentconstants.LB_PUBLIC_IP, False)
-                self.tenant_repository_path = self.read_property(
-                    cartridgeagentconstants.TENANT_REPO_PATH, False)
-                self.super_tenant_repository_path = self.read_property(
-                    cartridgeagentconstants.SUPER_TENANT_REPO_PATH, False)
+                self.tenant_id = self.read_property(cartridgeagentconstants.TENANT_ID)
+                self.lb_cluster_id = self.read_property(cartridgeagentconstants.LB_CLUSTER_ID)
+                self.min_count = self.read_property(cartridgeagentconstants.MIN_INSTANCE_COUNT)
+                self.lb_private_ip = self.read_property(cartridgeagentconstants.LB_PRIVATE_IP, False)
+                self.lb_public_ip = self.read_property(cartridgeagentconstants.LB_PUBLIC_IP, False)
+                self.tenant_repository_path = self.read_property(cartridgeagentconstants.TENANT_REPO_PATH, False)
+                self.super_tenant_repository_path = self.read_property(cartridgeagentconstants.SUPER_TENANT_REPO_PATH, False)
 
                 try:
                     self.deployment = self.read_property(
@@ -175,14 +163,14 @@ class CartridgeAgentConfiguration:
                 if self.deployment is None:
                     self.manager_service_name = None
 
-                if self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                if str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
                     self.manager_service_name = self.service_name
 
-                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                elif str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
                     self.deployment = self.read_property(
                         cartridgeagentconstants.MANAGER_SERVICE_TYPE)
 
-                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
+                elif str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
                     self.deployment = None
                 else:
                     self.deployment = None
@@ -191,14 +179,14 @@ class CartridgeAgentConfiguration:
                 if self.deployment is None:
                     self.worker_service_name = None
 
-                if self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                if str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
                     self.manager_service_name = self.service_name
 
-                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                elif str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
                     self.deployment = self.read_property(
                         cartridgeagentconstants.WORKER_SERVICE_TYPE)
 
-                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
+                elif str(self.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
                     self.deployment = None
                 else:
                     self.deployment = None
@@ -288,12 +276,16 @@ class CartridgeAgentConfiguration:
 
     instance = None
 
-    def __new__(cls, *args, **kwargs):
+    # def __new__(cls, *args, **kwargs):
+    #     if not CartridgeAgentConfiguration.instance:
+    #         CartridgeAgentConfiguration.instance = CartridgeAgentConfiguration.__CartridgeAgentConfiguration()
+    #
+    #     return CartridgeAgentConfiguration.instance
+
+    def __init__(self):
         if not CartridgeAgentConfiguration.instance:
             CartridgeAgentConfiguration.instance = CartridgeAgentConfiguration.__CartridgeAgentConfiguration()
 
-        return CartridgeAgentConfiguration.instance
-
     def __getattr__(self, name):
         return getattr(self.instance, name)
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 4a13765..21972ef 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -1,4 +1,4 @@
-from ..util import cartridgeagentutils, cartridgeagentconstants
+from ..util import cartridgeagentconstants
 
 
 class Topology:
@@ -207,7 +207,7 @@ class Cluster:
         self.hostnames.append(hostname)
 
     def set_tenant_range(self, tenant_range):
-        cartridgeagentutils.validate_tenant_range(tenant_range)
+        self.validate_tenant_range(tenant_range)
         self.tenant_range = tenant_range
 
     def get_members(self):
@@ -277,6 +277,26 @@ class Cluster:
 
         return False
 
+    def validate_tenant_range(self, tenant_range):
+        """
+        Validates the tenant range to be either '*' or a delimeted range of numbers
+        :param str tenant_range: The tenant range string to be validated
+        :return: void if the provided tenant range is valid, RuntimeError if otherwise
+        :exception: RuntimeError if the tenant range is invalid
+        """
+        valid = False
+        if tenant_range == "*":
+            valid = True
+        else:
+            arr = tenant_range.split(cartridgeagentconstants.TENANT_RANGE_DELIMITER)
+            if len(arr) == 2:
+                if arr[0].isdigit() and arr[1].isdigit():
+                    valid = True
+                elif arr[0].isdigit() and arr[1] == "*":
+                    valid = True
+
+        if not valid:
+            raise RuntimeError("Tenant range %r is not valid" % tenant_range)
 
 class Member:
     """

http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index 81b2b92..7a7a4fe 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -1,12 +1,10 @@
 from Crypto.Cipher import AES
 import base64
-import logging
 import os
 import time
 import socket
 import shutil
 
-import cartridgeagentconstants
 from log import LogFactory
 
 unpad = lambda s: s[0:-ord(s[-1])]
@@ -15,16 +13,6 @@ log = LogFactory().get_log(__name__)
 
 current_milli_time = lambda: int(round(time.time() * 1000))
 
-extension_handler = None
-
-
-def get_extension_handler():
-    global extension_handler
-    if extension_handler is None:
-        extension_handler = defaultextensionhandler.DefaultExtensionHandler()
-
-    return extension_handler
-
 
 def decrypt_password(pass_str, secret):
     """
@@ -138,28 +126,6 @@ def check_ports_active(ip_address, ports):
     return True
 
 
-def validate_tenant_range(tenant_range):
-    """
-    Validates the tenant range to be either '*' or a delimeted range of numbers
-    :param str tenant_range: The tenant range string to be validated
-    :return: void if the provided tenant range is valid, RuntimeError if otherwise
-    :exception: RuntimeError if the tenant range is invalid
-    """
-    valid = False
-    if tenant_range == "*":
-        valid = True
-    else:
-        arr = tenant_range.split(cartridgeagentconstants.TENANT_RANGE_DELIMITER)
-        if len(arr) == 2:
-            if arr[0].isdigit() and arr[1].isdigit():
-                valid = True
-            elif arr[0].isdigit() and arr[1] == "*":
-                valid = True
-
-    if not valid:
-        raise RuntimeError("Tenant range %r is not valid" % tenant_range)
-
-
 def get_carbon_server_property(property_key):
     """
     Reads the carbon.xml file and returns the value for the property key.
@@ -179,7 +145,4 @@ def get_working_dir():
     :rtype : str
     """
     #"/path/to/cartridge-agent/modules/util/".split("modules") returns ["/path/to/cartridge-agent/", "/util"]
-    return os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
-
-
-from ..extensions import defaultextensionhandler
+    return os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/2261bbec/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 013713b..9cf8ba3 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -4,6 +4,8 @@ import subprocess
 import time
 
 from log import LogFactory
+from .. config import cartridgeagentconfiguration
+
 
 log = LogFactory().get_log(__name__)
 


[05/50] [abbrv] Added WSO2 CEP/BAM Python data publisher Wrote a sample log publisher

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
new file mode 100644
index 0000000..cdec607
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
@@ -0,0 +1,403 @@
+#
+# 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 TProtocol import *
+from struct import pack, unpack
+
+__all__ = ['TCompactProtocol', 'TCompactProtocolFactory']
+
+CLEAR = 0
+FIELD_WRITE = 1
+VALUE_WRITE = 2
+CONTAINER_WRITE = 3
+BOOL_WRITE = 4
+FIELD_READ = 5
+CONTAINER_READ = 6
+VALUE_READ = 7
+BOOL_READ = 8
+
+
+def make_helper(v_from, container):
+  def helper(func):
+    def nested(self, *args, **kwargs):
+      assert self.state in (v_from, container), (self.state, v_from, container)
+      return func(self, *args, **kwargs)
+    return nested
+  return helper
+writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
+reader = make_helper(VALUE_READ, CONTAINER_READ)
+
+
+def makeZigZag(n, bits):
+  return (n << 1) ^ (n >> (bits - 1))
+
+
+def fromZigZag(n):
+  return (n >> 1) ^ -(n & 1)
+
+
+def writeVarint(trans, n):
+  out = []
+  while True:
+    if n & ~0x7f == 0:
+      out.append(n)
+      break
+    else:
+      out.append((n & 0xff) | 0x80)
+      n = n >> 7
+  trans.write(''.join(map(chr, out)))
+
+
+def readVarint(trans):
+  result = 0
+  shift = 0
+  while True:
+    x = trans.readAll(1)
+    byte = ord(x)
+    result |= (byte & 0x7f) << shift
+    if byte >> 7 == 0:
+      return result
+    shift += 7
+
+
+class CompactType:
+  STOP = 0x00
+  TRUE = 0x01
+  FALSE = 0x02
+  BYTE = 0x03
+  I16 = 0x04
+  I32 = 0x05
+  I64 = 0x06
+  DOUBLE = 0x07
+  BINARY = 0x08
+  LIST = 0x09
+  SET = 0x0A
+  MAP = 0x0B
+  STRUCT = 0x0C
+
+CTYPES = {TType.STOP: CompactType.STOP,
+          TType.BOOL: CompactType.TRUE,  # used for collection
+          TType.BYTE: CompactType.BYTE,
+          TType.I16: CompactType.I16,
+          TType.I32: CompactType.I32,
+          TType.I64: CompactType.I64,
+          TType.DOUBLE: CompactType.DOUBLE,
+          TType.STRING: CompactType.BINARY,
+          TType.STRUCT: CompactType.STRUCT,
+          TType.LIST: CompactType.LIST,
+          TType.SET: CompactType.SET,
+          TType.MAP: CompactType.MAP
+          }
+
+TTYPES = {}
+for k, v in CTYPES.items():
+  TTYPES[v] = k
+TTYPES[CompactType.FALSE] = TType.BOOL
+del k
+del v
+
+
+class TCompactProtocol(TProtocolBase):
+  """Compact implementation of the Thrift protocol driver."""
+
+  PROTOCOL_ID = 0x82
+  VERSION = 1
+  VERSION_MASK = 0x1f
+  TYPE_MASK = 0xe0
+  TYPE_SHIFT_AMOUNT = 5
+
+  def __init__(self, trans):
+    TProtocolBase.__init__(self, trans)
+    self.state = CLEAR
+    self.__last_fid = 0
+    self.__bool_fid = None
+    self.__bool_value = None
+    self.__structs = []
+    self.__containers = []
+
+  def __writeVarint(self, n):
+    writeVarint(self.trans, n)
+
+  def writeMessageBegin(self, name, type, seqid):
+    assert self.state == CLEAR
+    self.__writeUByte(self.PROTOCOL_ID)
+    self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
+    self.__writeVarint(seqid)
+    self.__writeString(name)
+    self.state = VALUE_WRITE
+
+  def writeMessageEnd(self):
+    assert self.state == VALUE_WRITE
+    self.state = CLEAR
+
+  def writeStructBegin(self, name):
+    assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
+    self.__structs.append((self.state, self.__last_fid))
+    self.state = FIELD_WRITE
+    self.__last_fid = 0
+
+  def writeStructEnd(self):
+    assert self.state == FIELD_WRITE
+    self.state, self.__last_fid = self.__structs.pop()
+
+  def writeFieldStop(self):
+    self.__writeByte(0)
+
+  def __writeFieldHeader(self, type, fid):
+    delta = fid - self.__last_fid
+    if 0 < delta <= 15:
+      self.__writeUByte(delta << 4 | type)
+    else:
+      self.__writeByte(type)
+      self.__writeI16(fid)
+    self.__last_fid = fid
+
+  def writeFieldBegin(self, name, type, fid):
+    assert self.state == FIELD_WRITE, self.state
+    if type == TType.BOOL:
+      self.state = BOOL_WRITE
+      self.__bool_fid = fid
+    else:
+      self.state = VALUE_WRITE
+      self.__writeFieldHeader(CTYPES[type], fid)
+
+  def writeFieldEnd(self):
+    assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
+    self.state = FIELD_WRITE
+
+  def __writeUByte(self, byte):
+    self.trans.write(pack('!B', byte))
+
+  def __writeByte(self, byte):
+    self.trans.write(pack('!b', byte))
+
+  def __writeI16(self, i16):
+    self.__writeVarint(makeZigZag(i16, 16))
+
+  def __writeSize(self, i32):
+    self.__writeVarint(i32)
+
+  def writeCollectionBegin(self, etype, size):
+    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+    if size <= 14:
+      self.__writeUByte(size << 4 | CTYPES[etype])
+    else:
+      self.__writeUByte(0xf0 | CTYPES[etype])
+      self.__writeSize(size)
+    self.__containers.append(self.state)
+    self.state = CONTAINER_WRITE
+  writeSetBegin = writeCollectionBegin
+  writeListBegin = writeCollectionBegin
+
+  def writeMapBegin(self, ktype, vtype, size):
+    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+    if size == 0:
+      self.__writeByte(0)
+    else:
+      self.__writeSize(size)
+      self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
+    self.__containers.append(self.state)
+    self.state = CONTAINER_WRITE
+
+  def writeCollectionEnd(self):
+    assert self.state == CONTAINER_WRITE, self.state
+    self.state = self.__containers.pop()
+  writeMapEnd = writeCollectionEnd
+  writeSetEnd = writeCollectionEnd
+  writeListEnd = writeCollectionEnd
+
+  def writeBool(self, bool):
+    if self.state == BOOL_WRITE:
+      if bool:
+        ctype = CompactType.TRUE
+      else:
+        ctype = CompactType.FALSE
+      self.__writeFieldHeader(ctype, self.__bool_fid)
+    elif self.state == CONTAINER_WRITE:
+      if bool:
+        self.__writeByte(CompactType.TRUE)
+      else:
+        self.__writeByte(CompactType.FALSE)
+    else:
+      raise AssertionError("Invalid state in compact protocol")
+
+  writeByte = writer(__writeByte)
+  writeI16 = writer(__writeI16)
+
+  @writer
+  def writeI32(self, i32):
+    self.__writeVarint(makeZigZag(i32, 32))
+
+  @writer
+  def writeI64(self, i64):
+    self.__writeVarint(makeZigZag(i64, 64))
+
+  @writer
+  def writeDouble(self, dub):
+    self.trans.write(pack('!d', dub))
+
+  def __writeString(self, s):
+    self.__writeSize(len(s))
+    self.trans.write(s)
+  writeString = writer(__writeString)
+
+  def readFieldBegin(self):
+    assert self.state == FIELD_READ, self.state
+    type = self.__readUByte()
+    if type & 0x0f == TType.STOP:
+      return (None, 0, 0)
+    delta = type >> 4
+    if delta == 0:
+      fid = self.__readI16()
+    else:
+      fid = self.__last_fid + delta
+    self.__last_fid = fid
+    type = type & 0x0f
+    if type == CompactType.TRUE:
+      self.state = BOOL_READ
+      self.__bool_value = True
+    elif type == CompactType.FALSE:
+      self.state = BOOL_READ
+      self.__bool_value = False
+    else:
+      self.state = VALUE_READ
+    return (None, self.__getTType(type), fid)
+
+  def readFieldEnd(self):
+    assert self.state in (VALUE_READ, BOOL_READ), self.state
+    self.state = FIELD_READ
+
+  def __readUByte(self):
+    result, = unpack('!B', self.trans.readAll(1))
+    return result
+
+  def __readByte(self):
+    result, = unpack('!b', self.trans.readAll(1))
+    return result
+
+  def __readVarint(self):
+    return readVarint(self.trans)
+
+  def __readZigZag(self):
+    return fromZigZag(self.__readVarint())
+
+  def __readSize(self):
+    result = self.__readVarint()
+    if result < 0:
+      raise TException("Length < 0")
+    return result
+
+  def readMessageBegin(self):
+    assert self.state == CLEAR
+    proto_id = self.__readUByte()
+    if proto_id != self.PROTOCOL_ID:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+          'Bad protocol id in the message: %d' % proto_id)
+    ver_type = self.__readUByte()
+    type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT
+    version = ver_type & self.VERSION_MASK
+    if version != self.VERSION:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+          'Bad version: %d (expect %d)' % (version, self.VERSION))
+    seqid = self.__readVarint()
+    name = self.__readString()
+    return (name, type, seqid)
+
+  def readMessageEnd(self):
+    assert self.state == CLEAR
+    assert len(self.__structs) == 0
+
+  def readStructBegin(self):
+    assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
+    self.__structs.append((self.state, self.__last_fid))
+    self.state = FIELD_READ
+    self.__last_fid = 0
+
+  def readStructEnd(self):
+    assert self.state == FIELD_READ
+    self.state, self.__last_fid = self.__structs.pop()
+
+  def readCollectionBegin(self):
+    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+    size_type = self.__readUByte()
+    size = size_type >> 4
+    type = self.__getTType(size_type)
+    if size == 15:
+      size = self.__readSize()
+    self.__containers.append(self.state)
+    self.state = CONTAINER_READ
+    return type, size
+  readSetBegin = readCollectionBegin
+  readListBegin = readCollectionBegin
+
+  def readMapBegin(self):
+    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+    size = self.__readSize()
+    types = 0
+    if size > 0:
+      types = self.__readUByte()
+    vtype = self.__getTType(types)
+    ktype = self.__getTType(types >> 4)
+    self.__containers.append(self.state)
+    self.state = CONTAINER_READ
+    return (ktype, vtype, size)
+
+  def readCollectionEnd(self):
+    assert self.state == CONTAINER_READ, self.state
+    self.state = self.__containers.pop()
+  readSetEnd = readCollectionEnd
+  readListEnd = readCollectionEnd
+  readMapEnd = readCollectionEnd
+
+  def readBool(self):
+    if self.state == BOOL_READ:
+      return self.__bool_value == CompactType.TRUE
+    elif self.state == CONTAINER_READ:
+      return self.__readByte() == CompactType.TRUE
+    else:
+      raise AssertionError("Invalid state in compact protocol: %d" %
+                           self.state)
+
+  readByte = reader(__readByte)
+  __readI16 = __readZigZag
+  readI16 = reader(__readZigZag)
+  readI32 = reader(__readZigZag)
+  readI64 = reader(__readZigZag)
+
+  @reader
+  def readDouble(self):
+    buff = self.trans.readAll(8)
+    val, = unpack('!d', buff)
+    return val
+
+  def __readString(self):
+    len = self.__readSize()
+    return self.trans.readAll(len)
+  readString = reader(__readString)
+
+  def __getTType(self, byte):
+    return TTYPES[byte & 0x0f]
+
+
+class TCompactProtocolFactory:
+  def __init__(self):
+    pass
+
+  def getProtocol(self, trans):
+    return TCompactProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
new file mode 100644
index 0000000..3048197
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
@@ -0,0 +1,550 @@
+#
+# 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 TProtocol import TType, TProtocolBase, TProtocolException
+import base64
+import json
+import math
+
+__all__ = ['TJSONProtocol',
+           'TJSONProtocolFactory',
+           'TSimpleJSONProtocol',
+           'TSimpleJSONProtocolFactory']
+
+VERSION = 1
+
+COMMA = ','
+COLON = ':'
+LBRACE = '{'
+RBRACE = '}'
+LBRACKET = '['
+RBRACKET = ']'
+QUOTE = '"'
+BACKSLASH = '\\'
+ZERO = '0'
+
+ESCSEQ = '\\u00'
+ESCAPE_CHAR = '"\\bfnrt'
+ESCAPE_CHAR_VALS = ['"', '\\', '\b', '\f', '\n', '\r', '\t']
+NUMERIC_CHAR = '+-.0123456789Ee'
+
+CTYPES = {TType.BOOL:       'tf',
+          TType.BYTE:       'i8',
+          TType.I16:        'i16',
+          TType.I32:        'i32',
+          TType.I64:        'i64',
+          TType.DOUBLE:     'dbl',
+          TType.STRING:     'str',
+          TType.STRUCT:     'rec',
+          TType.LIST:       'lst',
+          TType.SET:        'set',
+          TType.MAP:        'map'}
+
+JTYPES = {}
+for key in CTYPES.keys():
+  JTYPES[CTYPES[key]] = key
+
+
+class JSONBaseContext(object):
+
+  def __init__(self, protocol):
+    self.protocol = protocol
+    self.first = True
+
+  def doIO(self, function):
+    pass
+  
+  def write(self):
+    pass
+
+  def read(self):
+    pass
+
+  def escapeNum(self):
+    return False
+
+  def __str__(self):
+    return self.__class__.__name__
+
+
+class JSONListContext(JSONBaseContext):
+    
+  def doIO(self, function):
+    if self.first is True:
+      self.first = False
+    else:
+      function(COMMA)
+
+  def write(self):
+    self.doIO(self.protocol.trans.write)
+
+  def read(self):
+    self.doIO(self.protocol.readJSONSyntaxChar)
+
+
+class JSONPairContext(JSONBaseContext):
+  
+  def __init__(self, protocol):
+    super(JSONPairContext, self).__init__(protocol)
+    self.colon = True
+
+  def doIO(self, function):
+    if self.first:
+      self.first = False
+      self.colon = True
+    else:
+      function(COLON if self.colon else COMMA)
+      self.colon = not self.colon
+
+  def write(self):
+    self.doIO(self.protocol.trans.write)
+
+  def read(self):
+    self.doIO(self.protocol.readJSONSyntaxChar)
+
+  def escapeNum(self):
+    return self.colon
+
+  def __str__(self):
+    return '%s, colon=%s' % (self.__class__.__name__, self.colon)
+
+
+class LookaheadReader():
+  hasData = False
+  data = ''
+
+  def __init__(self, protocol):
+    self.protocol = protocol
+
+  def read(self):
+    if self.hasData is True:
+      self.hasData = False
+    else:
+      self.data = self.protocol.trans.read(1)
+    return self.data
+
+  def peek(self):
+    if self.hasData is False:
+      self.data = self.protocol.trans.read(1)
+    self.hasData = True
+    return self.data
+
+class TJSONProtocolBase(TProtocolBase):
+
+  def __init__(self, trans):
+    TProtocolBase.__init__(self, trans)
+    self.resetWriteContext()
+    self.resetReadContext()
+
+  def resetWriteContext(self):
+    self.context = JSONBaseContext(self)
+    self.contextStack = [self.context]
+
+  def resetReadContext(self):
+    self.resetWriteContext()
+    self.reader = LookaheadReader(self)
+
+  def pushContext(self, ctx):
+    self.contextStack.append(ctx)
+    self.context = ctx
+
+  def popContext(self):
+    self.contextStack.pop()
+    if self.contextStack:
+      self.context = self.contextStack[-1]
+    else:
+      self.context = JSONBaseContext(self)
+
+  def writeJSONString(self, string):
+    self.context.write()
+    self.trans.write(json.dumps(string))
+
+  def writeJSONNumber(self, number):
+    self.context.write()
+    jsNumber = str(number)
+    if self.context.escapeNum():
+      jsNumber = "%s%s%s" % (QUOTE, jsNumber,  QUOTE)
+    self.trans.write(jsNumber)
+
+  def writeJSONBase64(self, binary):
+    self.context.write()
+    self.trans.write(QUOTE)
+    self.trans.write(base64.b64encode(binary))
+    self.trans.write(QUOTE)
+
+  def writeJSONObjectStart(self):
+    self.context.write()
+    self.trans.write(LBRACE)
+    self.pushContext(JSONPairContext(self))
+
+  def writeJSONObjectEnd(self):
+    self.popContext()
+    self.trans.write(RBRACE)
+
+  def writeJSONArrayStart(self):
+    self.context.write()
+    self.trans.write(LBRACKET)
+    self.pushContext(JSONListContext(self))
+
+  def writeJSONArrayEnd(self):
+    self.popContext()
+    self.trans.write(RBRACKET)
+
+  def readJSONSyntaxChar(self, character):
+    current = self.reader.read()
+    if character != current:
+      raise TProtocolException(TProtocolException.INVALID_DATA,
+                               "Unexpected character: %s" % current)
+
+  def readJSONString(self, skipContext):
+    string = []
+    if skipContext is False:
+      self.context.read()
+    self.readJSONSyntaxChar(QUOTE)
+    while True:
+      character = self.reader.read()
+      if character == QUOTE:
+        break
+      if character == ESCSEQ[0]:
+        character = self.reader.read()
+        if character == ESCSEQ[1]:
+          self.readJSONSyntaxChar(ZERO)
+          self.readJSONSyntaxChar(ZERO)
+          character = json.JSONDecoder().decode('"\u00%s"' % self.trans.read(2))
+        else:
+          off = ESCAPE_CHAR.find(character)
+          if off == -1:
+            raise TProtocolException(TProtocolException.INVALID_DATA,
+                                     "Expected control char")
+          character = ESCAPE_CHAR_VALS[off]
+      string.append(character)
+    return ''.join(string)
+
+  def isJSONNumeric(self, character):
+    return (True if NUMERIC_CHAR.find(character) != - 1 else False)
+
+  def readJSONQuotes(self):
+    if (self.context.escapeNum()):
+      self.readJSONSyntaxChar(QUOTE)
+
+  def readJSONNumericChars(self):
+    numeric = []
+    while True:
+      character = self.reader.peek()
+      if self.isJSONNumeric(character) is False:
+        break
+      numeric.append(self.reader.read())
+    return ''.join(numeric)
+
+  def readJSONInteger(self):
+    self.context.read()
+    self.readJSONQuotes()
+    numeric = self.readJSONNumericChars()
+    self.readJSONQuotes()
+    try:
+      return int(numeric)
+    except ValueError:
+      raise TProtocolException(TProtocolException.INVALID_DATA,
+                               "Bad data encounted in numeric data")
+
+  def readJSONDouble(self):
+    self.context.read()
+    if self.reader.peek() == QUOTE:
+      string  = self.readJSONString(True)
+      try:
+        double = float(string)
+        if (self.context.escapeNum is False and
+            not math.isinf(double) and
+            not math.isnan(double)):
+          raise TProtocolException(TProtocolException.INVALID_DATA,
+                                   "Numeric data unexpectedly quoted")
+        return double
+      except ValueError:
+        raise TProtocolException(TProtocolException.INVALID_DATA,
+                                 "Bad data encounted in numeric data")
+    else:
+      if self.context.escapeNum() is True:
+        self.readJSONSyntaxChar(QUOTE)
+      try:
+        return float(self.readJSONNumericChars())
+      except ValueError:
+        raise TProtocolException(TProtocolException.INVALID_DATA,
+                                 "Bad data encounted in numeric data")
+
+  def readJSONBase64(self):
+    string = self.readJSONString(False)
+    return base64.b64decode(string)
+
+  def readJSONObjectStart(self):
+    self.context.read()
+    self.readJSONSyntaxChar(LBRACE)
+    self.pushContext(JSONPairContext(self))
+
+  def readJSONObjectEnd(self):
+    self.readJSONSyntaxChar(RBRACE)
+    self.popContext()
+
+  def readJSONArrayStart(self):
+    self.context.read()
+    self.readJSONSyntaxChar(LBRACKET)
+    self.pushContext(JSONListContext(self))
+
+  def readJSONArrayEnd(self):
+    self.readJSONSyntaxChar(RBRACKET)
+    self.popContext()
+
+
+class TJSONProtocol(TJSONProtocolBase):
+
+  def readMessageBegin(self):
+    self.resetReadContext()
+    self.readJSONArrayStart()
+    if self.readJSONInteger() != VERSION:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+                               "Message contained bad version.")
+    name = self.readJSONString(False)
+    typen = self.readJSONInteger()
+    seqid = self.readJSONInteger()
+    return (name, typen, seqid)
+
+  def readMessageEnd(self):
+    self.readJSONArrayEnd()
+
+  def readStructBegin(self):
+    self.readJSONObjectStart()
+
+  def readStructEnd(self):
+    self.readJSONObjectEnd()
+
+  def readFieldBegin(self):
+    character = self.reader.peek()
+    ttype = 0
+    id = 0
+    if character == RBRACE:
+      ttype = TType.STOP
+    else:
+      id = self.readJSONInteger()
+      self.readJSONObjectStart()
+      ttype = JTYPES[self.readJSONString(False)]
+    return (None, ttype, id)
+
+  def readFieldEnd(self):
+    self.readJSONObjectEnd()
+
+  def readMapBegin(self):
+    self.readJSONArrayStart()
+    keyType = JTYPES[self.readJSONString(False)]
+    valueType = JTYPES[self.readJSONString(False)]
+    size = self.readJSONInteger()
+    self.readJSONObjectStart()
+    return (keyType, valueType, size)
+
+  def readMapEnd(self):
+    self.readJSONObjectEnd()
+    self.readJSONArrayEnd()
+
+  def readCollectionBegin(self):
+    self.readJSONArrayStart()
+    elemType = JTYPES[self.readJSONString(False)]
+    size = self.readJSONInteger()
+    return (elemType, size)
+  readListBegin = readCollectionBegin
+  readSetBegin = readCollectionBegin
+
+  def readCollectionEnd(self):
+    self.readJSONArrayEnd()
+  readSetEnd = readCollectionEnd
+  readListEnd = readCollectionEnd
+
+  def readBool(self):
+    return (False if self.readJSONInteger() == 0 else True)
+
+  def readNumber(self):
+    return self.readJSONInteger()
+  readByte = readNumber
+  readI16 = readNumber
+  readI32 = readNumber
+  readI64 = readNumber
+
+  def readDouble(self):
+    return self.readJSONDouble()
+
+  def readString(self):
+    return self.readJSONString(False)
+
+  def readBinary(self):
+    return self.readJSONBase64()
+
+  def writeMessageBegin(self, name, request_type, seqid):
+    self.resetWriteContext()
+    self.writeJSONArrayStart()
+    self.writeJSONNumber(VERSION)
+    self.writeJSONString(name)
+    self.writeJSONNumber(request_type)
+    self.writeJSONNumber(seqid)
+
+  def writeMessageEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeStructBegin(self, name):
+    self.writeJSONObjectStart()
+
+  def writeStructEnd(self):
+    self.writeJSONObjectEnd()
+
+  def writeFieldBegin(self, name, ttype, id):
+    self.writeJSONNumber(id)
+    self.writeJSONObjectStart()
+    self.writeJSONString(CTYPES[ttype])
+
+  def writeFieldEnd(self):
+    self.writeJSONObjectEnd()
+
+  def writeFieldStop(self):
+    pass
+
+  def writeMapBegin(self, ktype, vtype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[ktype])
+    self.writeJSONString(CTYPES[vtype])
+    self.writeJSONNumber(size)
+    self.writeJSONObjectStart()
+
+  def writeMapEnd(self):
+    self.writeJSONObjectEnd()
+    self.writeJSONArrayEnd()
+    
+  def writeListBegin(self, etype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[etype])
+    self.writeJSONNumber(size)
+    
+  def writeListEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeSetBegin(self, etype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[etype])
+    self.writeJSONNumber(size)
+    
+  def writeSetEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeBool(self, boolean):
+    self.writeJSONNumber(1 if boolean is True else 0)
+
+  def writeInteger(self, integer):
+    self.writeJSONNumber(integer)
+  writeByte = writeInteger
+  writeI16 = writeInteger
+  writeI32 = writeInteger
+  writeI64 = writeInteger
+
+  def writeDouble(self, dbl):
+    self.writeJSONNumber(dbl)
+
+  def writeString(self, string):
+    self.writeJSONString(string)
+    
+  def writeBinary(self, binary):
+    self.writeJSONBase64(binary)
+
+
+class TJSONProtocolFactory:
+
+  def getProtocol(self, trans):
+    return TJSONProtocol(trans)
+
+
+class TSimpleJSONProtocol(TJSONProtocolBase):
+    """Simple, readable, write-only JSON protocol.
+    
+    Useful for interacting with scripting languages.
+    """
+
+    def readMessageBegin(self):
+        raise NotImplementedError()
+    
+    def readMessageEnd(self):
+        raise NotImplementedError()
+    
+    def readStructBegin(self):
+        raise NotImplementedError()
+    
+    def readStructEnd(self):
+        raise NotImplementedError()
+    
+    def writeMessageBegin(self, name, request_type, seqid):
+        self.resetWriteContext()
+    
+    def writeMessageEnd(self):
+        pass
+    
+    def writeStructBegin(self, name):
+        self.writeJSONObjectStart()
+    
+    def writeStructEnd(self):
+        self.writeJSONObjectEnd()
+      
+    def writeFieldBegin(self, name, ttype, fid):
+        self.writeJSONString(name)
+    
+    def writeFieldEnd(self):
+        pass
+    
+    def writeMapBegin(self, ktype, vtype, size):
+        self.writeJSONObjectStart()
+    
+    def writeMapEnd(self):
+        self.writeJSONObjectEnd()
+    
+    def _writeCollectionBegin(self, etype, size):
+        self.writeJSONArrayStart()
+    
+    def _writeCollectionEnd(self):
+        self.writeJSONArrayEnd()
+    writeListBegin = _writeCollectionBegin
+    writeListEnd = _writeCollectionEnd
+    writeSetBegin = _writeCollectionBegin
+    writeSetEnd = _writeCollectionEnd
+
+    def writeInteger(self, integer):
+        self.writeJSONNumber(integer)
+    writeByte = writeInteger
+    writeI16 = writeInteger
+    writeI32 = writeInteger
+    writeI64 = writeInteger
+    
+    def writeBool(self, boolean):
+        self.writeJSONNumber(1 if boolean is True else 0)
+
+    def writeDouble(self, dbl):
+        self.writeJSONNumber(dbl)
+    
+    def writeString(self, string):
+        self.writeJSONString(string)
+      
+    def writeBinary(self, binary):
+        self.writeJSONBase64(binary)
+
+
+class TSimpleJSONProtocolFactory(object):
+
+    def getProtocol(self, trans):
+        return TSimpleJSONProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
new file mode 100644
index 0000000..dc2b095
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
@@ -0,0 +1,406 @@
+#
+# 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.Thrift import *
+
+
+class TProtocolException(TException):
+  """Custom Protocol Exception class"""
+
+  UNKNOWN = 0
+  INVALID_DATA = 1
+  NEGATIVE_SIZE = 2
+  SIZE_LIMIT = 3
+  BAD_VERSION = 4
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
+
+class TProtocolBase:
+  """Base class for Thrift protocol driver."""
+
+  def __init__(self, trans):
+    self.trans = trans
+
+  def writeMessageBegin(self, name, ttype, seqid):
+    pass
+
+  def writeMessageEnd(self):
+    pass
+
+  def writeStructBegin(self, name):
+    pass
+
+  def writeStructEnd(self):
+    pass
+
+  def writeFieldBegin(self, name, ttype, fid):
+    pass
+
+  def writeFieldEnd(self):
+    pass
+
+  def writeFieldStop(self):
+    pass
+
+  def writeMapBegin(self, ktype, vtype, size):
+    pass
+
+  def writeMapEnd(self):
+    pass
+
+  def writeListBegin(self, etype, size):
+    pass
+
+  def writeListEnd(self):
+    pass
+
+  def writeSetBegin(self, etype, size):
+    pass
+
+  def writeSetEnd(self):
+    pass
+
+  def writeBool(self, bool_val):
+    pass
+
+  def writeByte(self, byte):
+    pass
+
+  def writeI16(self, i16):
+    pass
+
+  def writeI32(self, i32):
+    pass
+
+  def writeI64(self, i64):
+    pass
+
+  def writeDouble(self, dub):
+    pass
+
+  def writeString(self, str_val):
+    pass
+
+  def readMessageBegin(self):
+    pass
+
+  def readMessageEnd(self):
+    pass
+
+  def readStructBegin(self):
+    pass
+
+  def readStructEnd(self):
+    pass
+
+  def readFieldBegin(self):
+    pass
+
+  def readFieldEnd(self):
+    pass
+
+  def readMapBegin(self):
+    pass
+
+  def readMapEnd(self):
+    pass
+
+  def readListBegin(self):
+    pass
+
+  def readListEnd(self):
+    pass
+
+  def readSetBegin(self):
+    pass
+
+  def readSetEnd(self):
+    pass
+
+  def readBool(self):
+    pass
+
+  def readByte(self):
+    pass
+
+  def readI16(self):
+    pass
+
+  def readI32(self):
+    pass
+
+  def readI64(self):
+    pass
+
+  def readDouble(self):
+    pass
+
+  def readString(self):
+    pass
+
+  def skip(self, ttype):
+    if ttype == TType.STOP:
+      return
+    elif ttype == TType.BOOL:
+      self.readBool()
+    elif ttype == TType.BYTE:
+      self.readByte()
+    elif ttype == TType.I16:
+      self.readI16()
+    elif ttype == TType.I32:
+      self.readI32()
+    elif ttype == TType.I64:
+      self.readI64()
+    elif ttype == TType.DOUBLE:
+      self.readDouble()
+    elif ttype == TType.STRING:
+      self.readString()
+    elif ttype == TType.STRUCT:
+      name = self.readStructBegin()
+      while True:
+        (name, ttype, id) = self.readFieldBegin()
+        if ttype == TType.STOP:
+          break
+        self.skip(ttype)
+        self.readFieldEnd()
+      self.readStructEnd()
+    elif ttype == TType.MAP:
+      (ktype, vtype, size) = self.readMapBegin()
+      for i in xrange(size):
+        self.skip(ktype)
+        self.skip(vtype)
+      self.readMapEnd()
+    elif ttype == TType.SET:
+      (etype, size) = self.readSetBegin()
+      for i in xrange(size):
+        self.skip(etype)
+      self.readSetEnd()
+    elif ttype == TType.LIST:
+      (etype, size) = self.readListBegin()
+      for i in xrange(size):
+        self.skip(etype)
+      self.readListEnd()
+
+  # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
+  _TTYPE_HANDLERS = (
+       (None, None, False),  # 0 TType.STOP
+       (None, None, False),  # 1 TType.VOID # TODO: handle void?
+       ('readBool', 'writeBool', False),  # 2 TType.BOOL
+       ('readByte',  'writeByte', False),  # 3 TType.BYTE and I08
+       ('readDouble', 'writeDouble', False),  # 4 TType.DOUBLE
+       (None, None, False),  # 5 undefined
+       ('readI16', 'writeI16', False),  # 6 TType.I16
+       (None, None, False),  # 7 undefined
+       ('readI32', 'writeI32', False),  # 8 TType.I32
+       (None, None, False),  # 9 undefined
+       ('readI64', 'writeI64', False),  # 10 TType.I64
+       ('readString', 'writeString', False),  # 11 TType.STRING and UTF7
+       ('readContainerStruct', 'writeContainerStruct', True),  # 12 *.STRUCT
+       ('readContainerMap', 'writeContainerMap', True),  # 13 TType.MAP
+       ('readContainerSet', 'writeContainerSet', True),  # 14 TType.SET
+       ('readContainerList', 'writeContainerList', True),  # 15 TType.LIST
+       (None, None, False),  # 16 TType.UTF8 # TODO: handle utf8 types?
+       (None, None, False)  # 17 TType.UTF16 # TODO: handle utf16 types?
+      )
+
+  def readFieldByTType(self, ttype, spec):
+    try:
+      (r_handler, w_handler, is_container) = self._TTYPE_HANDLERS[ttype]
+    except IndexError:
+      raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                               message='Invalid field type %d' % (ttype))
+    if r_handler is None:
+      raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                               message='Invalid field type %d' % (ttype))
+    reader = getattr(self, r_handler)
+    if not is_container:
+      return reader()
+    return reader(spec)
+
+  def readContainerList(self, spec):
+    results = []
+    ttype, tspec = spec[0], spec[1]
+    r_handler = self._TTYPE_HANDLERS[ttype][0]
+    reader = getattr(self, r_handler)
+    (list_type, list_len) = self.readListBegin()
+    if tspec is None:
+      # list values are simple types
+      for idx in xrange(list_len):
+        results.append(reader())
+    else:
+      # this is like an inlined readFieldByTType
+      container_reader = self._TTYPE_HANDLERS[list_type][0]
+      val_reader = getattr(self, container_reader)
+      for idx in xrange(list_len):
+        val = val_reader(tspec)
+        results.append(val)
+    self.readListEnd()
+    return results
+
+  def readContainerSet(self, spec):
+    results = set()
+    ttype, tspec = spec[0], spec[1]
+    r_handler = self._TTYPE_HANDLERS[ttype][0]
+    reader = getattr(self, r_handler)
+    (set_type, set_len) = self.readSetBegin()
+    if tspec is None:
+      # set members are simple types
+      for idx in xrange(set_len):
+        results.add(reader())
+    else:
+      container_reader = self._TTYPE_HANDLERS[set_type][0]
+      val_reader = getattr(self, container_reader)
+      for idx in xrange(set_len):
+        results.add(val_reader(tspec))
+    self.readSetEnd()
+    return results
+
+  def readContainerStruct(self, spec):
+    (obj_class, obj_spec) = spec
+    obj = obj_class()
+    obj.read(self)
+    return obj
+
+  def readContainerMap(self, spec):
+    results = dict()
+    key_ttype, key_spec = spec[0], spec[1]
+    val_ttype, val_spec = spec[2], spec[3]
+    (map_ktype, map_vtype, map_len) = self.readMapBegin()
+    # TODO: compare types we just decoded with thrift_spec and
+    # abort/skip if types disagree
+    key_reader = getattr(self, self._TTYPE_HANDLERS[key_ttype][0])
+    val_reader = getattr(self, self._TTYPE_HANDLERS[val_ttype][0])
+    # list values are simple types
+    for idx in xrange(map_len):
+      if key_spec is None:
+        k_val = key_reader()
+      else:
+        k_val = self.readFieldByTType(key_ttype, key_spec)
+      if val_spec is None:
+        v_val = val_reader()
+      else:
+        v_val = self.readFieldByTType(val_ttype, val_spec)
+      # this raises a TypeError with unhashable keys types
+      # i.e. this fails: d=dict(); d[[0,1]] = 2
+      results[k_val] = v_val
+    self.readMapEnd()
+    return results
+
+  def readStruct(self, obj, thrift_spec):
+    self.readStructBegin()
+    while True:
+      (fname, ftype, fid) = self.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      try:
+        field = thrift_spec[fid]
+      except IndexError:
+        self.skip(ftype)
+      else:
+        if field is not None and ftype == field[1]:
+          fname = field[2]
+          fspec = field[3]
+          val = self.readFieldByTType(ftype, fspec)
+          setattr(obj, fname, val)
+        else:
+          self.skip(ftype)
+      self.readFieldEnd()
+    self.readStructEnd()
+
+  def writeContainerStruct(self, val, spec):
+    val.write(self)
+
+  def writeContainerList(self, val, spec):
+    self.writeListBegin(spec[0], len(val))
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
+    e_writer = getattr(self, w_handler)
+    if not is_container:
+      for elem in val:
+        e_writer(elem)
+    else:
+      for elem in val:
+        e_writer(elem, spec[1])
+    self.writeListEnd()
+
+  def writeContainerSet(self, val, spec):
+    self.writeSetBegin(spec[0], len(val))
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
+    e_writer = getattr(self, w_handler)
+    if not is_container:
+      for elem in val:
+        e_writer(elem)
+    else:
+      for elem in val:
+        e_writer(elem, spec[1])
+    self.writeSetEnd()
+
+  def writeContainerMap(self, val, spec):
+    k_type = spec[0]
+    v_type = spec[2]
+    ignore, ktype_name, k_is_container = self._TTYPE_HANDLERS[k_type]
+    ignore, vtype_name, v_is_container = self._TTYPE_HANDLERS[v_type]
+    k_writer = getattr(self, ktype_name)
+    v_writer = getattr(self, vtype_name)
+    self.writeMapBegin(k_type, v_type, len(val))
+    for m_key, m_val in val.iteritems():
+      if not k_is_container:
+        k_writer(m_key)
+      else:
+        k_writer(m_key, spec[1])
+      if not v_is_container:
+        v_writer(m_val)
+      else:
+        v_writer(m_val, spec[3])
+    self.writeMapEnd()
+
+  def writeStruct(self, obj, thrift_spec):
+    self.writeStructBegin(obj.__class__.__name__)
+    for field in thrift_spec:
+      if field is None:
+        continue
+      fname = field[2]
+      val = getattr(obj, fname)
+      if val is None:
+        # skip writing out unset fields
+        continue
+      fid = field[0]
+      ftype = field[1]
+      fspec = field[3]
+      # get the writer method for this value
+      self.writeFieldBegin(fname, ftype, fid)
+      self.writeFieldByTType(ftype, val, fspec)
+      self.writeFieldEnd()
+    self.writeFieldStop()
+    self.writeStructEnd()
+
+  def writeFieldByTType(self, ttype, val, spec):
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[ttype]
+    writer = getattr(self, w_handler)
+    if is_container:
+      writer(val, spec)
+    else:
+      writer(val)
+
+
+class TProtocolFactory:
+  def getProtocol(self, trans):
+    pass

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py
new file mode 100644
index 0000000..7eefb45
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__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__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol', 'TJSONProtocol', 'TProtocol']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
new file mode 100644
index 0000000..2ce5660
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
@@ -0,0 +1,1219 @@
+/*
+ * 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.
+ */
+
+#include <Python.h>
+#include "cStringIO.h"
+#include <stdint.h>
+#ifndef _WIN32
+# include <stdbool.h>
+# include <netinet/in.h>
+#else
+# include <WinSock2.h>
+# pragma comment (lib, "ws2_32.lib")
+# define BIG_ENDIAN (4321)
+# define LITTLE_ENDIAN (1234)
+# define BYTE_ORDER LITTLE_ENDIAN
+# if defined(_MSC_VER) && _MSC_VER < 1600
+   typedef int _Bool;
+#  define bool _Bool
+#  define false 0 
+#  define true 1
+# endif
+# define inline __inline
+#endif
+
+/* Fix endianness issues on Solaris */
+#if defined (__SVR4) && defined (__sun)
+ #if defined(__i386) && !defined(__i386__)
+  #define __i386__
+ #endif
+
+ #ifndef BIG_ENDIAN
+  #define BIG_ENDIAN (4321)
+ #endif
+ #ifndef LITTLE_ENDIAN
+  #define LITTLE_ENDIAN (1234)
+ #endif
+
+ /* I386 is LE, even on Solaris */
+ #if !defined(BYTE_ORDER) && defined(__i386__)
+  #define BYTE_ORDER LITTLE_ENDIAN
+ #endif
+#endif
+
+// TODO(dreiss): defval appears to be unused.  Look into removing it.
+// TODO(dreiss): Make parse_spec_args recursive, and cache the output
+//               permanently in the object.  (Malloc and orphan.)
+// TODO(dreiss): Why do we need cStringIO for reading, why not just char*?
+//               Can cStringIO let us work with a BufferedTransport?
+// TODO(dreiss): Don't ignore the rv from cwrite (maybe).
+
+/* ====== BEGIN UTILITIES ====== */
+
+#define INIT_OUTBUF_SIZE 128
+
+// Stolen out of TProtocol.h.
+// It would be a huge pain to have both get this from one place.
+typedef enum TType {
+  T_STOP       = 0,
+  T_VOID       = 1,
+  T_BOOL       = 2,
+  T_BYTE       = 3,
+  T_I08        = 3,
+  T_I16        = 6,
+  T_I32        = 8,
+  T_U64        = 9,
+  T_I64        = 10,
+  T_DOUBLE     = 4,
+  T_STRING     = 11,
+  T_UTF7       = 11,
+  T_STRUCT     = 12,
+  T_MAP        = 13,
+  T_SET        = 14,
+  T_LIST       = 15,
+  T_UTF8       = 16,
+  T_UTF16      = 17
+} TType;
+
+#ifndef __BYTE_ORDER
+# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
+#  define __BYTE_ORDER BYTE_ORDER
+#  define __LITTLE_ENDIAN LITTLE_ENDIAN
+#  define __BIG_ENDIAN BIG_ENDIAN
+# else
+#  error "Cannot determine endianness"
+# endif
+#endif
+
+// Same comment as the enum.  Sorry.
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ntohll(n) (n)
+# define htonll(n) (n)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# if defined(__GNUC__) && defined(__GLIBC__)
+#  include <byteswap.h>
+#  define ntohll(n) bswap_64(n)
+#  define htonll(n) bswap_64(n)
+# else /* GNUC & GLIBC */
+#  define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) )
+#  define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) )
+# endif /* GNUC & GLIBC */
+#else /* __BYTE_ORDER */
+# error "Can't define htonll or ntohll!"
+#endif
+
+// Doing a benchmark shows that interning actually makes a difference, amazingly.
+#define INTERN_STRING(value) _intern_ ## value
+
+#define INT_CONV_ERROR_OCCURRED(v) ( ((v) == -1) && PyErr_Occurred() )
+#define CHECK_RANGE(v, min, max) ( ((v) <= (max)) && ((v) >= (min)) )
+
+// Py_ssize_t was not defined before Python 2.5
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#endif
+
+/**
+ * A cache of the spec_args for a set or list,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  TType element_type;
+  PyObject* typeargs;
+} SetListTypeArgs;
+
+/**
+ * A cache of the spec_args for a map,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  TType ktag;
+  TType vtag;
+  PyObject* ktypeargs;
+  PyObject* vtypeargs;
+} MapTypeArgs;
+
+/**
+ * A cache of the spec_args for a struct,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  PyObject* klass;
+  PyObject* spec;
+} StructTypeArgs;
+
+/**
+ * A cache of the item spec from a struct specification,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  int tag;
+  TType type;
+  PyObject* attrname;
+  PyObject* typeargs;
+  PyObject* defval;
+} StructItemSpec;
+
+/**
+ * A cache of the two key attributes of a CReadableTransport,
+ * so we don't have to keep calling PyObject_GetAttr.
+ */
+typedef struct {
+  PyObject* stringiobuf;
+  PyObject* refill_callable;
+} DecodeBuffer;
+
+/** Pointer to interned string to speed up attribute lookup. */
+static PyObject* INTERN_STRING(cstringio_buf);
+/** Pointer to interned string to speed up attribute lookup. */
+static PyObject* INTERN_STRING(cstringio_refill);
+
+static inline bool
+check_ssize_t_32(Py_ssize_t len) {
+  // error from getting the int
+  if (INT_CONV_ERROR_OCCURRED(len)) {
+    return false;
+  }
+  if (!CHECK_RANGE(len, 0, INT32_MAX)) {
+    PyErr_SetString(PyExc_OverflowError, "string size out of range");
+    return false;
+  }
+  return true;
+}
+
+static inline bool
+parse_pyint(PyObject* o, int32_t* ret, int32_t min, int32_t max) {
+  long val = PyInt_AsLong(o);
+
+  if (INT_CONV_ERROR_OCCURRED(val)) {
+    return false;
+  }
+  if (!CHECK_RANGE(val, min, max)) {
+    PyErr_SetString(PyExc_OverflowError, "int out of range");
+    return false;
+  }
+
+  *ret = (int32_t) val;
+  return true;
+}
+
+
+/* --- FUNCTIONS TO PARSE STRUCT SPECIFICATOINS --- */
+
+static bool
+parse_set_list_args(SetListTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 2) {
+    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for list/set type args");
+    return false;
+  }
+
+  dest->element_type = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->element_type)) {
+    return false;
+  }
+
+  dest->typeargs = PyTuple_GET_ITEM(typeargs, 1);
+
+  return true;
+}
+
+static bool
+parse_map_args(MapTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 4) {
+    PyErr_SetString(PyExc_TypeError, "expecting 4 arguments for typeargs to map");
+    return false;
+  }
+
+  dest->ktag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->ktag)) {
+    return false;
+  }
+
+  dest->vtag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 2));
+  if (INT_CONV_ERROR_OCCURRED(dest->vtag)) {
+    return false;
+  }
+
+  dest->ktypeargs = PyTuple_GET_ITEM(typeargs, 1);
+  dest->vtypeargs = PyTuple_GET_ITEM(typeargs, 3);
+
+  return true;
+}
+
+static bool
+parse_struct_args(StructTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 2) {
+    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for struct args");
+    return false;
+  }
+
+  dest->klass = PyTuple_GET_ITEM(typeargs, 0);
+  dest->spec = PyTuple_GET_ITEM(typeargs, 1);
+
+  return true;
+}
+
+static int
+parse_struct_item_spec(StructItemSpec* dest, PyObject* spec_tuple) {
+
+  // i'd like to use ParseArgs here, but it seems to be a bottleneck.
+  if (PyTuple_Size(spec_tuple) != 5) {
+    PyErr_SetString(PyExc_TypeError, "expecting 5 arguments for spec tuple");
+    return false;
+  }
+
+  dest->tag = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->tag)) {
+    return false;
+  }
+
+  dest->type = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 1));
+  if (INT_CONV_ERROR_OCCURRED(dest->type)) {
+    return false;
+  }
+
+  dest->attrname = PyTuple_GET_ITEM(spec_tuple, 2);
+  dest->typeargs = PyTuple_GET_ITEM(spec_tuple, 3);
+  dest->defval = PyTuple_GET_ITEM(spec_tuple, 4);
+  return true;
+}
+
+/* ====== END UTILITIES ====== */
+
+
+/* ====== BEGIN WRITING FUNCTIONS ====== */
+
+/* --- LOW-LEVEL WRITING FUNCTIONS --- */
+
+static void writeByte(PyObject* outbuf, int8_t val) {
+  int8_t net = val;
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int8_t));
+}
+
+static void writeI16(PyObject* outbuf, int16_t val) {
+  int16_t net = (int16_t)htons(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int16_t));
+}
+
+static void writeI32(PyObject* outbuf, int32_t val) {
+  int32_t net = (int32_t)htonl(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int32_t));
+}
+
+static void writeI64(PyObject* outbuf, int64_t val) {
+  int64_t net = (int64_t)htonll(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int64_t));
+}
+
+static void writeDouble(PyObject* outbuf, double dub) {
+  // Unfortunately, bitwise_cast doesn't work in C.  Bad C!
+  union {
+    double f;
+    int64_t t;
+  } transfer;
+  transfer.f = dub;
+  writeI64(outbuf, transfer.t);
+}
+
+
+/* --- MAIN RECURSIVE OUTPUT FUCNTION -- */
+
+static int
+output_val(PyObject* output, PyObject* value, TType type, PyObject* typeargs) {
+  /*
+   * Refcounting Strategy:
+   *
+   * We assume that elements of the thrift_spec tuple are not going to be
+   * mutated, so we don't ref count those at all. Other than that, we try to
+   * keep a reference to all the user-created objects while we work with them.
+   * output_val assumes that a reference is already held. The *caller* is
+   * responsible for handling references
+   */
+
+  switch (type) {
+
+  case T_BOOL: {
+    int v = PyObject_IsTrue(value);
+    if (v == -1) {
+      return false;
+    }
+
+    writeByte(output, (int8_t) v);
+    break;
+  }
+  case T_I08: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT8_MIN, INT8_MAX)) {
+      return false;
+    }
+
+    writeByte(output, (int8_t) val);
+    break;
+  }
+  case T_I16: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT16_MIN, INT16_MAX)) {
+      return false;
+    }
+
+    writeI16(output, (int16_t) val);
+    break;
+  }
+  case T_I32: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT32_MIN, INT32_MAX)) {
+      return false;
+    }
+
+    writeI32(output, val);
+    break;
+  }
+  case T_I64: {
+    int64_t nval = PyLong_AsLongLong(value);
+
+    if (INT_CONV_ERROR_OCCURRED(nval)) {
+      return false;
+    }
+
+    if (!CHECK_RANGE(nval, INT64_MIN, INT64_MAX)) {
+      PyErr_SetString(PyExc_OverflowError, "int out of range");
+      return false;
+    }
+
+    writeI64(output, nval);
+    break;
+  }
+
+  case T_DOUBLE: {
+    double nval = PyFloat_AsDouble(value);
+    if (nval == -1.0 && PyErr_Occurred()) {
+      return false;
+    }
+
+    writeDouble(output, nval);
+    break;
+  }
+
+  case T_STRING: {
+    Py_ssize_t len = PyString_Size(value);
+
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    writeI32(output, (int32_t) len);
+    PycStringIO->cwrite(output, PyString_AsString(value), (int32_t) len);
+    break;
+  }
+
+  case T_LIST:
+  case T_SET: {
+    Py_ssize_t len;
+    SetListTypeArgs parsedargs;
+    PyObject *item;
+    PyObject *iterator;
+
+    if (!parse_set_list_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    len = PyObject_Length(value);
+
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    writeByte(output, parsedargs.element_type);
+    writeI32(output, (int32_t) len);
+
+    iterator =  PyObject_GetIter(value);
+    if (iterator == NULL) {
+      return false;
+    }
+
+    while ((item = PyIter_Next(iterator))) {
+      if (!output_val(output, item, parsedargs.element_type, parsedargs.typeargs)) {
+        Py_DECREF(item);
+        Py_DECREF(iterator);
+        return false;
+      }
+      Py_DECREF(item);
+    }
+
+    Py_DECREF(iterator);
+
+    if (PyErr_Occurred()) {
+      return false;
+    }
+
+    break;
+  }
+
+  case T_MAP: {
+    PyObject *k, *v;
+    Py_ssize_t pos = 0;
+    Py_ssize_t len;
+
+    MapTypeArgs parsedargs;
+
+    len = PyDict_Size(value);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    if (!parse_map_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    writeByte(output, parsedargs.ktag);
+    writeByte(output, parsedargs.vtag);
+    writeI32(output, len);
+
+    // TODO(bmaurer): should support any mapping, not just dicts
+    while (PyDict_Next(value, &pos, &k, &v)) {
+      // TODO(dreiss): Think hard about whether these INCREFs actually
+      //               turn any unsafe scenarios into safe scenarios.
+      Py_INCREF(k);
+      Py_INCREF(v);
+
+      if (!output_val(output, k, parsedargs.ktag, parsedargs.ktypeargs)
+          || !output_val(output, v, parsedargs.vtag, parsedargs.vtypeargs)) {
+        Py_DECREF(k);
+        Py_DECREF(v);
+        return false;
+      }
+      Py_DECREF(k);
+      Py_DECREF(v);
+    }
+    break;
+  }
+
+  // TODO(dreiss): Consider breaking this out as a function
+  //               the way we did for decode_struct.
+  case T_STRUCT: {
+    StructTypeArgs parsedargs;
+    Py_ssize_t nspec;
+    Py_ssize_t i;
+
+    if (!parse_struct_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    nspec = PyTuple_Size(parsedargs.spec);
+
+    if (nspec == -1) {
+      return false;
+    }
+
+    for (i = 0; i < nspec; i++) {
+      StructItemSpec parsedspec;
+      PyObject* spec_tuple;
+      PyObject* instval = NULL;
+
+      spec_tuple = PyTuple_GET_ITEM(parsedargs.spec, i);
+      if (spec_tuple == Py_None) {
+        continue;
+      }
+
+      if (!parse_struct_item_spec (&parsedspec, spec_tuple)) {
+        return false;
+      }
+
+      instval = PyObject_GetAttr(value, parsedspec.attrname);
+
+      if (!instval) {
+        return false;
+      }
+
+      if (instval == Py_None) {
+        Py_DECREF(instval);
+        continue;
+      }
+
+      writeByte(output, (int8_t) parsedspec.type);
+      writeI16(output, parsedspec.tag);
+
+      if (!output_val(output, instval, parsedspec.type, parsedspec.typeargs)) {
+        Py_DECREF(instval);
+        return false;
+      }
+
+      Py_DECREF(instval);
+    }
+
+    writeByte(output, (int8_t)T_STOP);
+    break;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return false;
+
+  }
+
+  return true;
+}
+
+
+/* --- TOP-LEVEL WRAPPER FOR OUTPUT -- */
+
+static PyObject *
+encode_binary(PyObject *self, PyObject *args) {
+  PyObject* enc_obj;
+  PyObject* type_args;
+  PyObject* buf;
+  PyObject* ret = NULL;
+
+  if (!PyArg_ParseTuple(args, "OO", &enc_obj, &type_args)) {
+    return NULL;
+  }
+
+  buf = PycStringIO->NewOutput(INIT_OUTBUF_SIZE);
+  if (output_val(buf, enc_obj, T_STRUCT, type_args)) {
+    ret = PycStringIO->cgetvalue(buf);
+  }
+
+  Py_DECREF(buf);
+  return ret;
+}
+
+/* ====== END WRITING FUNCTIONS ====== */
+
+
+/* ====== BEGIN READING FUNCTIONS ====== */
+
+/* --- LOW-LEVEL READING FUNCTIONS --- */
+
+static void
+free_decodebuf(DecodeBuffer* d) {
+  Py_XDECREF(d->stringiobuf);
+  Py_XDECREF(d->refill_callable);
+}
+
+static bool
+decode_buffer_from_obj(DecodeBuffer* dest, PyObject* obj) {
+  dest->stringiobuf = PyObject_GetAttr(obj, INTERN_STRING(cstringio_buf));
+  if (!dest->stringiobuf) {
+    return false;
+  }
+
+  if (!PycStringIO_InputCheck(dest->stringiobuf)) {
+    free_decodebuf(dest);
+    PyErr_SetString(PyExc_TypeError, "expecting stringio input");
+    return false;
+  }
+
+  dest->refill_callable = PyObject_GetAttr(obj, INTERN_STRING(cstringio_refill));
+
+  if(!dest->refill_callable) {
+    free_decodebuf(dest);
+    return false;
+  }
+
+  if (!PyCallable_Check(dest->refill_callable)) {
+    free_decodebuf(dest);
+    PyErr_SetString(PyExc_TypeError, "expecting callable");
+    return false;
+  }
+
+  return true;
+}
+
+static bool readBytes(DecodeBuffer* input, char** output, int len) {
+  int read;
+
+  // TODO(dreiss): Don't fear the malloc.  Think about taking a copy of
+  //               the partial read instead of forcing the transport
+  //               to prepend it to its buffer.
+
+  read = PycStringIO->cread(input->stringiobuf, output, len);
+
+  if (read == len) {
+    return true;
+  } else if (read == -1) {
+    return false;
+  } else {
+    PyObject* newiobuf;
+
+    // using building functions as this is a rare codepath
+    newiobuf = PyObject_CallFunction(
+        input->refill_callable, "s#i", *output, read, len, NULL);
+    if (newiobuf == NULL) {
+      return false;
+    }
+
+    // must do this *AFTER* the call so that we don't deref the io buffer
+    Py_CLEAR(input->stringiobuf);
+    input->stringiobuf = newiobuf;
+
+    read = PycStringIO->cread(input->stringiobuf, output, len);
+
+    if (read == len) {
+      return true;
+    } else if (read == -1) {
+      return false;
+    } else {
+      // TODO(dreiss): This could be a valid code path for big binary blobs.
+      PyErr_SetString(PyExc_TypeError,
+          "refill claimed to have refilled the buffer, but didn't!!");
+      return false;
+    }
+  }
+}
+
+static int8_t readByte(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int8_t))) {
+    return -1;
+  }
+
+  return *(int8_t*) buf;
+}
+
+static int16_t readI16(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int16_t))) {
+    return -1;
+  }
+
+  return (int16_t) ntohs(*(int16_t*) buf);
+}
+
+static int32_t readI32(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int32_t))) {
+    return -1;
+  }
+  return (int32_t) ntohl(*(int32_t*) buf);
+}
+
+
+static int64_t readI64(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int64_t))) {
+    return -1;
+  }
+
+  return (int64_t) ntohll(*(int64_t*) buf);
+}
+
+static double readDouble(DecodeBuffer* input) {
+  union {
+    int64_t f;
+    double t;
+  } transfer;
+
+  transfer.f = readI64(input);
+  if (transfer.f == -1) {
+    return -1;
+  }
+  return transfer.t;
+}
+
+static bool
+checkTypeByte(DecodeBuffer* input, TType expected) {
+  TType got = readByte(input);
+  if (INT_CONV_ERROR_OCCURRED(got)) {
+    return false;
+  }
+
+  if (expected != got) {
+    PyErr_SetString(PyExc_TypeError, "got wrong ttype while reading field");
+    return false;
+  }
+  return true;
+}
+
+static bool
+skip(DecodeBuffer* input, TType type) {
+#define SKIPBYTES(n) \
+  do { \
+    if (!readBytes(input, &dummy_buf, (n))) { \
+      return false; \
+    } \
+  } while(0)
+
+  char* dummy_buf;
+
+  switch (type) {
+
+  case T_BOOL:
+  case T_I08: SKIPBYTES(1); break;
+  case T_I16: SKIPBYTES(2); break;
+  case T_I32: SKIPBYTES(4); break;
+  case T_I64:
+  case T_DOUBLE: SKIPBYTES(8); break;
+
+  case T_STRING: {
+    // TODO(dreiss): Find out if these check_ssize_t32s are really necessary.
+    int len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+    SKIPBYTES(len);
+    break;
+  }
+
+  case T_LIST:
+  case T_SET: {
+    TType etype;
+    int len, i;
+
+    etype = readByte(input);
+    if (etype == -1) {
+      return false;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    for (i = 0; i < len; i++) {
+      if (!skip(input, etype)) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_MAP: {
+    TType ktype, vtype;
+    int len, i;
+
+    ktype = readByte(input);
+    if (ktype == -1) {
+      return false;
+    }
+
+    vtype = readByte(input);
+    if (vtype == -1) {
+      return false;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    for (i = 0; i < len; i++) {
+      if (!(skip(input, ktype) && skip(input, vtype))) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_STRUCT: {
+    while (true) {
+      TType type;
+
+      type = readByte(input);
+      if (type == -1) {
+        return false;
+      }
+
+      if (type == T_STOP)
+        break;
+
+      SKIPBYTES(2); // tag
+      if (!skip(input, type)) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return false;
+
+  }
+
+  return true;
+
+#undef SKIPBYTES
+}
+
+
+/* --- HELPER FUNCTION FOR DECODE_VAL --- */
+
+static PyObject*
+decode_val(DecodeBuffer* input, TType type, PyObject* typeargs);
+
+static bool
+decode_struct(DecodeBuffer* input, PyObject* output, PyObject* spec_seq) {
+  int spec_seq_len = PyTuple_Size(spec_seq);
+  if (spec_seq_len == -1) {
+    return false;
+  }
+
+  while (true) {
+    TType type;
+    int16_t tag;
+    PyObject* item_spec;
+    PyObject* fieldval = NULL;
+    StructItemSpec parsedspec;
+
+    type = readByte(input);
+    if (type == -1) {
+      return false;
+    }
+    if (type == T_STOP) {
+      break;
+    }
+    tag = readI16(input);
+    if (INT_CONV_ERROR_OCCURRED(tag)) {
+      return false;
+    }
+    if (tag >= 0 && tag < spec_seq_len) {
+      item_spec = PyTuple_GET_ITEM(spec_seq, tag);
+    } else {
+      item_spec = Py_None;
+    }
+
+    if (item_spec == Py_None) {
+      if (!skip(input, type)) {
+        return false;
+      } else {
+        continue;
+      }
+    }
+
+    if (!parse_struct_item_spec(&parsedspec, item_spec)) {
+      return false;
+    }
+    if (parsedspec.type != type) {
+      if (!skip(input, type)) {
+        PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading and can't be skipped");
+        return false;
+      } else {
+        continue;
+      }
+    }
+
+    fieldval = decode_val(input, parsedspec.type, parsedspec.typeargs);
+    if (fieldval == NULL) {
+      return false;
+    }
+
+    if (PyObject_SetAttr(output, parsedspec.attrname, fieldval) == -1) {
+      Py_DECREF(fieldval);
+      return false;
+    }
+    Py_DECREF(fieldval);
+  }
+  return true;
+}
+
+
+/* --- MAIN RECURSIVE INPUT FUCNTION --- */
+
+// Returns a new reference.
+static PyObject*
+decode_val(DecodeBuffer* input, TType type, PyObject* typeargs) {
+  switch (type) {
+
+  case T_BOOL: {
+    int8_t v = readByte(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+
+    switch (v) {
+    case 0: Py_RETURN_FALSE;
+    case 1: Py_RETURN_TRUE;
+    // Don't laugh.  This is a potentially serious issue.
+    default: PyErr_SetString(PyExc_TypeError, "boolean out of range"); return NULL;
+    }
+    break;
+  }
+  case T_I08: {
+    int8_t v = readByte(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+
+    return PyInt_FromLong(v);
+  }
+  case T_I16: {
+    int16_t v = readI16(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    return PyInt_FromLong(v);
+  }
+  case T_I32: {
+    int32_t v = readI32(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    return PyInt_FromLong(v);
+  }
+
+  case T_I64: {
+    int64_t v = readI64(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    // TODO(dreiss): Find out if we can take this fastpath always when
+    //               sizeof(long) == sizeof(long long).
+    if (CHECK_RANGE(v, LONG_MIN, LONG_MAX)) {
+      return PyInt_FromLong((long) v);
+    }
+
+    return PyLong_FromLongLong(v);
+  }
+
+  case T_DOUBLE: {
+    double v = readDouble(input);
+    if (v == -1.0 && PyErr_Occurred()) {
+      return false;
+    }
+    return PyFloat_FromDouble(v);
+  }
+
+  case T_STRING: {
+    Py_ssize_t len = readI32(input);
+    char* buf;
+    if (!readBytes(input, &buf, len)) {
+      return NULL;
+    }
+
+    return PyString_FromStringAndSize(buf, len);
+  }
+
+  case T_LIST:
+  case T_SET: {
+    SetListTypeArgs parsedargs;
+    int32_t len;
+    PyObject* ret = NULL;
+    int i;
+
+    if (!parse_set_list_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    if (!checkTypeByte(input, parsedargs.element_type)) {
+      return NULL;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return NULL;
+    }
+
+    ret = PyList_New(len);
+    if (!ret) {
+      return NULL;
+    }
+
+    for (i = 0; i < len; i++) {
+      PyObject* item = decode_val(input, parsedargs.element_type, parsedargs.typeargs);
+      if (!item) {
+        Py_DECREF(ret);
+        return NULL;
+      }
+      PyList_SET_ITEM(ret, i, item);
+    }
+
+    // TODO(dreiss): Consider biting the bullet and making two separate cases
+    //               for list and set, avoiding this post facto conversion.
+    if (type == T_SET) {
+      PyObject* setret;
+#if (PY_VERSION_HEX < 0x02050000)
+      // hack needed for older versions
+      setret = PyObject_CallFunctionObjArgs((PyObject*)&PySet_Type, ret, NULL);
+#else
+      // official version
+      setret = PySet_New(ret);
+#endif
+      Py_DECREF(ret);
+      return setret;
+    }
+    return ret;
+  }
+
+  case T_MAP: {
+    int32_t len;
+    int i;
+    MapTypeArgs parsedargs;
+    PyObject* ret = NULL;
+
+    if (!parse_map_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    if (!checkTypeByte(input, parsedargs.ktag)) {
+      return NULL;
+    }
+    if (!checkTypeByte(input, parsedargs.vtag)) {
+      return NULL;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    ret = PyDict_New();
+    if (!ret) {
+      goto error;
+    }
+
+    for (i = 0; i < len; i++) {
+      PyObject* k = NULL;
+      PyObject* v = NULL;
+      k = decode_val(input, parsedargs.ktag, parsedargs.ktypeargs);
+      if (k == NULL) {
+        goto loop_error;
+      }
+      v = decode_val(input, parsedargs.vtag, parsedargs.vtypeargs);
+      if (v == NULL) {
+        goto loop_error;
+      }
+      if (PyDict_SetItem(ret, k, v) == -1) {
+        goto loop_error;
+      }
+
+      Py_DECREF(k);
+      Py_DECREF(v);
+      continue;
+
+      // Yuck!  Destructors, anyone?
+      loop_error:
+      Py_XDECREF(k);
+      Py_XDECREF(v);
+      goto error;
+    }
+
+    return ret;
+
+    error:
+    Py_XDECREF(ret);
+    return NULL;
+  }
+
+  case T_STRUCT: {
+    StructTypeArgs parsedargs;
+	PyObject* ret;
+    if (!parse_struct_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    ret = PyObject_CallObject(parsedargs.klass, NULL);
+    if (!ret) {
+      return NULL;
+    }
+
+    if (!decode_struct(input, ret, parsedargs.spec)) {
+      Py_DECREF(ret);
+      return NULL;
+    }
+
+    return ret;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return NULL;
+  }
+}
+
+
+/* --- TOP-LEVEL WRAPPER FOR INPUT -- */
+
+static PyObject*
+decode_binary(PyObject *self, PyObject *args) {
+  PyObject* output_obj = NULL;
+  PyObject* transport = NULL;
+  PyObject* typeargs = NULL;
+  StructTypeArgs parsedargs;
+  DecodeBuffer input = {0, 0};
+  
+  if (!PyArg_ParseTuple(args, "OOO", &output_obj, &transport, &typeargs)) {
+    return NULL;
+  }
+
+  if (!parse_struct_args(&parsedargs, typeargs)) {
+    return NULL;
+  }
+
+  if (!decode_buffer_from_obj(&input, transport)) {
+    return NULL;
+  }
+
+  if (!decode_struct(&input, output_obj, parsedargs.spec)) {
+    free_decodebuf(&input);
+    return NULL;
+  }
+
+  free_decodebuf(&input);
+
+  Py_RETURN_NONE;
+}
+
+/* ====== END READING FUNCTIONS ====== */
+
+
+/* -- PYTHON MODULE SETUP STUFF --- */
+
+static PyMethodDef ThriftFastBinaryMethods[] = {
+
+  {"encode_binary",  encode_binary, METH_VARARGS, ""},
+  {"decode_binary",  decode_binary, METH_VARARGS, ""},
+
+  {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+PyMODINIT_FUNC
+initfastbinary(void) {
+#define INIT_INTERN_STRING(value) \
+  do { \
+    INTERN_STRING(value) = PyString_InternFromString(#value); \
+    if(!INTERN_STRING(value)) return; \
+  } while(0)
+
+  INIT_INTERN_STRING(cstringio_buf);
+  INIT_INTERN_STRING(cstringio_refill);
+#undef INIT_INTERN_STRING
+
+  PycString_IMPORT;
+  if (PycStringIO == NULL) return;
+
+  (void) Py_InitModule("thrift.protocol.fastbinary", ThriftFastBinaryMethods);
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
new file mode 100644
index 0000000..be54bab
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
@@ -0,0 +1,87 @@
+#
+# 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 BaseHTTPServer
+
+from thrift.server import TServer
+from thrift.transport import TTransport
+
+
+class ResponseException(Exception):
+  """Allows handlers to override the HTTP response
+
+  Normally, THttpServer always sends a 200 response.  If a handler wants
+  to override this behavior (e.g., to simulate a misconfigured or
+  overloaded web server during testing), it can raise a ResponseException.
+  The function passed to the constructor will be called with the
+  RequestHandler as its only argument.
+  """
+  def __init__(self, handler):
+    self.handler = handler
+
+
+class THttpServer(TServer.TServer):
+  """A simple HTTP-based Thrift server
+
+  This class is not very performant, but it is useful (for example) for
+  acting as a mock version of an Apache-based PHP Thrift endpoint.
+  """
+  def __init__(self,
+               processor,
+               server_address,
+               inputProtocolFactory,
+               outputProtocolFactory=None,
+               server_class=BaseHTTPServer.HTTPServer):
+    """Set up protocol factories and HTTP server.
+
+    See BaseHTTPServer for server_address.
+    See TServer for protocol factories.
+    """
+    if outputProtocolFactory is None:
+      outputProtocolFactory = inputProtocolFactory
+
+    TServer.TServer.__init__(self, processor, None, None, None,
+        inputProtocolFactory, outputProtocolFactory)
+
+    thttpserver = self
+
+    class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
+      def do_POST(self):
+        # Don't care about the request path.
+        itrans = TTransport.TFileObjectTransport(self.rfile)
+        otrans = TTransport.TFileObjectTransport(self.wfile)
+        itrans = TTransport.TBufferedTransport(
+          itrans, int(self.headers['Content-Length']))
+        otrans = TTransport.TMemoryBuffer()
+        iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
+        oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
+        try:
+          thttpserver.processor.process(iprot, oprot)
+        except ResponseException, exn:
+          exn.handler(self)
+        else:
+          self.send_response(200)
+          self.send_header("content-type", "application/x-thrift")
+          self.end_headers()
+          self.wfile.write(otrans.getvalue())
+
+    self.httpd = server_class(server_address, RequestHander)
+
+  def serve(self):
+    self.httpd.serve_forever()

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
new file mode 100644
index 0000000..fa478d0
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
@@ -0,0 +1,346 @@
+#
+# 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.
+#
+"""Implementation of non-blocking server.
+
+The main idea of the server is to receive and send requests
+only from the main thread.
+
+The thread poool should be sized for concurrent tasks, not
+maximum connections
+"""
+import threading
+import socket
+import Queue
+import select
+import struct
+import logging
+
+from thrift.transport import TTransport
+from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
+
+__all__ = ['TNonblockingServer']
+
+
+class Worker(threading.Thread):
+    """Worker is a small helper to process incoming connection."""
+
+    def __init__(self, queue):
+        threading.Thread.__init__(self)
+        self.queue = queue
+
+    def run(self):
+        """Process queries from task queue, stop if processor is None."""
+        while True:
+            try:
+                processor, iprot, oprot, otrans, callback = self.queue.get()
+                if processor is None:
+                    break
+                processor.process(iprot, oprot)
+                callback(True, otrans.getvalue())
+            except Exception:
+                logging.exception("Exception while processing request")
+                callback(False, '')
+
+WAIT_LEN = 0
+WAIT_MESSAGE = 1
+WAIT_PROCESS = 2
+SEND_ANSWER = 3
+CLOSED = 4
+
+
+def locked(func):
+    """Decorator which locks self.lock."""
+    def nested(self, *args, **kwargs):
+        self.lock.acquire()
+        try:
+            return func(self, *args, **kwargs)
+        finally:
+            self.lock.release()
+    return nested
+
+
+def socket_exception(func):
+    """Decorator close object on socket.error."""
+    def read(self, *args, **kwargs):
+        try:
+            return func(self, *args, **kwargs)
+        except socket.error:
+            self.close()
+    return read
+
+
+class Connection:
+    """Basic class is represented connection.
+
+    It can be in state:
+        WAIT_LEN --- connection is reading request len.
+        WAIT_MESSAGE --- connection is reading request.
+        WAIT_PROCESS --- connection has just read whole request and
+                         waits for call ready routine.
+        SEND_ANSWER --- connection is sending answer string (including length
+                        of answer).
+        CLOSED --- socket was closed and connection should be deleted.
+    """
+    def __init__(self, new_socket, wake_up):
+        self.socket = new_socket
+        self.socket.setblocking(False)
+        self.status = WAIT_LEN
+        self.len = 0
+        self.message = ''
+        self.lock = threading.Lock()
+        self.wake_up = wake_up
+
+    def _read_len(self):
+        """Reads length of request.
+
+        It's a safer alternative to self.socket.recv(4)
+        """
+        read = self.socket.recv(4 - len(self.message))
+        if len(read) == 0:
+            # if we read 0 bytes and self.message is empty, then
+            # the client closed the connection
+            if len(self.message) != 0:
+                logging.error("can't read frame size from socket")
+            self.close()
+            return
+        self.message += read
+        if len(self.message) == 4:
+            self.len, = struct.unpack('!i', self.message)
+            if self.len < 0:
+                logging.error("negative frame size, it seems client "
+                              "doesn't use FramedTransport")
+                self.close()
+            elif self.len == 0:
+                logging.error("empty frame, it's really strange")
+                self.close()
+            else:
+                self.message = ''
+                self.status = WAIT_MESSAGE
+
+    @socket_exception
+    def read(self):
+        """Reads data from stream and switch state."""
+        assert self.status in (WAIT_LEN, WAIT_MESSAGE)
+        if self.status == WAIT_LEN:
+            self._read_len()
+            # go back to the main loop here for simplicity instead of
+            # falling through, even though there is a good chance that
+            # the message is already available
+        elif self.status == WAIT_MESSAGE:
+            read = self.socket.recv(self.len - len(self.message))
+            if len(read) == 0:
+                logging.error("can't read frame from socket (get %d of "
+                              "%d bytes)" % (len(self.message), self.len))
+                self.close()
+                return
+            self.message += read
+            if len(self.message) == self.len:
+                self.status = WAIT_PROCESS
+
+    @socket_exception
+    def write(self):
+        """Writes data from socket and switch state."""
+        assert self.status == SEND_ANSWER
+        sent = self.socket.send(self.message)
+        if sent == len(self.message):
+            self.status = WAIT_LEN
+            self.message = ''
+            self.len = 0
+        else:
+            self.message = self.message[sent:]
+
+    @locked
+    def ready(self, all_ok, message):
+        """Callback function for switching state and waking up main thread.
+
+        This function is the only function witch can be called asynchronous.
+
+        The ready can switch Connection to three states:
+            WAIT_LEN if request was oneway.
+            SEND_ANSWER if request was processed in normal way.
+            CLOSED if request throws unexpected exception.
+
+        The one wakes up main thread.
+        """
+        assert self.status == WAIT_PROCESS
+        if not all_ok:
+            self.close()
+            self.wake_up()
+            return
+        self.len = ''
+        if len(message) == 0:
+            # it was a oneway request, do not write answer
+            self.message = ''
+            self.status = WAIT_LEN
+        else:
+            self.message = struct.pack('!i', len(message)) + message
+            self.status = SEND_ANSWER
+        self.wake_up()
+
+    @locked
+    def is_writeable(self):
+        """Return True if connection should be added to write list of select"""
+        return self.status == SEND_ANSWER
+
+    # it's not necessary, but...
+    @locked
+    def is_readable(self):
+        """Return True if connection should be added to read list of select"""
+        return self.status in (WAIT_LEN, WAIT_MESSAGE)
+
+    @locked
+    def is_closed(self):
+        """Returns True if connection is closed."""
+        return self.status == CLOSED
+
+    def fileno(self):
+        """Returns the file descriptor of the associated socket."""
+        return self.socket.fileno()
+
+    def close(self):
+        """Closes connection"""
+        self.status = CLOSED
+        self.socket.close()
+
+
+class TNonblockingServer:
+    """Non-blocking server."""
+
+    def __init__(self,
+                 processor,
+                 lsocket,
+                 inputProtocolFactory=None,
+                 outputProtocolFactory=None,
+                 threads=10):
+        self.processor = processor
+        self.socket = lsocket
+        self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory()
+        self.out_protocol = outputProtocolFactory or self.in_protocol
+        self.threads = int(threads)
+        self.clients = {}
+        self.tasks = Queue.Queue()
+        self._read, self._write = socket.socketpair()
+        self.prepared = False
+        self._stop = False
+
+    def setNumThreads(self, num):
+        """Set the number of worker threads that should be created."""
+        # implement ThreadPool interface
+        assert not self.prepared, "Can't change number of threads after start"
+        self.threads = num
+
+    def prepare(self):
+        """Prepares server for serve requests."""
+        if self.prepared:
+            return
+        self.socket.listen()
+        for _ in xrange(self.threads):
+            thread = Worker(self.tasks)
+            thread.setDaemon(True)
+            thread.start()
+        self.prepared = True
+
+    def wake_up(self):
+        """Wake up main thread.
+
+        The server usualy waits in select call in we should terminate one.
+        The simplest way is using socketpair.
+
+        Select always wait to read from the first socket of socketpair.
+
+        In this case, we can just write anything to the second socket from
+        socketpair.
+        """
+        self._write.send('1')
+
+    def stop(self):
+        """Stop the server.
+
+        This method causes the serve() method to return.  stop() may be invoked
+        from within your handler, or from another thread.
+
+        After stop() is called, serve() will return but the server will still
+        be listening on the socket.  serve() may then be called again to resume
+        processing requests.  Alternatively, close() may be called after
+        serve() returns to close the server socket and shutdown all worker
+        threads.
+        """
+        self._stop = True
+        self.wake_up()
+
+    def _select(self):
+        """Does select on open connections."""
+        readable = [self.socket.handle.fileno(), self._read.fileno()]
+        writable = []
+        for i, connection in self.clients.items():
+            if connection.is_readable():
+                readable.append(connection.fileno())
+            if connection.is_writeable():
+                writable.append(connection.fileno())
+            if connection.is_closed():
+                del self.clients[i]
+        return select.select(readable, writable, readable)
+
+    def handle(self):
+        """Handle requests.
+
+        WARNING! You must call prepare() BEFORE calling handle()
+        """
+        assert self.prepared, "You have to call prepare before handle"
+        rset, wset, xset = self._select()
+        for readable in rset:
+            if readable == self._read.fileno():
+                # don't care i just need to clean readable flag
+                self._read.recv(1024)
+            elif readable == self.socket.handle.fileno():
+                client = self.socket.accept().handle
+                self.clients[client.fileno()] = Connection(client,
+                                                           self.wake_up)
+            else:
+                connection = self.clients[readable]
+                connection.read()
+                if connection.status == WAIT_PROCESS:
+                    itransport = TTransport.TMemoryBuffer(connection.message)
+                    otransport = TTransport.TMemoryBuffer()
+                    iprot = self.in_protocol.getProtocol(itransport)
+                    oprot = self.out_protocol.getProtocol(otransport)
+                    self.tasks.put([self.processor, iprot, oprot,
+                                    otransport, connection.ready])
+        for writeable in wset:
+            self.clients[writeable].write()
+        for oob in xset:
+            self.clients[oob].close()
+            del self.clients[oob]
+
+    def close(self):
+        """Closes the server."""
+        for _ in xrange(self.threads):
+            self.tasks.put([None, None, None, None, None])
+        self.socket.close()
+        self.prepared = False
+
+    def serve(self):
+        """Serve requests.
+
+        Serve requests forever, or until stop() is called.
+        """
+        self._stop = False
+        self.prepare()
+        while not self._stop:
+            self.handle()


[47/50] [abbrv] git commit: Convert all values to str before being passed to Popen

Posted by ni...@apache.org.
Convert all values to str before being passed to Popen


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/fdf0d19a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fdf0d19a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fdf0d19a

Branch: refs/heads/master
Commit: fdf0d19a6a128dbd39221844506e78e1c742a67c
Parents: 3360d54
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 22:36:49 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 22:36:49 2014 +0530

----------------------------------------------------------------------
 .../extensions/defaultextensionhandler.py       | 20 ++++++++++----------
 .../modules/util/extensionutils.py              |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/fdf0d19a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index f0b9987..2e79f3e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -149,12 +149,12 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         if extensionutils.is_relevant_member_event(member_activated_event.service_name,
                                                    member_activated_event.cluster_id, lb_cluster_id):
 
-            env_params = {"STRATOS_MEMBER_ACTIVATED_MEMBER_IP": member_activated_event.member_ip,
-                          "STRATOS_MEMBER_ACTIVATED_MEMBER_ID": member_activated_event.member_id,
-                          "STRATOS_MEMBER_ACTIVATED_CLUSTER_ID": member_activated_event.cluster_id,
-                          "STRATOS_MEMBER_ACTIVATED_LB_CLUSTER_ID": lb_cluster_id,
-                          "STRATOS_MEMBER_ACTIVATED_NETWORK_PARTITION_ID": member_activated_event.network_partition_id,
-                          "STRATOS_MEMBER_ACTIVATED_SERVICE_NAME": member_activated_event.service_name}
+            env_params = {"STRATOS_MEMBER_ACTIVATED_MEMBER_IP": str(member_activated_event.member_ip),
+                          "STRATOS_MEMBER_ACTIVATED_MEMBER_ID": str(member_activated_event.member_id),
+                          "STRATOS_MEMBER_ACTIVATED_CLUSTER_ID": str(member_activated_event.cluster_id),
+                          "STRATOS_MEMBER_ACTIVATED_LB_CLUSTER_ID": str(lb_cluster_id),
+                          "STRATOS_MEMBER_ACTIVATED_NETWORK_PARTITION_ID": str(member_activated_event.network_partition_id),
+                          "STRATOS_MEMBER_ACTIVATED_SERVICE_NAME": str(member_activated_event.service_name)}
 
             ports = member_activated_event.port_map.values()
             ports_str = ""
@@ -167,8 +167,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
-                env_params["STRATOS_MEMBER_ACTIVATED_LB_IP"] = member_ips[0]
-                env_params["STRATOS_MEMBER_ACTIVATED_LB_PUBLIC_IP"] = member_ips[1]
+                env_params["STRATOS_MEMBER_ACTIVATED_LB_IP"] = str(member_ips[0])
+                env_params["STRATOS_MEMBER_ACTIVATED_LB_PUBLIC_IP"] = str(member_ips[1])
 
             env_params["STRATOS_TOPOLOGY_JSON"] = json.dumps(topology.json_str)
 
@@ -201,8 +201,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                     env_params["STRATOS_UPDATE_WK_IP"] = "true"
 
             self.log.debug("Setting env var STRATOS_CLUSTERING to %r" % clustered)
-            env_params["STRATOS_CLUSTERING"] = clustered
-            env_params["STRATOS_WK_MEMBER_COUNT"] = self.cartridge_agent_config.min_count
+            env_params["STRATOS_CLUSTERING"] = str(clustered)
+            env_params["STRATOS_WK_MEMBER_COUNT"] = str(self.cartridge_agent_config.min_count)
 
             extensionutils.execute_member_activated_extension(env_params)
         else:

http://git-wip-us.apache.org/repos/asf/stratos/blob/fdf0d19a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index e686fce..6c58852 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -449,7 +449,7 @@ def add_properties(properties, params, prefix):
         return
 
     for key in properties:
-        params["STRATOS_" + prefix + "_" + key] = properties[key]
+        params["STRATOS_" + prefix + "_" + key] = str(properties[key])
         log.debug("Property added: [key] STRATOS_ " + prefix + "_" + key + "[value] " + properties[key])
 
 


[42/50] [abbrv] git commit: Implemented for the Python agent, the fix done on 5e41897

Posted by ni...@apache.org.
Implemented for the Python agent, the fix done on 5e41897


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/535ea0cd
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/535ea0cd
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/535ea0cd

Branch: refs/heads/master
Commit: 535ea0cd9baf6111230ce0f99a92134e23cf83ab
Parents: 4139b16
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 19:29:11 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 19:29:11 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  5 ++++
 .../config/cartridgeagentconfiguration.py       |  3 +++
 .../extensions/abstractextensionhandler.py      |  3 +++
 .../extensions/defaultextensionhandler.py       | 27 +++++++++++++++++++-
 4 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/535ea0cd/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index c2976a8..5a2337c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -79,6 +79,11 @@ class CartridgeAgent(threading.Thread):
         #Start tenant event receiver thread
         self.register_tenant_event_listeners()
 
+        #wait for intance spawned event
+        while not self.cartridge_agent_config.initialized:
+            self.log.debug("Waiting for Cartridge Agent to be initialized...")
+            time.sleep(1)
+
         #Execute instance started shell script
         CartridgeAgent.extension_handler.on_instance_started_event()
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/535ea0cd/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 6a0525e..15871ba 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -97,6 +97,9 @@ class CartridgeAgentConfiguration:
             self.__read_conf_file()
             self.__read_parameter_file()
 
+            self.initialized = False
+            """ :type : bool """
+
             try:
                 self.service_group = self.payload_params[cartridgeagentconstants.SERVICE_GROUP] \
                     if cartridgeagentconstants.SERVICE_GROUP in self.payload_params \

http://git-wip-us.apache.org/repos/asf/stratos/blob/535ea0cd/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
index 3202341..1f2df10 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
@@ -41,6 +41,9 @@ class AbstractExtensionHandler:
     def on_complete_topology_event(self, complete_topology_event):
         raise NotImplementedError
 
+    def on_instance_spawned_event(self, instance_spawned_event):
+        raise NotImplementedError
+
     def on_complete_tenant_event(self, complete_tenant_event):
         raise NotImplementedError
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/535ea0cd/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 4c36e55..48ef81f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -213,7 +213,15 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         cluster_id_in_payload = self.cartridge_agent_config.cluster_id
         member_id_in_payload = self.cartridge_agent_config.member_id
 
-        extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
+        consistant = extensionutils.check_topology_consistency(
+            service_name_in_payload,
+            cluster_id_in_payload,
+            member_id_in_payload)
+
+        if not consistant:
+            return
+        else:
+            self.cartridge_agent_config.initialized = True
 
         topology = complete_topology_event.get_topology()
         service = topology.get_service(service_name_in_payload)
@@ -223,6 +231,23 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
         extensionutils.execute_complete_topology_extension(env_params)
 
+    def on_instance_spawned_event(self, instance_spawned_event):
+        self.log.debug("Instance Spawned event received")
+
+        service_name_in_payload = self.cartridge_agent_config.service_name
+        cluster_id_in_payload = self.cartridge_agent_config.cluster_id
+        member_id_in_payload = self.cartridge_agent_config.member_id
+
+        consistant = extensionutils.check_topology_consistency(
+            service_name_in_payload,
+            cluster_id_in_payload,
+            member_id_in_payload)
+
+        if not consistant:
+            return
+        else:
+            self.cartridge_agent_config.initialized = True
+
     def on_complete_tenant_event(self, complete_tenant_event):
         self.log.debug("Complete tenant event received")
 


[20/50] [abbrv] git commit: Refactored log initializers to Logfactory Added Gittle to be used to clone with authentication Added additional gittle repo object to gitrepository object

Posted by ni...@apache.org.
Refactored log initializers to Logfactory
Added Gittle to be used to clone with authentication
Added additional gittle repo object to gitrepository object


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b1c5d361
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b1c5d361
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b1c5d361

Branch: refs/heads/master
Commit: b1c5d36115dc36938d2b55f8ad33d0c7e498e9cf
Parents: fa48ec1
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 2 14:34:02 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:52 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |   3 +-
 .../modules/artifactmgt/git/agentgithandler.py  | 197 ++++++++++++++++---
 .../modules/artifactmgt/git/gitrepository.py    |   7 +-
 .../config/cartridgeagentconfiguration.py       |   4 +-
 .../extensions/defaultextensionhandler.py       |   8 +-
 .../publisher/cartridgeagentpublisher.py        |   3 +-
 .../modules/subscriber/eventsubscriber.py       |   4 +-
 .../modules/util/cartridgeagentutils.py         |  18 +-
 .../modules/util/extensionutils.py              |   4 +-
 9 files changed, 200 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index 5ae7664..bf47397 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -17,8 +17,7 @@ from modules.datapublisher.logpublisher import *
 
 
 class CartridgeAgent(threading.Thread):
-    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-    log = logging.getLogger(__name__)
+    log = LogFactory().get_log(__name__)
 
     def __init__(self):
         threading.Thread.__init__(self)

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index e433e0b..e6fd98e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -1,7 +1,9 @@
 import logging
 from threading import current_thread, Thread
-
+import os
 from git import *
+from gittle import Gittle, GittleAuth  # GitPython and Gittle are both used at the time being for pros and cons of both
+import urllib2
 
 from gitrepository import GitRepository
 from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
@@ -9,23 +11,42 @@ from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstant
 from ... util.asyncscheduledtask import AsyncScheduledTask
 from ... artifactmgt.repositoryinformation import RepositoryInformation
 from ... extensions.abstractextensionhandler import AbstractExtensionHandler
+from ... util.log import LogFactory
+
 
 
 class AgentGitHandler:
-    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-    log = logging.getLogger(__name__)
+    """
+    Handles all the git artifact management tasks related to a cartridge
+    """
+
+    log = LogFactory().get_log(__name__)
 
     SUPER_TENANT_ID = -1234
     SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
     TENANT_REPO_PATH = "/repository/tenants/"
 
-    extension_handler = AbstractExtensionHandler()
+    extension_handler = AbstractExtensionHandler()  # TODO: remove dependancy
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)
 
     @staticmethod
     def checkout(repo_info):
+        """
+        Checks out the code from the remote repository.
+        If local repository path is empty, a clone operation is done.
+        If there is a cloned repository already on the local repository path, a pull operation
+        will be performed.
+        If there are artifacts not in the repository already on the local repository path,
+        they will be added to a git repository, the remote url added as origin, and then
+        a pull operation will be performed.
+
+        :param RepositoryInformation repo_info: The repository information object
+        :return: A tuple containing whether it was an initial clone or not, and the repository
+        context object
+        :rtype: tuple(bool, GitRepository)
+        """
         repo_context = AgentGitHandler.get_repo_context(repo_info.tenant_id)
         if repo_context is not None:
             #has been previously cloned, this is not the subscription run
@@ -48,7 +69,7 @@ class AgentGitHandler:
             subscribe_run = True
             repo_context = AgentGitHandler.clone(repo_context)
 
-        return {"subscribe_run": subscribe_run, "repo_context": repo_context}
+        return subscribe_run, repo_context
 
     @staticmethod
     def sync_initial_local_artifacts(repo_context):
@@ -75,8 +96,7 @@ class AgentGitHandler:
     @staticmethod
     def init(path):
         try:
-            repo = Repo.init(path, mkdir=True)
-            repo.git.init()
+            repo = Gittle.init(path)
         except:
             AgentGitHandler.log.exception("Initializing local repo at %r failed" % path)
             raise Exception("Initializing local repo at %r failed" % path)
@@ -90,7 +110,6 @@ class AgentGitHandler:
             try:
                 ref._get_object()
             except ValueError:
-                #corrupt sha in the reference
                 return False
 
         return True
@@ -157,7 +176,6 @@ class AgentGitHandler:
 
     @staticmethod
     def clone(repo_info):
-        #TODO: credential management
         repo_context = None
         try:
             repo_context = AgentGitHandler.create_git_repo_context(repo_info)
@@ -165,23 +183,76 @@ class AgentGitHandler:
             if not os.path.isdir(repo_context.local_repo_path):
                 cartridgeagentutils.create_dir(repo_context.local_repo_path)
 
-            repo = Repo.clone_from(repo_context.repo_url, repo_context.local_repo_path)
+            auth = AgentGitHandler.create_auth_configuration(repo_context)
+
+            if auth is not None:
+                # authentication is required, use Gittle
+                gittle_repo = Gittle.clone(repo_context.repo_url, repo_context.local_repo_path, auth=auth)
+                repo = Repo(repo_context.local_repo_path)
+            else:
+                # authentication is not required, use GitPython
+                repo = Repo.clone_from(repo_context.repo_url, repo_context.local_repo_path)
+                gittle_repo = Gittle(repo_context.local_repo_path)
 
             repo_context.cloned = True
-            repo_context.repo = repo
+            repo_context.gittle_repo = gittle_repo
+            repo_context.repo  = repo
             AgentGitHandler.add_repo_context(repo_context)
             AgentGitHandler.log.info("Git clone operation for tenant %r successful" % repo_context.tenant_id)
-        except GitCommandError as ex:
-            if "remote: Repository not found." in ex:
-                AgentGitHandler.log.exception("Accessing remote git repository failed for tenant %r" % repo_context.tenant_id)
-                #GitPython deletes the target folder if remote not found
-                cartridgeagentutils.create_dir(repo_context.local_repo_path)
-            else:
-                AgentGitHandler.log.exception("Git clone operation for tenant %r failed" % repo_context.tenant_id)
+        except urllib2.URLError:
+            AgentGitHandler.log.exception("Accessing remote git repository failed for tenant %r" % repo_context.tenant_id)
+        except OSError:
+            AgentGitHandler.log.exception("Permission denied for repository path for tenant %r" % repo_context.tenant_id)
+        except:
+            AgentGitHandler.log.exception("Git clone operation for tenant %r failed" % repo_context.tenant_id)
         finally:
             return repo_context
 
     @staticmethod
+    def create_auth_configuration(repo_context):
+        """
+        Creates a GittleAuth object based on the type of authorization
+        :param GitRepository repo_context: The repository context object
+        :return: GittleAuth object or None if no authorization needed
+        :rtype: GittleAuth
+        """
+        if repo_context.key_based_auth:
+            pkey = AgentGitHandler.get_private_key()
+            auth = GittleAuth(pkey=pkey)
+        elif repo_context.repo_username.strip() != "" and repo_context.repo_password.strip() != "":
+            auth = GittleAuth(username=repo_context.repo_username, password=repo_context.repo_password)
+        else:
+            auth = None
+
+        return auth
+
+    @staticmethod
+    def get_private_key():
+        """
+        Returns a file handler to the private key path specified by Carbon or default if not specified
+        by Carbon
+        :return: The file object of the private key file
+        :rtype: file
+        """
+        pkey_name = cartridgeagentutils.get_carbon_server_property("SshPrivateKeyName")
+        if pkey_name is  None:
+            pkey_name = "wso2"
+
+        pkey_path = cartridgeagentutils.get_carbon_server_property("SshPrivateKeyPath")
+        if pkey_path is None:
+            pkey_path = os.environ["HOME"] + "/.ssh"
+
+        if pkey_path.endswith("/"):
+            pkey_ptr = pkey_path + pkey_name
+        else:
+            pkey_ptr = pkey_path + "/" + pkey_name
+
+        pkey_file = open(pkey_ptr)
+
+        return pkey_file
+
+
+    @staticmethod
     def add_repo_context(repo_context):
         AgentGitHandler.__git_repositories[repo_context.tenant_id] = repo_context
 
@@ -215,22 +286,39 @@ class AgentGitHandler:
         repo_context.is_multitenant = repo_info.is_multitenant
         repo_context.commit_enabled = repo_info.commit_enabled
 
-        # TODO: push
-        # push not implemented
-        # if is_key_based_auth(repo_info.repo_url, tenant_id):
-        #     repo.key_based_auth = True
-        #     init_ssh_auth()
-        # else:
-        #     repo.key_based_auth = False
+        if AgentGitHandler.is_key_based_auth(repo_info.repo_url, repo_info.tenant_id):
+            repo_context.key_based_auth = True
+        else:
+            repo_context.key_based_auth = False
 
         repo_context.cloned = False
 
         repo_context.repo = None
+        repo_context.gittle_repo = None
 
         return repo_context
 
-    # @staticmethod
-    # def is_key_based_auth(repo_url, tenant_id):
+    @staticmethod
+    def is_key_based_auth(repo_url, tenant_id):
+        """
+        Checks if the given git repo has key based authentication
+        :param str repo_url: Git repository remote url
+        :param str tenant_id: Tenant ID
+        :return: True if key based, False otherwise
+        :rtype: bool
+        """
+        if repo_url.startswith("http://") or repo_url.startswith("https://"):
+            # username and password, not key based
+            return False
+        elif repo_url.startswith("git://github.com"):
+            # no auth required
+            return False
+        elif repo_url.startswith("ssh://") or "@" in repo_url:
+            # key based
+            return True
+        else:
+            AgentGitHandler.log.error("Invalid git URL provided for tenant " + tenant_id)
+            raise RuntimeError("Invalid git URL provided for tenant " + tenant_id)
 
     @staticmethod
     def get_repo_path_for_tenant(tenant_id, git_local_repo_path, is_multitenant):
@@ -278,6 +366,58 @@ class AgentGitHandler:
 
     @staticmethod
     def commit(repo_info):
+        """
+        Commits and pushes new artifacts to the remote repository
+        :param repo_info:
+        :return:
+        """
+        tenant_id = repo_info.tenant_id
+        repo_context = AgentGitHandler.get_repo_context(tenant_id)
+        gittle_repo = repo_context.gittle_repo
+        try:
+            modified = True if gittle_repo.modified_unstaged_files.count > 0 else False
+        except OSError:
+            # removed files
+            modified = True
+
+        if not modified:
+            AgentGitHandler.log.debug("No changes detected in the local repository for tenant " + tenant_id)
+            return
+
+        gittle_repo.stage(gittle_repo.untracked_files)
+        gittle_repo.stage(gittle_repo.removed_files)
+        gittle_repo.stage(gittle_repo.modified_unstaged_files)
+
+        #commit to local repositpory
+        commit_message = "tenant " + tenant_id + "'s artifacts committed to local repo at " + repo_context.local_repo_path
+
+        try:
+            commit_hash = gittle_repo.commit(name="First Author", email="author@example.org", message=commit_message)
+            AgentGitHandler.log.debug("Committed artifacts for tenant : " + tenant_id + " : " + commit_hash)
+        except:
+            AgentGitHandler.log.exception("Committing artifacts to local repository failed for tenant " + tenant_id)
+
+        #push to remote
+        try:
+            repo = repo_context.repo
+            #TODO: check key based authentication
+            credentialed_remote_url = AgentGitHandler.get_credentialed_remote_url(repo_context)
+            push_remote = repo.create_remote('push_remote', credentialed_remote_url)
+            push_remote.push()
+            AgentGitHandler.log.debug("Pushed artifacts for tenant : " + tenant_id)
+        except:
+            AgentGitHandler.log.exception("Pushing artifacts to remote repository failed for tenant " + tenant_id)
+
+    @staticmethod
+    def get_credentialed_remote_url(repo_context):
+        """
+        Creates a remote url including the credentials
+        :param repo_context:
+        :return:
+        """
+        username = repo_context.repo_username
+        password = repo_context.repo_password
+
         raise NotImplementedError
 
     @staticmethod
@@ -326,8 +466,7 @@ class AgentGitHandler:
 class ArtifactUpdateTask(Thread):
 
     def __init__(self, repo_info, auto_checkout, auto_commit):
-        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
         Thread.__init__(self)
         self.repo_info = repo_info
         self.auto_checkout = auto_checkout

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
index ba9d3d7..b7445d5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
@@ -1,5 +1,6 @@
 from ...util.asyncscheduledtask import AsyncScheduledTask
-
+from gittle import Gittle
+from git import *
 
 class GitRepository:
     """
@@ -14,7 +15,9 @@ class GitRepository:
         self.cloned = False
         """ :type : bool  """
         self.repo = None
-        """ :type : str  """
+        """ :type : git.repo.base.Repo  """
+        self.gittle_repo = None
+        """ :type : gittle.gittle.Gittle  """
         self.tenant_id = None
         """ :type : int  """
         self.key_based_auth = False

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 3170e3d..c0e5ea6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -3,6 +3,7 @@ import logging
 import os
 
 from ..util import cartridgeagentconstants
+from ..util.log import LogFactory
 from ..exception.parameternotfoundexception import ParameterNotFoundException
 
 
@@ -11,8 +12,7 @@ class CartridgeAgentConfiguration:
     Handles the configuration information of the particular Cartridge Agent
     """
     # set log level
-    logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-    log = logging.getLogger(__name__)
+    log = LogFactory().get_log(__name__)
 
     payload_params = {}
     properties = None

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 2687687..8005a7a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -9,6 +9,7 @@ from ..publisher import cartridgeagentpublisher
 from ..exception.parameternotfoundexception import ParameterNotFoundException
 from ..topology.topologycontext import *
 from ..tenant.tenantcontext import *
+from ..util.log import LogFactory
 from abstractextensionhandler import AbstractExtensionHandler
 
 
@@ -19,8 +20,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
     log = None
 
     def __init__(self):
-        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
         self.wk_members = []
 
     def on_instance_started_event(self):
@@ -66,7 +66,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                                               is_multitenant, commit_enabled)
 
             # checkout code
-            checkout_result = AgentGitHandler.checkout(repo_info)
+            subscribe_run, repo_context = AgentGitHandler.checkout(repo_info)
             # repo_context = checkout_result["repo_context"]
             # execute artifact updated extension
             env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": artifacts_updated_event.cluster_id,
@@ -78,7 +78,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             extensionutils.execute_artifacts_updated_extension(env_params)
 
-            if checkout_result["subscribe_run"]:
+            if subscribe_run:
                 # publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 0427e46..260d67d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -9,8 +9,7 @@ from .. healthstatspublisher.healthstats import *
 from .. healthstatspublisher.abstracthealthstatisticspublisher import *
 
 
-logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-log = logging.getLogger(__name__)
+log = LogFactory().get_log(__name__)
 
 started = False
 activated = False

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index ad32180..a8209a5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -4,6 +4,7 @@ import paho.mqtt.client as mqtt
 
 from .. util import cartridgeagentconstants
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from .. util.log import LogFactory
 
 
 class EventSubscriber(threading.Thread):
@@ -18,8 +19,7 @@ class EventSubscriber(threading.Thread):
         #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
         self.__event_handlers = {}
 
-        logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
 
         self.__mb_client = None
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index efff3ec..d9916da 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -8,11 +8,11 @@ import shutil
 
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 import cartridgeagentconstants
+from log import LogFactory
 
 unpad = lambda s: s[0:-ord(s[-1])]
 
-logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-log = logging.getLogger(__name__)
+log = LogFactory().get_log(__name__)
 
 current_milli_time = lambda: int(round(time.time() * 1000))
 
@@ -148,4 +148,16 @@ def validate_tenant_range(tenant_range):
                 valid = True
 
     if not valid:
-        raise RuntimeError("Tenant range %r is not valid" % tenant_range)
\ No newline at end of file
+        raise RuntimeError("Tenant range %r is not valid" % tenant_range)
+
+
+def get_carbon_server_property(property_key):
+    """
+    Reads the carbon.xml file and returns the value for the property key.
+    TODO: Get carbon server xml location
+    :param str property_key: Property key to look for
+    :return: The value of the property, None if the property key is invalid or not present
+    :rtype : str
+    """
+
+    raise NotImplementedError
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/b1c5d361/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 8ce36ba..a694ff1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -5,9 +5,9 @@ import time
 
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. topology.topologycontext import *
+from log import LogFactory
 
-logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
-log = logging.getLogger(__name__)
+log = LogFactory().get_log(__name__)
 
 
 def execute_copy_artifact_extension(source, destination):


[07/50] [abbrv] git commit: Added WSO2 CEP/BAM Python data publisher Wrote a sample log publisher

Posted by ni...@apache.org.
Added WSO2 CEP/BAM Python data publisher
Wrote a sample log publisher


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/f4b2b5c7
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/f4b2b5c7
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/f4b2b5c7

Branch: refs/heads/master
Commit: f4b2b5c7fe9fe5028a2eb2bb732696fcb7205e93
Parents: f85bc0a
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Sep 30 15:30:41 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:39:50 2014 +0530

----------------------------------------------------------------------
 .../modules/logpublisher/__init__.py            |    1 +
 .../modules/logpublisher/logpublisher.py        |   71 +
 .../modules/thriftcom/Publisher.py              |   94 ++
 .../modules/thriftcom/__init__.py               |    0
 .../modules/thriftcom/gen-py/Data/__init__.py   |    1 +
 .../modules/thriftcom/gen-py/Data/constants.py  |   11 +
 .../modules/thriftcom/gen-py/Data/ttypes.py     |  320 ++++
 .../thriftcom/gen-py/Exception/__init__.py      |    1 +
 .../thriftcom/gen-py/Exception/constants.py     |   11 +
 .../thriftcom/gen-py/Exception/ttypes.py        |  473 ++++++
 .../ThriftEventTransmissionService-remote       |  116 ++
 .../ThriftEventTransmissionService.py           | 1144 ++++++++++++++
 .../ThriftEventTransmissionService/__init__.py  |    1 +
 .../ThriftEventTransmissionService/constants.py |   11 +
 .../ThriftEventTransmissionService/ttypes.py    |   21 +
 .../ThriftSecureEventTransmissionService-remote |  130 ++
 .../ThriftSecureEventTransmissionService.py     | 1494 ++++++++++++++++++
 .../__init__.py                                 |    1 +
 .../constants.py                                |   11 +
 .../ttypes.py                                   |   21 +
 .../modules/thriftcom/gen-py/__init__.py        |    0
 .../modules/thriftcom/thrift/TSCons.py          |   35 +
 .../modules/thriftcom/thrift/TSerialization.py  |   38 +
 .../modules/thriftcom/thrift/TTornado.py        |  153 ++
 .../modules/thriftcom/thrift/Thrift.py          |  170 ++
 .../modules/thriftcom/thrift/__init__.py        |   20 +
 .../modules/thriftcom/thrift/protocol/TBase.py  |   81 +
 .../thrift/protocol/TBinaryProtocol.py          |  260 +++
 .../thrift/protocol/TCompactProtocol.py         |  403 +++++
 .../thriftcom/thrift/protocol/TJSONProtocol.py  |  550 +++++++
 .../thriftcom/thrift/protocol/TProtocol.py      |  406 +++++
 .../thriftcom/thrift/protocol/__init__.py       |   20 +
 .../thriftcom/thrift/protocol/fastbinary.c      | 1219 ++++++++++++++
 .../thriftcom/thrift/server/THttpServer.py      |   87 +
 .../thrift/server/TNonblockingServer.py         |  346 ++++
 .../thrift/server/TProcessPoolServer.py         |  118 ++
 .../modules/thriftcom/thrift/server/TServer.py  |  269 ++++
 .../modules/thriftcom/thrift/server/__init__.py |   20 +
 .../thriftcom/thrift/transport/THttpClient.py   |  149 ++
 .../thriftcom/thrift/transport/TSSLSocket.py    |  214 +++
 .../thriftcom/thrift/transport/TSocket.py       |  176 +++
 .../thriftcom/thrift/transport/TTransport.py    |  330 ++++
 .../thriftcom/thrift/transport/TTwisted.py      |  221 +++
 .../thrift/transport/TZlibTransport.py          |  248 +++
 .../thriftcom/thrift/transport/__init__.py      |   20 +
 45 files changed, 9486 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
new file mode 100644
index 0000000..0de6991
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
@@ -0,0 +1 @@
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
new file mode 100644
index 0000000..7550811
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
@@ -0,0 +1,71 @@
+from ..thriftcom.Publisher import *
+from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+import json
+
+
+def get_valid_tenant_id(tenant_id):
+    raise NotImplementedError
+
+
+def get_alias(cluster_id):
+    raise NotImplementedError
+
+
+def get_current_date():
+    raise NotImplementedError
+
+ip = '192.168.1.2'	# IP address of the server
+port = 7711		# Thrift listen port of the server
+username = 'admin'	# username
+password = 'admin' 	# passowrd
+
+# Initialize publisher with ip and port of server
+publisher = Publisher(ip, port)
+
+# Connect to server with username and password
+publisher.connect(username, password)
+
+# Define stream definition
+valid_tenant_id = get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
+alias = get_alias(CartridgeAgentConfiguration.cluster_id)
+stream_name = "logs." + valid_tenant_id + "." \
+              + alias + "." + get_current_date()
+
+stream_version = "1.0.0"
+payload_data = '{"name": "tenantID", "type": "STRING"}, {"name": "serverName", "type": "STRING"}, {"name": "appName", "type": "STRING"}, {"name": "logTime", "type": "STRING"}, {"name": "priority", "type": "STRING"}, {"name": "message", "type": "STRING"}, {"name": "logger", "type": "STRING"}, {"name": "ip", "type": "STRING"}, {"name": "instance", "type": "STRING"}, {"name": "stacktrace", "type": "STRING"}'
+
+meta_data = '{"name": "memberId", "type": "STRING"}'
+
+streamDefinition = "{ 'name': '" + stream_name + "', 'version':'" + stream_version + \
+                   "', 'metaData':'" + meta_data + \
+                   "', 'payloadData':'" + payload_data + "' }"
+
+# streamDefinition = "{ 'name': '" + stream_name + "', 'version':'" + stream_version + \
+#                    "', 'payloadData':'" + json.dumps(payload_data) + "' }"
+
+publisher.defineStream(streamDefinition)
+
+#compile the event
+event = EventBundle()
+#add meta data
+event.addStringAttribute(CartridgeAgentConfiguration.member_id)
+#add correlation data
+
+#add payload data
+event.addStringAttribute(valid_tenant_id)
+event.addStringAttribute(alias)
+event.addStringAttribute("")
+event.addStringAttribute(get_current_date())
+event.addStringAttribute("")
+event.addStringAttribute("this line")
+event.addStringAttribute("")
+event.addStringAttribute("")
+event.addStringAttribute(CartridgeAgentConfiguration.member_id)
+event.addStringAttribute("")
+
+# Publish sample message
+publisher.publish(event)
+
+# Disconnect
+publisher.disconnect()
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
new file mode 100644
index 0000000..7ede910
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
@@ -0,0 +1,94 @@
+import time
+import sys
+
+sys.path.append("gen-py")
+
+from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from ThriftSecureEventTransmissionService.ttypes import *
+
+from thrift import Thrift
+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(1)
+        event.addLongAttribute(time.time() * 1000)
+        event.addStringAttribute(self.streamId)
+        #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 Data.ttypes.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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
new file mode 100644
index 0000000..35216c6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
@@ -0,0 +1,11 @@
+#
+# 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 ttypes import *
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
new file mode 100644
index 0000000..642c550
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
@@ -0,0 +1,320 @@
+#
+# 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 thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class ThriftAttributeType:
+  INT = 0
+  LONG = 1
+  FLOAT = 2
+  DOUBLE = 3
+  BOOL = 4
+  STRING = 5
+
+  _VALUES_TO_NAMES = {
+    0: "INT",
+    1: "LONG",
+    2: "FLOAT",
+    3: "DOUBLE",
+    4: "BOOL",
+    5: "STRING",
+  }
+
+  _NAMES_TO_VALUES = {
+    "INT": 0,
+    "LONG": 1,
+    "FLOAT": 2,
+    "DOUBLE": 3,
+    "BOOL": 4,
+    "STRING": 5,
+  }
+
+
+class ThriftAttribute:
+  """
+  Attributes:
+   - name
+   - attributeType
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.I32, 'attributeType', None, None, ), # 2
+  )
+
+  def __init__(self, name=None, attributeType=None,):
+    self.name = name
+    self.attributeType = attributeType
+
+  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.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.I32:
+          self.attributeType = iprot.readI32();
+        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('ThriftAttribute')
+    if self.name is not None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.attributeType is not None:
+      oprot.writeFieldBegin('attributeType', TType.I32, 2)
+      oprot.writeI32(self.attributeType)
+      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 ThriftEventBundle:
+  """
+  Attributes:
+   - sessionId
+   - eventNum
+   - intAttributeList
+   - longAttributeList
+   - doubleAttributeList
+   - boolAttributeList
+   - stringAttributeList
+   - arbitraryDataMapMap
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'sessionId', None, None, ), # 1
+    (2, TType.I32, 'eventNum', None, None, ), # 2
+    (3, TType.LIST, 'intAttributeList', (TType.I32,None), None, ), # 3
+    (4, TType.LIST, 'longAttributeList', (TType.I64,None), None, ), # 4
+    (5, TType.LIST, 'doubleAttributeList', (TType.DOUBLE,None), None, ), # 5
+    (6, TType.LIST, 'boolAttributeList', (TType.BOOL,None), None, ), # 6
+    (7, TType.LIST, 'stringAttributeList', (TType.STRING,None), None, ), # 7
+    (8, TType.MAP, 'arbitraryDataMapMap', (TType.I32,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 8
+  )
+
+  def __init__(self, sessionId=None, eventNum=None, intAttributeList=None, longAttributeList=None, doubleAttributeList=None, boolAttributeList=None, stringAttributeList=None, arbitraryDataMapMap=None,):
+    self.sessionId = sessionId
+    self.eventNum = eventNum
+    self.intAttributeList = intAttributeList
+    self.longAttributeList = longAttributeList
+    self.doubleAttributeList = doubleAttributeList
+    self.boolAttributeList = boolAttributeList
+    self.stringAttributeList = stringAttributeList
+    self.arbitraryDataMapMap = arbitraryDataMapMap
+
+  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.I32:
+          self.eventNum = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.LIST:
+          self.intAttributeList = []
+          (_etype3, _size0) = iprot.readListBegin()
+          for _i4 in xrange(_size0):
+            _elem5 = iprot.readI32();
+            self.intAttributeList.append(_elem5)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.LIST:
+          self.longAttributeList = []
+          (_etype9, _size6) = iprot.readListBegin()
+          for _i10 in xrange(_size6):
+            _elem11 = iprot.readI64();
+            self.longAttributeList.append(_elem11)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.LIST:
+          self.doubleAttributeList = []
+          (_etype15, _size12) = iprot.readListBegin()
+          for _i16 in xrange(_size12):
+            _elem17 = iprot.readDouble();
+            self.doubleAttributeList.append(_elem17)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TType.LIST:
+          self.boolAttributeList = []
+          (_etype21, _size18) = iprot.readListBegin()
+          for _i22 in xrange(_size18):
+            _elem23 = iprot.readBool();
+            self.boolAttributeList.append(_elem23)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TType.LIST:
+          self.stringAttributeList = []
+          (_etype27, _size24) = iprot.readListBegin()
+          for _i28 in xrange(_size24):
+            _elem29 = iprot.readString();
+            self.stringAttributeList.append(_elem29)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 8:
+        if ftype == TType.MAP:
+          self.arbitraryDataMapMap = {}
+          (_ktype31, _vtype32, _size30 ) = iprot.readMapBegin()
+          for _i34 in xrange(_size30):
+            _key35 = iprot.readI32();
+            _val36 = {}
+            (_ktype38, _vtype39, _size37 ) = iprot.readMapBegin()
+            for _i41 in xrange(_size37):
+              _key42 = iprot.readString();
+              _val43 = iprot.readString();
+              _val36[_key42] = _val43
+            iprot.readMapEnd()
+            self.arbitraryDataMapMap[_key35] = _val36
+          iprot.readMapEnd()
+        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('ThriftEventBundle')
+    if self.sessionId is not None:
+      oprot.writeFieldBegin('sessionId', TType.STRING, 1)
+      oprot.writeString(self.sessionId)
+      oprot.writeFieldEnd()
+    if self.eventNum is not None:
+      oprot.writeFieldBegin('eventNum', TType.I32, 2)
+      oprot.writeI32(self.eventNum)
+      oprot.writeFieldEnd()
+    if self.intAttributeList is not None:
+      oprot.writeFieldBegin('intAttributeList', TType.LIST, 3)
+      oprot.writeListBegin(TType.I32, len(self.intAttributeList))
+      for iter44 in self.intAttributeList:
+        oprot.writeI32(iter44)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.longAttributeList is not None:
+      oprot.writeFieldBegin('longAttributeList', TType.LIST, 4)
+      oprot.writeListBegin(TType.I64, len(self.longAttributeList))
+      for iter45 in self.longAttributeList:
+        oprot.writeI64(iter45)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.doubleAttributeList is not None:
+      oprot.writeFieldBegin('doubleAttributeList', TType.LIST, 5)
+      oprot.writeListBegin(TType.DOUBLE, len(self.doubleAttributeList))
+      for iter46 in self.doubleAttributeList:
+        oprot.writeDouble(iter46)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.boolAttributeList is not None:
+      oprot.writeFieldBegin('boolAttributeList', TType.LIST, 6)
+      oprot.writeListBegin(TType.BOOL, len(self.boolAttributeList))
+      for iter47 in self.boolAttributeList:
+        oprot.writeBool(iter47)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.stringAttributeList is not None:
+      oprot.writeFieldBegin('stringAttributeList', TType.LIST, 7)
+      oprot.writeListBegin(TType.STRING, len(self.stringAttributeList))
+      for iter48 in self.stringAttributeList:
+        oprot.writeString(iter48)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.arbitraryDataMapMap is not None:
+      oprot.writeFieldBegin('arbitraryDataMapMap', TType.MAP, 8)
+      oprot.writeMapBegin(TType.I32, TType.MAP, len(self.arbitraryDataMapMap))
+      for kiter49,viter50 in self.arbitraryDataMapMap.items():
+        oprot.writeI32(kiter49)
+        oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter50))
+        for kiter51,viter52 in viter50.items():
+          oprot.writeString(kiter51)
+          oprot.writeString(viter52)
+        oprot.writeMapEnd()
+      oprot.writeMapEnd()
+      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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
new file mode 100644
index 0000000..35216c6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
@@ -0,0 +1,11 @@
+#
+# 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 ttypes import *
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
new file mode 100644
index 0000000..c69fb5e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
@@ -0,0 +1,473 @@
+#
+# 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 thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+
+class ThriftStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftNoStreamDefinitionExistException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftNoStreamDefinitionExistException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftDifferentStreamDefinitionAlreadyDefinedException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftDifferentStreamDefinitionAlreadyDefinedException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftMalformedStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftMalformedStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftUndefinedEventTypeException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftUndefinedEventTypeException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftSessionExpiredException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftSessionExpiredException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftAuthenticationException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftAuthenticationException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
new file mode 100755
index 0000000..d17fbcc
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+from ThriftEventTransmissionService import ThriftEventTransmissionService
+from ThriftEventTransmissionService.ttypes import *
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
new file mode 100644
index 0000000..c5994d7
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
@@ -0,0 +1,1144 @@
+#
+# 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 ttypes import *
+from thrift.Thrift import TProcessor
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class Iface:
+  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 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["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_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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
+      result.ade = ade
+    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
+      result.mtd = mtd
+    except Exception.ttypes.ThriftStreamDefinitionException, tde:
+      result.tde = tde
+    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
+      result.tnde = tnde
+    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
+      result.ue = ue
+    except Exception.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 Exception.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 Exception.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 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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
+    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
+          self.ade.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
+          self.mtd.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
+          self.tde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
+          self.tnde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
+          self.ue.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
new file mode 100644
index 0000000..38575a6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
new file mode 100644
index 0000000..35216c6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
@@ -0,0 +1,11 @@
+#
+# 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 ttypes import *
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..a0727f8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/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
+import Data.ttypes
+import Exception.ttypes
+
+
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+


[16/50] [abbrv] git commit: Added health statistic publishing classes Refactored stream definition creation in datapublishing

Posted by ni...@apache.org.
Added health statistic publishing classes
Refactored stream definition creation in datapublishing


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1c2f0462
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1c2f0462
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1c2f0462

Branch: refs/heads/master
Commit: 1c2f0462963464b0958af81206939c8bcfa40492
Parents: 700a6d2
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:06:26 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:20 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/modules/databridge/agent.py |   4 +-
 .../exception/datapublisherexception.py         |   3 +
 .../modules/datapublisher/logpublisher.py       |  59 +++---
 .../modules/healthstatspublisher/__init__.py    |   0
 .../abstracthealthstatisticspublisher.py        |  45 +++++
 .../modules/healthstatspublisher/healthstats.py | 202 +++++++++++++++++++
 .../publisher/cartridgeagentpublisher.py        |  19 +-
 7 files changed, 304 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
index 03d5f31..7a8a0dc 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
@@ -71,7 +71,7 @@ class StreamDefinition:
         return json_str
 
 
-class LogEvent:
+class ThriftEvent:
     """
     Represents an event to be published to a BAM/CEP monitoring server
     """
@@ -114,7 +114,7 @@ class ThriftPublisher:
         """
         Publishes the given event by creating the event bundle from the log event
 
-        :param LogEvent event: The log event to be published
+        :param ThriftEvent event: The log event to be published
         :return: void
         """
         event_bundler = EventBundle()

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
index 59e103d..444c2c1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
@@ -1,4 +1,7 @@
 class DataPublisherException(Exception):
+    """
+    Exception to be used during log publishing operations
+    """
 
     def __init__(self, msg):
         super(self,  msg)

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index cf00b0b..d2769d9 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -47,7 +47,7 @@ class LogPublisher(Thread):
                     read_file.seek(where)  # set seeker
                 else:
                     # new line detected, create event object
-                    event = LogEvent()
+                    event = ThriftEvent()
                     event.metaData.append(self.member_id)
                     event.payloadData.append(self.tenant_id)
                     event.payloadData.append(self.alias)
@@ -80,6 +80,37 @@ class LogPublisherManager(Thread):
     definition and the BAM/CEP server information for a single publishing context.
     """
 
+    @staticmethod
+    def define_stream():
+        """
+        Creates a stream definition for Log Publishing
+        :return: A StreamDefinition object with the required attributes added
+        :rtype : StreamDefinition
+        """
+        # stream definition
+        stream_definition = StreamDefinition()
+        valid_tenant_id = LogPublisherManager.get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
+        alias = LogPublisherManager.get_alias(CartridgeAgentConfiguration.cluster_id)
+        stream_name = "logs." + valid_tenant_id + "." \
+                      + alias + "." + LogPublisherManager.get_current_date()
+        stream_version = "1.0.0"
+        stream_definition.name = stream_name
+        stream_definition.version = stream_version
+        stream_definition.description = "Apache Stratos Instance Log Publisher"
+        stream_definition.add_metadata_attribute("memberId", 'STRING')
+        stream_definition.add_payloaddata_attribute("tenantID", "STRING")
+        stream_definition.add_payloaddata_attribute("serverName", "STRING")
+        stream_definition.add_payloaddata_attribute("appName", "STRING")
+        stream_definition.add_payloaddata_attribute("logTime", "STRING")
+        stream_definition.add_payloaddata_attribute("priority", "STRING")
+        stream_definition.add_payloaddata_attribute("message", "STRING")
+        stream_definition.add_payloaddata_attribute("logger", "STRING")
+        stream_definition.add_payloaddata_attribute("ip", "STRING")
+        stream_definition.add_payloaddata_attribute("instance", "STRING")
+        stream_definition.add_payloaddata_attribute("stacktrace", "STRING")
+
+        return stream_definition
+
     def __init__(self, logfile_paths):
         Thread.__init__(self)
         self.logfile_paths = logfile_paths
@@ -93,29 +124,7 @@ class LogPublisherManager(Thread):
         if not ports_active:
             raise DataPublisherException("Monitoring server not active, data publishing is aborted")
 
-        #stream definition
-        self.stream_definition = StreamDefinition()
-        valid_tenant_id = LogPublisherManager.get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
-        alias = LogPublisherManager.get_alias(CartridgeAgentConfiguration.cluster_id)
-        stream_name = "logs." + valid_tenant_id + "." \
-                      + alias + "." + LogPublisherManager.get_current_date()
-
-        stream_version = "1.0.0"
-        self.stream_definition.name = stream_name
-        self.stream_definition.version = stream_version
-        self.stream_definition.description = "Apache Stratos Instance Log Publisher"
-        self.stream_definition.add_metadata_attribute("memberId", 'STRING')
-
-        self.stream_definition.add_payloaddata_attribute("tenantID", "STRING")
-        self.stream_definition.add_payloaddata_attribute("serverName", "STRING")
-        self.stream_definition.add_payloaddata_attribute("appName", "STRING")
-        self.stream_definition.add_payloaddata_attribute("logTime", "STRING")
-        self.stream_definition.add_payloaddata_attribute("priority", "STRING")
-        self.stream_definition.add_payloaddata_attribute("message", "STRING")
-        self.stream_definition.add_payloaddata_attribute("logger", "STRING")
-        self.stream_definition.add_payloaddata_attribute("ip", "STRING")
-        self.stream_definition.add_payloaddata_attribute("instance", "STRING")
-        self.stream_definition.add_payloaddata_attribute("stacktrace", "STRING")
+        self.stream_definition = self.define_stream()
 
     def run(self):
         if self.logfile_paths is not None and len(self.logfile_paths):
@@ -190,7 +199,7 @@ class DataPublisherConfiguration:
     def get_instance():
         """
         Singleton instance retriever
-        :return: Instnace
+        :return: Instance
         :rtype : DataPublisherConfiguration
         """
         if DataPublisherConfiguration.__instance is None:

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
new file mode 100644
index 0000000..e2121b6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
@@ -0,0 +1,45 @@
+class AbstractHealthStatisticsReader:
+    """
+    TODO:
+    """
+
+    def stat_cartridge_health(self):
+        """
+        Abstract method that when implemented reads the memory usage and the load average
+        of the instance running the agent and returns a CartridgeHealthStatistics object
+        with the information
+
+        :return: CartridgeHealthStatistics object with memory usage and load average values
+        :rtype : CartridgeHealthStatistics
+        """
+        raise NotImplementedError
+
+
+class CartridgeHealthStatistics:
+    """
+    Holds the memory usage and load average reading
+    """
+
+    def __init__(self):
+        self.memory_usage = None
+        """:type : float"""
+        self.load_avg = None
+        """:type : float"""
+
+
+class CEPPublisherException(Exception):
+    """
+    Exception to be used during CEP publishing operations
+    """
+
+    def __init__(self, msg):
+        super(self,  msg)
+        self.message = msg
+
+    def get_message(self):
+        """
+        The message provided when the exception is raised
+        :return: message
+        :rtype: str
+        """
+        return self.message

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
new file mode 100644
index 0000000..f647106
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -0,0 +1,202 @@
+from threading import Thread
+import time
+import logging
+
+from abstracthealthstatisticspublisher import *
+from ..databridge.agent import *
+from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from ..util import cartridgeagentutils, cartridgeagentconstants
+
+
+class HealthStatisticsPublisherManager(Thread):
+    """
+    Read from an implementation of AbstractHealthStatisticsPublisher the value for memory usage and
+    load average and publishes them as ThriftEvents to a CEP server
+    """
+    def __init__(self, publish_interval):
+        """
+        Initializes a new HealthStatistsPublisherManager with a given number of seconds as the interval
+        :param int publish_interval: Number of seconds as the interval
+        :return: void
+        """
+        Thread.__init__(self)
+
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+
+        self.publish_interval = publish_interval
+        """:type : int"""
+        self.terminated = False
+
+        self.publisher = HealthStatisticsPublisher()
+        """:type : HealthStatisticsPublisher"""
+        # TODO: load plugins for the reader
+        self.stats_reader = DefaultHealthStatisticsReader()
+        """:type : AbstractHealthStatisticsReader"""
+
+    def run(self):
+        while not self.terminated:
+            time.sleep(self.publish_interval)
+
+            cartridge_stats = self.stats_reader.stat_cartridge_health()
+            self.log.debug("Publishing memory consumption: %r" % cartridge_stats.memory_usage)
+            self.publisher.publish_memory_usage(cartridge_stats.memory_usage)
+
+            self.log.debug("Publishing load average: %r" % cartridge_stats.load_avg)
+            self.publisher.publish_load_average(cartridge_stats.load_avg)
+
+
+class HealthStatisticsPublisher:
+    """
+    Publishes memory usage and load average to thrift server
+    """
+    def __init__(self):
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+        self.ports = []
+        self.ports.append(CEPPublisherConfiguration.get_instance().server_port)
+        cartridgeagentutils.wait_until_ports_active(CEPPublisherConfiguration.get_instance().server_ip, self.ports)
+        cep_active = cartridgeagentutils.check_ports_active(CEPPublisherConfiguration.get_instance().server_ip, self.ports)
+        if not cep_active:
+            raise CEPPublisherException("CEP server not active. Health statistics publishing aborted.")
+
+        self.stream_definition = HealthStatisticsPublisher.create_stream_definition()
+        self.publisher = ThriftPublisher(
+            CEPPublisherConfiguration.get_instance().server_ip,
+            CEPPublisherConfiguration.get_instance().server_port,
+            CEPPublisherConfiguration.get_instance().admin_username,
+            CEPPublisherConfiguration.get_instance().admin_password,
+            self.stream_definition)
+
+
+    @staticmethod
+    def create_stream_definition():
+        """
+        Create a StreamDefinition for publishing to CEP
+        """
+        stream_def = StreamDefinition()
+        stream_def.name = "cartridge_agent_health_stats"
+        stream_def.version = "1.0.0"
+        stream_def.nickname = "agent health stats"
+        stream_def.description = "agent health stats"
+
+        stream_def.add_payloaddata_attribute("cluster_id", "STRING")
+        stream_def.add_payloaddata_attribute("network_partition_id", "STRING")
+        stream_def.add_payloaddata_attribute("member_id", "STRING")
+        stream_def.add_payloaddata_attribute("partition_id", "STRING")
+        stream_def.add_payloaddata_attribute("health_description", "STRING")
+        stream_def.add_payloaddata_attribute("value", "DOUBLE")
+
+        return stream_def
+
+    def publish_memory_usage(self, memory_usage):
+        """
+        Publishes the given memory usage value to the thrift server as a ThriftEvent
+        :param float memory_usage: memory usage
+        """
+
+        event = ThriftEvent()
+        event.payloadData.append(CartridgeAgentConfiguration.cluster_id)
+        event.payloadData.append(CartridgeAgentConfiguration.network_partition_id)
+        event.payloadData.append(CartridgeAgentConfiguration.member_id)
+        event.payloadData.append(CartridgeAgentConfiguration.partition_id)
+        event.payloadData.append(cartridgeagentconstants.MEMORY_CONSUMPTION)
+        event.payloadData.append(memory_usage)
+
+        self.log.debug("Publishing cep event: [stream] %r [version] %r" % (self.stream_definition.name, self.stream_definition.version))
+        self.publisher.publish(event)
+
+    def publish_load_average(self, load_avg):
+        """
+        Publishes the given load average value to the thrift server as a ThriftEvent
+        :param float load_avg: load average value
+        """
+
+        event = ThriftEvent()
+        event.payloadData.append(CartridgeAgentConfiguration.cluster_id)
+        event.payloadData.append(CartridgeAgentConfiguration.network_partition_id)
+        event.payloadData.append(CartridgeAgentConfiguration.member_id)
+        event.payloadData.append(CartridgeAgentConfiguration.partition_id)
+        event.payloadData.append(cartridgeagentconstants.LOAD_AVERAGE)
+        event.payloadData.append(load_avg)
+
+        self.log.debug("Publishing cep event: [stream] %r [version] %r" % (self.stream_definition.name, self.stream_definition.version))
+        self.publisher.publish(event)
+
+
+class DefaultHealthStatisticsReader(AbstractHealthStatisticsReader):
+    """
+    Default implementation of the AbstractHealthStatisticsReader
+    """
+
+    def stat_cartridge_health(self):
+        cartridge_stats = CartridgeHealthStatistics()
+        cartridge_stats.memory_usage = DefaultHealthStatisticsReader.__read_mem_usage()
+        cartridge_stats.load_avg = DefaultHealthStatisticsReader.__read_load_avg()
+
+        return cartridge_stats
+
+    @staticmethod
+    def __read_mem_usage():
+        raise NotImplementedError
+
+    @staticmethod
+    def __read_load_avg():
+        raise NotImplementedError
+
+
+class CEPPublisherConfiguration:
+    """
+    A singleton implementation to access configuration information for data publishing to BAM/CEP
+    TODO: perfect singleton impl ex: Borg
+    """
+
+    __instance = None
+    logging.basicConfig(level=logging.DEBUG)
+    log = logging.getLogger(__name__)
+
+    @staticmethod
+    def get_instance():
+        """
+        Singleton instance retriever
+        :return: Instance
+        :rtype : CEPPublisherConfiguration
+        """
+        if CEPPublisherConfiguration.__instance is None:
+            CEPPublisherConfiguration.__instance = CEPPublisherConfiguration()
+
+        return CEPPublisherConfiguration.__instance
+
+    def __init__(self):
+        self.enabled = False
+        self.server_ip = None
+        self.server_port = None
+        self.admin_username = None
+        self.admin_password = None
+        self.read_config()
+
+    def read_config(self):
+        self.enabled = True if CartridgeAgentConfiguration.read_property("cep.stats.publisher.enabled", False).strip().lower() == "true" else False
+        if not self.enabled:
+            CEPPublisherConfiguration.log.info("CEP Publisher disabled")
+            return
+
+        CEPPublisherConfiguration.log.info("CEP Publisher enabled")
+
+        self.server_ip = CartridgeAgentConfiguration.read_property("thrift.receiver.ip", False)
+        if self.server_ip.strip() == "":
+            raise RuntimeError("System property not found: thrift.receiver.ip")
+
+        self.server_port = CartridgeAgentConfiguration.read_property("thrift.receiver.port", False)
+        if self.server_port.strip() == "":
+            raise RuntimeError("System property not found: thrift.receiver.port")
+
+        self.admin_username = CartridgeAgentConfiguration.read_property("thrift.server.admin.username", False)
+        if self.admin_username.strip() == "":
+            raise RuntimeError("System property not found: thrift.server.admin.username")
+
+        self.admin_password = CartridgeAgentConfiguration.read_property("thrift.server.admin.password", False)
+        if self.admin_password.strip() == "":
+            raise RuntimeError("System property not found: thrift.server.admin.password")
+
+        CEPPublisherConfiguration.log.info("CEP Publisher configuration initialized")

http://git-wip-us.apache.org/repos/asf/stratos/blob/1c2f0462/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index a862967..fcbe5f1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -5,6 +5,8 @@ import paho.mqtt.publish as publish
 from .. event.instance.status.events import *
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. util import cartridgeagentconstants
+from .. healthstatspublisher.healthstats import *
+from .. healthstatspublisher.abstracthealthstatisticspublisher import *
 
 
 logging.basicConfig(level=logging.DEBUG, filename='/tmp/cartridge-agent.log')
@@ -57,7 +59,22 @@ def publish_instance_activated_event():
         log.info("Instance activated event published")
         log.info("Starting health statistics notifier")
 
-        # TODO: health stat publisher start()
+        if CEPPublisherConfiguration.get_instance().enabled:
+            interval_default = 15  # seconds
+            interval = CartridgeAgentConfiguration.read_property("stats.notifier.interval")
+            if interval is not None and len(interval) > 0:
+                try:
+                    interval = int(interval)
+                except ValueError:
+                    interval = interval_default
+            else:
+                interval = interval_default
+
+            health_stats_publisher = HealthStatisticsPublisherManager(interval)
+            health_stats_publisher.start()
+        else:
+            log.warn("Statistics publisher is disabled")
+
         activated = True
         log.info("Health statistics notifier started")
     else:


[13/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBinaryProtocol.py
new file mode 100644
index 0000000..2cdc6b5
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TCompactProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TCompactProtocol.py
new file mode 100644
index 0000000..953838e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TCompactProtocol.py
@@ -0,0 +1,405 @@
+#
+# 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 *
+
+
+__all__ = ['TCompactProtocol', 'TCompactProtocolFactory']
+
+CLEAR = 0
+FIELD_WRITE = 1
+VALUE_WRITE = 2
+CONTAINER_WRITE = 3
+BOOL_WRITE = 4
+FIELD_READ = 5
+CONTAINER_READ = 6
+VALUE_READ = 7
+BOOL_READ = 8
+
+
+def make_helper(v_from, container):
+  def helper(func):
+    def nested(self, *args, **kwargs):
+      assert self.state in (v_from, container), (self.state, v_from, container)
+      return func(self, *args, **kwargs)
+    return nested
+  return helper
+writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
+reader = make_helper(VALUE_READ, CONTAINER_READ)
+
+
+def makeZigZag(n, bits):
+  return (n << 1) ^ (n >> (bits - 1))
+
+
+def fromZigZag(n):
+  return (n >> 1) ^ -(n & 1)
+
+
+def writeVarint(trans, n):
+  out = []
+  while True:
+    if n & ~0x7f == 0:
+      out.append(n)
+      break
+    else:
+      out.append((n & 0xff) | 0x80)
+      n = n >> 7
+  trans.write(''.join(map(chr, out)))
+
+
+def readVarint(trans):
+  result = 0
+  shift = 0
+  while True:
+    x = trans.readAll(1)
+    byte = ord(x)
+    result |= (byte & 0x7f) << shift
+    if byte >> 7 == 0:
+      return result
+    shift += 7
+
+
+class CompactType:
+  STOP = 0x00
+  TRUE = 0x01
+  FALSE = 0x02
+  BYTE = 0x03
+  I16 = 0x04
+  I32 = 0x05
+  I64 = 0x06
+  DOUBLE = 0x07
+  BINARY = 0x08
+  LIST = 0x09
+  SET = 0x0A
+  MAP = 0x0B
+  STRUCT = 0x0C
+
+CTYPES = {TType.STOP: CompactType.STOP,
+          TType.BOOL: CompactType.TRUE,  # used for collection
+          TType.BYTE: CompactType.BYTE,
+          TType.I16: CompactType.I16,
+          TType.I32: CompactType.I32,
+          TType.I64: CompactType.I64,
+          TType.DOUBLE: CompactType.DOUBLE,
+          TType.STRING: CompactType.BINARY,
+          TType.STRUCT: CompactType.STRUCT,
+          TType.LIST: CompactType.LIST,
+          TType.SET: CompactType.SET,
+          TType.MAP: CompactType.MAP
+          }
+
+TTYPES = {}
+for k, v in CTYPES.items():
+  TTYPES[v] = k
+TTYPES[CompactType.FALSE] = TType.BOOL
+del k
+del v
+
+
+class TCompactProtocol(TProtocolBase):
+  """Compact implementation of the Thrift protocol driver."""
+
+  PROTOCOL_ID = 0x82
+  VERSION = 1
+  VERSION_MASK = 0x1f
+  TYPE_MASK = 0xe0
+  TYPE_SHIFT_AMOUNT = 5
+
+  def __init__(self, trans):
+    TProtocolBase.__init__(self, trans)
+    self.state = CLEAR
+    self.__last_fid = 0
+    self.__bool_fid = None
+    self.__bool_value = None
+    self.__structs = []
+    self.__containers = []
+
+  def __writeVarint(self, n):
+    writeVarint(self.trans, n)
+
+  def writeMessageBegin(self, name, type, seqid):
+    assert self.state == CLEAR
+    self.__writeUByte(self.PROTOCOL_ID)
+    self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
+    self.__writeVarint(seqid)
+    self.__writeString(name)
+    self.state = VALUE_WRITE
+
+  def writeMessageEnd(self):
+    assert self.state == VALUE_WRITE
+    self.state = CLEAR
+
+  def writeStructBegin(self, name):
+    assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
+    self.__structs.append((self.state, self.__last_fid))
+    self.state = FIELD_WRITE
+    self.__last_fid = 0
+
+  def writeStructEnd(self):
+    assert self.state == FIELD_WRITE
+    self.state, self.__last_fid = self.__structs.pop()
+
+  def writeFieldStop(self):
+    self.__writeByte(0)
+
+  def __writeFieldHeader(self, type, fid):
+    delta = fid - self.__last_fid
+    if 0 < delta <= 15:
+      self.__writeUByte(delta << 4 | type)
+    else:
+      self.__writeByte(type)
+      self.__writeI16(fid)
+    self.__last_fid = fid
+
+  def writeFieldBegin(self, name, type, fid):
+    assert self.state == FIELD_WRITE, self.state
+    if type == TType.BOOL:
+      self.state = BOOL_WRITE
+      self.__bool_fid = fid
+    else:
+      self.state = VALUE_WRITE
+      self.__writeFieldHeader(CTYPES[type], fid)
+
+  def writeFieldEnd(self):
+    assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
+    self.state = FIELD_WRITE
+
+  def __writeUByte(self, byte):
+    self.trans.write(pack('!B', byte))
+
+  def __writeByte(self, byte):
+    self.trans.write(pack('!b', byte))
+
+  def __writeI16(self, i16):
+    self.__writeVarint(makeZigZag(i16, 16))
+
+  def __writeSize(self, i32):
+    self.__writeVarint(i32)
+
+  def writeCollectionBegin(self, etype, size):
+    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+    if size <= 14:
+      self.__writeUByte(size << 4 | CTYPES[etype])
+    else:
+      self.__writeUByte(0xf0 | CTYPES[etype])
+      self.__writeSize(size)
+    self.__containers.append(self.state)
+    self.state = CONTAINER_WRITE
+  writeSetBegin = writeCollectionBegin
+  writeListBegin = writeCollectionBegin
+
+  def writeMapBegin(self, ktype, vtype, size):
+    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+    if size == 0:
+      self.__writeByte(0)
+    else:
+      self.__writeSize(size)
+      self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
+    self.__containers.append(self.state)
+    self.state = CONTAINER_WRITE
+
+  def writeCollectionEnd(self):
+    assert self.state == CONTAINER_WRITE, self.state
+    self.state = self.__containers.pop()
+  writeMapEnd = writeCollectionEnd
+  writeSetEnd = writeCollectionEnd
+  writeListEnd = writeCollectionEnd
+
+  def writeBool(self, bool):
+    if self.state == BOOL_WRITE:
+      if bool:
+        ctype = CompactType.TRUE
+      else:
+        ctype = CompactType.FALSE
+      self.__writeFieldHeader(ctype, self.__bool_fid)
+    elif self.state == CONTAINER_WRITE:
+      if bool:
+        self.__writeByte(CompactType.TRUE)
+      else:
+        self.__writeByte(CompactType.FALSE)
+    else:
+      raise AssertionError("Invalid state in compact protocol")
+
+  writeByte = writer(__writeByte)
+  writeI16 = writer(__writeI16)
+
+  @writer
+  def writeI32(self, i32):
+    self.__writeVarint(makeZigZag(i32, 32))
+
+  @writer
+  def writeI64(self, i64):
+    self.__writeVarint(makeZigZag(i64, 64))
+
+  @writer
+  def writeDouble(self, dub):
+    self.trans.write(pack('!d', dub))
+
+  def __writeString(self, s):
+    self.__writeSize(len(s))
+    self.trans.write(s)
+  writeString = writer(__writeString)
+
+  def readFieldBegin(self):
+    assert self.state == FIELD_READ, self.state
+    type = self.__readUByte()
+    if type & 0x0f == TType.STOP:
+      return (None, 0, 0)
+    delta = type >> 4
+    if delta == 0:
+      fid = self.__readI16()
+    else:
+      fid = self.__last_fid + delta
+    self.__last_fid = fid
+    type = type & 0x0f
+    if type == CompactType.TRUE:
+      self.state = BOOL_READ
+      self.__bool_value = True
+    elif type == CompactType.FALSE:
+      self.state = BOOL_READ
+      self.__bool_value = False
+    else:
+      self.state = VALUE_READ
+    return (None, self.__getTType(type), fid)
+
+  def readFieldEnd(self):
+    assert self.state in (VALUE_READ, BOOL_READ), self.state
+    self.state = FIELD_READ
+
+  def __readUByte(self):
+    result, = unpack('!B', self.trans.readAll(1))
+    return result
+
+  def __readByte(self):
+    result, = unpack('!b', self.trans.readAll(1))
+    return result
+
+  def __readVarint(self):
+    return readVarint(self.trans)
+
+  def __readZigZag(self):
+    return fromZigZag(self.__readVarint())
+
+  def __readSize(self):
+    result = self.__readVarint()
+    if result < 0:
+      raise TException("Length < 0")
+    return result
+
+  def readMessageBegin(self):
+    assert self.state == CLEAR
+    proto_id = self.__readUByte()
+    if proto_id != self.PROTOCOL_ID:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+          'Bad protocol id in the message: %d' % proto_id)
+    ver_type = self.__readUByte()
+    type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT
+    version = ver_type & self.VERSION_MASK
+    if version != self.VERSION:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+          'Bad version: %d (expect %d)' % (version, self.VERSION))
+    seqid = self.__readVarint()
+    name = self.__readString()
+    return (name, type, seqid)
+
+  def readMessageEnd(self):
+    assert self.state == CLEAR
+    assert len(self.__structs) == 0
+
+  def readStructBegin(self):
+    assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
+    self.__structs.append((self.state, self.__last_fid))
+    self.state = FIELD_READ
+    self.__last_fid = 0
+
+  def readStructEnd(self):
+    assert self.state == FIELD_READ
+    self.state, self.__last_fid = self.__structs.pop()
+
+  def readCollectionBegin(self):
+    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+    size_type = self.__readUByte()
+    size = size_type >> 4
+    type = self.__getTType(size_type)
+    if size == 15:
+      size = self.__readSize()
+    self.__containers.append(self.state)
+    self.state = CONTAINER_READ
+    return type, size
+  readSetBegin = readCollectionBegin
+  readListBegin = readCollectionBegin
+
+  def readMapBegin(self):
+    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+    size = self.__readSize()
+    types = 0
+    if size > 0:
+      types = self.__readUByte()
+    vtype = self.__getTType(types)
+    ktype = self.__getTType(types >> 4)
+    self.__containers.append(self.state)
+    self.state = CONTAINER_READ
+    return (ktype, vtype, size)
+
+  def readCollectionEnd(self):
+    assert self.state == CONTAINER_READ, self.state
+    self.state = self.__containers.pop()
+  readSetEnd = readCollectionEnd
+  readListEnd = readCollectionEnd
+  readMapEnd = readCollectionEnd
+
+  def readBool(self):
+    if self.state == BOOL_READ:
+      return self.__bool_value == CompactType.TRUE
+    elif self.state == CONTAINER_READ:
+      return self.__readByte() == CompactType.TRUE
+    else:
+      raise AssertionError("Invalid state in compact protocol: %d" %
+                           self.state)
+
+  readByte = reader(__readByte)
+  __readI16 = __readZigZag
+  readI16 = reader(__readZigZag)
+  readI32 = reader(__readZigZag)
+  readI64 = reader(__readZigZag)
+
+  @reader
+  def readDouble(self):
+    buff = self.trans.readAll(8)
+    val, = unpack('!d', buff)
+    return val
+
+  def __readString(self):
+    len = self.__readSize()
+    return self.trans.readAll(len)
+  readString = reader(__readString)
+
+  def __getTType(self, byte):
+    return TTYPES[byte & 0x0f]
+
+
+class TCompactProtocolFactory:
+  def __init__(self):
+    pass
+
+  def getProtocol(self, trans):
+    return TCompactProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TJSONProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TJSONProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TJSONProtocol.py
new file mode 100644
index 0000000..7d9d7aa
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TJSONProtocol.py
@@ -0,0 +1,552 @@
+#
+# 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 base64
+import json
+import math
+
+from TProtocol import TType, TProtocolBase, TProtocolException
+
+
+__all__ = ['TJSONProtocol',
+           'TJSONProtocolFactory',
+           'TSimpleJSONProtocol',
+           'TSimpleJSONProtocolFactory']
+
+VERSION = 1
+
+COMMA = ','
+COLON = ':'
+LBRACE = '{'
+RBRACE = '}'
+LBRACKET = '['
+RBRACKET = ']'
+QUOTE = '"'
+BACKSLASH = '\\'
+ZERO = '0'
+
+ESCSEQ = '\\u00'
+ESCAPE_CHAR = '"\\bfnrt'
+ESCAPE_CHAR_VALS = ['"', '\\', '\b', '\f', '\n', '\r', '\t']
+NUMERIC_CHAR = '+-.0123456789Ee'
+
+CTYPES = {TType.BOOL:       'tf',
+          TType.BYTE:       'i8',
+          TType.I16:        'i16',
+          TType.I32:        'i32',
+          TType.I64:        'i64',
+          TType.DOUBLE:     'dbl',
+          TType.STRING:     'str',
+          TType.STRUCT:     'rec',
+          TType.LIST:       'lst',
+          TType.SET:        'set',
+          TType.MAP:        'map'}
+
+JTYPES = {}
+for key in CTYPES.keys():
+  JTYPES[CTYPES[key]] = key
+
+
+class JSONBaseContext(object):
+
+  def __init__(self, protocol):
+    self.protocol = protocol
+    self.first = True
+
+  def doIO(self, function):
+    pass
+  
+  def write(self):
+    pass
+
+  def read(self):
+    pass
+
+  def escapeNum(self):
+    return False
+
+  def __str__(self):
+    return self.__class__.__name__
+
+
+class JSONListContext(JSONBaseContext):
+    
+  def doIO(self, function):
+    if self.first is True:
+      self.first = False
+    else:
+      function(COMMA)
+
+  def write(self):
+    self.doIO(self.protocol.trans.write)
+
+  def read(self):
+    self.doIO(self.protocol.readJSONSyntaxChar)
+
+
+class JSONPairContext(JSONBaseContext):
+  
+  def __init__(self, protocol):
+    super(JSONPairContext, self).__init__(protocol)
+    self.colon = True
+
+  def doIO(self, function):
+    if self.first:
+      self.first = False
+      self.colon = True
+    else:
+      function(COLON if self.colon else COMMA)
+      self.colon = not self.colon
+
+  def write(self):
+    self.doIO(self.protocol.trans.write)
+
+  def read(self):
+    self.doIO(self.protocol.readJSONSyntaxChar)
+
+  def escapeNum(self):
+    return self.colon
+
+  def __str__(self):
+    return '%s, colon=%s' % (self.__class__.__name__, self.colon)
+
+
+class LookaheadReader():
+  hasData = False
+  data = ''
+
+  def __init__(self, protocol):
+    self.protocol = protocol
+
+  def read(self):
+    if self.hasData is True:
+      self.hasData = False
+    else:
+      self.data = self.protocol.trans.read(1)
+    return self.data
+
+  def peek(self):
+    if self.hasData is False:
+      self.data = self.protocol.trans.read(1)
+    self.hasData = True
+    return self.data
+
+class TJSONProtocolBase(TProtocolBase):
+
+  def __init__(self, trans):
+    TProtocolBase.__init__(self, trans)
+    self.resetWriteContext()
+    self.resetReadContext()
+
+  def resetWriteContext(self):
+    self.context = JSONBaseContext(self)
+    self.contextStack = [self.context]
+
+  def resetReadContext(self):
+    self.resetWriteContext()
+    self.reader = LookaheadReader(self)
+
+  def pushContext(self, ctx):
+    self.contextStack.append(ctx)
+    self.context = ctx
+
+  def popContext(self):
+    self.contextStack.pop()
+    if self.contextStack:
+      self.context = self.contextStack[-1]
+    else:
+      self.context = JSONBaseContext(self)
+
+  def writeJSONString(self, string):
+    self.context.write()
+    self.trans.write(json.dumps(string))
+
+  def writeJSONNumber(self, number):
+    self.context.write()
+    jsNumber = str(number)
+    if self.context.escapeNum():
+      jsNumber = "%s%s%s" % (QUOTE, jsNumber,  QUOTE)
+    self.trans.write(jsNumber)
+
+  def writeJSONBase64(self, binary):
+    self.context.write()
+    self.trans.write(QUOTE)
+    self.trans.write(base64.b64encode(binary))
+    self.trans.write(QUOTE)
+
+  def writeJSONObjectStart(self):
+    self.context.write()
+    self.trans.write(LBRACE)
+    self.pushContext(JSONPairContext(self))
+
+  def writeJSONObjectEnd(self):
+    self.popContext()
+    self.trans.write(RBRACE)
+
+  def writeJSONArrayStart(self):
+    self.context.write()
+    self.trans.write(LBRACKET)
+    self.pushContext(JSONListContext(self))
+
+  def writeJSONArrayEnd(self):
+    self.popContext()
+    self.trans.write(RBRACKET)
+
+  def readJSONSyntaxChar(self, character):
+    current = self.reader.read()
+    if character != current:
+      raise TProtocolException(TProtocolException.INVALID_DATA,
+                               "Unexpected character: %s" % current)
+
+  def readJSONString(self, skipContext):
+    string = []
+    if skipContext is False:
+      self.context.read()
+    self.readJSONSyntaxChar(QUOTE)
+    while True:
+      character = self.reader.read()
+      if character == QUOTE:
+        break
+      if character == ESCSEQ[0]:
+        character = self.reader.read()
+        if character == ESCSEQ[1]:
+          self.readJSONSyntaxChar(ZERO)
+          self.readJSONSyntaxChar(ZERO)
+          character = json.JSONDecoder().decode('"\u00%s"' % self.trans.read(2))
+        else:
+          off = ESCAPE_CHAR.find(character)
+          if off == -1:
+            raise TProtocolException(TProtocolException.INVALID_DATA,
+                                     "Expected control char")
+          character = ESCAPE_CHAR_VALS[off]
+      string.append(character)
+    return ''.join(string)
+
+  def isJSONNumeric(self, character):
+    return (True if NUMERIC_CHAR.find(character) != - 1 else False)
+
+  def readJSONQuotes(self):
+    if (self.context.escapeNum()):
+      self.readJSONSyntaxChar(QUOTE)
+
+  def readJSONNumericChars(self):
+    numeric = []
+    while True:
+      character = self.reader.peek()
+      if self.isJSONNumeric(character) is False:
+        break
+      numeric.append(self.reader.read())
+    return ''.join(numeric)
+
+  def readJSONInteger(self):
+    self.context.read()
+    self.readJSONQuotes()
+    numeric = self.readJSONNumericChars()
+    self.readJSONQuotes()
+    try:
+      return int(numeric)
+    except ValueError:
+      raise TProtocolException(TProtocolException.INVALID_DATA,
+                               "Bad data encounted in numeric data")
+
+  def readJSONDouble(self):
+    self.context.read()
+    if self.reader.peek() == QUOTE:
+      string  = self.readJSONString(True)
+      try:
+        double = float(string)
+        if (self.context.escapeNum is False and
+            not math.isinf(double) and
+            not math.isnan(double)):
+          raise TProtocolException(TProtocolException.INVALID_DATA,
+                                   "Numeric data unexpectedly quoted")
+        return double
+      except ValueError:
+        raise TProtocolException(TProtocolException.INVALID_DATA,
+                                 "Bad data encounted in numeric data")
+    else:
+      if self.context.escapeNum() is True:
+        self.readJSONSyntaxChar(QUOTE)
+      try:
+        return float(self.readJSONNumericChars())
+      except ValueError:
+        raise TProtocolException(TProtocolException.INVALID_DATA,
+                                 "Bad data encounted in numeric data")
+
+  def readJSONBase64(self):
+    string = self.readJSONString(False)
+    return base64.b64decode(string)
+
+  def readJSONObjectStart(self):
+    self.context.read()
+    self.readJSONSyntaxChar(LBRACE)
+    self.pushContext(JSONPairContext(self))
+
+  def readJSONObjectEnd(self):
+    self.readJSONSyntaxChar(RBRACE)
+    self.popContext()
+
+  def readJSONArrayStart(self):
+    self.context.read()
+    self.readJSONSyntaxChar(LBRACKET)
+    self.pushContext(JSONListContext(self))
+
+  def readJSONArrayEnd(self):
+    self.readJSONSyntaxChar(RBRACKET)
+    self.popContext()
+
+
+class TJSONProtocol(TJSONProtocolBase):
+
+  def readMessageBegin(self):
+    self.resetReadContext()
+    self.readJSONArrayStart()
+    if self.readJSONInteger() != VERSION:
+      raise TProtocolException(TProtocolException.BAD_VERSION,
+                               "Message contained bad version.")
+    name = self.readJSONString(False)
+    typen = self.readJSONInteger()
+    seqid = self.readJSONInteger()
+    return (name, typen, seqid)
+
+  def readMessageEnd(self):
+    self.readJSONArrayEnd()
+
+  def readStructBegin(self):
+    self.readJSONObjectStart()
+
+  def readStructEnd(self):
+    self.readJSONObjectEnd()
+
+  def readFieldBegin(self):
+    character = self.reader.peek()
+    ttype = 0
+    id = 0
+    if character == RBRACE:
+      ttype = TType.STOP
+    else:
+      id = self.readJSONInteger()
+      self.readJSONObjectStart()
+      ttype = JTYPES[self.readJSONString(False)]
+    return (None, ttype, id)
+
+  def readFieldEnd(self):
+    self.readJSONObjectEnd()
+
+  def readMapBegin(self):
+    self.readJSONArrayStart()
+    keyType = JTYPES[self.readJSONString(False)]
+    valueType = JTYPES[self.readJSONString(False)]
+    size = self.readJSONInteger()
+    self.readJSONObjectStart()
+    return (keyType, valueType, size)
+
+  def readMapEnd(self):
+    self.readJSONObjectEnd()
+    self.readJSONArrayEnd()
+
+  def readCollectionBegin(self):
+    self.readJSONArrayStart()
+    elemType = JTYPES[self.readJSONString(False)]
+    size = self.readJSONInteger()
+    return (elemType, size)
+  readListBegin = readCollectionBegin
+  readSetBegin = readCollectionBegin
+
+  def readCollectionEnd(self):
+    self.readJSONArrayEnd()
+  readSetEnd = readCollectionEnd
+  readListEnd = readCollectionEnd
+
+  def readBool(self):
+    return (False if self.readJSONInteger() == 0 else True)
+
+  def readNumber(self):
+    return self.readJSONInteger()
+  readByte = readNumber
+  readI16 = readNumber
+  readI32 = readNumber
+  readI64 = readNumber
+
+  def readDouble(self):
+    return self.readJSONDouble()
+
+  def readString(self):
+    return self.readJSONString(False)
+
+  def readBinary(self):
+    return self.readJSONBase64()
+
+  def writeMessageBegin(self, name, request_type, seqid):
+    self.resetWriteContext()
+    self.writeJSONArrayStart()
+    self.writeJSONNumber(VERSION)
+    self.writeJSONString(name)
+    self.writeJSONNumber(request_type)
+    self.writeJSONNumber(seqid)
+
+  def writeMessageEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeStructBegin(self, name):
+    self.writeJSONObjectStart()
+
+  def writeStructEnd(self):
+    self.writeJSONObjectEnd()
+
+  def writeFieldBegin(self, name, ttype, id):
+    self.writeJSONNumber(id)
+    self.writeJSONObjectStart()
+    self.writeJSONString(CTYPES[ttype])
+
+  def writeFieldEnd(self):
+    self.writeJSONObjectEnd()
+
+  def writeFieldStop(self):
+    pass
+
+  def writeMapBegin(self, ktype, vtype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[ktype])
+    self.writeJSONString(CTYPES[vtype])
+    self.writeJSONNumber(size)
+    self.writeJSONObjectStart()
+
+  def writeMapEnd(self):
+    self.writeJSONObjectEnd()
+    self.writeJSONArrayEnd()
+    
+  def writeListBegin(self, etype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[etype])
+    self.writeJSONNumber(size)
+    
+  def writeListEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeSetBegin(self, etype, size):
+    self.writeJSONArrayStart()
+    self.writeJSONString(CTYPES[etype])
+    self.writeJSONNumber(size)
+    
+  def writeSetEnd(self):
+    self.writeJSONArrayEnd()
+
+  def writeBool(self, boolean):
+    self.writeJSONNumber(1 if boolean is True else 0)
+
+  def writeInteger(self, integer):
+    self.writeJSONNumber(integer)
+  writeByte = writeInteger
+  writeI16 = writeInteger
+  writeI32 = writeInteger
+  writeI64 = writeInteger
+
+  def writeDouble(self, dbl):
+    self.writeJSONNumber(dbl)
+
+  def writeString(self, string):
+    self.writeJSONString(string)
+    
+  def writeBinary(self, binary):
+    self.writeJSONBase64(binary)
+
+
+class TJSONProtocolFactory:
+
+  def getProtocol(self, trans):
+    return TJSONProtocol(trans)
+
+
+class TSimpleJSONProtocol(TJSONProtocolBase):
+    """Simple, readable, write-only JSON protocol.
+    
+    Useful for interacting with scripting languages.
+    """
+
+    def readMessageBegin(self):
+        raise NotImplementedError()
+    
+    def readMessageEnd(self):
+        raise NotImplementedError()
+    
+    def readStructBegin(self):
+        raise NotImplementedError()
+    
+    def readStructEnd(self):
+        raise NotImplementedError()
+    
+    def writeMessageBegin(self, name, request_type, seqid):
+        self.resetWriteContext()
+    
+    def writeMessageEnd(self):
+        pass
+    
+    def writeStructBegin(self, name):
+        self.writeJSONObjectStart()
+    
+    def writeStructEnd(self):
+        self.writeJSONObjectEnd()
+      
+    def writeFieldBegin(self, name, ttype, fid):
+        self.writeJSONString(name)
+    
+    def writeFieldEnd(self):
+        pass
+    
+    def writeMapBegin(self, ktype, vtype, size):
+        self.writeJSONObjectStart()
+    
+    def writeMapEnd(self):
+        self.writeJSONObjectEnd()
+    
+    def _writeCollectionBegin(self, etype, size):
+        self.writeJSONArrayStart()
+    
+    def _writeCollectionEnd(self):
+        self.writeJSONArrayEnd()
+    writeListBegin = _writeCollectionBegin
+    writeListEnd = _writeCollectionEnd
+    writeSetBegin = _writeCollectionBegin
+    writeSetEnd = _writeCollectionEnd
+
+    def writeInteger(self, integer):
+        self.writeJSONNumber(integer)
+    writeByte = writeInteger
+    writeI16 = writeInteger
+    writeI32 = writeInteger
+    writeI64 = writeInteger
+    
+    def writeBool(self, boolean):
+        self.writeJSONNumber(1 if boolean is True else 0)
+
+    def writeDouble(self, dbl):
+        self.writeJSONNumber(dbl)
+    
+    def writeString(self, string):
+        self.writeJSONString(string)
+      
+    def writeBinary(self, binary):
+        self.writeJSONBase64(binary)
+
+
+class TSimpleJSONProtocolFactory(object):
+
+    def getProtocol(self, trans):
+        return TSimpleJSONProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
new file mode 100644
index 0000000..dc2b095
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
@@ -0,0 +1,406 @@
+#
+# 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.Thrift import *
+
+
+class TProtocolException(TException):
+  """Custom Protocol Exception class"""
+
+  UNKNOWN = 0
+  INVALID_DATA = 1
+  NEGATIVE_SIZE = 2
+  SIZE_LIMIT = 3
+  BAD_VERSION = 4
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
+
+class TProtocolBase:
+  """Base class for Thrift protocol driver."""
+
+  def __init__(self, trans):
+    self.trans = trans
+
+  def writeMessageBegin(self, name, ttype, seqid):
+    pass
+
+  def writeMessageEnd(self):
+    pass
+
+  def writeStructBegin(self, name):
+    pass
+
+  def writeStructEnd(self):
+    pass
+
+  def writeFieldBegin(self, name, ttype, fid):
+    pass
+
+  def writeFieldEnd(self):
+    pass
+
+  def writeFieldStop(self):
+    pass
+
+  def writeMapBegin(self, ktype, vtype, size):
+    pass
+
+  def writeMapEnd(self):
+    pass
+
+  def writeListBegin(self, etype, size):
+    pass
+
+  def writeListEnd(self):
+    pass
+
+  def writeSetBegin(self, etype, size):
+    pass
+
+  def writeSetEnd(self):
+    pass
+
+  def writeBool(self, bool_val):
+    pass
+
+  def writeByte(self, byte):
+    pass
+
+  def writeI16(self, i16):
+    pass
+
+  def writeI32(self, i32):
+    pass
+
+  def writeI64(self, i64):
+    pass
+
+  def writeDouble(self, dub):
+    pass
+
+  def writeString(self, str_val):
+    pass
+
+  def readMessageBegin(self):
+    pass
+
+  def readMessageEnd(self):
+    pass
+
+  def readStructBegin(self):
+    pass
+
+  def readStructEnd(self):
+    pass
+
+  def readFieldBegin(self):
+    pass
+
+  def readFieldEnd(self):
+    pass
+
+  def readMapBegin(self):
+    pass
+
+  def readMapEnd(self):
+    pass
+
+  def readListBegin(self):
+    pass
+
+  def readListEnd(self):
+    pass
+
+  def readSetBegin(self):
+    pass
+
+  def readSetEnd(self):
+    pass
+
+  def readBool(self):
+    pass
+
+  def readByte(self):
+    pass
+
+  def readI16(self):
+    pass
+
+  def readI32(self):
+    pass
+
+  def readI64(self):
+    pass
+
+  def readDouble(self):
+    pass
+
+  def readString(self):
+    pass
+
+  def skip(self, ttype):
+    if ttype == TType.STOP:
+      return
+    elif ttype == TType.BOOL:
+      self.readBool()
+    elif ttype == TType.BYTE:
+      self.readByte()
+    elif ttype == TType.I16:
+      self.readI16()
+    elif ttype == TType.I32:
+      self.readI32()
+    elif ttype == TType.I64:
+      self.readI64()
+    elif ttype == TType.DOUBLE:
+      self.readDouble()
+    elif ttype == TType.STRING:
+      self.readString()
+    elif ttype == TType.STRUCT:
+      name = self.readStructBegin()
+      while True:
+        (name, ttype, id) = self.readFieldBegin()
+        if ttype == TType.STOP:
+          break
+        self.skip(ttype)
+        self.readFieldEnd()
+      self.readStructEnd()
+    elif ttype == TType.MAP:
+      (ktype, vtype, size) = self.readMapBegin()
+      for i in xrange(size):
+        self.skip(ktype)
+        self.skip(vtype)
+      self.readMapEnd()
+    elif ttype == TType.SET:
+      (etype, size) = self.readSetBegin()
+      for i in xrange(size):
+        self.skip(etype)
+      self.readSetEnd()
+    elif ttype == TType.LIST:
+      (etype, size) = self.readListBegin()
+      for i in xrange(size):
+        self.skip(etype)
+      self.readListEnd()
+
+  # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
+  _TTYPE_HANDLERS = (
+       (None, None, False),  # 0 TType.STOP
+       (None, None, False),  # 1 TType.VOID # TODO: handle void?
+       ('readBool', 'writeBool', False),  # 2 TType.BOOL
+       ('readByte',  'writeByte', False),  # 3 TType.BYTE and I08
+       ('readDouble', 'writeDouble', False),  # 4 TType.DOUBLE
+       (None, None, False),  # 5 undefined
+       ('readI16', 'writeI16', False),  # 6 TType.I16
+       (None, None, False),  # 7 undefined
+       ('readI32', 'writeI32', False),  # 8 TType.I32
+       (None, None, False),  # 9 undefined
+       ('readI64', 'writeI64', False),  # 10 TType.I64
+       ('readString', 'writeString', False),  # 11 TType.STRING and UTF7
+       ('readContainerStruct', 'writeContainerStruct', True),  # 12 *.STRUCT
+       ('readContainerMap', 'writeContainerMap', True),  # 13 TType.MAP
+       ('readContainerSet', 'writeContainerSet', True),  # 14 TType.SET
+       ('readContainerList', 'writeContainerList', True),  # 15 TType.LIST
+       (None, None, False),  # 16 TType.UTF8 # TODO: handle utf8 types?
+       (None, None, False)  # 17 TType.UTF16 # TODO: handle utf16 types?
+      )
+
+  def readFieldByTType(self, ttype, spec):
+    try:
+      (r_handler, w_handler, is_container) = self._TTYPE_HANDLERS[ttype]
+    except IndexError:
+      raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                               message='Invalid field type %d' % (ttype))
+    if r_handler is None:
+      raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                               message='Invalid field type %d' % (ttype))
+    reader = getattr(self, r_handler)
+    if not is_container:
+      return reader()
+    return reader(spec)
+
+  def readContainerList(self, spec):
+    results = []
+    ttype, tspec = spec[0], spec[1]
+    r_handler = self._TTYPE_HANDLERS[ttype][0]
+    reader = getattr(self, r_handler)
+    (list_type, list_len) = self.readListBegin()
+    if tspec is None:
+      # list values are simple types
+      for idx in xrange(list_len):
+        results.append(reader())
+    else:
+      # this is like an inlined readFieldByTType
+      container_reader = self._TTYPE_HANDLERS[list_type][0]
+      val_reader = getattr(self, container_reader)
+      for idx in xrange(list_len):
+        val = val_reader(tspec)
+        results.append(val)
+    self.readListEnd()
+    return results
+
+  def readContainerSet(self, spec):
+    results = set()
+    ttype, tspec = spec[0], spec[1]
+    r_handler = self._TTYPE_HANDLERS[ttype][0]
+    reader = getattr(self, r_handler)
+    (set_type, set_len) = self.readSetBegin()
+    if tspec is None:
+      # set members are simple types
+      for idx in xrange(set_len):
+        results.add(reader())
+    else:
+      container_reader = self._TTYPE_HANDLERS[set_type][0]
+      val_reader = getattr(self, container_reader)
+      for idx in xrange(set_len):
+        results.add(val_reader(tspec))
+    self.readSetEnd()
+    return results
+
+  def readContainerStruct(self, spec):
+    (obj_class, obj_spec) = spec
+    obj = obj_class()
+    obj.read(self)
+    return obj
+
+  def readContainerMap(self, spec):
+    results = dict()
+    key_ttype, key_spec = spec[0], spec[1]
+    val_ttype, val_spec = spec[2], spec[3]
+    (map_ktype, map_vtype, map_len) = self.readMapBegin()
+    # TODO: compare types we just decoded with thrift_spec and
+    # abort/skip if types disagree
+    key_reader = getattr(self, self._TTYPE_HANDLERS[key_ttype][0])
+    val_reader = getattr(self, self._TTYPE_HANDLERS[val_ttype][0])
+    # list values are simple types
+    for idx in xrange(map_len):
+      if key_spec is None:
+        k_val = key_reader()
+      else:
+        k_val = self.readFieldByTType(key_ttype, key_spec)
+      if val_spec is None:
+        v_val = val_reader()
+      else:
+        v_val = self.readFieldByTType(val_ttype, val_spec)
+      # this raises a TypeError with unhashable keys types
+      # i.e. this fails: d=dict(); d[[0,1]] = 2
+      results[k_val] = v_val
+    self.readMapEnd()
+    return results
+
+  def readStruct(self, obj, thrift_spec):
+    self.readStructBegin()
+    while True:
+      (fname, ftype, fid) = self.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      try:
+        field = thrift_spec[fid]
+      except IndexError:
+        self.skip(ftype)
+      else:
+        if field is not None and ftype == field[1]:
+          fname = field[2]
+          fspec = field[3]
+          val = self.readFieldByTType(ftype, fspec)
+          setattr(obj, fname, val)
+        else:
+          self.skip(ftype)
+      self.readFieldEnd()
+    self.readStructEnd()
+
+  def writeContainerStruct(self, val, spec):
+    val.write(self)
+
+  def writeContainerList(self, val, spec):
+    self.writeListBegin(spec[0], len(val))
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
+    e_writer = getattr(self, w_handler)
+    if not is_container:
+      for elem in val:
+        e_writer(elem)
+    else:
+      for elem in val:
+        e_writer(elem, spec[1])
+    self.writeListEnd()
+
+  def writeContainerSet(self, val, spec):
+    self.writeSetBegin(spec[0], len(val))
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
+    e_writer = getattr(self, w_handler)
+    if not is_container:
+      for elem in val:
+        e_writer(elem)
+    else:
+      for elem in val:
+        e_writer(elem, spec[1])
+    self.writeSetEnd()
+
+  def writeContainerMap(self, val, spec):
+    k_type = spec[0]
+    v_type = spec[2]
+    ignore, ktype_name, k_is_container = self._TTYPE_HANDLERS[k_type]
+    ignore, vtype_name, v_is_container = self._TTYPE_HANDLERS[v_type]
+    k_writer = getattr(self, ktype_name)
+    v_writer = getattr(self, vtype_name)
+    self.writeMapBegin(k_type, v_type, len(val))
+    for m_key, m_val in val.iteritems():
+      if not k_is_container:
+        k_writer(m_key)
+      else:
+        k_writer(m_key, spec[1])
+      if not v_is_container:
+        v_writer(m_val)
+      else:
+        v_writer(m_val, spec[3])
+    self.writeMapEnd()
+
+  def writeStruct(self, obj, thrift_spec):
+    self.writeStructBegin(obj.__class__.__name__)
+    for field in thrift_spec:
+      if field is None:
+        continue
+      fname = field[2]
+      val = getattr(obj, fname)
+      if val is None:
+        # skip writing out unset fields
+        continue
+      fid = field[0]
+      ftype = field[1]
+      fspec = field[3]
+      # get the writer method for this value
+      self.writeFieldBegin(fname, ftype, fid)
+      self.writeFieldByTType(ftype, val, fspec)
+      self.writeFieldEnd()
+    self.writeFieldStop()
+    self.writeStructEnd()
+
+  def writeFieldByTType(self, ttype, val, spec):
+    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[ttype]
+    writer = getattr(self, w_handler)
+    if is_container:
+      writer(val, spec)
+    else:
+      writer(val)
+
+
+class TProtocolFactory:
+  def getProtocol(self, trans):
+    pass

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/__init__.py
new file mode 100644
index 0000000..7eefb45
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/__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__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol', 'TJSONProtocol', 'TProtocol']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/fastbinary.c
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/fastbinary.c b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/fastbinary.c
new file mode 100644
index 0000000..2ce5660
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/fastbinary.c
@@ -0,0 +1,1219 @@
+/*
+ * 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.
+ */
+
+#include <Python.h>
+#include "cStringIO.h"
+#include <stdint.h>
+#ifndef _WIN32
+# include <stdbool.h>
+# include <netinet/in.h>
+#else
+# include <WinSock2.h>
+# pragma comment (lib, "ws2_32.lib")
+# define BIG_ENDIAN (4321)
+# define LITTLE_ENDIAN (1234)
+# define BYTE_ORDER LITTLE_ENDIAN
+# if defined(_MSC_VER) && _MSC_VER < 1600
+   typedef int _Bool;
+#  define bool _Bool
+#  define false 0 
+#  define true 1
+# endif
+# define inline __inline
+#endif
+
+/* Fix endianness issues on Solaris */
+#if defined (__SVR4) && defined (__sun)
+ #if defined(__i386) && !defined(__i386__)
+  #define __i386__
+ #endif
+
+ #ifndef BIG_ENDIAN
+  #define BIG_ENDIAN (4321)
+ #endif
+ #ifndef LITTLE_ENDIAN
+  #define LITTLE_ENDIAN (1234)
+ #endif
+
+ /* I386 is LE, even on Solaris */
+ #if !defined(BYTE_ORDER) && defined(__i386__)
+  #define BYTE_ORDER LITTLE_ENDIAN
+ #endif
+#endif
+
+// TODO(dreiss): defval appears to be unused.  Look into removing it.
+// TODO(dreiss): Make parse_spec_args recursive, and cache the output
+//               permanently in the object.  (Malloc and orphan.)
+// TODO(dreiss): Why do we need cStringIO for reading, why not just char*?
+//               Can cStringIO let us work with a BufferedTransport?
+// TODO(dreiss): Don't ignore the rv from cwrite (maybe).
+
+/* ====== BEGIN UTILITIES ====== */
+
+#define INIT_OUTBUF_SIZE 128
+
+// Stolen out of TProtocol.h.
+// It would be a huge pain to have both get this from one place.
+typedef enum TType {
+  T_STOP       = 0,
+  T_VOID       = 1,
+  T_BOOL       = 2,
+  T_BYTE       = 3,
+  T_I08        = 3,
+  T_I16        = 6,
+  T_I32        = 8,
+  T_U64        = 9,
+  T_I64        = 10,
+  T_DOUBLE     = 4,
+  T_STRING     = 11,
+  T_UTF7       = 11,
+  T_STRUCT     = 12,
+  T_MAP        = 13,
+  T_SET        = 14,
+  T_LIST       = 15,
+  T_UTF8       = 16,
+  T_UTF16      = 17
+} TType;
+
+#ifndef __BYTE_ORDER
+# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
+#  define __BYTE_ORDER BYTE_ORDER
+#  define __LITTLE_ENDIAN LITTLE_ENDIAN
+#  define __BIG_ENDIAN BIG_ENDIAN
+# else
+#  error "Cannot determine endianness"
+# endif
+#endif
+
+// Same comment as the enum.  Sorry.
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ntohll(n) (n)
+# define htonll(n) (n)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# if defined(__GNUC__) && defined(__GLIBC__)
+#  include <byteswap.h>
+#  define ntohll(n) bswap_64(n)
+#  define htonll(n) bswap_64(n)
+# else /* GNUC & GLIBC */
+#  define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) )
+#  define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) )
+# endif /* GNUC & GLIBC */
+#else /* __BYTE_ORDER */
+# error "Can't define htonll or ntohll!"
+#endif
+
+// Doing a benchmark shows that interning actually makes a difference, amazingly.
+#define INTERN_STRING(value) _intern_ ## value
+
+#define INT_CONV_ERROR_OCCURRED(v) ( ((v) == -1) && PyErr_Occurred() )
+#define CHECK_RANGE(v, min, max) ( ((v) <= (max)) && ((v) >= (min)) )
+
+// Py_ssize_t was not defined before Python 2.5
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#endif
+
+/**
+ * A cache of the spec_args for a set or list,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  TType element_type;
+  PyObject* typeargs;
+} SetListTypeArgs;
+
+/**
+ * A cache of the spec_args for a map,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  TType ktag;
+  TType vtag;
+  PyObject* ktypeargs;
+  PyObject* vtypeargs;
+} MapTypeArgs;
+
+/**
+ * A cache of the spec_args for a struct,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  PyObject* klass;
+  PyObject* spec;
+} StructTypeArgs;
+
+/**
+ * A cache of the item spec from a struct specification,
+ * so we don't have to keep calling PyTuple_GET_ITEM.
+ */
+typedef struct {
+  int tag;
+  TType type;
+  PyObject* attrname;
+  PyObject* typeargs;
+  PyObject* defval;
+} StructItemSpec;
+
+/**
+ * A cache of the two key attributes of a CReadableTransport,
+ * so we don't have to keep calling PyObject_GetAttr.
+ */
+typedef struct {
+  PyObject* stringiobuf;
+  PyObject* refill_callable;
+} DecodeBuffer;
+
+/** Pointer to interned string to speed up attribute lookup. */
+static PyObject* INTERN_STRING(cstringio_buf);
+/** Pointer to interned string to speed up attribute lookup. */
+static PyObject* INTERN_STRING(cstringio_refill);
+
+static inline bool
+check_ssize_t_32(Py_ssize_t len) {
+  // error from getting the int
+  if (INT_CONV_ERROR_OCCURRED(len)) {
+    return false;
+  }
+  if (!CHECK_RANGE(len, 0, INT32_MAX)) {
+    PyErr_SetString(PyExc_OverflowError, "string size out of range");
+    return false;
+  }
+  return true;
+}
+
+static inline bool
+parse_pyint(PyObject* o, int32_t* ret, int32_t min, int32_t max) {
+  long val = PyInt_AsLong(o);
+
+  if (INT_CONV_ERROR_OCCURRED(val)) {
+    return false;
+  }
+  if (!CHECK_RANGE(val, min, max)) {
+    PyErr_SetString(PyExc_OverflowError, "int out of range");
+    return false;
+  }
+
+  *ret = (int32_t) val;
+  return true;
+}
+
+
+/* --- FUNCTIONS TO PARSE STRUCT SPECIFICATOINS --- */
+
+static bool
+parse_set_list_args(SetListTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 2) {
+    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for list/set type args");
+    return false;
+  }
+
+  dest->element_type = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->element_type)) {
+    return false;
+  }
+
+  dest->typeargs = PyTuple_GET_ITEM(typeargs, 1);
+
+  return true;
+}
+
+static bool
+parse_map_args(MapTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 4) {
+    PyErr_SetString(PyExc_TypeError, "expecting 4 arguments for typeargs to map");
+    return false;
+  }
+
+  dest->ktag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->ktag)) {
+    return false;
+  }
+
+  dest->vtag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 2));
+  if (INT_CONV_ERROR_OCCURRED(dest->vtag)) {
+    return false;
+  }
+
+  dest->ktypeargs = PyTuple_GET_ITEM(typeargs, 1);
+  dest->vtypeargs = PyTuple_GET_ITEM(typeargs, 3);
+
+  return true;
+}
+
+static bool
+parse_struct_args(StructTypeArgs* dest, PyObject* typeargs) {
+  if (PyTuple_Size(typeargs) != 2) {
+    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for struct args");
+    return false;
+  }
+
+  dest->klass = PyTuple_GET_ITEM(typeargs, 0);
+  dest->spec = PyTuple_GET_ITEM(typeargs, 1);
+
+  return true;
+}
+
+static int
+parse_struct_item_spec(StructItemSpec* dest, PyObject* spec_tuple) {
+
+  // i'd like to use ParseArgs here, but it seems to be a bottleneck.
+  if (PyTuple_Size(spec_tuple) != 5) {
+    PyErr_SetString(PyExc_TypeError, "expecting 5 arguments for spec tuple");
+    return false;
+  }
+
+  dest->tag = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 0));
+  if (INT_CONV_ERROR_OCCURRED(dest->tag)) {
+    return false;
+  }
+
+  dest->type = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 1));
+  if (INT_CONV_ERROR_OCCURRED(dest->type)) {
+    return false;
+  }
+
+  dest->attrname = PyTuple_GET_ITEM(spec_tuple, 2);
+  dest->typeargs = PyTuple_GET_ITEM(spec_tuple, 3);
+  dest->defval = PyTuple_GET_ITEM(spec_tuple, 4);
+  return true;
+}
+
+/* ====== END UTILITIES ====== */
+
+
+/* ====== BEGIN WRITING FUNCTIONS ====== */
+
+/* --- LOW-LEVEL WRITING FUNCTIONS --- */
+
+static void writeByte(PyObject* outbuf, int8_t val) {
+  int8_t net = val;
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int8_t));
+}
+
+static void writeI16(PyObject* outbuf, int16_t val) {
+  int16_t net = (int16_t)htons(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int16_t));
+}
+
+static void writeI32(PyObject* outbuf, int32_t val) {
+  int32_t net = (int32_t)htonl(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int32_t));
+}
+
+static void writeI64(PyObject* outbuf, int64_t val) {
+  int64_t net = (int64_t)htonll(val);
+  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int64_t));
+}
+
+static void writeDouble(PyObject* outbuf, double dub) {
+  // Unfortunately, bitwise_cast doesn't work in C.  Bad C!
+  union {
+    double f;
+    int64_t t;
+  } transfer;
+  transfer.f = dub;
+  writeI64(outbuf, transfer.t);
+}
+
+
+/* --- MAIN RECURSIVE OUTPUT FUCNTION -- */
+
+static int
+output_val(PyObject* output, PyObject* value, TType type, PyObject* typeargs) {
+  /*
+   * Refcounting Strategy:
+   *
+   * We assume that elements of the thrift_spec tuple are not going to be
+   * mutated, so we don't ref count those at all. Other than that, we try to
+   * keep a reference to all the user-created objects while we work with them.
+   * output_val assumes that a reference is already held. The *caller* is
+   * responsible for handling references
+   */
+
+  switch (type) {
+
+  case T_BOOL: {
+    int v = PyObject_IsTrue(value);
+    if (v == -1) {
+      return false;
+    }
+
+    writeByte(output, (int8_t) v);
+    break;
+  }
+  case T_I08: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT8_MIN, INT8_MAX)) {
+      return false;
+    }
+
+    writeByte(output, (int8_t) val);
+    break;
+  }
+  case T_I16: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT16_MIN, INT16_MAX)) {
+      return false;
+    }
+
+    writeI16(output, (int16_t) val);
+    break;
+  }
+  case T_I32: {
+    int32_t val;
+
+    if (!parse_pyint(value, &val, INT32_MIN, INT32_MAX)) {
+      return false;
+    }
+
+    writeI32(output, val);
+    break;
+  }
+  case T_I64: {
+    int64_t nval = PyLong_AsLongLong(value);
+
+    if (INT_CONV_ERROR_OCCURRED(nval)) {
+      return false;
+    }
+
+    if (!CHECK_RANGE(nval, INT64_MIN, INT64_MAX)) {
+      PyErr_SetString(PyExc_OverflowError, "int out of range");
+      return false;
+    }
+
+    writeI64(output, nval);
+    break;
+  }
+
+  case T_DOUBLE: {
+    double nval = PyFloat_AsDouble(value);
+    if (nval == -1.0 && PyErr_Occurred()) {
+      return false;
+    }
+
+    writeDouble(output, nval);
+    break;
+  }
+
+  case T_STRING: {
+    Py_ssize_t len = PyString_Size(value);
+
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    writeI32(output, (int32_t) len);
+    PycStringIO->cwrite(output, PyString_AsString(value), (int32_t) len);
+    break;
+  }
+
+  case T_LIST:
+  case T_SET: {
+    Py_ssize_t len;
+    SetListTypeArgs parsedargs;
+    PyObject *item;
+    PyObject *iterator;
+
+    if (!parse_set_list_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    len = PyObject_Length(value);
+
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    writeByte(output, parsedargs.element_type);
+    writeI32(output, (int32_t) len);
+
+    iterator =  PyObject_GetIter(value);
+    if (iterator == NULL) {
+      return false;
+    }
+
+    while ((item = PyIter_Next(iterator))) {
+      if (!output_val(output, item, parsedargs.element_type, parsedargs.typeargs)) {
+        Py_DECREF(item);
+        Py_DECREF(iterator);
+        return false;
+      }
+      Py_DECREF(item);
+    }
+
+    Py_DECREF(iterator);
+
+    if (PyErr_Occurred()) {
+      return false;
+    }
+
+    break;
+  }
+
+  case T_MAP: {
+    PyObject *k, *v;
+    Py_ssize_t pos = 0;
+    Py_ssize_t len;
+
+    MapTypeArgs parsedargs;
+
+    len = PyDict_Size(value);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    if (!parse_map_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    writeByte(output, parsedargs.ktag);
+    writeByte(output, parsedargs.vtag);
+    writeI32(output, len);
+
+    // TODO(bmaurer): should support any mapping, not just dicts
+    while (PyDict_Next(value, &pos, &k, &v)) {
+      // TODO(dreiss): Think hard about whether these INCREFs actually
+      //               turn any unsafe scenarios into safe scenarios.
+      Py_INCREF(k);
+      Py_INCREF(v);
+
+      if (!output_val(output, k, parsedargs.ktag, parsedargs.ktypeargs)
+          || !output_val(output, v, parsedargs.vtag, parsedargs.vtypeargs)) {
+        Py_DECREF(k);
+        Py_DECREF(v);
+        return false;
+      }
+      Py_DECREF(k);
+      Py_DECREF(v);
+    }
+    break;
+  }
+
+  // TODO(dreiss): Consider breaking this out as a function
+  //               the way we did for decode_struct.
+  case T_STRUCT: {
+    StructTypeArgs parsedargs;
+    Py_ssize_t nspec;
+    Py_ssize_t i;
+
+    if (!parse_struct_args(&parsedargs, typeargs)) {
+      return false;
+    }
+
+    nspec = PyTuple_Size(parsedargs.spec);
+
+    if (nspec == -1) {
+      return false;
+    }
+
+    for (i = 0; i < nspec; i++) {
+      StructItemSpec parsedspec;
+      PyObject* spec_tuple;
+      PyObject* instval = NULL;
+
+      spec_tuple = PyTuple_GET_ITEM(parsedargs.spec, i);
+      if (spec_tuple == Py_None) {
+        continue;
+      }
+
+      if (!parse_struct_item_spec (&parsedspec, spec_tuple)) {
+        return false;
+      }
+
+      instval = PyObject_GetAttr(value, parsedspec.attrname);
+
+      if (!instval) {
+        return false;
+      }
+
+      if (instval == Py_None) {
+        Py_DECREF(instval);
+        continue;
+      }
+
+      writeByte(output, (int8_t) parsedspec.type);
+      writeI16(output, parsedspec.tag);
+
+      if (!output_val(output, instval, parsedspec.type, parsedspec.typeargs)) {
+        Py_DECREF(instval);
+        return false;
+      }
+
+      Py_DECREF(instval);
+    }
+
+    writeByte(output, (int8_t)T_STOP);
+    break;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return false;
+
+  }
+
+  return true;
+}
+
+
+/* --- TOP-LEVEL WRAPPER FOR OUTPUT -- */
+
+static PyObject *
+encode_binary(PyObject *self, PyObject *args) {
+  PyObject* enc_obj;
+  PyObject* type_args;
+  PyObject* buf;
+  PyObject* ret = NULL;
+
+  if (!PyArg_ParseTuple(args, "OO", &enc_obj, &type_args)) {
+    return NULL;
+  }
+
+  buf = PycStringIO->NewOutput(INIT_OUTBUF_SIZE);
+  if (output_val(buf, enc_obj, T_STRUCT, type_args)) {
+    ret = PycStringIO->cgetvalue(buf);
+  }
+
+  Py_DECREF(buf);
+  return ret;
+}
+
+/* ====== END WRITING FUNCTIONS ====== */
+
+
+/* ====== BEGIN READING FUNCTIONS ====== */
+
+/* --- LOW-LEVEL READING FUNCTIONS --- */
+
+static void
+free_decodebuf(DecodeBuffer* d) {
+  Py_XDECREF(d->stringiobuf);
+  Py_XDECREF(d->refill_callable);
+}
+
+static bool
+decode_buffer_from_obj(DecodeBuffer* dest, PyObject* obj) {
+  dest->stringiobuf = PyObject_GetAttr(obj, INTERN_STRING(cstringio_buf));
+  if (!dest->stringiobuf) {
+    return false;
+  }
+
+  if (!PycStringIO_InputCheck(dest->stringiobuf)) {
+    free_decodebuf(dest);
+    PyErr_SetString(PyExc_TypeError, "expecting stringio input");
+    return false;
+  }
+
+  dest->refill_callable = PyObject_GetAttr(obj, INTERN_STRING(cstringio_refill));
+
+  if(!dest->refill_callable) {
+    free_decodebuf(dest);
+    return false;
+  }
+
+  if (!PyCallable_Check(dest->refill_callable)) {
+    free_decodebuf(dest);
+    PyErr_SetString(PyExc_TypeError, "expecting callable");
+    return false;
+  }
+
+  return true;
+}
+
+static bool readBytes(DecodeBuffer* input, char** output, int len) {
+  int read;
+
+  // TODO(dreiss): Don't fear the malloc.  Think about taking a copy of
+  //               the partial read instead of forcing the transport
+  //               to prepend it to its buffer.
+
+  read = PycStringIO->cread(input->stringiobuf, output, len);
+
+  if (read == len) {
+    return true;
+  } else if (read == -1) {
+    return false;
+  } else {
+    PyObject* newiobuf;
+
+    // using building functions as this is a rare codepath
+    newiobuf = PyObject_CallFunction(
+        input->refill_callable, "s#i", *output, read, len, NULL);
+    if (newiobuf == NULL) {
+      return false;
+    }
+
+    // must do this *AFTER* the call so that we don't deref the io buffer
+    Py_CLEAR(input->stringiobuf);
+    input->stringiobuf = newiobuf;
+
+    read = PycStringIO->cread(input->stringiobuf, output, len);
+
+    if (read == len) {
+      return true;
+    } else if (read == -1) {
+      return false;
+    } else {
+      // TODO(dreiss): This could be a valid code path for big binary blobs.
+      PyErr_SetString(PyExc_TypeError,
+          "refill claimed to have refilled the buffer, but didn't!!");
+      return false;
+    }
+  }
+}
+
+static int8_t readByte(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int8_t))) {
+    return -1;
+  }
+
+  return *(int8_t*) buf;
+}
+
+static int16_t readI16(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int16_t))) {
+    return -1;
+  }
+
+  return (int16_t) ntohs(*(int16_t*) buf);
+}
+
+static int32_t readI32(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int32_t))) {
+    return -1;
+  }
+  return (int32_t) ntohl(*(int32_t*) buf);
+}
+
+
+static int64_t readI64(DecodeBuffer* input) {
+  char* buf;
+  if (!readBytes(input, &buf, sizeof(int64_t))) {
+    return -1;
+  }
+
+  return (int64_t) ntohll(*(int64_t*) buf);
+}
+
+static double readDouble(DecodeBuffer* input) {
+  union {
+    int64_t f;
+    double t;
+  } transfer;
+
+  transfer.f = readI64(input);
+  if (transfer.f == -1) {
+    return -1;
+  }
+  return transfer.t;
+}
+
+static bool
+checkTypeByte(DecodeBuffer* input, TType expected) {
+  TType got = readByte(input);
+  if (INT_CONV_ERROR_OCCURRED(got)) {
+    return false;
+  }
+
+  if (expected != got) {
+    PyErr_SetString(PyExc_TypeError, "got wrong ttype while reading field");
+    return false;
+  }
+  return true;
+}
+
+static bool
+skip(DecodeBuffer* input, TType type) {
+#define SKIPBYTES(n) \
+  do { \
+    if (!readBytes(input, &dummy_buf, (n))) { \
+      return false; \
+    } \
+  } while(0)
+
+  char* dummy_buf;
+
+  switch (type) {
+
+  case T_BOOL:
+  case T_I08: SKIPBYTES(1); break;
+  case T_I16: SKIPBYTES(2); break;
+  case T_I32: SKIPBYTES(4); break;
+  case T_I64:
+  case T_DOUBLE: SKIPBYTES(8); break;
+
+  case T_STRING: {
+    // TODO(dreiss): Find out if these check_ssize_t32s are really necessary.
+    int len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+    SKIPBYTES(len);
+    break;
+  }
+
+  case T_LIST:
+  case T_SET: {
+    TType etype;
+    int len, i;
+
+    etype = readByte(input);
+    if (etype == -1) {
+      return false;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    for (i = 0; i < len; i++) {
+      if (!skip(input, etype)) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_MAP: {
+    TType ktype, vtype;
+    int len, i;
+
+    ktype = readByte(input);
+    if (ktype == -1) {
+      return false;
+    }
+
+    vtype = readByte(input);
+    if (vtype == -1) {
+      return false;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    for (i = 0; i < len; i++) {
+      if (!(skip(input, ktype) && skip(input, vtype))) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_STRUCT: {
+    while (true) {
+      TType type;
+
+      type = readByte(input);
+      if (type == -1) {
+        return false;
+      }
+
+      if (type == T_STOP)
+        break;
+
+      SKIPBYTES(2); // tag
+      if (!skip(input, type)) {
+        return false;
+      }
+    }
+    break;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return false;
+
+  }
+
+  return true;
+
+#undef SKIPBYTES
+}
+
+
+/* --- HELPER FUNCTION FOR DECODE_VAL --- */
+
+static PyObject*
+decode_val(DecodeBuffer* input, TType type, PyObject* typeargs);
+
+static bool
+decode_struct(DecodeBuffer* input, PyObject* output, PyObject* spec_seq) {
+  int spec_seq_len = PyTuple_Size(spec_seq);
+  if (spec_seq_len == -1) {
+    return false;
+  }
+
+  while (true) {
+    TType type;
+    int16_t tag;
+    PyObject* item_spec;
+    PyObject* fieldval = NULL;
+    StructItemSpec parsedspec;
+
+    type = readByte(input);
+    if (type == -1) {
+      return false;
+    }
+    if (type == T_STOP) {
+      break;
+    }
+    tag = readI16(input);
+    if (INT_CONV_ERROR_OCCURRED(tag)) {
+      return false;
+    }
+    if (tag >= 0 && tag < spec_seq_len) {
+      item_spec = PyTuple_GET_ITEM(spec_seq, tag);
+    } else {
+      item_spec = Py_None;
+    }
+
+    if (item_spec == Py_None) {
+      if (!skip(input, type)) {
+        return false;
+      } else {
+        continue;
+      }
+    }
+
+    if (!parse_struct_item_spec(&parsedspec, item_spec)) {
+      return false;
+    }
+    if (parsedspec.type != type) {
+      if (!skip(input, type)) {
+        PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading and can't be skipped");
+        return false;
+      } else {
+        continue;
+      }
+    }
+
+    fieldval = decode_val(input, parsedspec.type, parsedspec.typeargs);
+    if (fieldval == NULL) {
+      return false;
+    }
+
+    if (PyObject_SetAttr(output, parsedspec.attrname, fieldval) == -1) {
+      Py_DECREF(fieldval);
+      return false;
+    }
+    Py_DECREF(fieldval);
+  }
+  return true;
+}
+
+
+/* --- MAIN RECURSIVE INPUT FUCNTION --- */
+
+// Returns a new reference.
+static PyObject*
+decode_val(DecodeBuffer* input, TType type, PyObject* typeargs) {
+  switch (type) {
+
+  case T_BOOL: {
+    int8_t v = readByte(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+
+    switch (v) {
+    case 0: Py_RETURN_FALSE;
+    case 1: Py_RETURN_TRUE;
+    // Don't laugh.  This is a potentially serious issue.
+    default: PyErr_SetString(PyExc_TypeError, "boolean out of range"); return NULL;
+    }
+    break;
+  }
+  case T_I08: {
+    int8_t v = readByte(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+
+    return PyInt_FromLong(v);
+  }
+  case T_I16: {
+    int16_t v = readI16(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    return PyInt_FromLong(v);
+  }
+  case T_I32: {
+    int32_t v = readI32(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    return PyInt_FromLong(v);
+  }
+
+  case T_I64: {
+    int64_t v = readI64(input);
+    if (INT_CONV_ERROR_OCCURRED(v)) {
+      return NULL;
+    }
+    // TODO(dreiss): Find out if we can take this fastpath always when
+    //               sizeof(long) == sizeof(long long).
+    if (CHECK_RANGE(v, LONG_MIN, LONG_MAX)) {
+      return PyInt_FromLong((long) v);
+    }
+
+    return PyLong_FromLongLong(v);
+  }
+
+  case T_DOUBLE: {
+    double v = readDouble(input);
+    if (v == -1.0 && PyErr_Occurred()) {
+      return false;
+    }
+    return PyFloat_FromDouble(v);
+  }
+
+  case T_STRING: {
+    Py_ssize_t len = readI32(input);
+    char* buf;
+    if (!readBytes(input, &buf, len)) {
+      return NULL;
+    }
+
+    return PyString_FromStringAndSize(buf, len);
+  }
+
+  case T_LIST:
+  case T_SET: {
+    SetListTypeArgs parsedargs;
+    int32_t len;
+    PyObject* ret = NULL;
+    int i;
+
+    if (!parse_set_list_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    if (!checkTypeByte(input, parsedargs.element_type)) {
+      return NULL;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return NULL;
+    }
+
+    ret = PyList_New(len);
+    if (!ret) {
+      return NULL;
+    }
+
+    for (i = 0; i < len; i++) {
+      PyObject* item = decode_val(input, parsedargs.element_type, parsedargs.typeargs);
+      if (!item) {
+        Py_DECREF(ret);
+        return NULL;
+      }
+      PyList_SET_ITEM(ret, i, item);
+    }
+
+    // TODO(dreiss): Consider biting the bullet and making two separate cases
+    //               for list and set, avoiding this post facto conversion.
+    if (type == T_SET) {
+      PyObject* setret;
+#if (PY_VERSION_HEX < 0x02050000)
+      // hack needed for older versions
+      setret = PyObject_CallFunctionObjArgs((PyObject*)&PySet_Type, ret, NULL);
+#else
+      // official version
+      setret = PySet_New(ret);
+#endif
+      Py_DECREF(ret);
+      return setret;
+    }
+    return ret;
+  }
+
+  case T_MAP: {
+    int32_t len;
+    int i;
+    MapTypeArgs parsedargs;
+    PyObject* ret = NULL;
+
+    if (!parse_map_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    if (!checkTypeByte(input, parsedargs.ktag)) {
+      return NULL;
+    }
+    if (!checkTypeByte(input, parsedargs.vtag)) {
+      return NULL;
+    }
+
+    len = readI32(input);
+    if (!check_ssize_t_32(len)) {
+      return false;
+    }
+
+    ret = PyDict_New();
+    if (!ret) {
+      goto error;
+    }
+
+    for (i = 0; i < len; i++) {
+      PyObject* k = NULL;
+      PyObject* v = NULL;
+      k = decode_val(input, parsedargs.ktag, parsedargs.ktypeargs);
+      if (k == NULL) {
+        goto loop_error;
+      }
+      v = decode_val(input, parsedargs.vtag, parsedargs.vtypeargs);
+      if (v == NULL) {
+        goto loop_error;
+      }
+      if (PyDict_SetItem(ret, k, v) == -1) {
+        goto loop_error;
+      }
+
+      Py_DECREF(k);
+      Py_DECREF(v);
+      continue;
+
+      // Yuck!  Destructors, anyone?
+      loop_error:
+      Py_XDECREF(k);
+      Py_XDECREF(v);
+      goto error;
+    }
+
+    return ret;
+
+    error:
+    Py_XDECREF(ret);
+    return NULL;
+  }
+
+  case T_STRUCT: {
+    StructTypeArgs parsedargs;
+	PyObject* ret;
+    if (!parse_struct_args(&parsedargs, typeargs)) {
+      return NULL;
+    }
+
+    ret = PyObject_CallObject(parsedargs.klass, NULL);
+    if (!ret) {
+      return NULL;
+    }
+
+    if (!decode_struct(input, ret, parsedargs.spec)) {
+      Py_DECREF(ret);
+      return NULL;
+    }
+
+    return ret;
+  }
+
+  case T_STOP:
+  case T_VOID:
+  case T_UTF16:
+  case T_UTF8:
+  case T_U64:
+  default:
+    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
+    return NULL;
+  }
+}
+
+
+/* --- TOP-LEVEL WRAPPER FOR INPUT -- */
+
+static PyObject*
+decode_binary(PyObject *self, PyObject *args) {
+  PyObject* output_obj = NULL;
+  PyObject* transport = NULL;
+  PyObject* typeargs = NULL;
+  StructTypeArgs parsedargs;
+  DecodeBuffer input = {0, 0};
+  
+  if (!PyArg_ParseTuple(args, "OOO", &output_obj, &transport, &typeargs)) {
+    return NULL;
+  }
+
+  if (!parse_struct_args(&parsedargs, typeargs)) {
+    return NULL;
+  }
+
+  if (!decode_buffer_from_obj(&input, transport)) {
+    return NULL;
+  }
+
+  if (!decode_struct(&input, output_obj, parsedargs.spec)) {
+    free_decodebuf(&input);
+    return NULL;
+  }
+
+  free_decodebuf(&input);
+
+  Py_RETURN_NONE;
+}
+
+/* ====== END READING FUNCTIONS ====== */
+
+
+/* -- PYTHON MODULE SETUP STUFF --- */
+
+static PyMethodDef ThriftFastBinaryMethods[] = {
+
+  {"encode_binary",  encode_binary, METH_VARARGS, ""},
+  {"decode_binary",  decode_binary, METH_VARARGS, ""},
+
+  {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+PyMODINIT_FUNC
+initfastbinary(void) {
+#define INIT_INTERN_STRING(value) \
+  do { \
+    INTERN_STRING(value) = PyString_InternFromString(#value); \
+    if(!INTERN_STRING(value)) return; \
+  } while(0)
+
+  INIT_INTERN_STRING(cstringio_buf);
+  INIT_INTERN_STRING(cstringio_refill);
+#undef INIT_INTERN_STRING
+
+  PycString_IMPORT;
+  if (PycStringIO == NULL) return;
+
+  (void) Py_InitModule("thrift.protocol.fastbinary", ThriftFastBinaryMethods);
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
new file mode 100644
index 0000000..be54bab
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
@@ -0,0 +1,87 @@
+#
+# 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 BaseHTTPServer
+
+from thrift.server import TServer
+from thrift.transport import TTransport
+
+
+class ResponseException(Exception):
+  """Allows handlers to override the HTTP response
+
+  Normally, THttpServer always sends a 200 response.  If a handler wants
+  to override this behavior (e.g., to simulate a misconfigured or
+  overloaded web server during testing), it can raise a ResponseException.
+  The function passed to the constructor will be called with the
+  RequestHandler as its only argument.
+  """
+  def __init__(self, handler):
+    self.handler = handler
+
+
+class THttpServer(TServer.TServer):
+  """A simple HTTP-based Thrift server
+
+  This class is not very performant, but it is useful (for example) for
+  acting as a mock version of an Apache-based PHP Thrift endpoint.
+  """
+  def __init__(self,
+               processor,
+               server_address,
+               inputProtocolFactory,
+               outputProtocolFactory=None,
+               server_class=BaseHTTPServer.HTTPServer):
+    """Set up protocol factories and HTTP server.
+
+    See BaseHTTPServer for server_address.
+    See TServer for protocol factories.
+    """
+    if outputProtocolFactory is None:
+      outputProtocolFactory = inputProtocolFactory
+
+    TServer.TServer.__init__(self, processor, None, None, None,
+        inputProtocolFactory, outputProtocolFactory)
+
+    thttpserver = self
+
+    class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
+      def do_POST(self):
+        # Don't care about the request path.
+        itrans = TTransport.TFileObjectTransport(self.rfile)
+        otrans = TTransport.TFileObjectTransport(self.wfile)
+        itrans = TTransport.TBufferedTransport(
+          itrans, int(self.headers['Content-Length']))
+        otrans = TTransport.TMemoryBuffer()
+        iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
+        oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
+        try:
+          thttpserver.processor.process(iprot, oprot)
+        except ResponseException, exn:
+          exn.handler(self)
+        else:
+          self.send_response(200)
+          self.send_header("content-type", "application/x-thrift")
+          self.end_headers()
+          self.wfile.write(otrans.getvalue())
+
+    self.httpd = server_class(server_address, RequestHander)
+
+  def serve(self):
+    self.httpd.serve_forever()


[03/50] [abbrv] git commit: Fixed exception handling for non critical parameter reading Fixed incorrect use of the configuration class Fixed minor issues in agent.py

Posted by ni...@apache.org.
Fixed exception handling for non critical parameter reading
Fixed incorrect use of the configuration class
Fixed minor issues in agent.py


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/f85bc0a1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/f85bc0a1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/f85bc0a1

Branch: refs/heads/master
Commit: f85bc0a164a0334b0a7c35cadc02746bc95c3a79
Parents: b7c8985
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Sep 29 19:26:57 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:39:43 2014 +0530

----------------------------------------------------------------------
 .../broker/publish/EventPublisher.java          |  2 +-
 .../config/cartridgeagentconfiguration.py       |  2 +-
 .../extensions/defaultextensionhandler.py       | 16 ++++-----
 .../publisher/cartridgeagentpublisher.py        |  8 ++---
 .../modules/subscriber/eventsubscriber.py       | 16 +++++----
 .../modules/util/cartridgeagentconstants.py     |  2 +-
 .../modules/util/cartridgeagentutils.py         |  4 +--
 .../modules/util/extensionutils.py              | 38 ++++++++++----------
 8 files changed, 46 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
index 2ba4df4..92ae4da 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/broker/publish/EventPublisher.java
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
- */
+ */INSTANCE_STATUS_TOPIC
 
 package org.apache.stratos.messaging.broker.publish;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 32ff23f..3170e3d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -271,7 +271,7 @@ class CartridgeAgentConfiguration:
         :return: void
         """
 
-        param_file = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+        param_file = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
 
         try:
             if param_file is not None:

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 96b6fd5..6d49d8f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -56,7 +56,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             repo_username = artifacts_updated_event.repo_username
             tenant_id = artifacts_updated_event.tenant_id
-            is_multitenant = CartridgeAgentConfiguration.is_multitenant()
+            is_multitenant = CartridgeAgentConfiguration.is_multitenant
             commit_enabled = artifacts_updated_event.commit_enabled
 
             self.log.info("Executing git checkout")
@@ -82,15 +82,15 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 # publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 
-            update_artifacts = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE)
+            update_artifacts = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE, False)
             update_artifacts = True if str(update_artifacts).strip().lower() == "true" else False
             if update_artifacts:
-                auto_commit = CartridgeAgentConfiguration.is_commits_enabled()
-                auto_checkout = CartridgeAgentConfiguration.is_checkout_enabled()
+                auto_commit = CartridgeAgentConfiguration.is_commits_enabled
+                auto_checkout = CartridgeAgentConfiguration.is_checkout_enabled
 
                 try:
                     update_interval = len(
-                        CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL))
+                        CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL, False))
                 except ParameterNotFoundException:
                     self.log.exception("Invalid artifact sync interval specified ")
                     update_interval = 10
@@ -374,9 +374,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         extensionutils.wait_for_complete_topology()
         self.log.info("[start server extension] complete topology event received")
 
-        service_name_in_payload = CartridgeAgentConfiguration.service_name()
-        cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id()
-        member_id_in_payload = CartridgeAgentConfiguration.member_id()
+        service_name_in_payload = CartridgeAgentConfiguration.service_name
+        cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
+        member_id_in_payload = CartridgeAgentConfiguration.member_id
 
         topology_consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 1ad437b..a862967 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -31,7 +31,7 @@ def publish_instance_started_event():
 
         instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                       member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceStartedEvent")
         publisher.publish(instance_started_event)
         started = True
         log.info("Instance started event published")
@@ -51,7 +51,7 @@ def publish_instance_activated_event():
 
         instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceActivatedEvent")
         publisher.publish(instance_activated_event)
 
         log.info("Instance activated event published")
@@ -78,7 +78,7 @@ def publish_maintenance_mode_event():
         instance_maintenance_mode_event = InstanceMaintenanceModeEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
 
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceMaintenanceModeEvent")
         publisher.publish(instance_maintenance_mode_event)
 
         maintenance = True
@@ -101,7 +101,7 @@ def publish_instance_ready_to_shutdown_event():
         instance_shutdown_event = InstanceReadyToShutdownEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
 
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceReadyToShutdownEvent")
         publisher.publish(instance_shutdown_event)
 
         ready_to_shutdown = True

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index 6d29a68..8d418fa 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -60,13 +60,17 @@ class EventSubscriber(threading.Thread):
         self.log.debug("Message received: %r:\n%r" % (msg.topic, msg.payload))
 
         event = msg.topic.rpartition('/')[2]
-        handler = self.__event_handlers[event]
 
-        try:
-            self.log.debug("Executing handler for event %r" % event)
-            handler(msg)
-        except:
-            self.log.exception("Error processing %r event" % event)
+        if event in self.__event_handlers:
+            handler = self.__event_handlers[event]
+
+            try:
+                self.log.debug("Executing handler for event %r" % event)
+                handler(msg)
+            except:
+                self.log.exception("Error processing %r event" % event)
+        else:
+            self.log.debug("Event handler not found for event : %r" % event)
 
     def is_subscribed(self):
         """

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
index 3b7f6c8..3d6dea1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -85,7 +85,7 @@ INSTANCE_NOTIFIER_TOPIC = "instance/#"
 HEALTH_STAT_TOPIC = "health/#"
 TOPOLOGY_TOPIC = "topology/#"
 TENANT_TOPIC = "tenant/#"
-INSTANCE_STATUS_TOPIC = "instance/#"
+INSTANCE_STATUS_TOPIC = "instance/status/"
 
 
 #Messaging Model

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index 8e47a37..efff3ec 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -82,7 +82,7 @@ def wait_until_ports_active(ip_address, ports):
     :param list[str] ports: List of ports to be checked
     :return: void
     """
-    ports_check_timeout = CartridgeAgentConfiguration.read_property("port.check.timeout")
+    ports_check_timeout = CartridgeAgentConfiguration.read_property("port.check.timeout", critical=False)
     if ports_check_timeout is None:
         ports_check_timeout = 1000 * 60 * 10
 
@@ -119,7 +119,7 @@ def check_ports_active(ip_address, ports):
         s = socket.socket()
         s.settimeout(5)
         try:
-            s.connect(ip_address, port)
+            s.connect((ip_address, int(port)))
             log.debug("Port %r is active" % port)
             s.close()
         except socket.error:

http://git-wip-us.apache.org/repos/asf/stratos/blob/f85bc0a1/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 53b6ea8..8ce36ba 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
 def execute_copy_artifact_extension(source, destination):
     try:
         log.debug("Executing artifacts copy extension")
-        script_name = cartridgeagentconstants.ARTIFACTS_COPY_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACTS_COPY_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command + " " + source + " " + destination)
@@ -26,7 +26,7 @@ def execute_instance_started_extension(env_params):
     try:
         log.debug("Executing instance started extension")
 
-        script_name = cartridgeagentconstants.INSTANCE_STARTED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.INSTANCE_STARTED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -40,7 +40,7 @@ def execute_instance_started_extension(env_params):
 def execute_instance_activated_extension():
     try:
         log.debug("Executing instance activated extension")
-        script_name = cartridgeagentconstants.INSTANCE_ACTIVATED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.INSTANCE_ACTIVATED_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command)
@@ -53,7 +53,7 @@ def execute_artifacts_updated_extension(env_params):
     try:
         log.debug("Executing artifacts updated extension")
 
-        script_name = cartridgeagentconstants.ARTIFACTS_UPDATED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACTS_UPDATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -68,7 +68,7 @@ def execute_subscription_domain_added_extension(env_params):
     try:
         log.debug("Executing subscription domain added extension")
 
-        script_name = cartridgeagentconstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -83,7 +83,7 @@ def execute_subscription_domain_removed_extension(env_params):
     try:
         log.debug("Executing subscription domain removed extension")
 
-        script_name = cartridgeagentconstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -98,7 +98,7 @@ def execute_start_servers_extension(env_params):
     try:
         log.debug("Executing start servers extension")
 
-        script_name = cartridgeagentconstants.START_SERVERS_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.START_SERVERS_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -113,7 +113,7 @@ def execute_complete_topology_extension(env_params):
     try:
         log.debug("Executing complete topology extension")
 
-        script_name = cartridgeagentconstants.COMPLETE_TOPOLOGY_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.COMPLETE_TOPOLOGY_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -128,7 +128,7 @@ def execute_complete_tenant_extension(env_params):
     try:
         log.debug("Executing complete tenant extension")
 
-        script_name = cartridgeagentconstants.COMPLETE_TENANT_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.COMPLETE_TENANT_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -143,7 +143,7 @@ def execute_tenant_subscribed_extension(env_params):
     try:
         log.debug("Executing tenant subscribed extension")
 
-        script_name = cartridgeagentconstants.TENANT_SUBSCRIBED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.TENANT_SUBSCRIBED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -158,7 +158,7 @@ def execute_tenant_unsubscribed_extension(env_params):
     try:
         log.debug("Executing tenant unsubscribed extension")
 
-        script_name = cartridgeagentconstants.TENANT_UNSUBSCRIBED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.TENANT_UNSUBSCRIBED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -173,7 +173,7 @@ def execute_member_terminated_extension(env_params):
     try:
         log.debug("Executing member terminated extension")
 
-        script_name = cartridgeagentconstants.MEMBER_TERMINATED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_TERMINATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -188,7 +188,7 @@ def execute_member_suspended_extension(env_params):
     try:
         log.debug("Executing member suspended extension")
 
-        script_name = cartridgeagentconstants.MEMBER_SUSPENDED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_SUSPENDED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -202,7 +202,7 @@ def execute_member_started_extension(env_params):
     try:
         log.debug("Executing member started extension")
 
-        script_name = cartridgeagentconstants.MEMBER_STARTED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_STARTED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -284,7 +284,7 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
 def execute_volume_mount_extension(persistance_mappings_payload):
     try:
         log.debug("Executing volume mounting extension: [payload] %r" % persistance_mappings_payload)
-        script_name = cartridgeagentconstants.MOUNT_VOLUMES_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MOUNT_VOLUMES_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command + " " + persistance_mappings_payload)
@@ -296,7 +296,7 @@ def execute_volume_mount_extension(persistance_mappings_payload):
 def execute_cleanup_extension():
     try:
         log.debug("Executing cleanup extension")
-        script_name = cartridgeagentconstants.CLEAN_UP_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.CLEAN_UP_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command)
@@ -309,7 +309,7 @@ def execute_member_activated_extension(env_params):
     try:
         log.debug("Executing member activated extension")
 
-        script_name = cartridgeagentconstants.MEMBER_ACTIVATED_SCRIPT
+        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_ACTIVATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -321,7 +321,7 @@ def execute_member_activated_extension(env_params):
 
 
 def prepare_command(script_name):
-    extensions_dir = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
+    extensions_dir = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR, False)
     if extensions_dir.strip() == "":
         raise RuntimeError("System property not found: %r" % cartridgeagentconstants.EXTENSIONS_DIR)
 
@@ -355,7 +355,7 @@ def add_payload_parameters(env_params):
     :rtype: dict[str, str]
     """
     env_params["STRATOS_APP_PATH"] = CartridgeAgentConfiguration.app_path
-    env_params["STRATOS_PARAM_FILE_PATH"] = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+    env_params["STRATOS_PARAM_FILE_PATH"] = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
     env_params["STRATOS_SERVICE_NAME"] = CartridgeAgentConfiguration.service_name
     env_params["STRATOS_TENANT_ID"] = CartridgeAgentConfiguration.tenant_id
     env_params["STRATOS_CARTRIDGE_KEY"] = CartridgeAgentConfiguration.cartridge_key


[18/50] [abbrv] git commit: Code cleanup : unnecessary TODOs

Posted by ni...@apache.org.
Code cleanup : unnecessary TODOs


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/850fd055
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/850fd055
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/850fd055

Branch: refs/heads/master
Commit: 850fd055d2277604448d4b0d2e9218a25b3a0510
Parents: 2d9f1ec
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:42:31 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:34 2014 +0530

----------------------------------------------------------------------
 .../modules/extensions/defaultextensionhandler.py               | 2 +-
 .../healthstatspublisher/abstracthealthstatisticspublisher.py   | 2 +-
 .../cartridge-agent/modules/healthstatspublisher/healthstats.py | 3 +--
 .../modules/publisher/cartridgeagentpublisher.py                | 2 +-
 .../cartridge-agent/modules/subscriber/eventsubscriber.py       | 2 +-
 .../cartridge-agent/modules/tenant/tenantcontext.py             | 2 +-
 .../cartridge-agent/modules/topology/topologycontext.py         | 5 -----
 7 files changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 6d49d8f..2687687 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -14,7 +14,7 @@ from abstractextensionhandler import AbstractExtensionHandler
 
 class DefaultExtensionHandler(AbstractExtensionHandler):
     """
-    TODO : Provide abstraction
+    Default implementation of the AbstractExtensionHandler
     """
     log = None
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
index e2121b6..eaf8546 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
@@ -1,6 +1,6 @@
 class AbstractHealthStatisticsReader:
     """
-    TODO:
+    Abstract class to implement to create a custom health stat reader
     """
 
     def stat_cartridge_health(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index d631b82..953c0fc 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -150,8 +150,7 @@ class DefaultHealthStatisticsReader(AbstractHealthStatisticsReader):
 
 class CEPPublisherConfiguration:
     """
-    A singleton implementation to access configuration information for data publishing to BAM/CEP
-    TODO: perfect singleton impl ex: Borg
+    TODO: Extract common functionality
     """
 
     __instance = None

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index fcbe5f1..0427e46 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -136,7 +136,7 @@ def get_publisher(topic):
 
 class EventPublisher:
     """
-    TODO: provide abstraction
+    Handles publishing events to topics to the provided message broker
     """
     def __init__(self, topic):
         self.__topic = topic

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index 8d418fa..ad32180 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -44,7 +44,7 @@ class EventSubscriber(threading.Thread):
         """
         Adds an event handler function mapped to the provided event.
         :param str event: Name of the event to attach the provided handler
-        :param handler: TODO
+        :param (str)->void handler: The handler function
         :return: void
         :rtype: void
         """

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
index 90c9f0b..43bea0b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
@@ -105,7 +105,7 @@ class Subscription:
 
 class SubscriptionDomain:
     """
-    TODO
+    Represents a Subscription Domain
     """
 
     def __init__(self, domain_name, application_context):

http://git-wip-us.apache.org/repos/asf/stratos/blob/850fd055/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 564b959..5d92306 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -406,11 +406,6 @@ class TopologyContext:
             TopologyContext.topology = Topology()
         return TopologyContext.topology
 
-        # @staticmethod
-        # def update(topology):
-        #     TopologyContext.topology = topology
-        #     #TODO: persist in registry
-
     @staticmethod
     def update(topology):
         TopologyContext.topology = topology
\ No newline at end of file


[43/50] [abbrv] git commit: Fixed syntax errors in obtaining json strings of events

Posted by ni...@apache.org.
Fixed syntax errors in obtaining json strings of events


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b6a871d1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b6a871d1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b6a871d1

Branch: refs/heads/master
Commit: b6a871d1e99fecc7f34de4b157ce3bcf961554ce
Parents: 4139b16
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 20:30:19 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 20:30:19 2014 +0530

----------------------------------------------------------------------
 .../modules/event/topology/events.py            |  5 +---
 .../extensions/defaultextensionhandler.py       | 27 ++++++++++----------
 2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b6a871d1/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 18580c2..72c4a99 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -166,7 +166,7 @@ class CompleteTopologyEvent:
                     cluster_obj.status = cluster_str["status"]
                     cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"] if "loadBalanceAlgorithmName" in cluster_str else None
                     cluster_obj.properties = cluster_str["properties"]
-                    cluster_obj.member_list_json = "["
+                    cluster_obj.member_list_json = cluster_str["memberMap"]
 
                     #add member map
                     for member_id in cluster_str["memberMap"]:
@@ -183,7 +183,6 @@ class CompleteTopologyEvent:
                         member_obj.properties = member_str["properties"]
                         member_obj.lb_cluster_id = member_str["lbClusterId"] if "lbClusterId" in member_str else None
                         member_obj.json_str = member_str
-                        cluster_obj.member_list_json += member_str + ","
 
                         #add port map
                         for mm_port_proxy in member_str["portMap"]:
@@ -191,8 +190,6 @@ class CompleteTopologyEvent:
                             mm_port_obj = Port(mm_port_str["protocol"], mm_port_str["value"], mm_port_proxy)
                             member_obj.add_port(mm_port_obj)
                         cluster_obj.add_member(member_obj)
-                    #remove final comma and close the square bracker of the json array
-                    cluster_obj.member_list_json = cluster_obj.member_list_json[:-1] + "]"
                     service_obj.add_cluster(cluster_obj)
                 topology_obj.add_service(service_obj)
             instance.topology = topology_obj

http://git-wip-us.apache.org/repos/asf/stratos/blob/b6a871d1/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 4c36e55..8ee3cd6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -16,6 +16,7 @@
 # under the License.
 
 import time
+import json
 
 from abstractextensionhandler import AbstractExtensionHandler
 from ..util import extensionutils, cartridgeagentutils
@@ -162,14 +163,14 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             env_params["STRATOS_MEMBER_ACTIVATED_PORTS"] = ports_str
 
-            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = cluster.member_list_json
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = json.dumps(cluster.member_list_json)
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
                 env_params["STRATOS_MEMBER_ACTIVATED_LB_IP"] = member_ips[0]
                 env_params["STRATOS_MEMBER_ACTIVATED_LB_PUBLIC_IP"] = member_ips[1]
 
-            env_params["STRATOS_TOPOLOGY_JSON"] = topology.json_str
+            env_params["STRATOS_TOPOLOGY_JSON"] = json.dumps(topology.json_str)
 
             extensionutils.add_properties(service.properties, env_params, "MEMBER_ACTIVATED_SERVICE_PROPERTY")
             extensionutils.add_properties(cluster.properties, env_params, "MEMBER_ACTIVATED_CLUSTER_PROPERTY")
@@ -219,7 +220,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         service = topology.get_service(service_name_in_payload)
         cluster = service.get_cluster(cluster_id_in_payload)
 
-        env_params = {"STRATOS_TOPOLOGY_JSON": topology.json_str, "STRATOS_MEMBER_LIST_JSON": cluster.member_list_json}
+        env_params = {"STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str), "STRATOS_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json)}
 
         extensionutils.execute_complete_topology_extension(env_params)
 
@@ -227,9 +228,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         self.log.debug("Complete tenant event received")
 
         tenant_list_json = complete_tenant_event.tenant_list_json
-        self.log.debug("Complete tenants:" + ','.join(tenant_list_json))
+        self.log.debug("Complete tenants:" + json.dumps(tenant_list_json))
 
-        env_params = {"STRATOS_TENANT_LIST_JSON": ','.join(tenant_list_json)}
+        env_params = {"STRATOS_TENANT_LIST_JSON": json.dumps(tenant_list_json)}
 
         extensionutils.execute_complete_tenant_extension(env_params)
 
@@ -266,8 +267,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                           "STRATOS_MEMBER_TERMINATED_LB_CLUSTER_ID": lb_cluster_id,
                           "STRATOS_MEMBER_TERMINATED_NETWORK_PARTITION_ID": member_terminated_event.network_partition_id,
                           "STRATOS_MEMBER_TERMINATED_SERVICE_NAME": member_terminated_event.service_name,
-                          "STRATOS_MEMBER_TERMINATED_MEMBER_LIST_JSON": cluster.member_list_json,
-                          "STRATOS_TOPOLOGY_JSON": topology.json_str}
+                          "STRATOS_MEMBER_TERMINATED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+                          "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
@@ -315,8 +316,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                           "STRATOS_MEMBER_SUSPENDED_LB_CLUSTER_ID": lb_cluster_id,
                           "STRATOS_MEMBER_SUSPENDED_NETWORK_PARTITION_ID": member_suspended_event.network_partition_id,
                           "STRATOS_MEMBER_SUSPENDED_SERVICE_NAME": member_suspended_event.service_name,
-                          "STRATOS_MEMBER_SUSPENDED_MEMBER_LIST_JSON": cluster.member_list_json,
-                          "STRATOS_TOPOLOGY_JSON": topology.json_str}
+                          "STRATOS_MEMBER_SUSPENDED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+                          "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
@@ -364,8 +365,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                           "STRATOS_MEMBER_STARTED_LB_CLUSTER_ID": lb_cluster_id,
                           "STRATOS_MEMBER_STARTED_NETWORK_PARTITION_ID": member_started_event.network_partition_id,
                           "STRATOS_MEMBER_STARTED_SERVICE_NAME": member_started_event.service_name,
-                          "STRATOS_MEMBER_STARTED_MEMBER_LIST_JSON": cluster.member_list_json,
-                          "STRATOS_TOPOLOGY_JSON": topology.json_str}
+                          "STRATOS_MEMBER_STARTED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+                          "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
@@ -415,8 +416,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 self.wait_for_wk_members(env_params)
                 self.log.info("All well known members have started! Resuming start server extension...")
 
-            env_params["STRATOS_TOPOLOGY_JSON"] = topology.json_str
-            env_params["STRATOS_MEMBER_LIST_JSON"] = cluster.member_list_json
+            env_params["STRATOS_TOPOLOGY_JSON"] = json.dumps(topology.json_str)
+            env_params["STRATOS_MEMBER_LIST_JSON"] = json.dumps(cluster.member_list_json)
 
             extensionutils.execute_start_servers_extension(env_params)
 


[39/50] [abbrv] git commit: Fixed trying to decrypt empty password Fixed issue in CEPPublisherConfiguration

Posted by ni...@apache.org.
Fixed trying to decrypt empty password
Fixed issue in CEPPublisherConfiguration


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c4c5f75e
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c4c5f75e
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c4c5f75e

Branch: refs/heads/master
Commit: c4c5f75e12c689cbcb01fe90bff866c8ced63eda
Parents: 4955598
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 18:16:41 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 18:16:41 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/modules/healthstatspublisher/healthstats.py  | 4 ++--
 .../cartridge-agent/modules/util/cartridgeagentutils.py          | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/c4c5f75e/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index ddc2543..aafe4db 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -199,10 +199,10 @@ class CEPPublisherConfiguration:
         self.server_port = None
         self.admin_username = None
         self.admin_password = None
-        self.read_config()
-
         self.cartridge_agent_config = CartridgeAgentConfiguration()
 
+        self.read_config()
+
     def read_config(self):
         self.enabled = True if self.cartridge_agent_config.read_property(
            cartridgeagentconstants.CEP_PUBLISHER_ENABLED, False).strip().lower() == "true" else False

http://git-wip-us.apache.org/repos/asf/stratos/blob/c4c5f75e/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index 556a348..42a7dd5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -41,8 +41,8 @@ def decrypt_password(pass_str, secret):
     :rtype: str
     """
 
-    if pass_str is None:
-        return pass_str
+    if pass_str is None or pass_str.strip() == "":
+        return pass_str.strip()
 
     dec_pass = ""
 


[27/50] [abbrv] git commit: Fixed path issues in thrift python client

Posted by ni...@apache.org.
Fixed path issues in thrift python client


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/105a09e9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/105a09e9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/105a09e9

Branch: refs/heads/master
Commit: 105a09e981f75b950ae8924ffafb4fbb90da0b39
Parents: 511aedf
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 03:42:24 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:41:15 2014 +0530

----------------------------------------------------------------------
 .../databridge/thrift/gen-py/Data/__init__.py   |    1 -
 .../databridge/thrift/gen-py/Data/constants.py  |    8 -
 .../databridge/thrift/gen-py/Data/ttypes.py     |  320 ----
 .../thrift/gen-py/Exception/__init__.py         |    1 -
 .../thrift/gen-py/Exception/constants.py        |    8 -
 .../thrift/gen-py/Exception/ttypes.py           |  473 ------
 .../ThriftEventTransmissionService-remote       |  117 --
 .../ThriftEventTransmissionService.py           | 1143 -------------
 .../ThriftEventTransmissionService/__init__.py  |    1 -
 .../ThriftEventTransmissionService/constants.py |    8 -
 .../ThriftEventTransmissionService/ttypes.py    |   21 -
 .../ThriftSecureEventTransmissionService-remote |  131 --
 .../ThriftSecureEventTransmissionService.py     | 1493 -----------------
 .../__init__.py                                 |    1 -
 .../constants.py                                |    8 -
 .../ttypes.py                                   |   21 -
 .../databridge/thrift/gen-py/__init__.py        |    0
 .../databridge/thrift/gen/Data/__init__.py      |    1 +
 .../databridge/thrift/gen/Data/constants.py     |    8 +
 .../databridge/thrift/gen/Data/ttypes.py        |  320 ++++
 .../databridge/thrift/gen/Exception/__init__.py |    1 +
 .../thrift/gen/Exception/constants.py           |    8 +
 .../databridge/thrift/gen/Exception/ttypes.py   |  473 ++++++
 .../ThriftEventTransmissionService-remote       |  117 ++
 .../ThriftEventTransmissionService.py           | 1143 +++++++++++++
 .../ThriftEventTransmissionService/__init__.py  |    1 +
 .../ThriftEventTransmissionService/constants.py |    8 +
 .../ThriftEventTransmissionService/ttypes.py    |   21 +
 .../ThriftSecureEventTransmissionService-remote |  131 ++
 .../ThriftSecureEventTransmissionService.py     | 1495 ++++++++++++++++++
 .../__init__.py                                 |    1 +
 .../constants.py                                |    8 +
 .../ttypes.py                                   |   21 +
 .../modules/databridge/thrift/gen/__init__.py   |    0
 .../modules/databridge/thrift/publisher.py      |    6 +-
 .../databridge/thrift/thrift/TTornado.py        |    4 +-
 .../databridge/thrift/thrift/protocol/TBase.py  |    8 +-
 .../thrift/thrift/protocol/TProtocol.py         |    2 +-
 .../thrift/thrift/server/THttpServer.py         |    4 +-
 .../thrift/thrift/server/TNonblockingServer.py  |    4 +-
 .../thrift/thrift/server/TProcessPoolServer.py  |    2 +-
 .../databridge/thrift/thrift/server/TServer.py  |    6 +-
 .../thrift/thrift/transport/TSSLSocket.py       |    4 +-
 .../thrift/thrift/transport/TTransport.py       |    2 +-
 .../thrift/thrift/transport/TTwisted.py         |    2 +-
 .../modules/util/extensionutils.py              |    1 -
 46 files changed, 3779 insertions(+), 3778 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
deleted file mode 100644
index adefd8e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py
deleted file mode 100644
index 36943ba..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# 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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
deleted file mode 100644
index 642c550..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
+++ /dev/null
@@ -1,320 +0,0 @@
-#
-# 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 thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-class ThriftAttributeType:
-  INT = 0
-  LONG = 1
-  FLOAT = 2
-  DOUBLE = 3
-  BOOL = 4
-  STRING = 5
-
-  _VALUES_TO_NAMES = {
-    0: "INT",
-    1: "LONG",
-    2: "FLOAT",
-    3: "DOUBLE",
-    4: "BOOL",
-    5: "STRING",
-  }
-
-  _NAMES_TO_VALUES = {
-    "INT": 0,
-    "LONG": 1,
-    "FLOAT": 2,
-    "DOUBLE": 3,
-    "BOOL": 4,
-    "STRING": 5,
-  }
-
-
-class ThriftAttribute:
-  """
-  Attributes:
-   - name
-   - attributeType
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'name', None, None, ), # 1
-    (2, TType.I32, 'attributeType', None, None, ), # 2
-  )
-
-  def __init__(self, name=None, attributeType=None,):
-    self.name = name
-    self.attributeType = attributeType
-
-  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.name = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.I32:
-          self.attributeType = iprot.readI32();
-        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('ThriftAttribute')
-    if self.name is not None:
-      oprot.writeFieldBegin('name', TType.STRING, 1)
-      oprot.writeString(self.name)
-      oprot.writeFieldEnd()
-    if self.attributeType is not None:
-      oprot.writeFieldBegin('attributeType', TType.I32, 2)
-      oprot.writeI32(self.attributeType)
-      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 ThriftEventBundle:
-  """
-  Attributes:
-   - sessionId
-   - eventNum
-   - intAttributeList
-   - longAttributeList
-   - doubleAttributeList
-   - boolAttributeList
-   - stringAttributeList
-   - arbitraryDataMapMap
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'sessionId', None, None, ), # 1
-    (2, TType.I32, 'eventNum', None, None, ), # 2
-    (3, TType.LIST, 'intAttributeList', (TType.I32,None), None, ), # 3
-    (4, TType.LIST, 'longAttributeList', (TType.I64,None), None, ), # 4
-    (5, TType.LIST, 'doubleAttributeList', (TType.DOUBLE,None), None, ), # 5
-    (6, TType.LIST, 'boolAttributeList', (TType.BOOL,None), None, ), # 6
-    (7, TType.LIST, 'stringAttributeList', (TType.STRING,None), None, ), # 7
-    (8, TType.MAP, 'arbitraryDataMapMap', (TType.I32,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 8
-  )
-
-  def __init__(self, sessionId=None, eventNum=None, intAttributeList=None, longAttributeList=None, doubleAttributeList=None, boolAttributeList=None, stringAttributeList=None, arbitraryDataMapMap=None,):
-    self.sessionId = sessionId
-    self.eventNum = eventNum
-    self.intAttributeList = intAttributeList
-    self.longAttributeList = longAttributeList
-    self.doubleAttributeList = doubleAttributeList
-    self.boolAttributeList = boolAttributeList
-    self.stringAttributeList = stringAttributeList
-    self.arbitraryDataMapMap = arbitraryDataMapMap
-
-  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.I32:
-          self.eventNum = iprot.readI32();
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.LIST:
-          self.intAttributeList = []
-          (_etype3, _size0) = iprot.readListBegin()
-          for _i4 in xrange(_size0):
-            _elem5 = iprot.readI32();
-            self.intAttributeList.append(_elem5)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.LIST:
-          self.longAttributeList = []
-          (_etype9, _size6) = iprot.readListBegin()
-          for _i10 in xrange(_size6):
-            _elem11 = iprot.readI64();
-            self.longAttributeList.append(_elem11)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 5:
-        if ftype == TType.LIST:
-          self.doubleAttributeList = []
-          (_etype15, _size12) = iprot.readListBegin()
-          for _i16 in xrange(_size12):
-            _elem17 = iprot.readDouble();
-            self.doubleAttributeList.append(_elem17)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 6:
-        if ftype == TType.LIST:
-          self.boolAttributeList = []
-          (_etype21, _size18) = iprot.readListBegin()
-          for _i22 in xrange(_size18):
-            _elem23 = iprot.readBool();
-            self.boolAttributeList.append(_elem23)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 7:
-        if ftype == TType.LIST:
-          self.stringAttributeList = []
-          (_etype27, _size24) = iprot.readListBegin()
-          for _i28 in xrange(_size24):
-            _elem29 = iprot.readString();
-            self.stringAttributeList.append(_elem29)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 8:
-        if ftype == TType.MAP:
-          self.arbitraryDataMapMap = {}
-          (_ktype31, _vtype32, _size30 ) = iprot.readMapBegin()
-          for _i34 in xrange(_size30):
-            _key35 = iprot.readI32();
-            _val36 = {}
-            (_ktype38, _vtype39, _size37 ) = iprot.readMapBegin()
-            for _i41 in xrange(_size37):
-              _key42 = iprot.readString();
-              _val43 = iprot.readString();
-              _val36[_key42] = _val43
-            iprot.readMapEnd()
-            self.arbitraryDataMapMap[_key35] = _val36
-          iprot.readMapEnd()
-        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('ThriftEventBundle')
-    if self.sessionId is not None:
-      oprot.writeFieldBegin('sessionId', TType.STRING, 1)
-      oprot.writeString(self.sessionId)
-      oprot.writeFieldEnd()
-    if self.eventNum is not None:
-      oprot.writeFieldBegin('eventNum', TType.I32, 2)
-      oprot.writeI32(self.eventNum)
-      oprot.writeFieldEnd()
-    if self.intAttributeList is not None:
-      oprot.writeFieldBegin('intAttributeList', TType.LIST, 3)
-      oprot.writeListBegin(TType.I32, len(self.intAttributeList))
-      for iter44 in self.intAttributeList:
-        oprot.writeI32(iter44)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.longAttributeList is not None:
-      oprot.writeFieldBegin('longAttributeList', TType.LIST, 4)
-      oprot.writeListBegin(TType.I64, len(self.longAttributeList))
-      for iter45 in self.longAttributeList:
-        oprot.writeI64(iter45)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.doubleAttributeList is not None:
-      oprot.writeFieldBegin('doubleAttributeList', TType.LIST, 5)
-      oprot.writeListBegin(TType.DOUBLE, len(self.doubleAttributeList))
-      for iter46 in self.doubleAttributeList:
-        oprot.writeDouble(iter46)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.boolAttributeList is not None:
-      oprot.writeFieldBegin('boolAttributeList', TType.LIST, 6)
-      oprot.writeListBegin(TType.BOOL, len(self.boolAttributeList))
-      for iter47 in self.boolAttributeList:
-        oprot.writeBool(iter47)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.stringAttributeList is not None:
-      oprot.writeFieldBegin('stringAttributeList', TType.LIST, 7)
-      oprot.writeListBegin(TType.STRING, len(self.stringAttributeList))
-      for iter48 in self.stringAttributeList:
-        oprot.writeString(iter48)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.arbitraryDataMapMap is not None:
-      oprot.writeFieldBegin('arbitraryDataMapMap', TType.MAP, 8)
-      oprot.writeMapBegin(TType.I32, TType.MAP, len(self.arbitraryDataMapMap))
-      for kiter49,viter50 in self.arbitraryDataMapMap.items():
-        oprot.writeI32(kiter49)
-        oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter50))
-        for kiter51,viter52 in viter50.items():
-          oprot.writeString(kiter51)
-          oprot.writeString(viter52)
-        oprot.writeMapEnd()
-      oprot.writeMapEnd()
-      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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
deleted file mode 100644
index adefd8e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py
deleted file mode 100644
index 36943ba..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# 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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
deleted file mode 100644
index c69fb5e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
+++ /dev/null
@@ -1,473 +0,0 @@
-#
-# 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 thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-
-class ThriftStreamDefinitionException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftStreamDefinitionException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftNoStreamDefinitionExistException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftNoStreamDefinitionExistException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftDifferentStreamDefinitionAlreadyDefinedException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftDifferentStreamDefinitionAlreadyDefinedException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftMalformedStreamDefinitionException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftMalformedStreamDefinitionException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftUndefinedEventTypeException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftUndefinedEventTypeException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftSessionExpiredException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftSessionExpiredException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftAuthenticationException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftAuthenticationException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
deleted file mode 100755
index 0d18f58..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python
-#
-# Autogenerated by Thrift Compiler (0.9.1)
-#
-# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-#
-#  options string: py
-#
-
-import sys
-import pprint
-from urlparse import urlparse
-
-from thrift.transport import TTransport
-from thrift.transport import TSocket
-from thrift.transport import THttpClient
-from thrift.protocol import TBinaryProtocol
-from ThriftEventTransmissionService import ThriftEventTransmissionService
-from ThriftEventTransmissionService.ttypes import *
-
-
-if len(sys.argv) <= 1 or sys.argv[1] == '--help':
-  print ''
-  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
-  print ''
-  print 'Functions:'
-  print '  string defineStream(string sessionId, string streamDefinition)'
-  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
-  print '  void publish(ThriftEventBundle eventBundle)'
-  print '  bool deleteStreamById(string sessionId, string streamId)'
-  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
-  print ''
-  sys.exit(0)
-
-pp = pprint.PrettyPrinter(indent = 2)
-host = 'localhost'
-port = 9090
-uri = ''
-framed = False
-http = False
-argi = 1
-
-if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  argi += 2
-
-if sys.argv[argi] == '-u':
-  url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  else:
-    port = 80
-  uri = url[2]
-  if url[4]:
-    uri += '?%s' % url[4]
-  http = True
-  argi += 2
-
-if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
-  framed = True
-  argi += 1
-
-cmd = sys.argv[argi]
-args = sys.argv[argi+1:]
-
-if http:
-  transport = THttpClient.THttpClient(host, port, uri)
-else:
-  socket = TSocket.TSocket(host, port)
-  if framed:
-    transport = TTransport.TFramedTransport(socket)
-  else:
-    transport = TTransport.TBufferedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(transport)
-client = ThriftEventTransmissionService.Client(protocol)
-transport.open()
-
-if cmd == 'defineStream':
-  if len(args) != 2:
-    print 'defineStream requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.defineStream(args[0],args[1],))
-
-elif cmd == 'findStreamId':
-  if len(args) != 3:
-    print 'findStreamId requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
-
-elif cmd == 'publish':
-  if len(args) != 1:
-    print 'publish requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.publish(eval(args[0]),))
-
-elif cmd == 'deleteStreamById':
-  if len(args) != 2:
-    print 'deleteStreamById requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamById(args[0],args[1],))
-
-elif cmd == 'deleteStreamByNameVersion':
-  if len(args) != 3:
-    print 'deleteStreamByNameVersion requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
-
-else:
-  print 'Unrecognized method %s' % cmd
-  sys.exit(1)
-
-transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
deleted file mode 100644
index cb96c29..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
+++ /dev/null
@@ -1,1143 +0,0 @@
-#
-# 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
-
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-class Iface:
-  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 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["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_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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
-      result.ade = ade
-    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
-      result.mtd = mtd
-    except Exception.ttypes.ThriftStreamDefinitionException, tde:
-      result.tde = tde
-    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
-      result.tnde = tnde
-    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
-      result.ue = ue
-    except Exception.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 Exception.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 Exception.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 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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
-    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
-    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
-          self.ade.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
-          self.mtd.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.STRUCT:
-          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
-          self.tde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
-          self.tnde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
-          self.ue.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
deleted file mode 100644
index 38575a6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants', 'ThriftEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py
deleted file mode 100644
index 36943ba..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/constants.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# 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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py
deleted file mode 100644
index a0727f8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ttypes.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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
-import Data.ttypes
-import Exception.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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
deleted file mode 100755
index 46757bf..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env python
-#
-# Autogenerated by Thrift Compiler (0.9.1)
-#
-# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-#
-#  options string: py
-#
-
-import sys
-import pprint
-from urlparse import urlparse
-
-from thrift.transport import TTransport
-from thrift.transport import TSocket
-from thrift.transport import THttpClient
-from thrift.protocol import TBinaryProtocol
-from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
-from ThriftSecureEventTransmissionService.ttypes import *
-
-
-if len(sys.argv) <= 1 or sys.argv[1] == '--help':
-  print ''
-  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
-  print ''
-  print 'Functions:'
-  print '  string connect(string userName, string password)'
-  print '  void disconnect(string sessionId)'
-  print '  string defineStream(string sessionId, string streamDefinition)'
-  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
-  print '  void publish(ThriftEventBundle eventBundle)'
-  print '  bool deleteStreamById(string sessionId, string streamId)'
-  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
-  print ''
-  sys.exit(0)
-
-pp = pprint.PrettyPrinter(indent = 2)
-host = 'localhost'
-port = 9090
-uri = ''
-framed = False
-http = False
-argi = 1
-
-if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  argi += 2
-
-if sys.argv[argi] == '-u':
-  url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  else:
-    port = 80
-  uri = url[2]
-  if url[4]:
-    uri += '?%s' % url[4]
-  http = True
-  argi += 2
-
-if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
-  framed = True
-  argi += 1
-
-cmd = sys.argv[argi]
-args = sys.argv[argi+1:]
-
-if http:
-  transport = THttpClient.THttpClient(host, port, uri)
-else:
-  socket = TSocket.TSocket(host, port)
-  if framed:
-    transport = TTransport.TFramedTransport(socket)
-  else:
-    transport = TTransport.TBufferedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(transport)
-client = ThriftSecureEventTransmissionService.Client(protocol)
-transport.open()
-
-if cmd == 'connect':
-  if len(args) != 2:
-    print 'connect requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.connect(args[0],args[1],))
-
-elif cmd == 'disconnect':
-  if len(args) != 1:
-    print 'disconnect requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.disconnect(args[0],))
-
-elif cmd == 'defineStream':
-  if len(args) != 2:
-    print 'defineStream requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.defineStream(args[0],args[1],))
-
-elif cmd == 'findStreamId':
-  if len(args) != 3:
-    print 'findStreamId requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
-
-elif cmd == 'publish':
-  if len(args) != 1:
-    print 'publish requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.publish(eval(args[0]),))
-
-elif cmd == 'deleteStreamById':
-  if len(args) != 2:
-    print 'deleteStreamById requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamById(args[0],args[1],))
-
-elif cmd == 'deleteStreamByNameVersion':
-  if len(args) != 3:
-    print 'deleteStreamByNameVersion requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
-
-else:
-  print 'Unrecognized method %s' % cmd
-  sys.exit(1)
-
-transport.close()


[46/50] [abbrv] git commit: Fixed issues in configuration related to missing params

Posted by ni...@apache.org.
Fixed issues in configuration related to missing params


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3360d540
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3360d540
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3360d540

Branch: refs/heads/master
Commit: 3360d54031069ef5eb9d730a74c3d1f239d9eba6
Parents: 98396a7
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 22:03:42 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 22:03:42 2014 +0530

----------------------------------------------------------------------
 .../modules/extensions/defaultextensionhandler.py               | 5 +++--
 .../modules/publisher/cartridgeagentpublisher.py                | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3360d540/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index f2ec818..f0b9987 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -178,8 +178,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             clustered = self.cartridge_agent_config.is_clustered
 
-            if member.properties is not None and member.properties[
-                    cartridgeagentconstants.CLUSTERING_PRIMARY_KEY] == "true" and clustered is not None and clustered:
+            if member.properties is not None and cartridgeagentconstants.CLUSTERING_PRIMARY_KEY in member.properties \
+                    and member.properties[cartridgeagentconstants.CLUSTERING_PRIMARY_KEY] == "true" \
+                    and clustered is not None and clustered:
 
                 self.log.debug(" If WK member is re-spawned, update axis2.xml ")
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/3360d540/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 89321b4..59401b5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -77,7 +77,7 @@ def publish_instance_activated_event():
 
         if CEPPublisherConfiguration.get_instance().enabled:
             interval_default = 15  # seconds
-            interval = CartridgeAgentConfiguration().read_property("stats.notifier.interval")
+            interval = CartridgeAgentConfiguration().read_property("stats.notifier.interval", False)
             if interval is not None and len(interval) > 0:
                 try:
                     interval = int(interval)


[15/50] [abbrv] git commit: Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
Refactored thrift communication module
Added databridge additional classes
Completed log publishing from agent


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/700a6d26
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/700a6d26
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/700a6d26

Branch: refs/heads/master
Commit: 700a6d26780b5e54975f65aa0c392e048845f3bd
Parents: f4b2b5c
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 02:40:14 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:12 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |   37 +-
 .../modules/databridge/__init__.py              |    0
 .../cartridge-agent/modules/databridge/agent.py |  164 ++
 .../modules/databridge/thrift/__init__.py       |    0
 .../databridge/thrift/gen-py/Data/__init__.py   |    1 +
 .../databridge/thrift/gen-py/Data/constants.py  |    8 +
 .../databridge/thrift/gen-py/Data/ttypes.py     |  320 ++++
 .../thrift/gen-py/Exception/__init__.py         |    1 +
 .../thrift/gen-py/Exception/constants.py        |    8 +
 .../thrift/gen-py/Exception/ttypes.py           |  473 ++++++
 .../ThriftEventTransmissionService-remote       |  117 ++
 .../ThriftEventTransmissionService.py           | 1143 ++++++++++++++
 .../ThriftEventTransmissionService/__init__.py  |    1 +
 .../ThriftEventTransmissionService/constants.py |    8 +
 .../ThriftEventTransmissionService/ttypes.py    |   21 +
 .../ThriftSecureEventTransmissionService-remote |  131 ++
 .../ThriftSecureEventTransmissionService.py     | 1493 +++++++++++++++++
 .../__init__.py                                 |    1 +
 .../constants.py                                |    8 +
 .../ttypes.py                                   |   21 +
 .../databridge/thrift/gen-py/__init__.py        |    0
 .../modules/databridge/thrift/publisher.py      |   94 ++
 .../modules/databridge/thrift/thrift/TSCons.py  |   35 +
 .../databridge/thrift/thrift/TSerialization.py  |   38 +
 .../databridge/thrift/thrift/TTornado.py        |  153 ++
 .../modules/databridge/thrift/thrift/Thrift.py  |  170 ++
 .../databridge/thrift/thrift/__init__.py        |   20 +
 .../databridge/thrift/thrift/protocol/TBase.py  |   81 +
 .../thrift/thrift/protocol/TBinaryProtocol.py   |  261 +++
 .../thrift/thrift/protocol/TCompactProtocol.py  |  405 +++++
 .../thrift/thrift/protocol/TJSONProtocol.py     |  552 +++++++
 .../thrift/thrift/protocol/TProtocol.py         |  406 +++++
 .../thrift/thrift/protocol/__init__.py          |   20 +
 .../thrift/thrift/protocol/fastbinary.c         | 1219 ++++++++++++++
 .../thrift/thrift/server/THttpServer.py         |   87 +
 .../thrift/thrift/server/TNonblockingServer.py  |  346 ++++
 .../thrift/thrift/server/TProcessPoolServer.py  |  118 ++
 .../databridge/thrift/thrift/server/TServer.py  |  269 ++++
 .../databridge/thrift/thrift/server/__init__.py |   20 +
 .../thrift/thrift/transport/THttpClient.py      |  147 ++
 .../thrift/thrift/transport/TSSLSocket.py       |  214 +++
 .../thrift/thrift/transport/TSocket.py          |  176 +++
 .../thrift/thrift/transport/TTransport.py       |  330 ++++
 .../thrift/thrift/transport/TTwisted.py         |  221 +++
 .../thrift/thrift/transport/TZlibTransport.py   |  249 +++
 .../thrift/thrift/transport/__init__.py         |   20 +
 .../modules/datapublisher/__init__.py           |    1 +
 .../modules/datapublisher/exception/__init__.py |    1 +
 .../exception/datapublisherexception.py         |   13 +
 .../modules/datapublisher/logpublisher.py       |  238 +++
 .../modules/logpublisher/__init__.py            |    1 -
 .../modules/logpublisher/logpublisher.py        |   71 -
 .../modules/thriftcom/Publisher.py              |   94 --
 .../modules/thriftcom/__init__.py               |    0
 .../modules/thriftcom/gen-py/Data/__init__.py   |    1 -
 .../modules/thriftcom/gen-py/Data/constants.py  |   11 -
 .../modules/thriftcom/gen-py/Data/ttypes.py     |  320 ----
 .../thriftcom/gen-py/Exception/__init__.py      |    1 -
 .../thriftcom/gen-py/Exception/constants.py     |   11 -
 .../thriftcom/gen-py/Exception/ttypes.py        |  473 ------
 .../ThriftEventTransmissionService-remote       |  116 --
 .../ThriftEventTransmissionService.py           | 1144 --------------
 .../ThriftEventTransmissionService/__init__.py  |    1 -
 .../ThriftEventTransmissionService/constants.py |   11 -
 .../ThriftEventTransmissionService/ttypes.py    |   21 -
 .../ThriftSecureEventTransmissionService-remote |  130 --
 .../ThriftSecureEventTransmissionService.py     | 1494 ------------------
 .../__init__.py                                 |    1 -
 .../constants.py                                |   11 -
 .../ttypes.py                                   |   21 -
 .../modules/thriftcom/gen-py/__init__.py        |    0
 .../modules/thriftcom/thrift/TSCons.py          |   35 -
 .../modules/thriftcom/thrift/TSerialization.py  |   38 -
 .../modules/thriftcom/thrift/TTornado.py        |  153 --
 .../modules/thriftcom/thrift/Thrift.py          |  170 --
 .../modules/thriftcom/thrift/__init__.py        |   20 -
 .../modules/thriftcom/thrift/protocol/TBase.py  |   81 -
 .../thrift/protocol/TBinaryProtocol.py          |  260 ---
 .../thrift/protocol/TCompactProtocol.py         |  403 -----
 .../thriftcom/thrift/protocol/TJSONProtocol.py  |  550 -------
 .../thriftcom/thrift/protocol/TProtocol.py      |  406 -----
 .../thriftcom/thrift/protocol/__init__.py       |   20 -
 .../thriftcom/thrift/protocol/fastbinary.c      | 1219 --------------
 .../thriftcom/thrift/server/THttpServer.py      |   87 -
 .../thrift/server/TNonblockingServer.py         |  346 ----
 .../thrift/server/TProcessPoolServer.py         |  118 --
 .../modules/thriftcom/thrift/server/TServer.py  |  269 ----
 .../modules/thriftcom/thrift/server/__init__.py |   20 -
 .../thriftcom/thrift/transport/THttpClient.py   |  149 --
 .../thriftcom/thrift/transport/TSSLSocket.py    |  214 ---
 .../thriftcom/thrift/transport/TSocket.py       |  176 ---
 .../thriftcom/thrift/transport/TTransport.py    |  330 ----
 .../thriftcom/thrift/transport/TTwisted.py      |  221 ---
 .../thrift/transport/TZlibTransport.py          |  248 ---
 .../thriftcom/thrift/transport/__init__.py      |   20 -
 95 files changed, 9855 insertions(+), 9491 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index ae85a5d..5ae7664 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -13,6 +13,7 @@ from modules.event.tenant.events import *
 from modules.event.topology.events import *
 from modules.tenant.tenantcontext import *
 from modules.topology.topologycontext import *
+from modules.datapublisher.logpublisher import *
 
 
 class CartridgeAgent(threading.Thread):
@@ -32,6 +33,10 @@ class CartridgeAgent(threading.Thread):
         self.__tenant_context_initialized = False
         self.__topology_context_initialized = False
 
+        self.log_publish_manager = None
+
+        self.terminated = False
+
     def run(self):
         self.log.info("Starting Cartridge Agent...")
 
@@ -77,14 +82,33 @@ class CartridgeAgent(threading.Thread):
         if persistence_mappping_payload is not None:
             self.extension_handler.volume_mount_extension(persistence_mappping_payload)
 
-            # TODO: logpublisher shceduled event
+        # start log publishing thread
+        if DataPublisherConfiguration.get_instance().enabled:
+            log_file_paths = CartridgeAgentConfiguration.log_file_paths
+            if log_file_paths is None:
+                self.log.exception("No valid log file paths found, no logs will be published")
+            else:
+                self.log_publish_manager = LogPublisherManager(log_file_paths)
+                self.log_publish_manager.start()
+
+        while not self.terminated:
+            time.sleep(1)
+
+        if DataPublisherConfiguration.get_instance().enabled:
+            self.log_publish_manager.terminate_all_publishers()
 
-            #TODO: wait until terminated is true
+    def terminate(self):
+        """
+        Allows the CartridgeAgent thread to be terminated
+
+        :return: void
+        """
+        self.terminated = True
 
     def validate_required_properties(self):
         """
         Checks if required properties are set
-        :return: True if
+        :return: void
         """
         # JNDI_PROPERTIES_DIR
         try:
@@ -256,8 +280,11 @@ class CartridgeAgent(threading.Thread):
 
 
 def main():
-    cartridge_agent = CartridgeAgent()
-    cartridge_agent.start()
+    try:
+        cartridge_agent = CartridgeAgent()
+        cartridge_agent.start()
+    except:
+        cartridge_agent.terminate()
 
 
 if __name__ == "__main__":

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
new file mode 100644
index 0000000..03d5f31
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
@@ -0,0 +1,164 @@
+from thrift.publisher import *
+import logging
+
+
+class StreamDefinition:
+    """
+    Represents a BAM/CEP stream definition
+    """
+    def __init__(self):
+        self.name = None
+        """:type : str"""
+        self.version = None
+        """:type : str"""
+        self.nickname = None
+        """:type : str"""
+        self.description = None
+        """:type : str"""
+        self.meta_data = []
+        """:type : list[str]"""
+        self.correlation_data = []
+        """:type : list[str]"""
+        self.payload_data = []
+        """:type : list[str]"""
+
+    def add_metadata_attribute(self, name, type):
+        self.meta_data.append({"name": name, "type": type})
+
+    def add_payloaddata_attribute(self, name, type):
+        self.payload_data.append({"name": name, "type": type})
+
+    def add_correlationdata_attribute(self, name, type):
+        self.correlation_data.append({"name": name, "type": type})
+
+    def __str__(self):
+        """
+        To string override
+        """
+
+        json_str = "{"
+        json_str += "\"name\":\"" + self.name + "\","
+        json_str += "\"version\":\"" + self.version + "\","
+        json_str += "\"nickName\":\"" + self.nickname + "\","
+        json_str += "\"description\":\"" + self.description + "\","
+
+        # add metadata attributes if exists
+        if len(self.meta_data > 0):
+            json_str += "\"metaData\":["
+            for metadatum in self.meta_data:
+                json_str += "{\"name\":\"" + metadatum["name"] + ", \"type\": \"" + metadatum["type"] + "\"},"
+
+            json_str = json_str[:-1] + "],"
+
+        # add correlationdata attributes if exists
+        if len(self.correlation_data > 0):
+            json_str += "\"correlationData\":["
+            for coredatum in self.correlation_data:
+                json_str += "{\"name\":\"" + coredatum["name"] + ", \"type\": \"" + coredatum["type"] + "\"},"
+
+            json_str = json_str[:-1] + "],"
+
+        # add payloaddata attributes if exists
+        if len(self.payload_data > 0):
+            json_str += "\"payloadData\":["
+            for payloaddatum in self.payload_data:
+                json_str += "{\"name\":\"" + payloaddatum["name"] + ", \"type\": \"" + payloaddatum["type"] + "\"},"
+
+            json_str = json_str[:-1] + "],"
+
+        json_str = json_str[:-1] + "}"
+
+        return json_str
+
+
+class LogEvent:
+    """
+    Represents an event to be published to a BAM/CEP monitoring server
+    """
+    def __init__(self):
+        self.metaData = []
+        """:type : list[str]"""
+        self.correlationData = []
+        """:type : list[str]"""
+        self.payloadData = []
+        """:type : list[str]"""
+
+
+class ThriftPublisher:
+    """
+    Handles publishing events to BAM/CEP through thrift using the provided address and credentials
+    """
+    logging.basicConfig(level=logging.DEBUG)
+    log = logging.getLogger(__name__)
+
+    def __init__(self, ip, port, username, password, stream_definition):
+        """
+        Initializes a ThriftPublisher object.
+
+        At initialization a ThriftPublisher connects and defines a stream definition. A connection
+        should be disconnected after all the publishing has been done.
+
+        :param str ip: IP address of the monitoring server
+        :param str port: Port of the monitoring server
+        :param str username: Username
+        :param str password: Password
+        :param StreamDefinition stream_definition: StreamDefinition object for this particular connection
+        :return: ThriftPublisher object
+        :rtype: ThriftPublisher
+        """
+        self.__publisher = Publisher(ip, port)
+        self.__publisher.connect(username, password)
+        self.__publisher.defineStream(str(stream_definition))
+
+    def publish(self, event):
+        """
+        Publishes the given event by creating the event bundle from the log event
+
+        :param LogEvent event: The log event to be published
+        :return: void
+        """
+        event_bundler = EventBundle()
+        ThriftPublisher.assign_attributes(event.metaData, event_bundler)
+        ThriftPublisher.assign_attributes(event.correlationData, event_bundler)
+        ThriftPublisher.assign_attributes(event.payloadData, event_bundler)
+
+        self.__publisher.publish(event)
+
+    def disconnect(self):
+        """
+        Disconnect the thrift publisher
+        :return: void
+        """
+        self.__publisher.disconnect()
+
+    @staticmethod
+    def assign_attributes(attributes, event_bundler):
+        """
+        Adds the given attributes to the given event bundler according to type of each attribute
+        :param list attributes: attributes to be assigned
+        :param EventBundle event_bundler: Event bundle to assign attributes to
+        :return: void
+        """
+
+        # __intAttributeList = []
+        # __longAttributeList = []
+        # __doubleAttributeList = []
+        # __boolAttributeList = []
+        # __stringAttributeList = []
+
+        if attributes is not None and len(attributes) > 0:
+            for attrib in attributes:
+                if isinstance(attrib, int):
+                    event_bundler.addIntAttribute(attrib)
+                elif isinstance(attrib, long):
+                    event_bundler.addLongAttribute(attrib)
+                elif isinstance(attrib, float):
+                    event_bundler.addDoubleAttribute(attrib)
+                elif isinstance(attrib, bool):
+                    event_bundler.addBoolAttribute(attrib)
+                elif isinstance(attrib, str):
+                    event_bundler.addStringAttribute(attrib)
+                else:
+                    ThriftPublisher.log.error("Undefined attribute type: %r" % attrib)
+
+        ThriftPublisher.log.debug("Empty attribute list")

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
new file mode 100644
index 0000000..642c550
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Data/ttypes.py
@@ -0,0 +1,320 @@
+#
+# 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 thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class ThriftAttributeType:
+  INT = 0
+  LONG = 1
+  FLOAT = 2
+  DOUBLE = 3
+  BOOL = 4
+  STRING = 5
+
+  _VALUES_TO_NAMES = {
+    0: "INT",
+    1: "LONG",
+    2: "FLOAT",
+    3: "DOUBLE",
+    4: "BOOL",
+    5: "STRING",
+  }
+
+  _NAMES_TO_VALUES = {
+    "INT": 0,
+    "LONG": 1,
+    "FLOAT": 2,
+    "DOUBLE": 3,
+    "BOOL": 4,
+    "STRING": 5,
+  }
+
+
+class ThriftAttribute:
+  """
+  Attributes:
+   - name
+   - attributeType
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.I32, 'attributeType', None, None, ), # 2
+  )
+
+  def __init__(self, name=None, attributeType=None,):
+    self.name = name
+    self.attributeType = attributeType
+
+  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.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.I32:
+          self.attributeType = iprot.readI32();
+        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('ThriftAttribute')
+    if self.name is not None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.attributeType is not None:
+      oprot.writeFieldBegin('attributeType', TType.I32, 2)
+      oprot.writeI32(self.attributeType)
+      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 ThriftEventBundle:
+  """
+  Attributes:
+   - sessionId
+   - eventNum
+   - intAttributeList
+   - longAttributeList
+   - doubleAttributeList
+   - boolAttributeList
+   - stringAttributeList
+   - arbitraryDataMapMap
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'sessionId', None, None, ), # 1
+    (2, TType.I32, 'eventNum', None, None, ), # 2
+    (3, TType.LIST, 'intAttributeList', (TType.I32,None), None, ), # 3
+    (4, TType.LIST, 'longAttributeList', (TType.I64,None), None, ), # 4
+    (5, TType.LIST, 'doubleAttributeList', (TType.DOUBLE,None), None, ), # 5
+    (6, TType.LIST, 'boolAttributeList', (TType.BOOL,None), None, ), # 6
+    (7, TType.LIST, 'stringAttributeList', (TType.STRING,None), None, ), # 7
+    (8, TType.MAP, 'arbitraryDataMapMap', (TType.I32,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 8
+  )
+
+  def __init__(self, sessionId=None, eventNum=None, intAttributeList=None, longAttributeList=None, doubleAttributeList=None, boolAttributeList=None, stringAttributeList=None, arbitraryDataMapMap=None,):
+    self.sessionId = sessionId
+    self.eventNum = eventNum
+    self.intAttributeList = intAttributeList
+    self.longAttributeList = longAttributeList
+    self.doubleAttributeList = doubleAttributeList
+    self.boolAttributeList = boolAttributeList
+    self.stringAttributeList = stringAttributeList
+    self.arbitraryDataMapMap = arbitraryDataMapMap
+
+  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.I32:
+          self.eventNum = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.LIST:
+          self.intAttributeList = []
+          (_etype3, _size0) = iprot.readListBegin()
+          for _i4 in xrange(_size0):
+            _elem5 = iprot.readI32();
+            self.intAttributeList.append(_elem5)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.LIST:
+          self.longAttributeList = []
+          (_etype9, _size6) = iprot.readListBegin()
+          for _i10 in xrange(_size6):
+            _elem11 = iprot.readI64();
+            self.longAttributeList.append(_elem11)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.LIST:
+          self.doubleAttributeList = []
+          (_etype15, _size12) = iprot.readListBegin()
+          for _i16 in xrange(_size12):
+            _elem17 = iprot.readDouble();
+            self.doubleAttributeList.append(_elem17)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TType.LIST:
+          self.boolAttributeList = []
+          (_etype21, _size18) = iprot.readListBegin()
+          for _i22 in xrange(_size18):
+            _elem23 = iprot.readBool();
+            self.boolAttributeList.append(_elem23)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TType.LIST:
+          self.stringAttributeList = []
+          (_etype27, _size24) = iprot.readListBegin()
+          for _i28 in xrange(_size24):
+            _elem29 = iprot.readString();
+            self.stringAttributeList.append(_elem29)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 8:
+        if ftype == TType.MAP:
+          self.arbitraryDataMapMap = {}
+          (_ktype31, _vtype32, _size30 ) = iprot.readMapBegin()
+          for _i34 in xrange(_size30):
+            _key35 = iprot.readI32();
+            _val36 = {}
+            (_ktype38, _vtype39, _size37 ) = iprot.readMapBegin()
+            for _i41 in xrange(_size37):
+              _key42 = iprot.readString();
+              _val43 = iprot.readString();
+              _val36[_key42] = _val43
+            iprot.readMapEnd()
+            self.arbitraryDataMapMap[_key35] = _val36
+          iprot.readMapEnd()
+        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('ThriftEventBundle')
+    if self.sessionId is not None:
+      oprot.writeFieldBegin('sessionId', TType.STRING, 1)
+      oprot.writeString(self.sessionId)
+      oprot.writeFieldEnd()
+    if self.eventNum is not None:
+      oprot.writeFieldBegin('eventNum', TType.I32, 2)
+      oprot.writeI32(self.eventNum)
+      oprot.writeFieldEnd()
+    if self.intAttributeList is not None:
+      oprot.writeFieldBegin('intAttributeList', TType.LIST, 3)
+      oprot.writeListBegin(TType.I32, len(self.intAttributeList))
+      for iter44 in self.intAttributeList:
+        oprot.writeI32(iter44)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.longAttributeList is not None:
+      oprot.writeFieldBegin('longAttributeList', TType.LIST, 4)
+      oprot.writeListBegin(TType.I64, len(self.longAttributeList))
+      for iter45 in self.longAttributeList:
+        oprot.writeI64(iter45)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.doubleAttributeList is not None:
+      oprot.writeFieldBegin('doubleAttributeList', TType.LIST, 5)
+      oprot.writeListBegin(TType.DOUBLE, len(self.doubleAttributeList))
+      for iter46 in self.doubleAttributeList:
+        oprot.writeDouble(iter46)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.boolAttributeList is not None:
+      oprot.writeFieldBegin('boolAttributeList', TType.LIST, 6)
+      oprot.writeListBegin(TType.BOOL, len(self.boolAttributeList))
+      for iter47 in self.boolAttributeList:
+        oprot.writeBool(iter47)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.stringAttributeList is not None:
+      oprot.writeFieldBegin('stringAttributeList', TType.LIST, 7)
+      oprot.writeListBegin(TType.STRING, len(self.stringAttributeList))
+      for iter48 in self.stringAttributeList:
+        oprot.writeString(iter48)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.arbitraryDataMapMap is not None:
+      oprot.writeFieldBegin('arbitraryDataMapMap', TType.MAP, 8)
+      oprot.writeMapBegin(TType.I32, TType.MAP, len(self.arbitraryDataMapMap))
+      for kiter49,viter50 in self.arbitraryDataMapMap.items():
+        oprot.writeI32(kiter49)
+        oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter50))
+        for kiter51,viter52 in viter50.items():
+          oprot.writeString(kiter51)
+          oprot.writeString(viter52)
+        oprot.writeMapEnd()
+      oprot.writeMapEnd()
+      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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
new file mode 100644
index 0000000..c69fb5e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/Exception/ttypes.py
@@ -0,0 +1,473 @@
+#
+# 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 thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+
+class ThriftStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftNoStreamDefinitionExistException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftNoStreamDefinitionExistException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftDifferentStreamDefinitionAlreadyDefinedException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftDifferentStreamDefinitionAlreadyDefinedException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftMalformedStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftMalformedStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftUndefinedEventTypeException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftUndefinedEventTypeException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftSessionExpiredException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftSessionExpiredException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftAuthenticationException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftAuthenticationException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
new file mode 100755
index 0000000..0d18f58
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+from ThriftEventTransmissionService import ThriftEventTransmissionService
+from ThriftEventTransmissionService.ttypes import *
+
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
new file mode 100644
index 0000000..cb96c29
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
@@ -0,0 +1,1143 @@
+#
+# 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
+
+try:
+  from thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class Iface:
+  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 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["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_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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
+      result.ade = ade
+    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
+      result.mtd = mtd
+    except Exception.ttypes.ThriftStreamDefinitionException, tde:
+      result.tde = tde
+    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
+      result.tnde = tnde
+    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
+      result.ue = ue
+    except Exception.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 Exception.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 Exception.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 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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
+    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
+          self.ade.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
+          self.mtd.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
+          self.tde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
+          self.tnde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
+          self.ue.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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)


[12/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
new file mode 100644
index 0000000..fa478d0
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
@@ -0,0 +1,346 @@
+#
+# 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.
+#
+"""Implementation of non-blocking server.
+
+The main idea of the server is to receive and send requests
+only from the main thread.
+
+The thread poool should be sized for concurrent tasks, not
+maximum connections
+"""
+import threading
+import socket
+import Queue
+import select
+import struct
+import logging
+
+from thrift.transport import TTransport
+from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
+
+__all__ = ['TNonblockingServer']
+
+
+class Worker(threading.Thread):
+    """Worker is a small helper to process incoming connection."""
+
+    def __init__(self, queue):
+        threading.Thread.__init__(self)
+        self.queue = queue
+
+    def run(self):
+        """Process queries from task queue, stop if processor is None."""
+        while True:
+            try:
+                processor, iprot, oprot, otrans, callback = self.queue.get()
+                if processor is None:
+                    break
+                processor.process(iprot, oprot)
+                callback(True, otrans.getvalue())
+            except Exception:
+                logging.exception("Exception while processing request")
+                callback(False, '')
+
+WAIT_LEN = 0
+WAIT_MESSAGE = 1
+WAIT_PROCESS = 2
+SEND_ANSWER = 3
+CLOSED = 4
+
+
+def locked(func):
+    """Decorator which locks self.lock."""
+    def nested(self, *args, **kwargs):
+        self.lock.acquire()
+        try:
+            return func(self, *args, **kwargs)
+        finally:
+            self.lock.release()
+    return nested
+
+
+def socket_exception(func):
+    """Decorator close object on socket.error."""
+    def read(self, *args, **kwargs):
+        try:
+            return func(self, *args, **kwargs)
+        except socket.error:
+            self.close()
+    return read
+
+
+class Connection:
+    """Basic class is represented connection.
+
+    It can be in state:
+        WAIT_LEN --- connection is reading request len.
+        WAIT_MESSAGE --- connection is reading request.
+        WAIT_PROCESS --- connection has just read whole request and
+                         waits for call ready routine.
+        SEND_ANSWER --- connection is sending answer string (including length
+                        of answer).
+        CLOSED --- socket was closed and connection should be deleted.
+    """
+    def __init__(self, new_socket, wake_up):
+        self.socket = new_socket
+        self.socket.setblocking(False)
+        self.status = WAIT_LEN
+        self.len = 0
+        self.message = ''
+        self.lock = threading.Lock()
+        self.wake_up = wake_up
+
+    def _read_len(self):
+        """Reads length of request.
+
+        It's a safer alternative to self.socket.recv(4)
+        """
+        read = self.socket.recv(4 - len(self.message))
+        if len(read) == 0:
+            # if we read 0 bytes and self.message is empty, then
+            # the client closed the connection
+            if len(self.message) != 0:
+                logging.error("can't read frame size from socket")
+            self.close()
+            return
+        self.message += read
+        if len(self.message) == 4:
+            self.len, = struct.unpack('!i', self.message)
+            if self.len < 0:
+                logging.error("negative frame size, it seems client "
+                              "doesn't use FramedTransport")
+                self.close()
+            elif self.len == 0:
+                logging.error("empty frame, it's really strange")
+                self.close()
+            else:
+                self.message = ''
+                self.status = WAIT_MESSAGE
+
+    @socket_exception
+    def read(self):
+        """Reads data from stream and switch state."""
+        assert self.status in (WAIT_LEN, WAIT_MESSAGE)
+        if self.status == WAIT_LEN:
+            self._read_len()
+            # go back to the main loop here for simplicity instead of
+            # falling through, even though there is a good chance that
+            # the message is already available
+        elif self.status == WAIT_MESSAGE:
+            read = self.socket.recv(self.len - len(self.message))
+            if len(read) == 0:
+                logging.error("can't read frame from socket (get %d of "
+                              "%d bytes)" % (len(self.message), self.len))
+                self.close()
+                return
+            self.message += read
+            if len(self.message) == self.len:
+                self.status = WAIT_PROCESS
+
+    @socket_exception
+    def write(self):
+        """Writes data from socket and switch state."""
+        assert self.status == SEND_ANSWER
+        sent = self.socket.send(self.message)
+        if sent == len(self.message):
+            self.status = WAIT_LEN
+            self.message = ''
+            self.len = 0
+        else:
+            self.message = self.message[sent:]
+
+    @locked
+    def ready(self, all_ok, message):
+        """Callback function for switching state and waking up main thread.
+
+        This function is the only function witch can be called asynchronous.
+
+        The ready can switch Connection to three states:
+            WAIT_LEN if request was oneway.
+            SEND_ANSWER if request was processed in normal way.
+            CLOSED if request throws unexpected exception.
+
+        The one wakes up main thread.
+        """
+        assert self.status == WAIT_PROCESS
+        if not all_ok:
+            self.close()
+            self.wake_up()
+            return
+        self.len = ''
+        if len(message) == 0:
+            # it was a oneway request, do not write answer
+            self.message = ''
+            self.status = WAIT_LEN
+        else:
+            self.message = struct.pack('!i', len(message)) + message
+            self.status = SEND_ANSWER
+        self.wake_up()
+
+    @locked
+    def is_writeable(self):
+        """Return True if connection should be added to write list of select"""
+        return self.status == SEND_ANSWER
+
+    # it's not necessary, but...
+    @locked
+    def is_readable(self):
+        """Return True if connection should be added to read list of select"""
+        return self.status in (WAIT_LEN, WAIT_MESSAGE)
+
+    @locked
+    def is_closed(self):
+        """Returns True if connection is closed."""
+        return self.status == CLOSED
+
+    def fileno(self):
+        """Returns the file descriptor of the associated socket."""
+        return self.socket.fileno()
+
+    def close(self):
+        """Closes connection"""
+        self.status = CLOSED
+        self.socket.close()
+
+
+class TNonblockingServer:
+    """Non-blocking server."""
+
+    def __init__(self,
+                 processor,
+                 lsocket,
+                 inputProtocolFactory=None,
+                 outputProtocolFactory=None,
+                 threads=10):
+        self.processor = processor
+        self.socket = lsocket
+        self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory()
+        self.out_protocol = outputProtocolFactory or self.in_protocol
+        self.threads = int(threads)
+        self.clients = {}
+        self.tasks = Queue.Queue()
+        self._read, self._write = socket.socketpair()
+        self.prepared = False
+        self._stop = False
+
+    def setNumThreads(self, num):
+        """Set the number of worker threads that should be created."""
+        # implement ThreadPool interface
+        assert not self.prepared, "Can't change number of threads after start"
+        self.threads = num
+
+    def prepare(self):
+        """Prepares server for serve requests."""
+        if self.prepared:
+            return
+        self.socket.listen()
+        for _ in xrange(self.threads):
+            thread = Worker(self.tasks)
+            thread.setDaemon(True)
+            thread.start()
+        self.prepared = True
+
+    def wake_up(self):
+        """Wake up main thread.
+
+        The server usualy waits in select call in we should terminate one.
+        The simplest way is using socketpair.
+
+        Select always wait to read from the first socket of socketpair.
+
+        In this case, we can just write anything to the second socket from
+        socketpair.
+        """
+        self._write.send('1')
+
+    def stop(self):
+        """Stop the server.
+
+        This method causes the serve() method to return.  stop() may be invoked
+        from within your handler, or from another thread.
+
+        After stop() is called, serve() will return but the server will still
+        be listening on the socket.  serve() may then be called again to resume
+        processing requests.  Alternatively, close() may be called after
+        serve() returns to close the server socket and shutdown all worker
+        threads.
+        """
+        self._stop = True
+        self.wake_up()
+
+    def _select(self):
+        """Does select on open connections."""
+        readable = [self.socket.handle.fileno(), self._read.fileno()]
+        writable = []
+        for i, connection in self.clients.items():
+            if connection.is_readable():
+                readable.append(connection.fileno())
+            if connection.is_writeable():
+                writable.append(connection.fileno())
+            if connection.is_closed():
+                del self.clients[i]
+        return select.select(readable, writable, readable)
+
+    def handle(self):
+        """Handle requests.
+
+        WARNING! You must call prepare() BEFORE calling handle()
+        """
+        assert self.prepared, "You have to call prepare before handle"
+        rset, wset, xset = self._select()
+        for readable in rset:
+            if readable == self._read.fileno():
+                # don't care i just need to clean readable flag
+                self._read.recv(1024)
+            elif readable == self.socket.handle.fileno():
+                client = self.socket.accept().handle
+                self.clients[client.fileno()] = Connection(client,
+                                                           self.wake_up)
+            else:
+                connection = self.clients[readable]
+                connection.read()
+                if connection.status == WAIT_PROCESS:
+                    itransport = TTransport.TMemoryBuffer(connection.message)
+                    otransport = TTransport.TMemoryBuffer()
+                    iprot = self.in_protocol.getProtocol(itransport)
+                    oprot = self.out_protocol.getProtocol(otransport)
+                    self.tasks.put([self.processor, iprot, oprot,
+                                    otransport, connection.ready])
+        for writeable in wset:
+            self.clients[writeable].write()
+        for oob in xset:
+            self.clients[oob].close()
+            del self.clients[oob]
+
+    def close(self):
+        """Closes the server."""
+        for _ in xrange(self.threads):
+            self.tasks.put([None, None, None, None, None])
+        self.socket.close()
+        self.prepared = False
+
+    def serve(self):
+        """Serve requests.
+
+        Serve requests forever, or until stop() is called.
+        """
+        self._stop = False
+        self.prepare()
+        while not self._stop:
+            self.handle()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
new file mode 100644
index 0000000..2cd2189
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
@@ -0,0 +1,118 @@
+#
+# 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 logging
+from multiprocessing import  Process, Value, Condition
+
+from TServer import TServer
+from thrift.transport.TTransport import TTransportException
+
+
+class TProcessPoolServer(TServer):
+    """Server with a fixed size pool of worker subprocesses to service requests
+
+    Note that if you need shared state between the handlers - it's up to you!
+    Written by Dvir Volk, doat.com
+    """
+    def __init__(self, *args):
+        TServer.__init__(self, *args)
+        self.numWorkers = 10
+        self.workers = []
+        self.isRunning = Value('b', False)
+        self.stopCondition = Condition()
+        self.postForkCallback = None
+
+    def setPostForkCallback(self, callback):
+        if not callable(callback):
+            raise TypeError("This is not a callback!")
+        self.postForkCallback = callback
+
+    def setNumWorkers(self, num):
+        """Set the number of worker threads that should be created"""
+        self.numWorkers = num
+
+    def workerProcess(self):
+        """Loop getting clients from the shared queue and process them"""
+        if self.postForkCallback:
+            self.postForkCallback()
+
+        while self.isRunning.value:
+            try:
+                client = self.serverTransport.accept()
+                self.serveClient(client)
+            except (KeyboardInterrupt, SystemExit):
+                return 0
+            except Exception, x:
+                logging.exception(x)
+
+    def serveClient(self, client):
+        """Process input/output from a client for as long as possible"""
+        itrans = self.inputTransportFactory.getTransport(client)
+        otrans = self.outputTransportFactory.getTransport(client)
+        iprot = self.inputProtocolFactory.getProtocol(itrans)
+        oprot = self.outputProtocolFactory.getProtocol(otrans)
+
+        try:
+            while True:
+                self.processor.process(iprot, oprot)
+        except TTransportException, tx:
+            pass
+        except Exception, x:
+            logging.exception(x)
+
+        itrans.close()
+        otrans.close()
+
+    def serve(self):
+        """Start workers and put into queue"""
+        # this is a shared state that can tell the workers to exit when False
+        self.isRunning.value = True
+
+        # first bind and listen to the port
+        self.serverTransport.listen()
+
+        # fork the children
+        for i in range(self.numWorkers):
+            try:
+                w = Process(target=self.workerProcess)
+                w.daemon = True
+                w.start()
+                self.workers.append(w)
+            except Exception, x:
+                logging.exception(x)
+
+        # wait until the condition is set by stop()
+        while True:
+            self.stopCondition.acquire()
+            try:
+                self.stopCondition.wait()
+                break
+            except (SystemExit, KeyboardInterrupt):
+                break
+            except Exception, x:
+                logging.exception(x)
+
+        self.isRunning.value = False
+
+    def stop(self):
+        self.isRunning.value = False
+        self.stopCondition.acquire()
+        self.stopCondition.notify()
+        self.stopCondition.release()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
new file mode 100644
index 0000000..2f24842
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
@@ -0,0 +1,269 @@
+#
+# 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 Queue
+import logging
+import os
+import sys
+import threading
+import traceback
+
+from thrift.Thrift import TProcessor
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+
+class TServer:
+  """Base interface for a server, which must have a serve() method.
+
+  Three constructors for all servers:
+  1) (processor, serverTransport)
+  2) (processor, serverTransport, transportFactory, protocolFactory)
+  3) (processor, serverTransport,
+      inputTransportFactory, outputTransportFactory,
+      inputProtocolFactory, outputProtocolFactory)
+  """
+  def __init__(self, *args):
+    if (len(args) == 2):
+      self.__initArgs__(args[0], args[1],
+                        TTransport.TTransportFactoryBase(),
+                        TTransport.TTransportFactoryBase(),
+                        TBinaryProtocol.TBinaryProtocolFactory(),
+                        TBinaryProtocol.TBinaryProtocolFactory())
+    elif (len(args) == 4):
+      self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3])
+    elif (len(args) == 6):
+      self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5])
+
+  def __initArgs__(self, processor, serverTransport,
+                   inputTransportFactory, outputTransportFactory,
+                   inputProtocolFactory, outputProtocolFactory):
+    self.processor = processor
+    self.serverTransport = serverTransport
+    self.inputTransportFactory = inputTransportFactory
+    self.outputTransportFactory = outputTransportFactory
+    self.inputProtocolFactory = inputProtocolFactory
+    self.outputProtocolFactory = outputProtocolFactory
+
+  def serve(self):
+    pass
+
+
+class TSimpleServer(TServer):
+  """Simple single-threaded server that just pumps around one transport."""
+
+  def __init__(self, *args):
+    TServer.__init__(self, *args)
+
+  def serve(self):
+    self.serverTransport.listen()
+    while True:
+      client = self.serverTransport.accept()
+      itrans = self.inputTransportFactory.getTransport(client)
+      otrans = self.outputTransportFactory.getTransport(client)
+      iprot = self.inputProtocolFactory.getProtocol(itrans)
+      oprot = self.outputProtocolFactory.getProtocol(otrans)
+      try:
+        while True:
+          self.processor.process(iprot, oprot)
+      except TTransport.TTransportException, tx:
+        pass
+      except Exception, x:
+        logging.exception(x)
+
+      itrans.close()
+      otrans.close()
+
+
+class TThreadedServer(TServer):
+  """Threaded server that spawns a new thread per each connection."""
+
+  def __init__(self, *args, **kwargs):
+    TServer.__init__(self, *args)
+    self.daemon = kwargs.get("daemon", False)
+
+  def serve(self):
+    self.serverTransport.listen()
+    while True:
+      try:
+        client = self.serverTransport.accept()
+        t = threading.Thread(target=self.handle, args=(client,))
+        t.setDaemon(self.daemon)
+        t.start()
+      except KeyboardInterrupt:
+        raise
+      except Exception, x:
+        logging.exception(x)
+
+  def handle(self, client):
+    itrans = self.inputTransportFactory.getTransport(client)
+    otrans = self.outputTransportFactory.getTransport(client)
+    iprot = self.inputProtocolFactory.getProtocol(itrans)
+    oprot = self.outputProtocolFactory.getProtocol(otrans)
+    try:
+      while True:
+        self.processor.process(iprot, oprot)
+    except TTransport.TTransportException, tx:
+      pass
+    except Exception, x:
+      logging.exception(x)
+
+    itrans.close()
+    otrans.close()
+
+
+class TThreadPoolServer(TServer):
+  """Server with a fixed size pool of threads which service requests."""
+
+  def __init__(self, *args, **kwargs):
+    TServer.__init__(self, *args)
+    self.clients = Queue.Queue()
+    self.threads = 10
+    self.daemon = kwargs.get("daemon", False)
+
+  def setNumThreads(self, num):
+    """Set the number of worker threads that should be created"""
+    self.threads = num
+
+  def serveThread(self):
+    """Loop around getting clients from the shared queue and process them."""
+    while True:
+      try:
+        client = self.clients.get()
+        self.serveClient(client)
+      except Exception, x:
+        logging.exception(x)
+
+  def serveClient(self, client):
+    """Process input/output from a client for as long as possible"""
+    itrans = self.inputTransportFactory.getTransport(client)
+    otrans = self.outputTransportFactory.getTransport(client)
+    iprot = self.inputProtocolFactory.getProtocol(itrans)
+    oprot = self.outputProtocolFactory.getProtocol(otrans)
+    try:
+      while True:
+        self.processor.process(iprot, oprot)
+    except TTransport.TTransportException, tx:
+      pass
+    except Exception, x:
+      logging.exception(x)
+
+    itrans.close()
+    otrans.close()
+
+  def serve(self):
+    """Start a fixed number of worker threads and put client into a queue"""
+    for i in range(self.threads):
+      try:
+        t = threading.Thread(target=self.serveThread)
+        t.setDaemon(self.daemon)
+        t.start()
+      except Exception, x:
+        logging.exception(x)
+
+    # Pump the socket for clients
+    self.serverTransport.listen()
+    while True:
+      try:
+        client = self.serverTransport.accept()
+        self.clients.put(client)
+      except Exception, x:
+        logging.exception(x)
+
+
+class TForkingServer(TServer):
+  """A Thrift server that forks a new process for each request
+
+  This is more scalable than the threaded server as it does not cause
+  GIL contention.
+
+  Note that this has different semantics from the threading server.
+  Specifically, updates to shared variables will no longer be shared.
+  It will also not work on windows.
+
+  This code is heavily inspired by SocketServer.ForkingMixIn in the
+  Python stdlib.
+  """
+  def __init__(self, *args):
+    TServer.__init__(self, *args)
+    self.children = []
+
+  def serve(self):
+    def try_close(file):
+      try:
+        file.close()
+      except IOError, e:
+        logging.warning(e, exc_info=True)
+
+    self.serverTransport.listen()
+    while True:
+      client = self.serverTransport.accept()
+      try:
+        pid = os.fork()
+
+        if pid:  # parent
+          # add before collect, otherwise you race w/ waitpid
+          self.children.append(pid)
+          self.collect_children()
+
+          # Parent must close socket or the connection may not get
+          # closed promptly
+          itrans = self.inputTransportFactory.getTransport(client)
+          otrans = self.outputTransportFactory.getTransport(client)
+          try_close(itrans)
+          try_close(otrans)
+        else:
+          itrans = self.inputTransportFactory.getTransport(client)
+          otrans = self.outputTransportFactory.getTransport(client)
+
+          iprot = self.inputProtocolFactory.getProtocol(itrans)
+          oprot = self.outputProtocolFactory.getProtocol(otrans)
+
+          ecode = 0
+          try:
+            try:
+              while True:
+                self.processor.process(iprot, oprot)
+            except TTransport.TTransportException, tx:
+              pass
+            except Exception, e:
+              logging.exception(e)
+              ecode = 1
+          finally:
+            try_close(itrans)
+            try_close(otrans)
+
+          os._exit(ecode)
+
+      except TTransport.TTransportException, tx:
+        pass
+      except Exception, x:
+        logging.exception(x)
+
+  def collect_children(self):
+    while self.children:
+      try:
+        pid, status = os.waitpid(0, os.WNOHANG)
+      except os.error:
+        pid = None
+
+      if pid:
+        self.children.remove(pid)
+      else:
+        break

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/__init__.py
new file mode 100644
index 0000000..1bf6e25
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/__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__ = ['TServer', 'TNonblockingServer']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/THttpClient.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/THttpClient.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/THttpClient.py
new file mode 100644
index 0000000..9ef9535
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/THttpClient.py
@@ -0,0 +1,147 @@
+#
+# 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 httplib
+import os
+import socket
+import sys
+import urllib
+import urlparse
+import warnings
+
+from TTransport import *
+
+
+class THttpClient(TTransportBase):
+  """Http implementation of TTransport base."""
+
+  def __init__(self, uri_or_host, port=None, path=None):
+    """THttpClient supports two different types constructor parameters.
+
+    THttpClient(host, port, path) - deprecated
+    THttpClient(uri)
+
+    Only the second supports https.
+    """
+    if port is not None:
+      warnings.warn(
+        "Please use the THttpClient('http://host:port/path') syntax",
+        DeprecationWarning,
+        stacklevel=2)
+      self.host = uri_or_host
+      self.port = port
+      assert path
+      self.path = path
+      self.scheme = 'http'
+    else:
+      parsed = urlparse.urlparse(uri_or_host)
+      self.scheme = parsed.scheme
+      assert self.scheme in ('http', 'https')
+      if self.scheme == 'http':
+        self.port = parsed.port or httplib.HTTP_PORT
+      elif self.scheme == 'https':
+        self.port = parsed.port or httplib.HTTPS_PORT
+      self.host = parsed.hostname
+      self.path = parsed.path
+      if parsed.query:
+        self.path += '?%s' % parsed.query
+    self.__wbuf = StringIO()
+    self.__http = None
+    self.__timeout = None
+    self.__custom_headers = None
+
+  def open(self):
+    if self.scheme == 'http':
+      self.__http = httplib.HTTP(self.host, self.port)
+    else:
+      self.__http = httplib.HTTPS(self.host, self.port)
+
+  def close(self):
+    self.__http.close()
+    self.__http = None
+
+  def isOpen(self):
+    return self.__http is not None
+
+  def setTimeout(self, ms):
+    if not hasattr(socket, 'getdefaulttimeout'):
+      raise NotImplementedError
+
+    if ms is None:
+      self.__timeout = None
+    else:
+      self.__timeout = ms / 1000.0
+
+  def setCustomHeaders(self, headers):
+    self.__custom_headers = headers
+
+  def read(self, sz):
+    return self.__http.file.read(sz)
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def __withTimeout(f):
+    def _f(*args, **kwargs):
+      orig_timeout = socket.getdefaulttimeout()
+      socket.setdefaulttimeout(args[0].__timeout)
+      result = f(*args, **kwargs)
+      socket.setdefaulttimeout(orig_timeout)
+      return result
+    return _f
+
+  def flush(self):
+    if self.isOpen():
+      self.close()
+    self.open()
+
+    # Pull data out of buffer
+    data = self.__wbuf.getvalue()
+    self.__wbuf = StringIO()
+
+    # HTTP request
+    self.__http.putrequest('POST', self.path)
+
+    # Write headers
+    self.__http.putheader('Host', self.host)
+    self.__http.putheader('Content-Type', 'application/x-thrift')
+    self.__http.putheader('Content-Length', str(len(data)))
+
+    if not self.__custom_headers or 'User-Agent' not in self.__custom_headers:
+      user_agent = 'Python/THttpClient'
+      script = os.path.basename(sys.argv[0])
+      if script:
+        user_agent = '%s (%s)' % (user_agent, urllib.quote(script))
+      self.__http.putheader('User-Agent', user_agent)
+
+    if self.__custom_headers:
+        for key, val in self.__custom_headers.iteritems():
+            self.__http.putheader(key, val)
+
+    self.__http.endheaders()
+
+    # Write payload
+    self.__http.send(data)
+
+    # Get reply to flush the request
+    self.code, self.message, self.headers = self.__http.getreply()
+
+  # Decorate if we know how to timeout
+  if hasattr(socket, 'getdefaulttimeout'):
+    flush = __withTimeout(flush)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
new file mode 100644
index 0000000..81e0984
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
@@ -0,0 +1,214 @@
+#
+# 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 os
+import socket
+import ssl
+
+from thrift.transport import TSocket
+from thrift.transport.TTransport import TTransportException
+
+
+class TSSLSocket(TSocket.TSocket):
+  """
+  SSL implementation of client-side TSocket
+
+  This class creates outbound sockets wrapped using the
+  python standard ssl module for encrypted connections.
+
+  The protocol used is set using the class variable
+  SSL_VERSION, which must be one of ssl.PROTOCOL_* and
+  defaults to  ssl.PROTOCOL_TLSv1 for greatest security.
+  """
+  SSL_VERSION = ssl.PROTOCOL_TLSv1
+
+  def __init__(self,
+               host='localhost',
+               port=9090,
+               validate=True,
+               ca_certs=None,
+               keyfile=None,
+               certfile=None,
+               unix_socket=None):
+    """Create SSL TSocket
+
+    @param validate: Set to False to disable SSL certificate validation
+    @type validate: bool
+    @param ca_certs: Filename to the Certificate Authority pem file, possibly a
+    file downloaded from: http://curl.haxx.se/ca/cacert.pem  This is passed to
+    the ssl_wrap function as the 'ca_certs' parameter.
+    @type ca_certs: str
+    @param keyfile: The private key
+    @type keyfile: str
+    @param certfile: The cert file
+    @type certfile: str
+    
+    Raises an IOError exception if validate is True and the ca_certs file is
+    None, not present or unreadable.
+    """
+    self.validate = validate
+    self.is_valid = False
+    self.peercert = None
+    if not validate:
+      self.cert_reqs = ssl.CERT_NONE
+    else:
+      self.cert_reqs = ssl.CERT_REQUIRED
+    self.ca_certs = ca_certs
+    self.keyfile = keyfile
+    self.certfile = certfile
+    if validate:
+      if ca_certs is None or not os.access(ca_certs, os.R_OK):
+        raise IOError('Certificate Authority ca_certs file "%s" '
+                      'is not readable, cannot validate SSL '
+                      'certificates.' % (ca_certs))
+    TSocket.TSocket.__init__(self, host, port, unix_socket)
+
+  def open(self):
+    try:
+      res0 = self._resolveAddr()
+      for res in res0:
+        sock_family, sock_type = res[0:2]
+        ip_port = res[4]
+        plain_sock = socket.socket(sock_family, sock_type)
+        self.handle = ssl.wrap_socket(plain_sock,
+                                      ssl_version=self.SSL_VERSION,
+                                      do_handshake_on_connect=True,
+                                      ca_certs=self.ca_certs,
+                                      keyfile=self.keyfile,
+                                      certfile=self.certfile,
+                                      cert_reqs=self.cert_reqs)
+        self.handle.settimeout(self._timeout)
+        try:
+          self.handle.connect(ip_port)
+        except socket.error, e:
+          if res is not res0[-1]:
+            continue
+          else:
+            raise e
+        break
+    except socket.error, e:
+      if self._unix_socket:
+        message = 'Could not connect to secure socket %s: %s' \
+                % (self._unix_socket, e)
+      else:
+        message = 'Could not connect to %s:%d: %s' % (self.host, self.port, e)
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message=message)
+    if self.validate:
+      self._validate_cert()
+
+  def _validate_cert(self):
+    """internal method to validate the peer's SSL certificate, and to check the
+    commonName of the certificate to ensure it matches the hostname we
+    used to make this connection.  Does not support subjectAltName records
+    in certificates.
+
+    raises TTransportException if the certificate fails validation.
+    """
+    cert = self.handle.getpeercert()
+    self.peercert = cert
+    if 'subject' not in cert:
+      raise TTransportException(
+        type=TTransportException.NOT_OPEN,
+        message='No SSL certificate found from %s:%s' % (self.host, self.port))
+    fields = cert['subject']
+    for field in fields:
+      # ensure structure we get back is what we expect
+      if not isinstance(field, tuple):
+        continue
+      cert_pair = field[0]
+      if len(cert_pair) < 2:
+        continue
+      cert_key, cert_value = cert_pair[0:2]
+      if cert_key != 'commonName':
+        continue
+      certhost = cert_value
+      # this check should be performed by some sort of Access Manager
+      if certhost == self.host:
+        # success, cert commonName matches desired hostname
+        self.is_valid = True
+        return
+      else:
+        raise TTransportException(
+          type=TTransportException.UNKNOWN,
+          message='Hostname we connected to "%s" doesn\'t match certificate '
+                  'provided commonName "%s"' % (self.host, certhost))
+    raise TTransportException(
+      type=TTransportException.UNKNOWN,
+      message='Could not validate SSL certificate from '
+              'host "%s".  Cert=%s' % (self.host, cert))
+
+
+class TSSLServerSocket(TSocket.TServerSocket):
+  """SSL implementation of TServerSocket
+
+  This uses the ssl module's wrap_socket() method to provide SSL
+  negotiated encryption.
+  """
+  SSL_VERSION = ssl.PROTOCOL_TLSv1
+
+  def __init__(self,
+               host=None,
+               port=9090,
+               certfile='cert.pem',
+               unix_socket=None):
+    """Initialize a TSSLServerSocket
+
+    @param certfile: filename of the server certificate, defaults to cert.pem
+    @type certfile: str
+    @param host: The hostname or IP to bind the listen socket to,
+                 i.e. 'localhost' for only allowing local network connections.
+                 Pass None to bind to all interfaces.
+    @type host: str
+    @param port: The port to listen on for inbound connections.
+    @type port: int
+    """
+    self.setCertfile(certfile)
+    TSocket.TServerSocket.__init__(self, host, port)
+
+  def setCertfile(self, certfile):
+    """Set or change the server certificate file used to wrap new connections.
+
+    @param certfile: The filename of the server certificate,
+                     i.e. '/etc/certs/server.pem'
+    @type certfile: str
+
+    Raises an IOError exception if the certfile is not present or unreadable.
+    """
+    if not os.access(certfile, os.R_OK):
+      raise IOError('No such certfile found: %s' % (certfile))
+    self.certfile = certfile
+
+  def accept(self):
+    plain_client, addr = self.handle.accept()
+    try:
+      client = ssl.wrap_socket(plain_client, certfile=self.certfile,
+                      server_side=True, ssl_version=self.SSL_VERSION)
+    except ssl.SSLError, ssl_exc:
+      # failed handshake/ssl wrap, close socket to client
+      plain_client.close()
+      # raise ssl_exc
+      # We can't raise the exception, because it kills most TServer derived
+      # serve() methods.
+      # Instead, return None, and let the TServer instance deal with it in
+      # other exception handling.  (but TSimpleServer dies anyway)
+      return None
+    result = TSocket.TSocket()
+    result.setHandle(client)
+    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSocket.py
new file mode 100644
index 0000000..9e2b384
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSocket.py
@@ -0,0 +1,176 @@
+#
+# 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 errno
+import os
+import socket
+import sys
+
+from TTransport import *
+
+
+class TSocketBase(TTransportBase):
+  def _resolveAddr(self):
+    if self._unix_socket is not None:
+      return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None,
+               self._unix_socket)]
+    else:
+      return socket.getaddrinfo(self.host,
+                                self.port,
+                                socket.AF_UNSPEC,
+                                socket.SOCK_STREAM,
+                                0,
+                                socket.AI_PASSIVE | socket.AI_ADDRCONFIG)
+
+  def close(self):
+    if self.handle:
+      self.handle.close()
+      self.handle = None
+
+
+class TSocket(TSocketBase):
+  """Socket implementation of TTransport base."""
+
+  def __init__(self, host='localhost', port=9090, unix_socket=None):
+    """Initialize a TSocket
+
+    @param host(str)  The host to connect to.
+    @param port(int)  The (TCP) port to connect to.
+    @param unix_socket(str)  The filename of a unix socket to connect to.
+                             (host and port will be ignored.)
+    """
+    self.host = host
+    self.port = port
+    self.handle = None
+    self._unix_socket = unix_socket
+    self._timeout = None
+
+  def setHandle(self, h):
+    self.handle = h
+
+  def isOpen(self):
+    return self.handle is not None
+
+  def setTimeout(self, ms):
+    if ms is None:
+      self._timeout = None
+    else:
+      self._timeout = ms / 1000.0
+
+    if self.handle is not None:
+      self.handle.settimeout(self._timeout)
+
+  def open(self):
+    try:
+      res0 = self._resolveAddr()
+      for res in res0:
+        self.handle = socket.socket(res[0], res[1])
+        self.handle.settimeout(self._timeout)
+        try:
+          self.handle.connect(res[4])
+        except socket.error, e:
+          if res is not res0[-1]:
+            continue
+          else:
+            raise e
+        break
+    except socket.error, e:
+      if self._unix_socket:
+        message = 'Could not connect to socket %s' % self._unix_socket
+      else:
+        message = 'Could not connect to %s:%d' % (self.host, self.port)
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message=message)
+
+  def read(self, sz):
+    try:
+      buff = self.handle.recv(sz)
+    except socket.error, e:
+      if (e.args[0] == errno.ECONNRESET and
+          (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))):
+        # freebsd and Mach don't follow POSIX semantic of recv
+        # and fail with ECONNRESET if peer performed shutdown.
+        # See corresponding comment and code in TSocket::read()
+        # in lib/cpp/src/transport/TSocket.cpp.
+        self.close()
+        # Trigger the check to raise the END_OF_FILE exception below.
+        buff = ''
+      else:
+        raise
+    if len(buff) == 0:
+      raise TTransportException(type=TTransportException.END_OF_FILE,
+                                message='TSocket read 0 bytes')
+    return buff
+
+  def write(self, buff):
+    if not self.handle:
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message='Transport not open')
+    sent = 0
+    have = len(buff)
+    while sent < have:
+      plus = self.handle.send(buff)
+      if plus == 0:
+        raise TTransportException(type=TTransportException.END_OF_FILE,
+                                  message='TSocket sent 0 bytes')
+      sent += plus
+      buff = buff[plus:]
+
+  def flush(self):
+    pass
+
+
+class TServerSocket(TSocketBase, TServerTransportBase):
+  """Socket implementation of TServerTransport base."""
+
+  def __init__(self, host=None, port=9090, unix_socket=None):
+    self.host = host
+    self.port = port
+    self._unix_socket = unix_socket
+    self.handle = None
+
+  def listen(self):
+    res0 = self._resolveAddr()
+    for res in res0:
+      if res[0] is socket.AF_INET6 or res is res0[-1]:
+        break
+
+    # We need remove the old unix socket if the file exists and
+    # nobody is listening on it.
+    if self._unix_socket:
+      tmp = socket.socket(res[0], res[1])
+      try:
+        tmp.connect(res[4])
+      except socket.error, err:
+        eno, message = err.args
+        if eno == errno.ECONNREFUSED:
+          os.unlink(res[4])
+
+    self.handle = socket.socket(res[0], res[1])
+    self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+    if hasattr(self.handle, 'settimeout'):
+      self.handle.settimeout(None)
+    self.handle.bind(res[4])
+    self.handle.listen(128)
+
+  def accept(self):
+    client, addr = self.handle.accept()
+    result = TSocket()
+    result.setHandle(client)
+    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
new file mode 100644
index 0000000..4481371
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
@@ -0,0 +1,330 @@
+#
+# 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
+from struct import pack, unpack
+from thrift.Thrift import TException
+
+
+class TTransportException(TException):
+  """Custom Transport Exception class"""
+
+  UNKNOWN = 0
+  NOT_OPEN = 1
+  ALREADY_OPEN = 2
+  TIMED_OUT = 3
+  END_OF_FILE = 4
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
+
+class TTransportBase:
+  """Base class for Thrift transport layer."""
+
+  def isOpen(self):
+    pass
+
+  def open(self):
+    pass
+
+  def close(self):
+    pass
+
+  def read(self, sz):
+    pass
+
+  def readAll(self, sz):
+    buff = ''
+    have = 0
+    while (have < sz):
+      chunk = self.read(sz - have)
+      have += len(chunk)
+      buff += chunk
+
+      if len(chunk) == 0:
+        raise EOFError()
+
+    return buff
+
+  def write(self, buf):
+    pass
+
+  def flush(self):
+    pass
+
+
+# This class should be thought of as an interface.
+class CReadableTransport:
+  """base class for transports that are readable from C"""
+
+  # TODO(dreiss): Think about changing this interface to allow us to use
+  #               a (Python, not c) StringIO instead, because it allows
+  #               you to write after reading.
+
+  # NOTE: This is a classic class, so properties will NOT work
+  #       correctly for setting.
+  @property
+  def cstringio_buf(self):
+    """A cStringIO buffer that contains the current chunk we are reading."""
+    pass
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Refills cstringio_buf.
+
+    Returns the currently used buffer (which can but need not be the same as
+    the old cstringio_buf). partialread is what the C code has read from the
+    buffer, and should be inserted into the buffer before any more reads.  The
+    return value must be a new, not borrowed reference.  Something along the
+    lines of self._buf should be fine.
+
+    If reqlen bytes can't be read, throw EOFError.
+    """
+    pass
+
+
+class TServerTransportBase:
+  """Base class for Thrift server transports."""
+
+  def listen(self):
+    pass
+
+  def accept(self):
+    pass
+
+  def close(self):
+    pass
+
+
+class TTransportFactoryBase:
+  """Base class for a Transport Factory"""
+
+  def getTransport(self, trans):
+    return trans
+
+
+class TBufferedTransportFactory:
+  """Factory transport that builds buffered transports"""
+
+  def getTransport(self, trans):
+    buffered = TBufferedTransport(trans)
+    return buffered
+
+
+class TBufferedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and buffers its I/O.
+
+  The implementation uses a (configurable) fixed-size read buffer
+  but buffers all writes until a flush is performed.
+  """
+  DEFAULT_BUFFER = 4096
+
+  def __init__(self, trans, rbuf_size=DEFAULT_BUFFER):
+    self.__trans = trans
+    self.__wbuf = StringIO()
+    self.__rbuf = StringIO("")
+    self.__rbuf_size = rbuf_size
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
+    return self.__rbuf.read(sz)
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    out = self.__wbuf.getvalue()
+    # reset wbuf before write/flush to preserve state on underlying failure
+    self.__wbuf = StringIO()
+    self.__trans.write(out)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    retstring = partialread
+    if reqlen < self.__rbuf_size:
+      # try to make a read of as much as we can.
+      retstring += self.__trans.read(self.__rbuf_size)
+
+    # but make sure we do read reqlen bytes.
+    if len(retstring) < reqlen:
+      retstring += self.__trans.readAll(reqlen - len(retstring))
+
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf
+
+
+class TMemoryBuffer(TTransportBase, CReadableTransport):
+  """Wraps a cStringIO object as a TTransport.
+
+  NOTE: Unlike the C++ version of this class, you cannot write to it
+        then immediately read from it.  If you want to read from a
+        TMemoryBuffer, you must either pass a string to the constructor.
+  TODO(dreiss): Make this work like the C++ version.
+  """
+
+  def __init__(self, value=None):
+    """value -- a value to read from for stringio
+
+    If value is set, this will be a transport for reading,
+    otherwise, it is for writing"""
+    if value is not None:
+      self._buffer = StringIO(value)
+    else:
+      self._buffer = StringIO()
+
+  def isOpen(self):
+    return not self._buffer.closed
+
+  def open(self):
+    pass
+
+  def close(self):
+    self._buffer.close()
+
+  def read(self, sz):
+    return self._buffer.read(sz)
+
+  def write(self, buf):
+    self._buffer.write(buf)
+
+  def flush(self):
+    pass
+
+  def getvalue(self):
+    return self._buffer.getvalue()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self._buffer
+
+  def cstringio_refill(self, partialread, reqlen):
+    # only one shot at reading...
+    raise EOFError()
+
+
+class TFramedTransportFactory:
+  """Factory transport that builds framed transports"""
+
+  def getTransport(self, trans):
+    framed = TFramedTransport(trans)
+    return framed
+
+
+class TFramedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and frames its I/O when writing."""
+
+  def __init__(self, trans,):
+    self.__trans = trans
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.readFrame()
+    return self.__rbuf.read(sz)
+
+  def readFrame(self):
+    buff = self.__trans.readAll(4)
+    sz, = unpack('!i', buff)
+    self.__rbuf = StringIO(self.__trans.readAll(sz))
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    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 = pack("!i", wsz) + wout
+    self.__trans.write(buf)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, prefix, reqlen):
+    # self.__rbuf will already be empty here because fastbinary doesn't
+    # ask for a refill until the previous buffer is empty.  Therefore,
+    # we can start reading new frames immediately.
+    while len(prefix) < reqlen:
+      self.readFrame()
+      prefix += self.__rbuf.getvalue()
+    self.__rbuf = StringIO(prefix)
+    return self.__rbuf
+
+
+class TFileObjectTransport(TTransportBase):
+  """Wraps a file-like object to make it work as a Thrift transport."""
+
+  def __init__(self, fileobj):
+    self.fileobj = fileobj
+
+  def isOpen(self):
+    return True
+
+  def close(self):
+    self.fileobj.close()
+
+  def read(self, sz):
+    return self.fileobj.read(sz)
+
+  def write(self, buf):
+    self.fileobj.write(buf)
+
+  def flush(self):
+    self.fileobj.flush()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
new file mode 100644
index 0000000..3ce3eb2
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
@@ -0,0 +1,221 @@
+#
+# 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
+
+from zope.interface import implements, Interface, Attribute
+from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \
+    connectionDone
+from twisted.internet import defer
+from twisted.protocols import basic
+from twisted.python import log
+from twisted.web import server, resource, http
+
+from thrift.transport import TTransport
+
+
+class TMessageSenderTransport(TTransport.TTransportBase):
+
+    def __init__(self):
+        self.__wbuf = StringIO()
+
+    def write(self, buf):
+        self.__wbuf.write(buf)
+
+    def flush(self):
+        msg = self.__wbuf.getvalue()
+        self.__wbuf = StringIO()
+        self.sendMessage(msg)
+
+    def sendMessage(self, message):
+        raise NotImplementedError
+
+
+class TCallbackTransport(TMessageSenderTransport):
+
+    def __init__(self, func):
+        TMessageSenderTransport.__init__(self)
+        self.func = func
+
+    def sendMessage(self, message):
+        self.func(message)
+
+
+class ThriftClientProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self._client_class = client_class
+        self._iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self._oprot_factory = iprot_factory
+        else:
+            self._oprot_factory = oprot_factory
+
+        self.recv_map = {}
+        self.started = defer.Deferred()
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def connectionMade(self):
+        tmo = TCallbackTransport(self.dispatch)
+        self.client = self._client_class(tmo, self._oprot_factory)
+        self.started.callback(self.client)
+
+    def connectionLost(self, reason=connectionDone):
+        for k, v in self.client._reqs.iteritems():
+            tex = TTransport.TTransportException(
+                type=TTransport.TTransportException.END_OF_FILE,
+                message='Connection closed')
+            v.errback(tex)
+
+    def stringReceived(self, frame):
+        tr = TTransport.TMemoryBuffer(frame)
+        iprot = self._iprot_factory.getProtocol(tr)
+        (fname, mtype, rseqid) = iprot.readMessageBegin()
+
+        try:
+            method = self.recv_map[fname]
+        except KeyError:
+            method = getattr(self.client, 'recv_' + fname)
+            self.recv_map[fname] = method
+
+        method(iprot, mtype, rseqid)
+
+
+class ThriftServerProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def processError(self, error):
+        self.transport.loseConnection()
+
+    def processOk(self, _, tmo):
+        msg = tmo.getvalue()
+
+        if len(msg) > 0:
+            self.dispatch(msg)
+
+    def stringReceived(self, frame):
+        tmi = TTransport.TMemoryBuffer(frame)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.factory.iprot_factory.getProtocol(tmi)
+        oprot = self.factory.oprot_factory.getProtocol(tmo)
+
+        d = self.factory.processor.process(iprot, oprot)
+        d.addCallbacks(self.processOk, self.processError,
+            callbackArgs=(tmo,))
+
+
+class IThriftServerFactory(Interface):
+
+    processor = Attribute("Thrift processor")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class IThriftClientFactory(Interface):
+
+    client_class = Attribute("Thrift client class")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class ThriftServerFactory(ServerFactory):
+
+    implements(IThriftServerFactory)
+
+    protocol = ThriftServerProtocol
+
+    def __init__(self, processor, iprot_factory, oprot_factory=None):
+        self.processor = processor
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+
+class ThriftClientFactory(ClientFactory):
+
+    implements(IThriftClientFactory)
+
+    protocol = ThriftClientProtocol
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self.client_class = client_class
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+    def buildProtocol(self, addr):
+        p = self.protocol(self.client_class, self.iprot_factory,
+            self.oprot_factory)
+        p.factory = self
+        return p
+
+
+class ThriftResource(resource.Resource):
+
+    allowedMethods = ('POST',)
+
+    def __init__(self, processor, inputProtocolFactory,
+        outputProtocolFactory=None):
+        resource.Resource.__init__(self)
+        self.inputProtocolFactory = inputProtocolFactory
+        if outputProtocolFactory is None:
+            self.outputProtocolFactory = inputProtocolFactory
+        else:
+            self.outputProtocolFactory = outputProtocolFactory
+        self.processor = processor
+
+    def getChild(self, path, request):
+        return self
+
+    def _cbProcess(self, _, request, tmo):
+        msg = tmo.getvalue()
+        request.setResponseCode(http.OK)
+        request.setHeader("content-type", "application/x-thrift")
+        request.write(msg)
+        request.finish()
+
+    def render_POST(self, request):
+        request.content.seek(0, 0)
+        data = request.content.read()
+        tmi = TTransport.TMemoryBuffer(data)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.inputProtocolFactory.getProtocol(tmi)
+        oprot = self.outputProtocolFactory.getProtocol(tmo)
+
+        d = self.processor.process(iprot, oprot)
+        d.addCallback(self._cbProcess, request, tmo)
+        return server.NOT_DONE_YET

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TZlibTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TZlibTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TZlibTransport.py
new file mode 100644
index 0000000..2bdfd14
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TZlibTransport.py
@@ -0,0 +1,249 @@
+#
+# 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.
+#
+
+"""TZlibTransport provides a compressed transport and transport factory
+class, using the python standard library zlib module to implement
+data compression.
+"""
+
+from __future__ import division
+import zlib
+from cStringIO import StringIO
+
+from TTransport import TTransportBase, CReadableTransport
+
+
+class TZlibTransportFactory(object):
+  """Factory transport that builds zlib compressed transports.
+
+  This factory caches the last single client/transport that it was passed
+  and returns the same TZlibTransport object that was created.
+
+  This caching means the TServer class will get the _same_ transport
+  object for both input and output transports from this factory.
+  (For non-threaded scenarios only, since the cache only holds one object)
+
+  The purpose of this caching is to allocate only one TZlibTransport where
+  only one is really needed (since it must have separate read/write buffers),
+  and makes the statistics from getCompSavings() and getCompRatio()
+  easier to understand.
+  """
+  # class scoped cache of last transport given and zlibtransport returned
+  _last_trans = None
+  _last_z = None
+
+  def getTransport(self, trans, compresslevel=9):
+    """Wrap a transport, trans, with the TZlibTransport
+    compressed transport class, returning a new
+    transport to the caller.
+
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Defaults to 9.
+    @type compresslevel: int
+
+    This method returns a TZlibTransport which wraps the
+    passed C{trans} TTransport derived instance.
+    """
+    if trans == self._last_trans:
+      return self._last_z
+    ztrans = TZlibTransport(trans, compresslevel)
+    self._last_trans = trans
+    self._last_z = ztrans
+    return ztrans
+
+
+class TZlibTransport(TTransportBase, CReadableTransport):
+  """Class that wraps a transport with zlib, compressing writes
+  and decompresses reads, using the python standard
+  library zlib module.
+  """
+  # Read buffer size for the python fastbinary C extension,
+  # the TBinaryProtocolAccelerated class.
+  DEFAULT_BUFFSIZE = 4096
+
+  def __init__(self, trans, compresslevel=9):
+    """Create a new TZlibTransport, wrapping C{trans}, another
+    TTransport derived object.
+
+    @param trans: A thrift transport object, i.e. a TSocket() object.
+    @type trans: TTransport
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Default is 9.
+    @type compresslevel: int
+    """
+    self.__trans = trans
+    self.compresslevel = compresslevel
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+    self._init_zlib()
+    self._init_stats()
+
+  def _reinit_buffers(self):
+    """Internal method to initialize/reset the internal StringIO objects
+    for read and write buffers.
+    """
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def _init_stats(self):
+    """Internal method to reset the internal statistics counters
+    for compression ratios and bandwidth savings.
+    """
+    self.bytes_in = 0
+    self.bytes_out = 0
+    self.bytes_in_comp = 0
+    self.bytes_out_comp = 0
+
+  def _init_zlib(self):
+    """Internal method for setting up the zlib compression and
+    decompression objects.
+    """
+    self._zcomp_read = zlib.decompressobj()
+    self._zcomp_write = zlib.compressobj(self.compresslevel)
+
+  def getCompRatio(self):
+    """Get the current measured compression ratios (in,out) from
+    this transport.
+
+    Returns a tuple of:
+    (inbound_compression_ratio, outbound_compression_ratio)
+
+    The compression ratios are computed as:
+        compressed / uncompressed
+
+    E.g., data that compresses by 10x will have a ratio of: 0.10
+    and data that compresses to half of ts original size will
+    have a ratio of 0.5
+
+    None is returned if no bytes have yet been processed in
+    a particular direction.
+    """
+    r_percent, w_percent = (None, None)
+    if self.bytes_in > 0:
+      r_percent = self.bytes_in_comp / self.bytes_in
+    if self.bytes_out > 0:
+      w_percent = self.bytes_out_comp / self.bytes_out
+    return (r_percent, w_percent)
+
+  def getCompSavings(self):
+    """Get the current count of saved bytes due to data
+    compression.
+
+    Returns a tuple of:
+    (inbound_saved_bytes, outbound_saved_bytes)
+
+    Note: if compression is actually expanding your
+    data (only likely with very tiny thrift objects), then
+    the values returned will be negative.
+    """
+    r_saved = self.bytes_in - self.bytes_in_comp
+    w_saved = self.bytes_out - self.bytes_out_comp
+    return (r_saved, w_saved)
+
+  def isOpen(self):
+    """Return the underlying transport's open status"""
+    return self.__trans.isOpen()
+
+  def open(self):
+    """Open the underlying transport"""
+    self._init_stats()
+    return self.__trans.open()
+
+  def listen(self):
+    """Invoke the underlying transport's listen() method"""
+    self.__trans.listen()
+
+  def accept(self):
+    """Accept connections on the underlying transport"""
+    return self.__trans.accept()
+
+  def close(self):
+    """Close the underlying transport,"""
+    self._reinit_buffers()
+    self._init_zlib()
+    return self.__trans.close()
+
+  def read(self, sz):
+    """Read up to sz bytes from the decompressed bytes buffer, and
+    read from the underlying transport if the decompression
+    buffer is empty.
+    """
+    ret = self.__rbuf.read(sz)
+    if len(ret) > 0:
+      return ret
+    # keep reading from transport until something comes back
+    while True:
+      if self.readComp(sz):
+        break
+    ret = self.__rbuf.read(sz)
+    return ret
+
+  def readComp(self, sz):
+    """Read compressed data from the underlying transport, then
+    decompress it and append it to the internal StringIO read buffer
+    """
+    zbuf = self.__trans.read(sz)
+    zbuf = self._zcomp_read.unconsumed_tail + zbuf
+    buf = self._zcomp_read.decompress(zbuf)
+    self.bytes_in += len(zbuf)
+    self.bytes_in_comp += len(buf)
+    old = self.__rbuf.read()
+    self.__rbuf = StringIO(old + buf)
+    if len(old) + len(buf) == 0:
+      return False
+    return True
+
+  def write(self, buf):
+    """Write some bytes, putting them into the internal write
+    buffer for eventual compression.
+    """
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    """Flush any queued up data in the write buffer and ensure the
+    compression buffer is flushed out to the underlying transport
+    """
+    wout = self.__wbuf.getvalue()
+    if len(wout) > 0:
+      zbuf = self._zcomp_write.compress(wout)
+      self.bytes_out += len(wout)
+      self.bytes_out_comp += len(zbuf)
+    else:
+      zbuf = ''
+    ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH)
+    self.bytes_out_comp += len(ztail)
+    if (len(zbuf) + len(ztail)) > 0:
+      self.__wbuf = StringIO()
+      self.__trans.write(zbuf + ztail)
+    self.__trans.flush()
+
+  @property
+  def cstringio_buf(self):
+    """Implement the CReadableTransport interface"""
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Implement the CReadableTransport interface for refill"""
+    retstring = partialread
+    if reqlen < self.DEFAULT_BUFFSIZE:
+      retstring += self.read(self.DEFAULT_BUFFSIZE)
+    while len(retstring) < reqlen:
+      retstring += self.read(reqlen - len(retstring))
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/__init__.py
new file mode 100644
index 0000000..c9596d9
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/__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__ = ['TTransport', 'TSocket', 'THttpClient', 'TZlibTransport']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
new file mode 100644
index 0000000..0de6991
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
@@ -0,0 +1 @@
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
new file mode 100644
index 0000000..0de6991
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
@@ -0,0 +1 @@
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
new file mode 100644
index 0000000..59e103d
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
@@ -0,0 +1,13 @@
+class DataPublisherException(Exception):
+
+    def __init__(self, msg):
+        super(self,  msg)
+        self.message = msg
+
+    def get_message(self):
+        """
+        The message provided when the exception is raised
+        :return: message
+        :rtype: str
+        """
+        return self.message

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
new file mode 100644
index 0000000..cf00b0b
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -0,0 +1,238 @@
+import os
+import datetime
+import logging
+from threading import Thread, current_thread
+
+from ..databridge.agent import *
+from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from ..util import cartridgeagentutils
+from exception.datapublisherexception import DataPublisherException
+
+
+class LogPublisher(Thread):
+
+    def __init__(self, file_path, stream_definition, tenant_id, alias, date_time, member_id):
+        Thread.__init__(self)
+
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+
+        self.file_path = file_path
+        self.thrift_publisher = ThriftPublisher(
+            DataPublisherConfiguration.get_instance().monitoring_server_ip,
+            DataPublisherConfiguration.get_instance().monitoring_server_port,
+            DataPublisherConfiguration.get_instance().admin_username,
+            DataPublisherConfiguration.get_instance().admin_password,
+            stream_definition)
+        self.tenant_id = tenant_id
+        self.alias = alias
+        self.datetime = date_time
+        self.member_id = member_id
+
+        self.terminated = False
+
+    def run(self):
+        if os.path.isfile(self.file_path) and os.access(self.file_path, os.R_OK):
+            self.log.info("Starting log publisher for file: " + self.file_path + ", thread: " + current_thread())
+            # open file and keep reading for new entries
+            read_file = open(self.file_path, "r")
+            read_file.seek(os.stat(self.file_path)[6])  # go to the end of the file
+
+            while not self.terminated:
+                where = read_file.tell()  # where the seeker is in the file
+                line = read_file.readline()   # read the current line
+                if not line:
+                    # no new line entered
+                    time.sleep(1)
+                    read_file.seek(where)  # set seeker
+                else:
+                    # new line detected, create event object
+                    event = LogEvent()
+                    event.metaData.append(self.member_id)
+                    event.payloadData.append(self.tenant_id)
+                    event.payloadData.append(self.alias)
+                    event.payloadData.append("")
+                    event.payloadData.append(self.datetime)
+                    event.payloadData.append("")
+                    event.payloadData.append(line)
+                    event.payloadData.append("")
+                    event.payloadData.append("")
+                    event.payloadData.append(self.member_id)
+                    event.payloadData.append("")
+
+                    self.thrift_publisher.publish(event)
+
+            self.thrift_publisher.disconnect()  # dicsonnect the publisher upon being terminated
+        else:
+            raise DataPublisherException("Unable to read the file at path %r" % self.file_path)
+
+    def terminate(self):
+        """
+        Allows the LogPublisher thread to be terminated to stop publishing to BAM/CEP. Allow a minimum of 1 second delay
+        to take effect.
+        """
+        self.terminated = True
+
+
+class LogPublisherManager(Thread):
+    """
+    A log publishing thread management thread which maintains a log publisher for each log file. Also defines a stream
+    definition and the BAM/CEP server information for a single publishing context.
+    """
+
+    def __init__(self, logfile_paths):
+        Thread.__init__(self)
+        self.logfile_paths = logfile_paths
+        self.publishers = {}
+        self.ports = []
+        self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_port)
+        self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_secure_port)
+
+        cartridgeagentutils.wait_until_ports_active(DataPublisherConfiguration.get_instance().monitoring_server_ip, self.ports)
+        ports_active = cartridgeagentutils.check_ports_active(DataPublisherConfiguration.get_instance().monitoring_server_ip, self.ports)
+        if not ports_active:
+            raise DataPublisherException("Monitoring server not active, data publishing is aborted")
+
+        #stream definition
+        self.stream_definition = StreamDefinition()
+        valid_tenant_id = LogPublisherManager.get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
+        alias = LogPublisherManager.get_alias(CartridgeAgentConfiguration.cluster_id)
+        stream_name = "logs." + valid_tenant_id + "." \
+                      + alias + "." + LogPublisherManager.get_current_date()
+
+        stream_version = "1.0.0"
+        self.stream_definition.name = stream_name
+        self.stream_definition.version = stream_version
+        self.stream_definition.description = "Apache Stratos Instance Log Publisher"
+        self.stream_definition.add_metadata_attribute("memberId", 'STRING')
+
+        self.stream_definition.add_payloaddata_attribute("tenantID", "STRING")
+        self.stream_definition.add_payloaddata_attribute("serverName", "STRING")
+        self.stream_definition.add_payloaddata_attribute("appName", "STRING")
+        self.stream_definition.add_payloaddata_attribute("logTime", "STRING")
+        self.stream_definition.add_payloaddata_attribute("priority", "STRING")
+        self.stream_definition.add_payloaddata_attribute("message", "STRING")
+        self.stream_definition.add_payloaddata_attribute("logger", "STRING")
+        self.stream_definition.add_payloaddata_attribute("ip", "STRING")
+        self.stream_definition.add_payloaddata_attribute("instance", "STRING")
+        self.stream_definition.add_payloaddata_attribute("stacktrace", "STRING")
+
+    def run(self):
+        if self.logfile_paths is not None and len(self.logfile_paths):
+            for log_path in self.logfile_paths:
+                # thread for each log file
+                publisher = self.get_publisher(log_path)
+                publisher.start()
+
+    def get_publisher(self, log_path):
+        """
+        Retrieve the publisher for the specified log file path. Creates a new LogPublisher if one is not available
+        :return: The LogPublisher object
+        :rtype : LogPublisher
+        """
+        if log_path not in self.publishers:
+            self.publishers[log_path] = LogPublisher(log_path, self.stream_definition)
+
+        return self.publishers[log_path]
+
+    def terminate_publisher(self, log_path):
+        """
+        Terminates the LogPublisher thread associated with the specified log file
+        """
+        if log_path in self.publishers:
+            self.publishers[log_path].terminate()
+
+    def terminate_all_publishers(self):
+        """
+        Terminates all LogPublisher threads
+        """
+        for publisher in self.publishers:
+            publisher.terminate()
+
+    @staticmethod
+    def get_valid_tenant_id(tenant_id):
+        if tenant_id == "-1" or tenant_id == "-1234":
+            return "0"
+
+        return tenant_id
+
+    @staticmethod
+    def get_alias(cluster_id):
+        alias = ""
+        try:
+            alias = cluster_id.split("\\.")[0]
+        except:
+            alias = cluster_id
+
+        return alias
+
+    @staticmethod
+    def get_current_date():
+        """
+        Returns the current date formatted as yyyy-MM-dd
+        :return: Formatted date string
+        :rtype : str
+        """
+        return datetime.date.today().strftime("%Y.%m.%d")
+
+
+class DataPublisherConfiguration:
+    """
+    A singleton implementation to access configuration information for data publishing to BAM/CEP
+    TODO: perfect singleton impl ex: Borg
+    """
+
+    __instance = None
+    logging.basicConfig(level=logging.DEBUG)
+    log = logging.getLogger(__name__)
+
+    @staticmethod
+    def get_instance():
+        """
+        Singleton instance retriever
+        :return: Instnace
+        :rtype : DataPublisherConfiguration
+        """
+        if DataPublisherConfiguration.__instance is None:
+            DataPublisherConfiguration.__instance = DataPublisherConfiguration()
+
+        return DataPublisherConfiguration.__instance
+
+    def __init__(self):
+        self.enabled = False
+        self.monitoring_server_ip = None
+        self.monitoring_server_port = None
+        self.monitoring_server_secure_port = None
+        self.admin_username = None
+        self.admin_password = None
+        self.read_config()
+
+    def read_config(self):
+        self.enabled = True if CartridgeAgentConfiguration.read_property("enable.data.publisher", False).strip().lower() == "true" else False
+        if not self.enabled:
+            DataPublisherConfiguration.log.info("Data Publisher disabled")
+            return
+
+        DataPublisherConfiguration.log.info("Data Publisher enabled")
+
+        self.monitoring_server_ip = CartridgeAgentConfiguration.read_property("monitoring.server.ip", False)
+        if self.monitoring_server_ip.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.ip")
+
+        self.monitoring_server_port = CartridgeAgentConfiguration.read_property("monitoring.server.port", False)
+        if self.monitoring_server_port.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.port")
+
+        self.monitoring_server_secure_port = CartridgeAgentConfiguration.read_property("monitoring.server.secure.port", False)
+        if self.monitoring_server_secure_port.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.secure.port")
+
+        self.admin_username = CartridgeAgentConfiguration.read_property("monitoring.server.admin.username", False)
+        if self.admin_username.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.admin.username")
+
+        self.admin_password = CartridgeAgentConfiguration.read_property("monitoring.server.admin.password", False)
+        if self.admin_password.strip() == "":
+            raise RuntimeError("System property not found: monitoring.server.admin.password")
+
+        DataPublisherConfiguration.log.info("Data Publisher configuration initialized")

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
deleted file mode 100644
index 0de6991..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__author__ = 'chamilad'


[06/50] [abbrv] Added WSO2 CEP/BAM Python data publisher Wrote a sample log publisher

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
new file mode 100755
index 0000000..2187bfa
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from ThriftSecureEventTransmissionService.ttypes import *
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string connect(string userName, string password)'
+  print '  void disconnect(string sessionId)'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftSecureEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'connect':
+  if len(args) != 2:
+    print 'connect requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.connect(args[0],args[1],))
+
+elif cmd == 'disconnect':
+  if len(args) != 1:
+    print 'disconnect requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.disconnect(args[0],))
+
+elif cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
new file mode 100644
index 0000000..9d44d71
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
@@ -0,0 +1,1494 @@
+#
+# 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 ttypes import *
+from thrift.Thrift import TProcessor
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+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 Exception.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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
+      result.ade = ade
+    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
+      result.mtd = mtd
+    except Exception.ttypes.ThriftStreamDefinitionException, tde:
+      result.tde = tde
+    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
+      result.tnde = tnde
+    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
+      result.ue = ue
+    except Exception.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 Exception.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 Exception.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', (Exception.ttypes.ThriftAuthenticationException, Exception.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 = Exception.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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
+    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
+          self.ade.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
+          self.mtd.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
+          self.tde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
+          self.tnde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
+          self.ue.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
new file mode 100644
index 0000000..c321ae1
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
new file mode 100644
index 0000000..35216c6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
@@ -0,0 +1,11 @@
+#
+# 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 ttypes import *
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..a0727f8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/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
+import Data.ttypes
+import Exception.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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py
new file mode 100644
index 0000000..da8d283
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py
new file mode 100644
index 0000000..8a58d89
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py
new file mode 100644
index 0000000..af309c3
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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 thrift.transport import TTransport
+from thrift.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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py
new file mode 100644
index 0000000..9890af7
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py
new file mode 100644
index 0000000..48d659c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py
new file mode 100644
index 0000000..6cbd5f3
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/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.Thrift import *
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+try:
+  from thrift.protocol 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/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
new file mode 100644
index 0000000..6fdd08c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
@@ -0,0 +1,260 @@
+#
+# 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 TProtocol import *
+from struct import pack, unpack
+
+
+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)


[48/50] [abbrv] git commit: Merge branch 'new_agent_fixes'

Posted by ni...@apache.org.
Merge branch 'new_agent_fixes'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2891c08d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2891c08d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2891c08d

Branch: refs/heads/master
Commit: 2891c08d0d27011e56eee954868273b5a7035e3a
Parents: fdf0d19 535ea0c
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 23:04:17 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 23:04:17 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  5 ++++
 .../config/cartridgeagentconfiguration.py       |  3 +++
 .../extensions/abstractextensionhandler.py      |  3 +++
 .../extensions/defaultextensionhandler.py       | 27 +++++++++++++++++++-
 4 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2891c08d/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/stratos/blob/2891c08d/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------


[41/50] [abbrv] git commit: Fixed raising KeyError on optional values

Posted by ni...@apache.org.
Fixed raising KeyError on optional values


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4139b16b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4139b16b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4139b16b

Branch: refs/heads/master
Commit: 4139b16bbf4075dd4d1ebdeb6eb43d1a89857179
Parents: d23da98
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 19:16:11 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 19:16:11 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/modules/event/topology/events.py            | 5 +++--
 .../cartridge-agent/modules/topology/topologycontext.py         | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4139b16b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 3b0a97c..18580c2 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -162,8 +162,9 @@ class CompleteTopologyEvent:
                     cluster_obj.hostnames = cluster_str["hostNames"]
                     cluster_obj.tenant_range = cluster_str["tenantRange"] if "tenantRange" in cluster_str else None
                     cluster_obj.is_lb_cluster = cluster_str["isLbCluster"]
+                    cluster_obj.is_kubernetes_cluster = cluster_str["isKubernetesCluster"]
                     cluster_obj.status = cluster_str["status"]
-                    cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"]
+                    cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"] if "loadBalanceAlgorithmName" in cluster_str else None
                     cluster_obj.properties = cluster_str["properties"]
                     cluster_obj.member_list_json = "["
 
@@ -180,7 +181,7 @@ class CompleteTopologyEvent:
                         member_obj.status = member_str["status"]
                         member_obj.member_ip = member_str["memberIp"]
                         member_obj.properties = member_str["properties"]
-                        member_obj.lb_cluster_id = member_str["lbClusterId"]
+                        member_obj.lb_cluster_id = member_str["lbClusterId"] if "lbClusterId" in member_str else None
                         member_obj.json_str = member_str
                         cluster_obj.member_list_json += member_str + ","
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/4139b16b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 8f81802..5fe2ea4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -211,6 +211,8 @@ class Cluster:
         """ :type : str  """
         self.is_lb_cluster = False
         """ :type : bool  """
+        self.is_kubernetes_cluster = False
+        """ :type : bool  """
         self.status = None
         """ :type : str  """
         self.load_balancer_algorithm_name = None


[23/50] [abbrv] git commit: Added new properties to the agent.conf Refactored modules and dependencies to avoid circular dependencies Added singleton to CartridgeAgentConfiguration by overriding __new__ Refactored hard coded strings to constants file Cle

Posted by ni...@apache.org.
Added new properties to the agent.conf
Refactored modules and dependencies to avoid circular dependencies
Added singleton to CartridgeAgentConfiguration by overriding __new__
Refactored hard coded strings to constants file
Cleaned up files
Fixed info log level to INFO


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/511aedfa
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/511aedfa
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/511aedfa

Branch: refs/heads/master
Commit: 511aedfa7bf93c83ec1eebcc39fe544504bbdb04
Parents: b5ed6f0
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 03:06:50 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:41:09 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.conf                  |   9 +-
 .../cartridge-agent/agent.py                    |  62 +-
 .../cartridge-agent/logging.ini                 |   2 +-
 .../modules/artifactmgt/git/agentgithandler.py  |  33 +-
 .../config/cartridgeagentconfiguration.py       | 571 +++++++++----------
 .../cartridge-agent/modules/databridge/agent.py |   7 +
 .../modules/datapublisher/logpublisher.py       |  74 ++-
 .../extensions/abstractextensionhandler.py      |   6 +-
 .../extensions/defaultextensionhandler.py       | 175 +++---
 .../modules/healthstatspublisher/healthstats.py |  76 ++-
 .../publisher/cartridgeagentpublisher.py        |  60 +-
 .../modules/subscriber/eventsubscriber.py       |  20 +-
 .../modules/topology/topologycontext.py         |   6 +-
 .../modules/util/cartridgeagentconstants.py     |  49 +-
 .../modules/util/cartridgeagentutils.py         |  30 +-
 .../modules/util/extensionutils.py              | 127 +++--
 .../cartridge-agent/modules/util/log.py         |   2 +-
 17 files changed, 711 insertions(+), 598 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.conf b/tools/python-cartridge-agent/cartridge-agent/agent.conf
index f9724fc..0161b7d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.conf
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.conf
@@ -4,11 +4,9 @@ mb.port                               =MB-PORT
 listen.address                        =localhost
 thrift.receiver.ip                    =CEP-IP
 thrift.receiver.port                  =CEP-PORT
-jndi.properties.template.file.path    =${script_path}/../conf/templates/jndi.properties.template
-jndi.properties.dir                   =${script_path}/../conf
-log4j.configuration                   =file://${script_path}/../conf/log4j.properties
-param.file.path                       =${script_path}/../payload/launch-params
-extensions.dir                        =${script_path}/../extensions
+agent.root                            =
+param.file.path                       =/tmp/payload/launch-params
+extensions.dir                        =/extensions
 cep.stats.publisher.enabled           =true
 lb.private.ip                         =
 lb.public.ip                          =
@@ -18,6 +16,7 @@ enable.artifact.update                =true
 auto.commit                           =false
 auto.checkout                         =true
 artifact.update.interval              =15
+port.check.timeout                    =600
 enable.data.publisher                 =ENABLE-DATA-PUBLISHER
 monitoring.server.ip                  =MONITORING-SERVER-IP
 monitoring.server.port                =MONITORING-SERVER-PORT

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index ecc8c45..4858b9d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -1,12 +1,8 @@
 #!/usr/bin/env python
-import logging
 import threading
-import time
 
-from modules.config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from modules.exception.parameternotfoundexception import ParameterNotFoundException
-from modules.subscriber.eventsubscriber import EventSubscriber
-from modules.extensions.defaultextensionhandler import DefaultExtensionHandler
+from modules.subscriber import eventsubscriber
 from modules.publisher import cartridgeagentpublisher
 from modules.event.instance.notifier.events import *
 from modules.event.tenant.events import *
@@ -14,7 +10,7 @@ from modules.event.topology.events import *
 from modules.tenant.tenantcontext import *
 from modules.topology.topologycontext import *
 from modules.datapublisher.logpublisher import *
-from modules.extensions.abstractextensionhandler import *
+from modules.config import cartridgeagentconfiguration
 
 
 class CartridgeAgent(threading.Thread):
@@ -22,11 +18,22 @@ class CartridgeAgent(threading.Thread):
 
     def __init__(self):
         threading.Thread.__init__(self)
-        CartridgeAgentConfiguration.initialize_configuration()
 
-        self.__instance_event_subscriber = EventSubscriber(cartridgeagentconstants.INSTANCE_NOTIFIER_TOPIC)
-        self.__tenant_event_subscriber = EventSubscriber(cartridgeagentconstants.TENANT_TOPIC)
-        self.__topology_event_subscriber = EventSubscriber(cartridgeagentconstants.TOPOLOGY_TOPIC)
+        mb_ip = cartridgeagentconfiguration.CartridgeAgentConfiguration().read_property(cartridgeagentconstants.MB_IP)
+        mb_port = cartridgeagentconfiguration.CartridgeAgentConfiguration().read_property(cartridgeagentconstants.MB_PORT)
+
+        self.__instance_event_subscriber = eventsubscriber.EventSubscriber(
+            cartridgeagentconstants.INSTANCE_NOTIFIER_TOPIC,
+            mb_ip,
+            mb_port)
+        self.__tenant_event_subscriber = eventsubscriber.EventSubscriber(
+            cartridgeagentconstants.TENANT_TOPIC,
+            mb_ip,
+            mb_port)
+        self.__topology_event_subscriber = eventsubscriber.EventSubscriber(
+            cartridgeagentconstants.TOPOLOGY_TOPIC,
+            mb_ip,
+            mb_port)
 
         self.__tenant_context_initialized = False
         self.__topology_context_initialized = False
@@ -37,6 +44,8 @@ class CartridgeAgent(threading.Thread):
 
         self.log = LogFactory().get_log(__name__)
 
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
     def run(self):
         self.log.info("Starting Cartridge Agent...")
 
@@ -66,25 +75,26 @@ class CartridgeAgent(threading.Thread):
 
         #Wait for all ports to be active
         cartridgeagentutils.wait_until_ports_active(
-            CartridgeAgentConfiguration.listen_address,
-            CartridgeAgentConfiguration.ports
+            self.cartridge_agent_config.listen_address,
+            self.cartridge_agent_config.ports,
+            int(self.cartridge_agent_config.read_property("port.check.timeout", critical=False))
         )
 
         # check if artifact management is required before publishing instance activated event
-        repo_url = CartridgeAgentConfiguration.repo_url
+        repo_url = self.cartridge_agent_config.repo_url
         if repo_url is None or str(repo_url).strip() == "":
             self.log.info("No artifact repository found")
             CartridgeAgent.extension_handler.on_instance_activated_event()
 
             cartridgeagentpublisher.publish_instance_activated_event()
 
-        persistence_mappping_payload = CartridgeAgentConfiguration.persistence_mappings
+        persistence_mappping_payload = self.cartridge_agent_config.persistence_mappings
         if persistence_mappping_payload is not None:
             CartridgeAgent.extension_handler.volume_mount_extension(persistence_mappping_payload)
 
         # start log publishing thread
         if DataPublisherConfiguration.get_instance().enabled:
-            log_file_paths = CartridgeAgentConfiguration.log_file_paths
+            log_file_paths = self.cartridge_agent_config.log_file_paths
             if log_file_paths is None:
                 self.log.exception("No valid log file paths found, no logs will be published")
             else:
@@ -112,21 +122,21 @@ class CartridgeAgent(threading.Thread):
         """
         # JNDI_PROPERTIES_DIR
         try:
-            CartridgeAgentConfiguration.read_property(cartridgeagentconstants.JNDI_PROPERTIES_DIR)
+            self.cartridge_agent_config.read_property(cartridgeagentconstants.JNDI_PROPERTIES_DIR)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.JNDI_PROPERTIES_DIR)
             return
 
         #PARAM_FILE_PATH
         try:
-            CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+            self.cartridge_agent_config.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.PARAM_FILE_PATH)
             return
 
         #EXTENSIONS_DIR
         try:
-            CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
+            self.cartridge_agent_config.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
         except ParameterNotFoundException:
             self.log.error("System property not found: %r" % cartridgeagentconstants.EXTENSIONS_DIR)
             return
@@ -150,7 +160,7 @@ class CartridgeAgent(threading.Thread):
         CartridgeAgent.extension_handler.on_artifact_updated_event(event_obj)
 
     def on_instance_cleanup_member(self, msg):
-        member_in_payload = CartridgeAgentConfiguration.member_id
+        member_in_payload = self.cartridge_agent_config.member_id
         event_obj = InstanceCleanupMemberEvent.create_from_json(msg.payload)
         member_in_event = event_obj.member_id
         if member_in_payload == member_in_event:
@@ -158,7 +168,7 @@ class CartridgeAgent(threading.Thread):
 
     def on_instance_cleanup_cluster(self, msg):
         event_obj = InstanceCleanupClusterEvent.create_from_json(msg.payload)
-        cluster_in_payload = CartridgeAgentConfiguration.cluster_id
+        cluster_in_payload = self.cartridge_agent_config.cluster_id
         cluster_in_event = event_obj.cluster_id
 
         if cluster_in_event == cluster_in_payload:
@@ -277,18 +287,6 @@ class CartridgeAgent(threading.Thread):
             CartridgeAgent.extension_handler.on_tenant_unsubscribed_event(event_obj)
         except:
             self.log.exception("Error processing tenant unSubscribed event")
-            
-    @staticmethod
-    def get_extension_handler():
-        """
-        Returns the Extension handler implementation
-        :return: An implmentation of AbstractExtensionHandler
-        :rtype : AbstractExtensionHandler
-        """
-        if CartridgeAgent.extension_handler is None:
-            CartridgeAgent.extension_handler = DefaultExtensionHandler()
-            
-        return CartridgeAgent.extension_handler
 
 
 def main():

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
index cf6bc7d..3fd9381 100644
--- a/tools/python-cartridge-agent/cartridge-agent/logging.ini
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -15,7 +15,7 @@ args=tuple()
 
 [handler_log_file]
 class=logging.FileHandler
-level=ERROR
+level=INFO
 formatter=default
 args=("agent.log", "w")
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index d192e75..be46c5d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -1,17 +1,10 @@
-import logging
 from threading import current_thread, Thread
-import os
 from git import *
 from gittle import Gittle, GittleAuth  # GitPython and Gittle are both used at the time being for pros and cons of both
 import urllib2
 
-from gitrepository import GitRepository
-from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
-from ... util.asyncscheduledtask import AsyncScheduledTask
-from ... artifactmgt.repositoryinformation import RepositoryInformation
 from ... util.log import LogFactory
-from ....agent import CartridgeAgent
+from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
 
 
 class AgentGitHandler:
@@ -25,11 +18,13 @@ class AgentGitHandler:
     SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
     TENANT_REPO_PATH = "/repository/tenants/"
 
-    extension_handler = CartridgeAgent.get_extension_handler()
+    extension_handler = cartridgeagentutils.get_extension_handler()
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)
 
+    cartridge_agent_config = cartridgeagentconfiguration.CartridgeAgentConfiguration()
+
     @staticmethod
     def checkout(repo_info):
         """
@@ -89,13 +84,15 @@ class AgentGitHandler:
             repo_context.repo.git.branch("-f", "--track", "master", "origin/master")
             return True
         except:
-            AgentGitHandler.log.exception("Error in adding remote origin %r for local repository %r" % (repo_context.repo_url, repo_context.local_repo_path))
+            AgentGitHandler.log.exception("Error in adding remote origin %r for local repository %r"
+                                          % (repo_context.repo_url, repo_context.local_repo_path))
             return False
 
     @staticmethod
     def init(path):
         try:
             repo = Gittle.init(path)
+            return repo
         except:
             AgentGitHandler.log.exception("Initializing local repo at %r failed" % path)
             raise Exception("Initializing local repo at %r failed" % path)
@@ -326,7 +323,7 @@ class AgentGitHandler:
         if is_multitenant:
             if tenant_id == AgentGitHandler.SUPER_TENANT_ID:
                 #super tenant, /repository/deploy/server/
-                super_tenant_repo_path = CartridgeAgentConfiguration.super_tenant_repository_path
+                super_tenant_repo_path = AgentGitHandler.cartridge_agent_config.super_tenant_repository_path
                 #"app_path"
                 repo_path += git_local_repo_path
 
@@ -341,7 +338,7 @@ class AgentGitHandler:
 
             else:
                 #normal tenant, /repository/tenants/tenant_id
-                tenant_repo_path = CartridgeAgentConfiguration.tenant_repository_path
+                tenant_repo_path = AgentGitHandler.cartridge_agent_config.tenant_repository_path
                 #"app_path"
                 repo_path += git_local_repo_path
 
@@ -451,10 +448,10 @@ class AgentGitHandler:
         AgentGitHandler.remove_repo_context(tenant_id)
 
         if tenant_id == -1234:
-            if CartridgeAgentConfiguration.is_multitenant:
+            if AgentGitHandler.cartridge_agent_config.is_multitenant:
                 extensionutils.execute_copy_artifact_extension(
                     cartridgeagentconstants.SUPERTENANT_TEMP_PATH,
-                    CartridgeAgentConfiguration.app_path + "/repository/deployment/server/"
+                    AgentGitHandler.cartridge_agent_config.app_path + "/repository/deployment/server/"
                 )
 
         AgentGitHandler.log.info("git repository deleted for tenant %r" % repo_context.tenant_id)
@@ -476,7 +473,13 @@ class ArtifactUpdateTask(Thread):
             if self.auto_checkout:
                 AgentGitHandler.checkout(self.repo_info)
         except:
-            self.log.exception()
+            self.log.exception("Auto checkout task failed")
 
         if self.auto_commit:
             AgentGitHandler.commit(self.repo_info)
+
+
+from gitrepository import GitRepository
+from ... config import cartridgeagentconfiguration
+from ... util.asyncscheduledtask import AsyncScheduledTask
+from ... artifactmgt.repositoryinformation import RepositoryInformation
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index c0e5ea6..27c9a89 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -2,315 +2,304 @@ import ConfigParser
 import logging
 import os
 
-from ..util import cartridgeagentconstants
 from ..util.log import LogFactory
-from ..exception.parameternotfoundexception import ParameterNotFoundException
 
 
 class CartridgeAgentConfiguration:
     """
     Handles the configuration information of the particular Cartridge Agent
     """
-    # set log level
-    log = LogFactory().get_log(__name__)
-
-    payload_params = {}
-    properties = None
-
-    service_group = None
-    """ :type : str  """
-    is_clustered = False
-    """ :type : bool  """
-    service_name = None
-    """ :type : str  """
-    cluster_id = None
-    """ :type : str  """
-    network_partition_id = None
-    """ :type : str  """
-    partition_id = None
-    """ :type : str  """
-    member_id = None
-    """ :type : str  """
-    cartridge_key = None
-    """ :type : str  """
-    app_path = None
-    """ :type : str  """
-    repo_url = None
-    """ :type : str  """
-    ports = []
-    """ :type : list[str]  """
-    log_file_paths = []
-    """ :type : list[str]  """
-    is_multitenant = False
-    """ :type : bool  """
-    persistence_mappings = None
-    """ :type : str  """
-    is_commits_enabled = False
-    """ :type : bool  """
-    is_checkout_enabled = False
-    """ :type : bool  """
-    listen_address = None
-    """ :type : str  """
-    is_internal_repo = False
-    """ :type : bool  """
-    tenant_id = None
-    """ :type : str  """
-    lb_cluster_id = None
-    """ :type : str  """
-    min_count = None
-    """ :type : str  """
-    lb_private_ip = None
-    """ :type : str  """
-    lb_public_ip = None
-    """ :type : str  """
-    tenant_repository_path = None
-    """ :type : str  """
-    super_tenant_repository_path = None
-    """ :type : str  """
-    deployment = None
-    """ :type : str  """
-    manager_service_name = None
-    """ :type : str  """
-    worker_service_name = None
-    """ :type : str  """
-    is_primary = False
-    """ :type : bool  """
-
-    @staticmethod
-    def initialize_configuration():
-        """
-        Initializes the configuration by reading and parsing properties
-        from configuration file and payload parameter file
-        :return: void
-        """
-
-        CartridgeAgentConfiguration.payload_params = {}
-        CartridgeAgentConfiguration.__read_conf_file()
-        CartridgeAgentConfiguration.__read_parameter_file()
-
-        try:
-            CartridgeAgentConfiguration.service_group = CartridgeAgentConfiguration.payload_params[
-                cartridgeagentconstants.SERVICE_GROUP] \
-                if cartridgeagentconstants.SERVICE_GROUP in CartridgeAgentConfiguration.payload_params \
-                else None
-
-            if cartridgeagentconstants.CLUSTERING in CartridgeAgentConfiguration.payload_params and \
-                            str(CartridgeAgentConfiguration.payload_params[
-                                cartridgeagentconstants.CLUSTERING]).strip().lower() == "true":
-                CartridgeAgentConfiguration.is_clustered = True
-            else:
-                CartridgeAgentConfiguration.is_clustered = False
-            # CartridgeAgentConfiguration.__isClustered = CartridgeAgentConfiguration.payload_params[
-            # cartridgeagentconstants.CLUSTERING] if cartridgeagentconstants.CLUSTERING in CartridgeAgentConfiguration.payload_params else None
-
-            CartridgeAgentConfiguration.service_name = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.SERVICE_NAME)
-            CartridgeAgentConfiguration.cluster_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.CLUSTER_ID)
-            CartridgeAgentConfiguration.network_partition_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.NETWORK_PARTITION_ID)
-            CartridgeAgentConfiguration.partition_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.PARTITION_ID)
-            CartridgeAgentConfiguration.member_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.MEMBER_ID)
-            CartridgeAgentConfiguration.cartridge_key = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.CARTRIDGE_KEY)
-            CartridgeAgentConfiguration.app_path = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.APP_PATH)
-            CartridgeAgentConfiguration.repo_url = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.REPO_URL)
-            CartridgeAgentConfiguration.ports = str(
-                CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PORTS)).split("|")
+    class __CartridgeAgentConfiguration:
+        def __init__(self):
+            # set log level
+            self.log = LogFactory().get_log(__name__)
+
+            self.payload_params = {}
+            self.properties = None
+
+            self.service_group = None
+            """ :type : str  """
+            self.is_clustered = False
+            """ :type : bool  """
+            self.service_name = None
+            """ :type : str  """
+            self.cluster_id = None
+            """ :type : str  """
+            self.network_partition_id = None
+            """ :type : str  """
+            self.partition_id = None
+            """ :type : str  """
+            self.member_id = None
+            """ :type : str  """
+            self.cartridge_key = None
+            """ :type : str  """
+            self.app_path = None
+            """ :type : str  """
+            self.repo_url = None
+            """ :type : str  """
+            self.ports = []
+            """ :type : list[str]  """
+            self.log_file_paths = []
+            """ :type : list[str]  """
+            self.is_multitenant = False
+            """ :type : bool  """
+            self.persistence_mappings = None
+            """ :type : str  """
+            self.is_commits_enabled = False
+            """ :type : bool  """
+            self.is_checkout_enabled = False
+            """ :type : bool  """
+            self.listen_address = None
+            """ :type : str  """
+            self.is_internal_repo = False
+            """ :type : bool  """
+            self.tenant_id = None
+            """ :type : str  """
+            self.lb_cluster_id = None
+            """ :type : str  """
+            self.min_count = None
+            """ :type : str  """
+            self.lb_private_ip = None
+            """ :type : str  """
+            self.lb_public_ip = None
+            """ :type : str  """
+            self.tenant_repository_path = None
+            """ :type : str  """
+            self.super_tenant_repository_path = None
+            """ :type : str  """
+            self.deployment = None
+            """ :type : str  """
+            self.manager_service_name = None
+            """ :type : str  """
+            self.worker_service_name = None
+            """ :type : str  """
+            self.is_primary = False
+            """ :type : bool  """
+
+            self.payload_params = {}
+            self.__read_conf_file()
+            self.__read_parameter_file()
 
             try:
-                CartridgeAgentConfiguration.log_file_paths = str(
-                    CartridgeAgentConfiguration.read_property(cartridgeagentconstants.CLUSTER_ID)).strip().split("|")
-            except ParameterNotFoundException as ex:
-                CartridgeAgentConfiguration.log.debug("Cannot read log file path : %r" % ex.get_message())
-                CartridgeAgentConfiguration.log_file_paths = None
+                service_group = self.payload_params[cartridgeagentconstants.SERVICE_GROUP] \
+                    if cartridgeagentconstants.SERVICE_GROUP in self.payload_params \
+                    else None
+
+                if cartridgeagentconstants.CLUSTERING in self.payload_params and \
+                        str(self.payload_params[cartridgeagentconstants.CLUSTERING]).strip().lower() == "true":
+                    self.is_clustered = True
+                else:
+                    self.is_clustered = False
+                # self.__isClustered = self.payload_params[
+                # cartridgeagentconstants.CLUSTERING] if cartridgeagentconstants.CLUSTERING in self.payload_params else None
+
+                self.service_name = self.read_property(cartridgeagentconstants.SERVICE_NAME)
+                self.cluster_id = self.read_property(cartridgeagentconstants.CLUSTER_ID)
+                self.network_partition_id = self.read_property(cartridgeagentconstants.NETWORK_PARTITION_ID)
+                self.partition_id = self.read_property(cartridgeagentconstants.PARTITION_ID)
+                self.member_id = self.read_property(cartridgeagentconstants.MEMBER_ID)
+                self.cartridge_key = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
+                self.app_path = self.read_property(cartridgeagentconstants.APP_PATH)
+                self.repo_url = self.read_property(cartridgeagentconstants.REPO_URL)
+                self.ports = str(self.read_property(cartridgeagentconstants.PORTS)).split("|")
 
-            is_multi_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.CLUSTER_ID)
-            CartridgeAgentConfiguration.is_multitenant = True if str(
-                is_multi_str).lower().strip() == "true" else False
+                try:
+                    self.log_file_paths = str(
+                        self.read_property(cartridgeagentconstants.CLUSTER_ID)).strip().split("|")
+                except ParameterNotFoundException as ex:
+                    self.log.debug("Cannot read log file path : %r" % ex.get_message())
+                    self.log_file_paths = None
 
-            try:
-                CartridgeAgentConfiguration.persistence_mappings = CartridgeAgentConfiguration.read_property(
-                    "PERSISTENCE_MAPPING")
-            except ParameterNotFoundException as ex:
-                CartridgeAgentConfiguration.log.debug("Cannot read persistence mapping : %r" % ex.get_message())
-                CartridgeAgentConfiguration.persistence_mappings = None
+                is_multi_str = self.read_property(cartridgeagentconstants.CLUSTER_ID)
+                self.is_multitenant = True if str(
+                    is_multi_str).lower().strip() == "true" else False
 
-            try:
-                is_commit_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.COMMIT_ENABLED)
-                CartridgeAgentConfiguration.is_commits_enabled = True if str(
-                    is_commit_str).lower().strip() == "true" else False
-            except ParameterNotFoundException:
                 try:
-                    is_commit_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.AUTO_COMMIT)
-                    CartridgeAgentConfiguration.is_commits_enabled = True if str(
+                    self.persistence_mappings = self.read_property(
+                        cartridgeagentconstants.PERSISTENCE_MAPPING)
+                except ParameterNotFoundException as ex:
+                    self.log.debug("Cannot read persistence mapping : %r" % ex.get_message())
+                    self.persistence_mappings = None
+
+                try:
+                    is_commit_str = self.read_property(cartridgeagentconstants.COMMIT_ENABLED)
+                    self.is_commits_enabled = True if str(
                         is_commit_str).lower().strip() == "true" else False
                 except ParameterNotFoundException:
-                    CartridgeAgentConfiguration.log.info(
-                        "%r is not found and setting it to false" % cartridgeagentconstants.COMMIT_ENABLED)
-                    CartridgeAgentConfiguration.is_commits_enabled = False
+                    try:
+                        is_commit_str = self.read_property(cartridgeagentconstants.AUTO_COMMIT)
+                        self.is_commits_enabled = True if str(
+                            is_commit_str).lower().strip() == "true" else False
+                    except ParameterNotFoundException:
+                        self.log.info(
+                            "%r is not found and setting it to false" % cartridgeagentconstants.COMMIT_ENABLED)
+                        self.is_commits_enabled = False
+
+                auto_checkout_str = self.read_property(cartridgeagentconstants.AUTO_CHECKOUT, False)
+                self.is_checkout_enabled = True if str(
+                    auto_checkout_str).lower().strip() == "true" else False
+
+                self.listen_address = self.read_property(
+                    cartridgeagentconstants.LISTEN_ADDRESS, False)
 
-            auto_checkout_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.AUTO_CHECKOUT, False)
-            CartridgeAgentConfiguration.is_checkout_enabled = True if str(
-                auto_checkout_str).lower().strip() == "true" else False
+                try:
+                    int_repo_str = self.read_property(cartridgeagentconstants.PROVIDER)
+                    self.is_internal_repo = True if str(
+                        int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
+                except ParameterNotFoundException:
+                    self.log.info(" INTERNAL payload parameter is not found")
+                    self.is_internal_repo = False
+
+                self.tenant_id = self.read_property(
+                    cartridgeagentconstants.TENANT_ID)
+                self.lb_cluster_id = self.read_property(
+                    cartridgeagentconstants.LB_CLUSTER_ID)
+                self.min_count = self.read_property(
+                    cartridgeagentconstants.MIN_INSTANCE_COUNT)
+                self.lb_private_ip = self.read_property(
+                    cartridgeagentconstants.LB_PRIVATE_IP, False)
+                self.lb_public_ip = self.read_property(
+                    cartridgeagentconstants.LB_PUBLIC_IP, False)
+                self.tenant_repository_path = self.read_property(
+                    cartridgeagentconstants.TENANT_REPO_PATH, False)
+                self.super_tenant_repository_path = self.read_property(
+                    cartridgeagentconstants.SUPER_TENANT_REPO_PATH, False)
 
-            CartridgeAgentConfiguration.listen_address = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LISTEN_ADDRESS, False)
+                try:
+                    self.deployment = self.read_property(
+                        cartridgeagentconstants.DEPLOYMENT)
+                except ParameterNotFoundException:
+                    self.deployment = None
 
-            try:
-                int_repo_str = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PROVIDER)
-                CartridgeAgentConfiguration.is_internal_repo = True if str(
-                    int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
-            except ParameterNotFoundException:
-                CartridgeAgentConfiguration.log.info(" INTERNAL payload parameter is not found")
-                CartridgeAgentConfiguration.is_internal_repo = False
-
-            CartridgeAgentConfiguration.tenant_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.TENANT_ID)
-            CartridgeAgentConfiguration.lb_cluster_id = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LB_CLUSTER_ID)
-            CartridgeAgentConfiguration.min_count = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.MIN_INSTANCE_COUNT)
-            CartridgeAgentConfiguration.lb_private_ip = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LB_PRIVATE_IP, False)
-            CartridgeAgentConfiguration.lb_public_ip = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.LB_PUBLIC_IP, False)
-            CartridgeAgentConfiguration.tenant_repository_path = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.TENANT_REPO_PATH, False)
-            CartridgeAgentConfiguration.super_tenant_repository_path = CartridgeAgentConfiguration.read_property(
-                cartridgeagentconstants.SUPER_TENANT_REPO_PATH, False)
+                # Setting worker-manager setup - manager service name
+                if self.deployment is None:
+                    self.manager_service_name = None
 
-            try:
-                CartridgeAgentConfiguration.deployment = CartridgeAgentConfiguration.read_property(
-                    cartridgeagentconstants.DEPLOYMENT)
-            except ParameterNotFoundException:
-                CartridgeAgentConfiguration.deployment = None
-
-            # Setting worker-manager setup - manager service name
-            if CartridgeAgentConfiguration.deployment is None:
-                CartridgeAgentConfiguration.manager_service_name = None
-
-            if str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
-                CartridgeAgentConfiguration.manager_service_name = CartridgeAgentConfiguration.service_name
-
-            elif str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
-                CartridgeAgentConfiguration.deployment = CartridgeAgentConfiguration.read_property(
-                    cartridgeagentconstants.MANAGER_SERVICE_TYPE)
-
-            elif str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
-                CartridgeAgentConfiguration.deployment = None
-            else:
-                CartridgeAgentConfiguration.deployment = None
-
-            # Setting worker-manager setup - worker service name
-            if CartridgeAgentConfiguration.deployment is None:
-                CartridgeAgentConfiguration.worker_service_name = None
-
-            if str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
-                CartridgeAgentConfiguration.manager_service_name = CartridgeAgentConfiguration.service_name
-
-            elif str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
-                CartridgeAgentConfiguration.deployment = CartridgeAgentConfiguration.read_property(
-                    cartridgeagentconstants.WORKER_SERVICE_TYPE)
-
-            elif str(
-                    CartridgeAgentConfiguration.deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
-                CartridgeAgentConfiguration.deployment = None
-            else:
-                CartridgeAgentConfiguration.deployment = None
+                if self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                    self.manager_service_name = self.service_name
+
+                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                    self.deployment = self.read_property(
+                        cartridgeagentconstants.MANAGER_SERVICE_TYPE)
+
+                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
+                    self.deployment = None
+                else:
+                    self.deployment = None
+
+                # Setting worker-manager setup - worker service name
+                if self.deployment is None:
+                    self.worker_service_name = None
+
+                if self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                    self.manager_service_name = self.service_name
+
+                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                    self.deployment = self.read_property(
+                        cartridgeagentconstants.WORKER_SERVICE_TYPE)
+
+                elif self.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
+                    self.deployment = None
+                else:
+                    self.deployment = None
+
+                try:
+                    self.is_primary = self.read_property(
+                        cartridgeagentconstants.CLUSTERING_PRIMARY_KEY)
+                except ParameterNotFoundException:
+                    self.is_primary = None
+            except ParameterNotFoundException as ex:
+                raise RuntimeError(ex)
+
+            self.log.info("Cartridge agent configuration initialized")
+
+            self.log.debug("service-name: %r" % self.service_name)
+            self.log.debug("cluster-id: %r" % self.cluster_id)
+            self.log.debug(
+                "network-partition-id: %r" % self.network_partition_id)
+            self.log.debug("partition-id: %r" % self.partition_id)
+            self.log.debug("member-id: %r" % self.member_id)
+            self.log.debug("cartridge-key: %r" % self.cartridge_key)
+            self.log.debug("app-path: %r" % self.app_path)
+            self.log.debug("repo-url: %r" % self.repo_url)
+            self.log.debug("ports: %r" % str(self.ports))
+            self.log.debug("lb-private-ip: %r" % self.lb_private_ip)
+            self.log.debug("lb-public-ip: %r" % self.lb_public_ip)
+
+        def __read_conf_file(self):
+            """
+            Reads and stores the agent's configuration file
+            :return: void
+            """
+
+            conf_file_path = os.path.abspath(os.path.dirname(__file__)).split("modules")[0] + "agent.conf"
+            self.log.debug("Config file path : %r" % conf_file_path)
+            self.properties = ConfigParser.SafeConfigParser()
+            self.properties.read(conf_file_path)
+
+        def __read_parameter_file(self):
+            """
+            Reads the payload file of the cartridge and stores the values in a dictionary
+            :return: void
+            """
+
+            param_file = self.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
 
             try:
-                CartridgeAgentConfiguration.is_primary = CartridgeAgentConfiguration.read_property(
-                    cartridgeagentconstants.CLUSTERING_PRIMARY_KEY)
-            except ParameterNotFoundException:
-                CartridgeAgentConfiguration.is_primary = None
-        except ParameterNotFoundException as ex:
-            raise RuntimeError(ex)
-
-        CartridgeAgentConfiguration.log.info("Cartridge agent configuration initialized")
-
-        CartridgeAgentConfiguration.log.debug("service-name: %r" % CartridgeAgentConfiguration.service_name)
-        CartridgeAgentConfiguration.log.debug("cluster-id: %r" % CartridgeAgentConfiguration.cluster_id)
-        CartridgeAgentConfiguration.log.debug(
-            "network-partition-id: %r" % CartridgeAgentConfiguration.network_partition_id)
-        CartridgeAgentConfiguration.log.debug("partition-id: %r" % CartridgeAgentConfiguration.partition_id)
-        CartridgeAgentConfiguration.log.debug("member-id: %r" % CartridgeAgentConfiguration.member_id)
-        CartridgeAgentConfiguration.log.debug("cartridge-key: %r" % CartridgeAgentConfiguration.cartridge_key)
-        CartridgeAgentConfiguration.log.debug("app-path: %r" % CartridgeAgentConfiguration.app_path)
-        CartridgeAgentConfiguration.log.debug("repo-url: %r" % CartridgeAgentConfiguration.repo_url)
-        CartridgeAgentConfiguration.log.debug("ports: %r" % str(CartridgeAgentConfiguration.ports))
-        CartridgeAgentConfiguration.log.debug("lb-private-ip: %r" % CartridgeAgentConfiguration.lb_private_ip)
-        CartridgeAgentConfiguration.log.debug("lb-public-ip: %r" % CartridgeAgentConfiguration.lb_public_ip)
-
-    @staticmethod
-    def __read_conf_file():
-        """
-        Reads and stores the agent's configuration file
-        :return: void
-        """
-
-        base_working_dir = os.path.abspath(os.path.dirname(__file__)).replace("modules/config", "")
-        conf_file_path = base_working_dir + "agent.conf"
-        CartridgeAgentConfiguration.log.debug("Config file path : %r" % conf_file_path)
-        CartridgeAgentConfiguration.properties = ConfigParser.SafeConfigParser()
-        CartridgeAgentConfiguration.properties.read(conf_file_path)
-
-    @staticmethod
-    def __read_parameter_file():
-        """
-        Reads the payload file of the cartridge and stores the values in a dictionary
-        :return: void
-        """
-
-        param_file = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
-
-        try:
-            if param_file is not None:
-                metadata_file = open(param_file)
-                metadata_payload_content = metadata_file.read()
-                for param in metadata_payload_content.split(","):
-                    if param.strip() != "":
-                        param_value = param.strip().split("=")
-                        CartridgeAgentConfiguration.payload_params[param_value[0]] = param_value[1]
-
-                # CartridgeAgentConfiguration.payload_params = dict(
-                #     param.split("=") for param in metadata_payload_content.split(","))
-                metadata_file.close()
-            else:
-                CartridgeAgentConfiguration.log.error("File not found: %r" % param_file)
-        except:
-            CartridgeAgentConfiguration.log.exception(
-                "Could not read launch parameter file, hence trying to read from System properties.")
-
-    @staticmethod
-    def read_property(property_key, critical=True):
-        """
-        Returns the value of the provided property
-        :param str property_key: the name of the property to be read
-        :return: Value of the property,
-        :rtype: str
-        :exception: ParameterNotFoundException if the provided property cannot be found
-        """
-
-        if CartridgeAgentConfiguration.properties.has_option("agent", property_key):
-            CartridgeAgentConfiguration.log.debug("Has key: %r" % property_key)
-            temp_str = CartridgeAgentConfiguration.properties.get("agent", property_key)
-            if temp_str != "" and temp_str is not None:
-                return temp_str
-
-        if property_key in CartridgeAgentConfiguration.payload_params:
-            temp_str = CartridgeAgentConfiguration.payload_params[property_key]
-            if temp_str != "" and temp_str is not None:
-                return temp_str
-
-        if critical:
-            raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
+                if param_file is not None:
+                    metadata_file = open(param_file)
+                    metadata_payload_content = metadata_file.read()
+                    for param in metadata_payload_content.split(","):
+                        if param.strip() != "":
+                            param_value = param.strip().split("=")
+                            self.payload_params[param_value[0]] = param_value[1]
+
+                    # self.payload_params = dict(
+                    #     param.split("=") for param in metadata_payload_content.split(","))
+                    metadata_file.close()
+                else:
+                    self.log.error("File not found: %r" % param_file)
+            except:
+                self.log.exception(
+                    "Could not read launch parameter file, hence trying to read from System properties.")
+
+        def read_property(self, property_key, critical=True):
+            """
+            Returns the value of the provided property
+            :param str property_key: the name of the property to be read
+            :return: Value of the property,
+            :rtype: str
+            :exception: ParameterNotFoundException if the provided property cannot be found
+            """
+
+            if self.properties.has_option("agent", property_key):
+                self.log.debug("Has key: %r" % property_key)
+                temp_str = self.properties.get("agent", property_key)
+                if temp_str != "" and temp_str is not None:
+                    return temp_str
+
+            if property_key in self.payload_params:
+                temp_str = self.payload_params[property_key]
+                if temp_str != "" and temp_str is not None:
+                    return temp_str
+
+            if critical:
+                raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
+
+    instance = None
+
+    def __new__(cls, *args, **kwargs):
+        if not CartridgeAgentConfiguration.instance:
+            CartridgeAgentConfiguration.instance = CartridgeAgentConfiguration.__CartridgeAgentConfiguration()
+
+        return CartridgeAgentConfiguration.instance
+
+    def __getattr__(self, name):
+        return getattr(self.instance, name)
+
+    def __setattr__(self, name):
+        return setattr(self.instance, name)
+
+
+from ..exception.parameternotfoundexception import ParameterNotFoundException
+from ..util import cartridgeagentconstants

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
index b65a2be..e229af1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
@@ -6,6 +6,13 @@ class StreamDefinition:
     """
     Represents a BAM/CEP stream definition
     """
+
+    STRING = 'STRING'
+    DOUBLE = 'DOUBLE'
+    INT = 'INT'
+    LONG = 'LONG'
+    BOOL = 'BOOL'
+
     def __init__(self):
         self.name = None
         """:type : str"""

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index d5cdc01..ea30c85 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -4,7 +4,7 @@ from threading import Thread, current_thread
 
 from ..databridge.agent import *
 from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import cartridgeagentutils
+from ..util import cartridgeagentutils, cartridgeagentconstants
 from exception.datapublisherexception import DataPublisherException
 
 
@@ -87,25 +87,26 @@ class LogPublisherManager(Thread):
         """
         # stream definition
         stream_definition = StreamDefinition()
-        valid_tenant_id = LogPublisherManager.get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
-        alias = LogPublisherManager.get_alias(CartridgeAgentConfiguration.cluster_id)
+        valid_tenant_id = LogPublisherManager.get_valid_tenant_id(CartridgeAgentConfiguration().tenant_id)
+        alias = LogPublisherManager.get_alias(CartridgeAgentConfiguration().cluster_id)
         stream_name = "logs." + valid_tenant_id + "." \
                       + alias + "." + LogPublisherManager.get_current_date()
         stream_version = "1.0.0"
+
         stream_definition.name = stream_name
         stream_definition.version = stream_version
         stream_definition.description = "Apache Stratos Instance Log Publisher"
-        stream_definition.add_metadata_attribute("memberId", 'STRING')
-        stream_definition.add_payloaddata_attribute("tenantID", "STRING")
-        stream_definition.add_payloaddata_attribute("serverName", "STRING")
-        stream_definition.add_payloaddata_attribute("appName", "STRING")
-        stream_definition.add_payloaddata_attribute("logTime", "STRING")
-        stream_definition.add_payloaddata_attribute("priority", "STRING")
-        stream_definition.add_payloaddata_attribute("message", "STRING")
-        stream_definition.add_payloaddata_attribute("logger", "STRING")
-        stream_definition.add_payloaddata_attribute("ip", "STRING")
-        stream_definition.add_payloaddata_attribute("instance", "STRING")
-        stream_definition.add_payloaddata_attribute("stacktrace", "STRING")
+        stream_definition.add_metadata_attribute("memberId", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("tenantID", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("serverName", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("appName", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("logTime", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("priority", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("message", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("logger", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("ip", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("instance", StreamDefinition.STRING)
+        stream_definition.add_payloaddata_attribute("stacktrace", StreamDefinition.STRING)
 
         return stream_definition
 
@@ -117,8 +118,17 @@ class LogPublisherManager(Thread):
         self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_port)
         self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_secure_port)
 
-        cartridgeagentutils.wait_until_ports_active(DataPublisherConfiguration.get_instance().monitoring_server_ip, self.ports)
-        ports_active = cartridgeagentutils.check_ports_active(DataPublisherConfiguration.get_instance().monitoring_server_ip, self.ports)
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+        cartridgeagentutils.wait_until_ports_active(
+            DataPublisherConfiguration.get_instance().monitoring_server_ip,
+            self.ports,
+            int(self.cartridge_agent_config.read_property("port.check.timeout", critical=False)))
+
+        ports_active = cartridgeagentutils.check_ports_active(
+            DataPublisherConfiguration.get_instance().monitoring_server_ip,
+            self.ports)
+
         if not ports_active:
             raise DataPublisherException("Monitoring server not active, data publishing is aborted")
 
@@ -158,14 +168,14 @@ class LogPublisherManager(Thread):
 
     @staticmethod
     def get_valid_tenant_id(tenant_id):
-        if tenant_id == "-1" or tenant_id == "-1234":
+        if tenant_id == cartridgeagentconstants.INVALID_TENANT_ID \
+                or tenant_id == cartridgeagentconstants.SUPER_TENANT_ID:
             return "0"
 
         return tenant_id
 
     @staticmethod
     def get_alias(cluster_id):
-        alias = ""
         try:
             alias = cluster_id.split("\\.")[0]
         except:
@@ -180,7 +190,7 @@ class LogPublisherManager(Thread):
         :return: Formatted date string
         :rtype : str
         """
-        return datetime.date.today().strftime("%Y.%m.%d")
+        return datetime.date.today().strftime(cartridgeagentconstants.DATE_FORMAT)
 
 
 class DataPublisherConfiguration:
@@ -213,32 +223,34 @@ class DataPublisherConfiguration:
         self.admin_password = None
         self.read_config()
 
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
     def read_config(self):
-        self.enabled = True if CartridgeAgentConfiguration.read_property("enable.data.publisher", False).strip().lower() == "true" else False
+        self.enabled = True if self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_PUBLISHER_ENABLED, False).strip().lower() == "true" else False
         if not self.enabled:
             DataPublisherConfiguration.log.info("Data Publisher disabled")
             return
 
         DataPublisherConfiguration.log.info("Data Publisher enabled")
 
-        self.monitoring_server_ip = CartridgeAgentConfiguration.read_property("monitoring.server.ip", False)
+        self.monitoring_server_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_RECEIVER_IP, False)
         if self.monitoring_server_ip.strip() == "":
-            raise RuntimeError("System property not found: monitoring.server.ip")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_RECEIVER_IP)
 
-        self.monitoring_server_port = CartridgeAgentConfiguration.read_property("monitoring.server.port", False)
+        self.monitoring_server_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_RECEIVER_PORT, False)
         if self.monitoring_server_port.strip() == "":
-            raise RuntimeError("System property not found: monitoring.server.port")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_RECEIVER_PORT)
 
-        self.monitoring_server_secure_port = CartridgeAgentConfiguration.read_property("monitoring.server.secure.port", False)
-        if self.monitoring_server_secure_port.strip() == "":
-            raise RuntimeError("System property not found: monitoring.server.secure.port")
+        # self.monitoring_server_secure_port = self.cartridge_agent_config.read_property("monitoring.server.secure.port", False)
+        # if self.monitoring_server_secure_port.strip() == "":
+        #     raise RuntimeError("System property not found: monitoring.server.secure.port")
 
-        self.admin_username = CartridgeAgentConfiguration.read_property("monitoring.server.admin.username", False)
+        self.admin_username = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_SERVER_ADMIN_USERNAME, False)
         if self.admin_username.strip() == "":
-            raise RuntimeError("System property not found: monitoring.server.admin.username")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_SERVER_ADMIN_USERNAME)
 
-        self.admin_password = CartridgeAgentConfiguration.read_property("monitoring.server.admin.password", False)
+        self.admin_password = self.cartridge_agent_config.read_property(cartridgeagentconstants.MONITORING_SERVER_ADMIN_PASSWORD, False)
         if self.admin_password.strip() == "":
-            raise RuntimeError("System property not found: monitoring.server.admin.password")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.MONITORING_SERVER_ADMIN_PASSWORD)
 
         DataPublisherConfiguration.log.info("Data Publisher configuration initialized")

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
index f57a1cf..765d3bc 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
@@ -12,10 +12,10 @@ class AbstractExtensionHandler:
     def on_artifact_update_scheduler_event(self, tenant_id):
         raise NotImplementedError
 
-    def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
+    def on_instance_cleanup_cluster_event(self, instance_cleanup_cluster_event):
         raise NotImplementedError
 
-    def on_instance_cleanup_member_event(self, instanceCleanupMemberEvent):
+    def on_instance_cleanup_member_event(self, instance_cleanup_member_event):
         raise NotImplementedError
 
     def on_member_activated_event(self, member_activated_event):
@@ -45,7 +45,7 @@ class AbstractExtensionHandler:
     def on_subscription_domain_added_event(self, subscription_domain_added_event):
         raise NotImplementedError
 
-    def on_subscription_domain_removed_event(self, subscriptionDomainRemovedEvent):
+    def on_subscription_domain_removed_event(self, subscription_domain_removed_event):
         raise NotImplementedError
 
     def on_copy_artifacts_extension(self, src, des):

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 8005a7a..58a5aa7 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -1,15 +1,5 @@
-import logging
 import time
 
-from ..artifactmgt.git.agentgithandler import AgentGitHandler
-from ..artifactmgt.repositoryinformation import RepositoryInformation
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import extensionutils
-from ..publisher import cartridgeagentpublisher
-from ..exception.parameternotfoundexception import ParameterNotFoundException
-from ..topology.topologycontext import *
-from ..tenant.tenantcontext import *
-from ..util.log import LogFactory
 from abstractextensionhandler import AbstractExtensionHandler
 
 
@@ -22,12 +12,13 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
     def __init__(self):
         self.log = LogFactory().get_log(__name__)
         self.wk_members = []
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
 
     def on_instance_started_event(self):
         try:
             self.log.debug("Processing instance started event...")
-            if CartridgeAgentConfiguration.is_multitenant:
-                artifact_source = "%r/repository/deployment/server/" % CartridgeAgentConfiguration.app_path
+            if self.cartridge_agent_config.is_multitenant:
+                artifact_source = "%r/repository/deployment/server/" % self.cartridge_agent_config.app_path
                 artifact_dest = cartridgeagentconstants.SUPERTENANT_TEMP_PATH
                 extensionutils.execute_copy_artifact_extension(artifact_source, artifact_dest)
 
@@ -45,18 +36,18 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                        artifacts_updated_event.status))
 
         cluster_id_event = str(artifacts_updated_event.cluster_id).strip()
-        cluster_id_payload = CartridgeAgentConfiguration.cluster_id
+        cluster_id_payload = self.cartridge_agent_config.cluster_id
         repo_url = str(artifacts_updated_event.repo_url).strip()
 
         if (repo_url != "") and (cluster_id_payload is not None) and (cluster_id_payload == cluster_id_event):
-            local_repo_path = CartridgeAgentConfiguration.app_path
+            local_repo_path = self.cartridge_agent_config.app_path
 
-            secret = CartridgeAgentConfiguration.cartridge_key
+            secret = self.cartridge_agent_config.cartridge_key
             repo_password = cartridgeagentutils.decrypt_password(artifacts_updated_event.repo_password, secret)
 
             repo_username = artifacts_updated_event.repo_username
             tenant_id = artifacts_updated_event.tenant_id
-            is_multitenant = CartridgeAgentConfiguration.is_multitenant
+            is_multitenant = self.cartridge_agent_config.is_multitenant
             commit_enabled = artifacts_updated_event.commit_enabled
 
             self.log.info("Executing git checkout")
@@ -66,7 +57,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                                               is_multitenant, commit_enabled)
 
             # checkout code
-            subscribe_run, repo_context = AgentGitHandler.checkout(repo_info)
+            subscribe_run, repo_context = agentgithandler.AgentGitHandler.checkout(repo_info)
             # repo_context = checkout_result["repo_context"]
             # execute artifact updated extension
             env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": artifacts_updated_event.cluster_id,
@@ -82,15 +73,15 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 # publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 
-            update_artifacts = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE, False)
+            update_artifacts = self.cartridge_agent_config.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE, False)
             update_artifacts = True if str(update_artifacts).strip().lower() == "true" else False
             if update_artifacts:
-                auto_commit = CartridgeAgentConfiguration.is_commits_enabled
-                auto_checkout = CartridgeAgentConfiguration.is_checkout_enabled
+                auto_commit = self.cartridge_agent_config.is_commits_enabled
+                auto_checkout = self.cartridge_agent_config.is_checkout_enabled
 
                 try:
                     update_interval = len(
-                        CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL, False))
+                        self.cartridge_agent_config.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL, False))
                 except ParameterNotFoundException:
                     self.log.exception("Invalid artifact sync interval specified ")
                     update_interval = 10
@@ -103,7 +94,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 self.log.info("Auto Commit is turned %r " % "on" if auto_commit else "off")
                 self.log.info("Auto Checkout is turned %r " % "on" if auto_checkout else "off")
 
-                AgentGitHandler.schedule_artifact_update_scheduled_task(repo_info, auto_checkout, auto_commit,
+                agentgithandler.AgentGitHandler.schedule_artifact_update_scheduled_task(repo_info, auto_checkout, auto_commit,
                                                                         update_interval)
 
     def on_artifact_update_scheduler_event(self, tenant_id):
@@ -111,19 +102,21 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
         extensionutils.execute_artifacts_updated_extension(env_params)
 
-    def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
+    def on_instance_cleanup_cluster_event(self, instance_cleanup_cluster_event):
         self.cleanup()
 
-    def on_instance_cleanup_member_event(self, instanceCleanupMemberEvent):
+    def on_instance_cleanup_member_event(self, instance_cleanup_member_event):
         self.cleanup()
 
     def on_member_activated_event(self, member_activated_event):
         self.log.info("Member activated event received: [service] %r [cluster] %r [member] %r"
             % (member_activated_event.service_name, member_activated_event.cluster_id, member_activated_event.member_id))
 
-        topology_consistent = extensionutils.check_topology_consistency(member_activated_event.service_name,
-                                                               member_activated_event.cluster_id,
-                                                               member_activated_event.member_id)
+        topology_consistent = extensionutils.check_topology_consistency(
+            member_activated_event.service_name,
+            member_activated_event.cluster_id,
+            member_activated_event.member_id)
+
         if not topology_consistent:
             self.log.error("Topology is inconsistent...failed to execute member activated event")
             return
@@ -164,7 +157,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
             extensionutils.add_properties(cluster.properties, env_params, "MEMBER_ACTIVATED_CLUSTER_PROPERTY")
             extensionutils.add_properties(member.properties, env_params, "MEMBER_ACTIVATED_MEMBER_PROPERTY")
 
-            clustered = CartridgeAgentConfiguration.is_clustered
+            clustered = self.cartridge_agent_config.is_clustered
 
             if member.properties is not None and member.properties[
                     cartridgeagentconstants.CLUSTERING_PRIMARY_KEY] == "true" and clustered is not None and clustered:
@@ -178,7 +171,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
                 self.log.debug(" hasWKIpChanged %r" + has_wk_ip_changed)
 
-                min_count = int(CartridgeAgentConfiguration.min_count)
+                min_count = int(self.cartridge_agent_config.min_count)
                 is_wk_member_grp_ready = self.is_wk_member_group_ready(env_params, min_count)
                 self.log.debug("MinCount: %r" % min_count)
                 self.log.debug("is_wk_member_grp_ready : %r" % is_wk_member_grp_ready)
@@ -189,7 +182,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
             self.log.debug("Setting env var STRATOS_CLUSTERING to %r" % clustered)
             env_params["STRATOS_CLUSTERING"] = clustered
-            env_params["STRATOS_WK_MEMBER_COUNT"] = CartridgeAgentConfiguration.min_count
+            env_params["STRATOS_WK_MEMBER_COUNT"] = self.cartridge_agent_config.min_count
 
             extensionutils.execute_member_activated_extension(env_params)
         else:
@@ -198,9 +191,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
     def on_complete_topology_event(self, complete_topology_event):
         self.log.debug("Complete topology event received")
 
-        service_name_in_payload = CartridgeAgentConfiguration.service_name
-        cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
-        member_id_in_payload = CartridgeAgentConfiguration.member_id
+        service_name_in_payload = self.cartridge_agent_config.service_name
+        cluster_id_in_payload = self.cartridge_agent_config.cluster_id
+        member_id_in_payload = self.cartridge_agent_config.member_id
 
         extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
 
@@ -224,7 +217,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
     def on_member_terminated_event(self, member_terminated_event):
         self.log.info("Member terminated event received: [service] " + member_terminated_event.service_name +
-                      " [cluster] " + member_terminated_event.cluster_id + " [member] " + member_terminated_event.member_id)
+                      " [cluster] " + member_terminated_event.cluster_id
+                      + " [member] " + member_terminated_event.member_id)
 
         topology_consistent = extensionutils.check_topology_consistency(
             member_terminated_event.service_name,
@@ -374,9 +368,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         extensionutils.wait_for_complete_topology()
         self.log.info("[start server extension] complete topology event received")
 
-        service_name_in_payload = CartridgeAgentConfiguration.service_name
-        cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
-        member_id_in_payload = CartridgeAgentConfiguration.member_id
+        service_name_in_payload = self.cartridge_agent_config.service_name
+        cluster_id_in_payload = self.cartridge_agent_config.cluster_id
+        member_id_in_payload = self.cartridge_agent_config.member_id
 
         topology_consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
 
@@ -393,12 +387,12 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
             env_params = {}
 
             # if clustering is enabled wait until all well known members have started
-            clustering_enabled = CartridgeAgentConfiguration.is_clustered
+            clustering_enabled = self.cartridge_agent_config.is_clustered
             if clustering_enabled:
                 env_params["STRATOS_CLUSTERING"] = "true"
-                env_params["STRATOS_WK_MEMBER_COUNT"] = CartridgeAgentConfiguration.min_count
+                env_params["STRATOS_WK_MEMBER_COUNT"] = self.cartridge_agent_config.min_count
 
-                env_params["STRATOS_PRIMARY"] = "true" if CartridgeAgentConfiguration.is_primary else "false"
+                env_params["STRATOS_PRIMARY"] = "true" if self.cartridge_agent_config.is_primary else "false"
 
                 self.wait_for_wk_members(env_params)
                 self.log.info("All well known members have started! Resuming start server extension...")
@@ -430,16 +424,16 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
         extensionutils.execute_subscription_domain_added_extension(env_params)
 
-    def on_subscription_domain_removed_event(self, subscriptionDomainRemovedEvent):
-        tenant_domain = self.find_tenant_domain(subscriptionDomainRemovedEvent.tenant_id)
+    def on_subscription_domain_removed_event(self, subscription_domain_removed_event):
+        tenant_domain = self.find_tenant_domain(subscription_domain_removed_event.tenant_id)
         self.log.info(
-            "Subscription domain removed event received: [tenant-id] " + subscriptionDomainRemovedEvent.tenant_id +
-            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscriptionDomainRemovedEvent.domain_name
+            "Subscription domain removed event received: [tenant-id] " + subscription_domain_removed_event.tenant_id +
+            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscription_domain_removed_event.domain_name
         )
 
-        env_params = {"STRATOS_SUBSCRIPTION_SERVICE_NAME": subscriptionDomainRemovedEvent.service_name,
-                      "STRATOS_SUBSCRIPTION_DOMAIN_NAME": subscriptionDomainRemovedEvent.domain_name,
-                      "STRATOS_SUBSCRIPTION_TENANT_ID": int(subscriptionDomainRemovedEvent.tenant_id),
+        env_params = {"STRATOS_SUBSCRIPTION_SERVICE_NAME": subscription_domain_removed_event.service_name,
+                      "STRATOS_SUBSCRIPTION_DOMAIN_NAME": subscription_domain_removed_event.domain_name,
+                      "STRATOS_SUBSCRIPTION_TENANT_ID": int(subscription_domain_removed_event.tenant_id),
                       "STRATOS_SUBSCRIPTION_TENANT_DOMAIN": tenant_domain}
 
         extensionutils.execute_subscription_domain_removed_extension(env_params)
@@ -458,14 +452,15 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
     def on_tenant_unsubscribed_event(self, tenant_unsubscribed_event):
         self.log.info(
             "Tenant unsubscribed event received: [tenant] " + tenant_unsubscribed_event.tenant_id +
-            " [service] " + tenant_unsubscribed_event.service_name + " [cluster] " + tenant_unsubscribed_event.cluster_ids
+            " [service] " + tenant_unsubscribed_event.service_name +
+            " [cluster] " + tenant_unsubscribed_event.cluster_ids
         )
 
         try:
-            if CartridgeAgentConfiguration.service_name == tenant_unsubscribed_event.service_name:
-                AgentGitHandler.remove_repo(tenant_unsubscribed_event.tenant_id)
+            if self.cartridge_agent_config.service_name == tenant_unsubscribed_event.service_name:
+                agentgithandler.AgentGitHandler.remove_repo(tenant_unsubscribed_event.tenant_id)
         except:
-            self.log.exception()
+            self.log.exception("Removing git repository failed: ")
         extensionutils.execute_tenant_unsubscribed_extension({})
 
     def cleanup(self):
@@ -484,18 +479,20 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         if topology is None or not topology.initialized:
             return False
 
-        service_group_in_payload = CartridgeAgentConfiguration.service_group
+        service_group_in_payload = self.cartridge_agent_config.service_group
         if service_group_in_payload is not None:
             env_params["STRATOS_SERVICE_GROUP"] = service_group_in_payload
 
         # clustering logic for apimanager
         if service_group_in_payload is not None and service_group_in_payload == "apim":
             # handle apistore and publisher case
-            if CartridgeAgentConfiguration.service_name == "apistore" or \
-                    CartridgeAgentConfiguration.service_name == "publisher":
+            if self.cartridge_agent_config.service_name == cartridgeagentconstants.APIMANAGER_SERVICE_NAME or \
+                    self.cartridge_agent_config.service_name == cartridgeagentconstants.PUBLISHER_SERVICE_NAME:
 
-                apistore_cluster_collection = topology.get_service("apistore").get_clusters()
-                publisher_cluster_collection = topology.get_service("publisher").get_clusters()
+                apistore_cluster_collection = topology.get_service(cartridgeagentconstants.APIMANAGER_SERVICE_NAME)\
+                    .get_clusters()
+                publisher_cluster_collection = topology.get_service(cartridgeagentconstants.PUBLISHER_SERVICE_NAME)\
+                    .get_clusters()
 
                 apistore_member_list = []
                 for member in apistore_cluster_collection[0].get_members():
@@ -526,42 +523,43 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
                 return True
 
-            elif CartridgeAgentConfiguration.service_name == "gatewaymgt" or \
-                    CartridgeAgentConfiguration.service_name == "gateway":
+            elif self.cartridge_agent_config.service_name == cartridgeagentconstants.GATEWAY_MGT_SERVICE_NAME or \
+                    self.cartridge_agent_config.service_name == cartridgeagentconstants.GATEWAY_SERVICE_NAME:
 
-                if CartridgeAgentConfiguration.deployment is not None:
+                if self.cartridge_agent_config.deployment is not None:
                     # check if deployment is Manager Worker separated
-                    if CartridgeAgentConfiguration.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower() or \
-                            CartridgeAgentConfiguration.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                    if self.cartridge_agent_config.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower() or \
+                            self.cartridge_agent_config.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
 
-                        self.log.info("Deployment pattern for the node: %r" % CartridgeAgentConfiguration.deployment)
-                        env_params["DEPLOYMENT"] = CartridgeAgentConfiguration.deployment
+                        self.log.info("Deployment pattern for the node: %r" % self.cartridge_agent_config.deployment)
+                        env_params["DEPLOYMENT"] = self.cartridge_agent_config.deployment
                         # check if WKA members of Manager Worker separated deployment is ready
                         return self.is_manager_worker_WKA_group_ready(env_params)
 
-            elif CartridgeAgentConfiguration.service_name == "keymanager":
+            elif self.cartridge_agent_config.service_name == cartridgeagentconstants.KEY_MANAGER_SERVICE_NAME:
                 return True
 
         else:
-            if CartridgeAgentConfiguration.deployment is not None:
+            if self.cartridge_agent_config.deployment is not None:
                 # check if deployment is Manager Worker separated
-                if CartridgeAgentConfiguration.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower() or \
-                        CartridgeAgentConfiguration.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                if self.cartridge_agent_config.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower() or \
+                        self.cartridge_agent_config.deployment.lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
 
-                    self.log.info("Deployment pattern for the node: %r" % CartridgeAgentConfiguration.deployment)
-                    env_params["DEPLOYMENT"] = CartridgeAgentConfiguration.deployment
+                    self.log.info("Deployment pattern for the node: %r" % self.cartridge_agent_config.deployment)
+                    env_params["DEPLOYMENT"] = self.cartridge_agent_config.deployment
                     # check if WKA members of Manager Worker separated deployment is ready
                     return self.is_manager_worker_WKA_group_ready(env_params)
 
-            service_name_in_payload = CartridgeAgentConfiguration.service_name
-            cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
+            service_name_in_payload = self.cartridge_agent_config.service_name
+            cluster_id_in_payload = self.cartridge_agent_config.cluster_id
             service = topology.get_service(service_name_in_payload)
             cluster = service.get_cluster(cluster_id_in_payload)
 
             wk_members = []
             for member in cluster.get_members():
                 if member.properties is not None and \
-                        "PRIMARY" in member.properties and member.properties["PRIMARY"].lower() == "true" and \
+                        cartridgeagentconstants.PRIMARY in member.properties \
+                        and member.properties[cartridgeagentconstants.PRIMARY].lower() == "true" and \
                         (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
 
                     wk_members.append(member)
@@ -584,8 +582,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
     def is_manager_worker_WKA_group_ready(self, env_params):
 
         # for this, we need both manager cluster service name and worker cluster service name
-        manager_service_name = CartridgeAgentConfiguration.manager_service_name
-        worker_service_name = CartridgeAgentConfiguration.worker_service_name
+        manager_service_name = self.cartridge_agent_config.manager_service_name
+        worker_service_name = self.cartridge_agent_config.worker_service_name
 
         # managerServiceName and workerServiceName both should not be null /empty
         if manager_service_name is None or manager_service_name.strip() == "":
@@ -623,7 +621,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         manager_wka_members = []
         for member in manager_clusters[0].get_members():
             if member.properties is not None and \
-                    "PRIMARY" in member.properties and member.properties["PRIMARY"].lower() == "true" and \
+                    cartridgeagentconstants.PRIMARY in member.properties \
+                    and member.properties[cartridgeagentconstants.PRIMARY].lower() == "true" and \
                     (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
 
                 manager_wka_members.append(member)
@@ -656,8 +655,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 self.log.info(
                     "Manager min instance count when allManagersNonPrimary true : " + manager_min_instance_count)
 
-            if member.properties is not None and "PRIMARY" in member.properties and \
-                            member.properties["PRIMARY"].lower() == "true":
+            if member.properties is not None and cartridgeagentconstants.PRIMARY in member.properties and \
+                    member.properties[cartridgeagentconstants.PRIMARY].lower() == "true":
                 all_managers_non_primary = False
                 break
 
@@ -681,8 +680,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         for member in worker_clusters[0].get_members():
             self.log.debug("Checking member : " + member.member_id)
 
-            if member.properties is not None and "PRIMARY" in member.properties and \
-                    member.properties["PRIMARY"].lower() == "true" and \
+            if member.properties is not None and cartridgeagentconstants.PRIMARY in member.properties and \
+                    member.properties[cartridgeagentconstants.PRIMARY].lower() == "true" and \
                     (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
 
                 self.log.debug("Added worker member " + member.member_id)
@@ -713,8 +712,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         return min_manager_instances_available and min_worker_instances_available
 
     def get_min_instance_count_from_member(self, member):
-        if "MIN_COUNT" in member.properties:
-            return int(member.properties["MIN_COUNT"])
+        if cartridgeagentconstants.MIN_COUNT in member.properties:
+            return int(member.properties[cartridgeagentconstants.MIN_COUNT])
 
         return 1
 
@@ -726,11 +725,21 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         return tenant.tenant_domain
 
     def wait_for_wk_members(self, env_params):
-        min_count = int(CartridgeAgentConfiguration.min_count)
+        min_count = int(self.cartridge_agent_config.min_count)
         is_wk_member_group_ready = False
         while not is_wk_member_group_ready:
             self.log.info("Waiting for %r well known members..." % min_count)
 
             time.sleep(5)
 
-            is_wk_member_group_ready = self.is_wk_member_group_ready(env_params, min_count)
\ No newline at end of file
+            is_wk_member_group_ready = self.is_wk_member_group_ready(env_params, min_count)
+
+from ..artifactmgt.git import agentgithandler
+from ..artifactmgt.repositoryinformation import RepositoryInformation
+from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from ..util import extensionutils
+from ..publisher import cartridgeagentpublisher
+from ..exception.parameternotfoundexception import ParameterNotFoundException
+from ..topology.topologycontext import *
+from ..tenant.tenantcontext import *
+from ..util.log import LogFactory
\ No newline at end of file


[08/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
deleted file mode 100644
index 7a695a8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# 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 logging
-from multiprocessing import  Process, Value, Condition, reduction
-
-from TServer import TServer
-from thrift.transport.TTransport import TTransportException
-
-
-class TProcessPoolServer(TServer):
-    """Server with a fixed size pool of worker subprocesses to service requests
-
-    Note that if you need shared state between the handlers - it's up to you!
-    Written by Dvir Volk, doat.com
-    """
-    def __init__(self, *args):
-        TServer.__init__(self, *args)
-        self.numWorkers = 10
-        self.workers = []
-        self.isRunning = Value('b', False)
-        self.stopCondition = Condition()
-        self.postForkCallback = None
-
-    def setPostForkCallback(self, callback):
-        if not callable(callback):
-            raise TypeError("This is not a callback!")
-        self.postForkCallback = callback
-
-    def setNumWorkers(self, num):
-        """Set the number of worker threads that should be created"""
-        self.numWorkers = num
-
-    def workerProcess(self):
-        """Loop getting clients from the shared queue and process them"""
-        if self.postForkCallback:
-            self.postForkCallback()
-
-        while self.isRunning.value:
-            try:
-                client = self.serverTransport.accept()
-                self.serveClient(client)
-            except (KeyboardInterrupt, SystemExit):
-                return 0
-            except Exception, x:
-                logging.exception(x)
-
-    def serveClient(self, client):
-        """Process input/output from a client for as long as possible"""
-        itrans = self.inputTransportFactory.getTransport(client)
-        otrans = self.outputTransportFactory.getTransport(client)
-        iprot = self.inputProtocolFactory.getProtocol(itrans)
-        oprot = self.outputProtocolFactory.getProtocol(otrans)
-
-        try:
-            while True:
-                self.processor.process(iprot, oprot)
-        except TTransportException, tx:
-            pass
-        except Exception, x:
-            logging.exception(x)
-
-        itrans.close()
-        otrans.close()
-
-    def serve(self):
-        """Start workers and put into queue"""
-        # this is a shared state that can tell the workers to exit when False
-        self.isRunning.value = True
-
-        # first bind and listen to the port
-        self.serverTransport.listen()
-
-        # fork the children
-        for i in range(self.numWorkers):
-            try:
-                w = Process(target=self.workerProcess)
-                w.daemon = True
-                w.start()
-                self.workers.append(w)
-            except Exception, x:
-                logging.exception(x)
-
-        # wait until the condition is set by stop()
-        while True:
-            self.stopCondition.acquire()
-            try:
-                self.stopCondition.wait()
-                break
-            except (SystemExit, KeyboardInterrupt):
-                break
-            except Exception, x:
-                logging.exception(x)
-
-        self.isRunning.value = False
-
-    def stop(self):
-        self.isRunning.value = False
-        self.stopCondition.acquire()
-        self.stopCondition.notify()
-        self.stopCondition.release()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
deleted file mode 100644
index 2f24842..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
+++ /dev/null
@@ -1,269 +0,0 @@
-#
-# 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 Queue
-import logging
-import os
-import sys
-import threading
-import traceback
-
-from thrift.Thrift import TProcessor
-from thrift.protocol import TBinaryProtocol
-from thrift.transport import TTransport
-
-
-class TServer:
-  """Base interface for a server, which must have a serve() method.
-
-  Three constructors for all servers:
-  1) (processor, serverTransport)
-  2) (processor, serverTransport, transportFactory, protocolFactory)
-  3) (processor, serverTransport,
-      inputTransportFactory, outputTransportFactory,
-      inputProtocolFactory, outputProtocolFactory)
-  """
-  def __init__(self, *args):
-    if (len(args) == 2):
-      self.__initArgs__(args[0], args[1],
-                        TTransport.TTransportFactoryBase(),
-                        TTransport.TTransportFactoryBase(),
-                        TBinaryProtocol.TBinaryProtocolFactory(),
-                        TBinaryProtocol.TBinaryProtocolFactory())
-    elif (len(args) == 4):
-      self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3])
-    elif (len(args) == 6):
-      self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5])
-
-  def __initArgs__(self, processor, serverTransport,
-                   inputTransportFactory, outputTransportFactory,
-                   inputProtocolFactory, outputProtocolFactory):
-    self.processor = processor
-    self.serverTransport = serverTransport
-    self.inputTransportFactory = inputTransportFactory
-    self.outputTransportFactory = outputTransportFactory
-    self.inputProtocolFactory = inputProtocolFactory
-    self.outputProtocolFactory = outputProtocolFactory
-
-  def serve(self):
-    pass
-
-
-class TSimpleServer(TServer):
-  """Simple single-threaded server that just pumps around one transport."""
-
-  def __init__(self, *args):
-    TServer.__init__(self, *args)
-
-  def serve(self):
-    self.serverTransport.listen()
-    while True:
-      client = self.serverTransport.accept()
-      itrans = self.inputTransportFactory.getTransport(client)
-      otrans = self.outputTransportFactory.getTransport(client)
-      iprot = self.inputProtocolFactory.getProtocol(itrans)
-      oprot = self.outputProtocolFactory.getProtocol(otrans)
-      try:
-        while True:
-          self.processor.process(iprot, oprot)
-      except TTransport.TTransportException, tx:
-        pass
-      except Exception, x:
-        logging.exception(x)
-
-      itrans.close()
-      otrans.close()
-
-
-class TThreadedServer(TServer):
-  """Threaded server that spawns a new thread per each connection."""
-
-  def __init__(self, *args, **kwargs):
-    TServer.__init__(self, *args)
-    self.daemon = kwargs.get("daemon", False)
-
-  def serve(self):
-    self.serverTransport.listen()
-    while True:
-      try:
-        client = self.serverTransport.accept()
-        t = threading.Thread(target=self.handle, args=(client,))
-        t.setDaemon(self.daemon)
-        t.start()
-      except KeyboardInterrupt:
-        raise
-      except Exception, x:
-        logging.exception(x)
-
-  def handle(self, client):
-    itrans = self.inputTransportFactory.getTransport(client)
-    otrans = self.outputTransportFactory.getTransport(client)
-    iprot = self.inputProtocolFactory.getProtocol(itrans)
-    oprot = self.outputProtocolFactory.getProtocol(otrans)
-    try:
-      while True:
-        self.processor.process(iprot, oprot)
-    except TTransport.TTransportException, tx:
-      pass
-    except Exception, x:
-      logging.exception(x)
-
-    itrans.close()
-    otrans.close()
-
-
-class TThreadPoolServer(TServer):
-  """Server with a fixed size pool of threads which service requests."""
-
-  def __init__(self, *args, **kwargs):
-    TServer.__init__(self, *args)
-    self.clients = Queue.Queue()
-    self.threads = 10
-    self.daemon = kwargs.get("daemon", False)
-
-  def setNumThreads(self, num):
-    """Set the number of worker threads that should be created"""
-    self.threads = num
-
-  def serveThread(self):
-    """Loop around getting clients from the shared queue and process them."""
-    while True:
-      try:
-        client = self.clients.get()
-        self.serveClient(client)
-      except Exception, x:
-        logging.exception(x)
-
-  def serveClient(self, client):
-    """Process input/output from a client for as long as possible"""
-    itrans = self.inputTransportFactory.getTransport(client)
-    otrans = self.outputTransportFactory.getTransport(client)
-    iprot = self.inputProtocolFactory.getProtocol(itrans)
-    oprot = self.outputProtocolFactory.getProtocol(otrans)
-    try:
-      while True:
-        self.processor.process(iprot, oprot)
-    except TTransport.TTransportException, tx:
-      pass
-    except Exception, x:
-      logging.exception(x)
-
-    itrans.close()
-    otrans.close()
-
-  def serve(self):
-    """Start a fixed number of worker threads and put client into a queue"""
-    for i in range(self.threads):
-      try:
-        t = threading.Thread(target=self.serveThread)
-        t.setDaemon(self.daemon)
-        t.start()
-      except Exception, x:
-        logging.exception(x)
-
-    # Pump the socket for clients
-    self.serverTransport.listen()
-    while True:
-      try:
-        client = self.serverTransport.accept()
-        self.clients.put(client)
-      except Exception, x:
-        logging.exception(x)
-
-
-class TForkingServer(TServer):
-  """A Thrift server that forks a new process for each request
-
-  This is more scalable than the threaded server as it does not cause
-  GIL contention.
-
-  Note that this has different semantics from the threading server.
-  Specifically, updates to shared variables will no longer be shared.
-  It will also not work on windows.
-
-  This code is heavily inspired by SocketServer.ForkingMixIn in the
-  Python stdlib.
-  """
-  def __init__(self, *args):
-    TServer.__init__(self, *args)
-    self.children = []
-
-  def serve(self):
-    def try_close(file):
-      try:
-        file.close()
-      except IOError, e:
-        logging.warning(e, exc_info=True)
-
-    self.serverTransport.listen()
-    while True:
-      client = self.serverTransport.accept()
-      try:
-        pid = os.fork()
-
-        if pid:  # parent
-          # add before collect, otherwise you race w/ waitpid
-          self.children.append(pid)
-          self.collect_children()
-
-          # Parent must close socket or the connection may not get
-          # closed promptly
-          itrans = self.inputTransportFactory.getTransport(client)
-          otrans = self.outputTransportFactory.getTransport(client)
-          try_close(itrans)
-          try_close(otrans)
-        else:
-          itrans = self.inputTransportFactory.getTransport(client)
-          otrans = self.outputTransportFactory.getTransport(client)
-
-          iprot = self.inputProtocolFactory.getProtocol(itrans)
-          oprot = self.outputProtocolFactory.getProtocol(otrans)
-
-          ecode = 0
-          try:
-            try:
-              while True:
-                self.processor.process(iprot, oprot)
-            except TTransport.TTransportException, tx:
-              pass
-            except Exception, e:
-              logging.exception(e)
-              ecode = 1
-          finally:
-            try_close(itrans)
-            try_close(otrans)
-
-          os._exit(ecode)
-
-      except TTransport.TTransportException, tx:
-        pass
-      except Exception, x:
-        logging.exception(x)
-
-  def collect_children(self):
-    while self.children:
-      try:
-        pid, status = os.waitpid(0, os.WNOHANG)
-      except os.error:
-        pid = None
-
-      if pid:
-        self.children.remove(pid)
-      else:
-        break

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py
deleted file mode 100644
index 1bf6e25..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# 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__ = ['TServer', 'TNonblockingServer']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
deleted file mode 100644
index ea80a1a..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
+++ /dev/null
@@ -1,149 +0,0 @@
-#
-# 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 httplib
-import os
-import socket
-import sys
-import urllib
-import urlparse
-import warnings
-
-from cStringIO import StringIO
-
-from TTransport import *
-
-
-class THttpClient(TTransportBase):
-  """Http implementation of TTransport base."""
-
-  def __init__(self, uri_or_host, port=None, path=None):
-    """THttpClient supports two different types constructor parameters.
-
-    THttpClient(host, port, path) - deprecated
-    THttpClient(uri)
-
-    Only the second supports https.
-    """
-    if port is not None:
-      warnings.warn(
-        "Please use the THttpClient('http://host:port/path') syntax",
-        DeprecationWarning,
-        stacklevel=2)
-      self.host = uri_or_host
-      self.port = port
-      assert path
-      self.path = path
-      self.scheme = 'http'
-    else:
-      parsed = urlparse.urlparse(uri_or_host)
-      self.scheme = parsed.scheme
-      assert self.scheme in ('http', 'https')
-      if self.scheme == 'http':
-        self.port = parsed.port or httplib.HTTP_PORT
-      elif self.scheme == 'https':
-        self.port = parsed.port or httplib.HTTPS_PORT
-      self.host = parsed.hostname
-      self.path = parsed.path
-      if parsed.query:
-        self.path += '?%s' % parsed.query
-    self.__wbuf = StringIO()
-    self.__http = None
-    self.__timeout = None
-    self.__custom_headers = None
-
-  def open(self):
-    if self.scheme == 'http':
-      self.__http = httplib.HTTP(self.host, self.port)
-    else:
-      self.__http = httplib.HTTPS(self.host, self.port)
-
-  def close(self):
-    self.__http.close()
-    self.__http = None
-
-  def isOpen(self):
-    return self.__http is not None
-
-  def setTimeout(self, ms):
-    if not hasattr(socket, 'getdefaulttimeout'):
-      raise NotImplementedError
-
-    if ms is None:
-      self.__timeout = None
-    else:
-      self.__timeout = ms / 1000.0
-
-  def setCustomHeaders(self, headers):
-    self.__custom_headers = headers
-
-  def read(self, sz):
-    return self.__http.file.read(sz)
-
-  def write(self, buf):
-    self.__wbuf.write(buf)
-
-  def __withTimeout(f):
-    def _f(*args, **kwargs):
-      orig_timeout = socket.getdefaulttimeout()
-      socket.setdefaulttimeout(args[0].__timeout)
-      result = f(*args, **kwargs)
-      socket.setdefaulttimeout(orig_timeout)
-      return result
-    return _f
-
-  def flush(self):
-    if self.isOpen():
-      self.close()
-    self.open()
-
-    # Pull data out of buffer
-    data = self.__wbuf.getvalue()
-    self.__wbuf = StringIO()
-
-    # HTTP request
-    self.__http.putrequest('POST', self.path)
-
-    # Write headers
-    self.__http.putheader('Host', self.host)
-    self.__http.putheader('Content-Type', 'application/x-thrift')
-    self.__http.putheader('Content-Length', str(len(data)))
-
-    if not self.__custom_headers or 'User-Agent' not in self.__custom_headers:
-      user_agent = 'Python/THttpClient'
-      script = os.path.basename(sys.argv[0])
-      if script:
-        user_agent = '%s (%s)' % (user_agent, urllib.quote(script))
-      self.__http.putheader('User-Agent', user_agent)
-
-    if self.__custom_headers:
-        for key, val in self.__custom_headers.iteritems():
-            self.__http.putheader(key, val)
-
-    self.__http.endheaders()
-
-    # Write payload
-    self.__http.send(data)
-
-    # Get reply to flush the request
-    self.code, self.message, self.headers = self.__http.getreply()
-
-  # Decorate if we know how to timeout
-  if hasattr(socket, 'getdefaulttimeout'):
-    flush = __withTimeout(flush)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
deleted file mode 100644
index 81e0984..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
+++ /dev/null
@@ -1,214 +0,0 @@
-#
-# 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 os
-import socket
-import ssl
-
-from thrift.transport import TSocket
-from thrift.transport.TTransport import TTransportException
-
-
-class TSSLSocket(TSocket.TSocket):
-  """
-  SSL implementation of client-side TSocket
-
-  This class creates outbound sockets wrapped using the
-  python standard ssl module for encrypted connections.
-
-  The protocol used is set using the class variable
-  SSL_VERSION, which must be one of ssl.PROTOCOL_* and
-  defaults to  ssl.PROTOCOL_TLSv1 for greatest security.
-  """
-  SSL_VERSION = ssl.PROTOCOL_TLSv1
-
-  def __init__(self,
-               host='localhost',
-               port=9090,
-               validate=True,
-               ca_certs=None,
-               keyfile=None,
-               certfile=None,
-               unix_socket=None):
-    """Create SSL TSocket
-
-    @param validate: Set to False to disable SSL certificate validation
-    @type validate: bool
-    @param ca_certs: Filename to the Certificate Authority pem file, possibly a
-    file downloaded from: http://curl.haxx.se/ca/cacert.pem  This is passed to
-    the ssl_wrap function as the 'ca_certs' parameter.
-    @type ca_certs: str
-    @param keyfile: The private key
-    @type keyfile: str
-    @param certfile: The cert file
-    @type certfile: str
-    
-    Raises an IOError exception if validate is True and the ca_certs file is
-    None, not present or unreadable.
-    """
-    self.validate = validate
-    self.is_valid = False
-    self.peercert = None
-    if not validate:
-      self.cert_reqs = ssl.CERT_NONE
-    else:
-      self.cert_reqs = ssl.CERT_REQUIRED
-    self.ca_certs = ca_certs
-    self.keyfile = keyfile
-    self.certfile = certfile
-    if validate:
-      if ca_certs is None or not os.access(ca_certs, os.R_OK):
-        raise IOError('Certificate Authority ca_certs file "%s" '
-                      'is not readable, cannot validate SSL '
-                      'certificates.' % (ca_certs))
-    TSocket.TSocket.__init__(self, host, port, unix_socket)
-
-  def open(self):
-    try:
-      res0 = self._resolveAddr()
-      for res in res0:
-        sock_family, sock_type = res[0:2]
-        ip_port = res[4]
-        plain_sock = socket.socket(sock_family, sock_type)
-        self.handle = ssl.wrap_socket(plain_sock,
-                                      ssl_version=self.SSL_VERSION,
-                                      do_handshake_on_connect=True,
-                                      ca_certs=self.ca_certs,
-                                      keyfile=self.keyfile,
-                                      certfile=self.certfile,
-                                      cert_reqs=self.cert_reqs)
-        self.handle.settimeout(self._timeout)
-        try:
-          self.handle.connect(ip_port)
-        except socket.error, e:
-          if res is not res0[-1]:
-            continue
-          else:
-            raise e
-        break
-    except socket.error, e:
-      if self._unix_socket:
-        message = 'Could not connect to secure socket %s: %s' \
-                % (self._unix_socket, e)
-      else:
-        message = 'Could not connect to %s:%d: %s' % (self.host, self.port, e)
-      raise TTransportException(type=TTransportException.NOT_OPEN,
-                                message=message)
-    if self.validate:
-      self._validate_cert()
-
-  def _validate_cert(self):
-    """internal method to validate the peer's SSL certificate, and to check the
-    commonName of the certificate to ensure it matches the hostname we
-    used to make this connection.  Does not support subjectAltName records
-    in certificates.
-
-    raises TTransportException if the certificate fails validation.
-    """
-    cert = self.handle.getpeercert()
-    self.peercert = cert
-    if 'subject' not in cert:
-      raise TTransportException(
-        type=TTransportException.NOT_OPEN,
-        message='No SSL certificate found from %s:%s' % (self.host, self.port))
-    fields = cert['subject']
-    for field in fields:
-      # ensure structure we get back is what we expect
-      if not isinstance(field, tuple):
-        continue
-      cert_pair = field[0]
-      if len(cert_pair) < 2:
-        continue
-      cert_key, cert_value = cert_pair[0:2]
-      if cert_key != 'commonName':
-        continue
-      certhost = cert_value
-      # this check should be performed by some sort of Access Manager
-      if certhost == self.host:
-        # success, cert commonName matches desired hostname
-        self.is_valid = True
-        return
-      else:
-        raise TTransportException(
-          type=TTransportException.UNKNOWN,
-          message='Hostname we connected to "%s" doesn\'t match certificate '
-                  'provided commonName "%s"' % (self.host, certhost))
-    raise TTransportException(
-      type=TTransportException.UNKNOWN,
-      message='Could not validate SSL certificate from '
-              'host "%s".  Cert=%s' % (self.host, cert))
-
-
-class TSSLServerSocket(TSocket.TServerSocket):
-  """SSL implementation of TServerSocket
-
-  This uses the ssl module's wrap_socket() method to provide SSL
-  negotiated encryption.
-  """
-  SSL_VERSION = ssl.PROTOCOL_TLSv1
-
-  def __init__(self,
-               host=None,
-               port=9090,
-               certfile='cert.pem',
-               unix_socket=None):
-    """Initialize a TSSLServerSocket
-
-    @param certfile: filename of the server certificate, defaults to cert.pem
-    @type certfile: str
-    @param host: The hostname or IP to bind the listen socket to,
-                 i.e. 'localhost' for only allowing local network connections.
-                 Pass None to bind to all interfaces.
-    @type host: str
-    @param port: The port to listen on for inbound connections.
-    @type port: int
-    """
-    self.setCertfile(certfile)
-    TSocket.TServerSocket.__init__(self, host, port)
-
-  def setCertfile(self, certfile):
-    """Set or change the server certificate file used to wrap new connections.
-
-    @param certfile: The filename of the server certificate,
-                     i.e. '/etc/certs/server.pem'
-    @type certfile: str
-
-    Raises an IOError exception if the certfile is not present or unreadable.
-    """
-    if not os.access(certfile, os.R_OK):
-      raise IOError('No such certfile found: %s' % (certfile))
-    self.certfile = certfile
-
-  def accept(self):
-    plain_client, addr = self.handle.accept()
-    try:
-      client = ssl.wrap_socket(plain_client, certfile=self.certfile,
-                      server_side=True, ssl_version=self.SSL_VERSION)
-    except ssl.SSLError, ssl_exc:
-      # failed handshake/ssl wrap, close socket to client
-      plain_client.close()
-      # raise ssl_exc
-      # We can't raise the exception, because it kills most TServer derived
-      # serve() methods.
-      # Instead, return None, and let the TServer instance deal with it in
-      # other exception handling.  (but TSimpleServer dies anyway)
-      return None
-    result = TSocket.TSocket()
-    result.setHandle(client)
-    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
deleted file mode 100644
index 9e2b384..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
+++ /dev/null
@@ -1,176 +0,0 @@
-#
-# 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 errno
-import os
-import socket
-import sys
-
-from TTransport import *
-
-
-class TSocketBase(TTransportBase):
-  def _resolveAddr(self):
-    if self._unix_socket is not None:
-      return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None,
-               self._unix_socket)]
-    else:
-      return socket.getaddrinfo(self.host,
-                                self.port,
-                                socket.AF_UNSPEC,
-                                socket.SOCK_STREAM,
-                                0,
-                                socket.AI_PASSIVE | socket.AI_ADDRCONFIG)
-
-  def close(self):
-    if self.handle:
-      self.handle.close()
-      self.handle = None
-
-
-class TSocket(TSocketBase):
-  """Socket implementation of TTransport base."""
-
-  def __init__(self, host='localhost', port=9090, unix_socket=None):
-    """Initialize a TSocket
-
-    @param host(str)  The host to connect to.
-    @param port(int)  The (TCP) port to connect to.
-    @param unix_socket(str)  The filename of a unix socket to connect to.
-                             (host and port will be ignored.)
-    """
-    self.host = host
-    self.port = port
-    self.handle = None
-    self._unix_socket = unix_socket
-    self._timeout = None
-
-  def setHandle(self, h):
-    self.handle = h
-
-  def isOpen(self):
-    return self.handle is not None
-
-  def setTimeout(self, ms):
-    if ms is None:
-      self._timeout = None
-    else:
-      self._timeout = ms / 1000.0
-
-    if self.handle is not None:
-      self.handle.settimeout(self._timeout)
-
-  def open(self):
-    try:
-      res0 = self._resolveAddr()
-      for res in res0:
-        self.handle = socket.socket(res[0], res[1])
-        self.handle.settimeout(self._timeout)
-        try:
-          self.handle.connect(res[4])
-        except socket.error, e:
-          if res is not res0[-1]:
-            continue
-          else:
-            raise e
-        break
-    except socket.error, e:
-      if self._unix_socket:
-        message = 'Could not connect to socket %s' % self._unix_socket
-      else:
-        message = 'Could not connect to %s:%d' % (self.host, self.port)
-      raise TTransportException(type=TTransportException.NOT_OPEN,
-                                message=message)
-
-  def read(self, sz):
-    try:
-      buff = self.handle.recv(sz)
-    except socket.error, e:
-      if (e.args[0] == errno.ECONNRESET and
-          (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))):
-        # freebsd and Mach don't follow POSIX semantic of recv
-        # and fail with ECONNRESET if peer performed shutdown.
-        # See corresponding comment and code in TSocket::read()
-        # in lib/cpp/src/transport/TSocket.cpp.
-        self.close()
-        # Trigger the check to raise the END_OF_FILE exception below.
-        buff = ''
-      else:
-        raise
-    if len(buff) == 0:
-      raise TTransportException(type=TTransportException.END_OF_FILE,
-                                message='TSocket read 0 bytes')
-    return buff
-
-  def write(self, buff):
-    if not self.handle:
-      raise TTransportException(type=TTransportException.NOT_OPEN,
-                                message='Transport not open')
-    sent = 0
-    have = len(buff)
-    while sent < have:
-      plus = self.handle.send(buff)
-      if plus == 0:
-        raise TTransportException(type=TTransportException.END_OF_FILE,
-                                  message='TSocket sent 0 bytes')
-      sent += plus
-      buff = buff[plus:]
-
-  def flush(self):
-    pass
-
-
-class TServerSocket(TSocketBase, TServerTransportBase):
-  """Socket implementation of TServerTransport base."""
-
-  def __init__(self, host=None, port=9090, unix_socket=None):
-    self.host = host
-    self.port = port
-    self._unix_socket = unix_socket
-    self.handle = None
-
-  def listen(self):
-    res0 = self._resolveAddr()
-    for res in res0:
-      if res[0] is socket.AF_INET6 or res is res0[-1]:
-        break
-
-    # We need remove the old unix socket if the file exists and
-    # nobody is listening on it.
-    if self._unix_socket:
-      tmp = socket.socket(res[0], res[1])
-      try:
-        tmp.connect(res[4])
-      except socket.error, err:
-        eno, message = err.args
-        if eno == errno.ECONNREFUSED:
-          os.unlink(res[4])
-
-    self.handle = socket.socket(res[0], res[1])
-    self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-    if hasattr(self.handle, 'settimeout'):
-      self.handle.settimeout(None)
-    self.handle.bind(res[4])
-    self.handle.listen(128)
-
-  def accept(self):
-    client, addr = self.handle.accept()
-    result = TSocket()
-    result.setHandle(client)
-    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
deleted file mode 100644
index 4481371..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
+++ /dev/null
@@ -1,330 +0,0 @@
-#
-# 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
-from struct import pack, unpack
-from thrift.Thrift import TException
-
-
-class TTransportException(TException):
-  """Custom Transport Exception class"""
-
-  UNKNOWN = 0
-  NOT_OPEN = 1
-  ALREADY_OPEN = 2
-  TIMED_OUT = 3
-  END_OF_FILE = 4
-
-  def __init__(self, type=UNKNOWN, message=None):
-    TException.__init__(self, message)
-    self.type = type
-
-
-class TTransportBase:
-  """Base class for Thrift transport layer."""
-
-  def isOpen(self):
-    pass
-
-  def open(self):
-    pass
-
-  def close(self):
-    pass
-
-  def read(self, sz):
-    pass
-
-  def readAll(self, sz):
-    buff = ''
-    have = 0
-    while (have < sz):
-      chunk = self.read(sz - have)
-      have += len(chunk)
-      buff += chunk
-
-      if len(chunk) == 0:
-        raise EOFError()
-
-    return buff
-
-  def write(self, buf):
-    pass
-
-  def flush(self):
-    pass
-
-
-# This class should be thought of as an interface.
-class CReadableTransport:
-  """base class for transports that are readable from C"""
-
-  # TODO(dreiss): Think about changing this interface to allow us to use
-  #               a (Python, not c) StringIO instead, because it allows
-  #               you to write after reading.
-
-  # NOTE: This is a classic class, so properties will NOT work
-  #       correctly for setting.
-  @property
-  def cstringio_buf(self):
-    """A cStringIO buffer that contains the current chunk we are reading."""
-    pass
-
-  def cstringio_refill(self, partialread, reqlen):
-    """Refills cstringio_buf.
-
-    Returns the currently used buffer (which can but need not be the same as
-    the old cstringio_buf). partialread is what the C code has read from the
-    buffer, and should be inserted into the buffer before any more reads.  The
-    return value must be a new, not borrowed reference.  Something along the
-    lines of self._buf should be fine.
-
-    If reqlen bytes can't be read, throw EOFError.
-    """
-    pass
-
-
-class TServerTransportBase:
-  """Base class for Thrift server transports."""
-
-  def listen(self):
-    pass
-
-  def accept(self):
-    pass
-
-  def close(self):
-    pass
-
-
-class TTransportFactoryBase:
-  """Base class for a Transport Factory"""
-
-  def getTransport(self, trans):
-    return trans
-
-
-class TBufferedTransportFactory:
-  """Factory transport that builds buffered transports"""
-
-  def getTransport(self, trans):
-    buffered = TBufferedTransport(trans)
-    return buffered
-
-
-class TBufferedTransport(TTransportBase, CReadableTransport):
-  """Class that wraps another transport and buffers its I/O.
-
-  The implementation uses a (configurable) fixed-size read buffer
-  but buffers all writes until a flush is performed.
-  """
-  DEFAULT_BUFFER = 4096
-
-  def __init__(self, trans, rbuf_size=DEFAULT_BUFFER):
-    self.__trans = trans
-    self.__wbuf = StringIO()
-    self.__rbuf = StringIO("")
-    self.__rbuf_size = rbuf_size
-
-  def isOpen(self):
-    return self.__trans.isOpen()
-
-  def open(self):
-    return self.__trans.open()
-
-  def close(self):
-    return self.__trans.close()
-
-  def read(self, sz):
-    ret = self.__rbuf.read(sz)
-    if len(ret) != 0:
-      return ret
-
-    self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
-    return self.__rbuf.read(sz)
-
-  def write(self, buf):
-    self.__wbuf.write(buf)
-
-  def flush(self):
-    out = self.__wbuf.getvalue()
-    # reset wbuf before write/flush to preserve state on underlying failure
-    self.__wbuf = StringIO()
-    self.__trans.write(out)
-    self.__trans.flush()
-
-  # Implement the CReadableTransport interface.
-  @property
-  def cstringio_buf(self):
-    return self.__rbuf
-
-  def cstringio_refill(self, partialread, reqlen):
-    retstring = partialread
-    if reqlen < self.__rbuf_size:
-      # try to make a read of as much as we can.
-      retstring += self.__trans.read(self.__rbuf_size)
-
-    # but make sure we do read reqlen bytes.
-    if len(retstring) < reqlen:
-      retstring += self.__trans.readAll(reqlen - len(retstring))
-
-    self.__rbuf = StringIO(retstring)
-    return self.__rbuf
-
-
-class TMemoryBuffer(TTransportBase, CReadableTransport):
-  """Wraps a cStringIO object as a TTransport.
-
-  NOTE: Unlike the C++ version of this class, you cannot write to it
-        then immediately read from it.  If you want to read from a
-        TMemoryBuffer, you must either pass a string to the constructor.
-  TODO(dreiss): Make this work like the C++ version.
-  """
-
-  def __init__(self, value=None):
-    """value -- a value to read from for stringio
-
-    If value is set, this will be a transport for reading,
-    otherwise, it is for writing"""
-    if value is not None:
-      self._buffer = StringIO(value)
-    else:
-      self._buffer = StringIO()
-
-  def isOpen(self):
-    return not self._buffer.closed
-
-  def open(self):
-    pass
-
-  def close(self):
-    self._buffer.close()
-
-  def read(self, sz):
-    return self._buffer.read(sz)
-
-  def write(self, buf):
-    self._buffer.write(buf)
-
-  def flush(self):
-    pass
-
-  def getvalue(self):
-    return self._buffer.getvalue()
-
-  # Implement the CReadableTransport interface.
-  @property
-  def cstringio_buf(self):
-    return self._buffer
-
-  def cstringio_refill(self, partialread, reqlen):
-    # only one shot at reading...
-    raise EOFError()
-
-
-class TFramedTransportFactory:
-  """Factory transport that builds framed transports"""
-
-  def getTransport(self, trans):
-    framed = TFramedTransport(trans)
-    return framed
-
-
-class TFramedTransport(TTransportBase, CReadableTransport):
-  """Class that wraps another transport and frames its I/O when writing."""
-
-  def __init__(self, trans,):
-    self.__trans = trans
-    self.__rbuf = StringIO()
-    self.__wbuf = StringIO()
-
-  def isOpen(self):
-    return self.__trans.isOpen()
-
-  def open(self):
-    return self.__trans.open()
-
-  def close(self):
-    return self.__trans.close()
-
-  def read(self, sz):
-    ret = self.__rbuf.read(sz)
-    if len(ret) != 0:
-      return ret
-
-    self.readFrame()
-    return self.__rbuf.read(sz)
-
-  def readFrame(self):
-    buff = self.__trans.readAll(4)
-    sz, = unpack('!i', buff)
-    self.__rbuf = StringIO(self.__trans.readAll(sz))
-
-  def write(self, buf):
-    self.__wbuf.write(buf)
-
-  def flush(self):
-    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 = pack("!i", wsz) + wout
-    self.__trans.write(buf)
-    self.__trans.flush()
-
-  # Implement the CReadableTransport interface.
-  @property
-  def cstringio_buf(self):
-    return self.__rbuf
-
-  def cstringio_refill(self, prefix, reqlen):
-    # self.__rbuf will already be empty here because fastbinary doesn't
-    # ask for a refill until the previous buffer is empty.  Therefore,
-    # we can start reading new frames immediately.
-    while len(prefix) < reqlen:
-      self.readFrame()
-      prefix += self.__rbuf.getvalue()
-    self.__rbuf = StringIO(prefix)
-    return self.__rbuf
-
-
-class TFileObjectTransport(TTransportBase):
-  """Wraps a file-like object to make it work as a Thrift transport."""
-
-  def __init__(self, fileobj):
-    self.fileobj = fileobj
-
-  def isOpen(self):
-    return True
-
-  def close(self):
-    self.fileobj.close()
-
-  def read(self, sz):
-    return self.fileobj.read(sz)
-
-  def write(self, buf):
-    self.fileobj.write(buf)
-
-  def flush(self):
-    self.fileobj.flush()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
deleted file mode 100644
index 3ce3eb2..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
+++ /dev/null
@@ -1,221 +0,0 @@
-#
-# 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
-
-from zope.interface import implements, Interface, Attribute
-from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \
-    connectionDone
-from twisted.internet import defer
-from twisted.protocols import basic
-from twisted.python import log
-from twisted.web import server, resource, http
-
-from thrift.transport import TTransport
-
-
-class TMessageSenderTransport(TTransport.TTransportBase):
-
-    def __init__(self):
-        self.__wbuf = StringIO()
-
-    def write(self, buf):
-        self.__wbuf.write(buf)
-
-    def flush(self):
-        msg = self.__wbuf.getvalue()
-        self.__wbuf = StringIO()
-        self.sendMessage(msg)
-
-    def sendMessage(self, message):
-        raise NotImplementedError
-
-
-class TCallbackTransport(TMessageSenderTransport):
-
-    def __init__(self, func):
-        TMessageSenderTransport.__init__(self)
-        self.func = func
-
-    def sendMessage(self, message):
-        self.func(message)
-
-
-class ThriftClientProtocol(basic.Int32StringReceiver):
-
-    MAX_LENGTH = 2 ** 31 - 1
-
-    def __init__(self, client_class, iprot_factory, oprot_factory=None):
-        self._client_class = client_class
-        self._iprot_factory = iprot_factory
-        if oprot_factory is None:
-            self._oprot_factory = iprot_factory
-        else:
-            self._oprot_factory = oprot_factory
-
-        self.recv_map = {}
-        self.started = defer.Deferred()
-
-    def dispatch(self, msg):
-        self.sendString(msg)
-
-    def connectionMade(self):
-        tmo = TCallbackTransport(self.dispatch)
-        self.client = self._client_class(tmo, self._oprot_factory)
-        self.started.callback(self.client)
-
-    def connectionLost(self, reason=connectionDone):
-        for k, v in self.client._reqs.iteritems():
-            tex = TTransport.TTransportException(
-                type=TTransport.TTransportException.END_OF_FILE,
-                message='Connection closed')
-            v.errback(tex)
-
-    def stringReceived(self, frame):
-        tr = TTransport.TMemoryBuffer(frame)
-        iprot = self._iprot_factory.getProtocol(tr)
-        (fname, mtype, rseqid) = iprot.readMessageBegin()
-
-        try:
-            method = self.recv_map[fname]
-        except KeyError:
-            method = getattr(self.client, 'recv_' + fname)
-            self.recv_map[fname] = method
-
-        method(iprot, mtype, rseqid)
-
-
-class ThriftServerProtocol(basic.Int32StringReceiver):
-
-    MAX_LENGTH = 2 ** 31 - 1
-
-    def dispatch(self, msg):
-        self.sendString(msg)
-
-    def processError(self, error):
-        self.transport.loseConnection()
-
-    def processOk(self, _, tmo):
-        msg = tmo.getvalue()
-
-        if len(msg) > 0:
-            self.dispatch(msg)
-
-    def stringReceived(self, frame):
-        tmi = TTransport.TMemoryBuffer(frame)
-        tmo = TTransport.TMemoryBuffer()
-
-        iprot = self.factory.iprot_factory.getProtocol(tmi)
-        oprot = self.factory.oprot_factory.getProtocol(tmo)
-
-        d = self.factory.processor.process(iprot, oprot)
-        d.addCallbacks(self.processOk, self.processError,
-            callbackArgs=(tmo,))
-
-
-class IThriftServerFactory(Interface):
-
-    processor = Attribute("Thrift processor")
-
-    iprot_factory = Attribute("Input protocol factory")
-
-    oprot_factory = Attribute("Output protocol factory")
-
-
-class IThriftClientFactory(Interface):
-
-    client_class = Attribute("Thrift client class")
-
-    iprot_factory = Attribute("Input protocol factory")
-
-    oprot_factory = Attribute("Output protocol factory")
-
-
-class ThriftServerFactory(ServerFactory):
-
-    implements(IThriftServerFactory)
-
-    protocol = ThriftServerProtocol
-
-    def __init__(self, processor, iprot_factory, oprot_factory=None):
-        self.processor = processor
-        self.iprot_factory = iprot_factory
-        if oprot_factory is None:
-            self.oprot_factory = iprot_factory
-        else:
-            self.oprot_factory = oprot_factory
-
-
-class ThriftClientFactory(ClientFactory):
-
-    implements(IThriftClientFactory)
-
-    protocol = ThriftClientProtocol
-
-    def __init__(self, client_class, iprot_factory, oprot_factory=None):
-        self.client_class = client_class
-        self.iprot_factory = iprot_factory
-        if oprot_factory is None:
-            self.oprot_factory = iprot_factory
-        else:
-            self.oprot_factory = oprot_factory
-
-    def buildProtocol(self, addr):
-        p = self.protocol(self.client_class, self.iprot_factory,
-            self.oprot_factory)
-        p.factory = self
-        return p
-
-
-class ThriftResource(resource.Resource):
-
-    allowedMethods = ('POST',)
-
-    def __init__(self, processor, inputProtocolFactory,
-        outputProtocolFactory=None):
-        resource.Resource.__init__(self)
-        self.inputProtocolFactory = inputProtocolFactory
-        if outputProtocolFactory is None:
-            self.outputProtocolFactory = inputProtocolFactory
-        else:
-            self.outputProtocolFactory = outputProtocolFactory
-        self.processor = processor
-
-    def getChild(self, path, request):
-        return self
-
-    def _cbProcess(self, _, request, tmo):
-        msg = tmo.getvalue()
-        request.setResponseCode(http.OK)
-        request.setHeader("content-type", "application/x-thrift")
-        request.write(msg)
-        request.finish()
-
-    def render_POST(self, request):
-        request.content.seek(0, 0)
-        data = request.content.read()
-        tmi = TTransport.TMemoryBuffer(data)
-        tmo = TTransport.TMemoryBuffer()
-
-        iprot = self.inputProtocolFactory.getProtocol(tmi)
-        oprot = self.outputProtocolFactory.getProtocol(tmo)
-
-        d = self.processor.process(iprot, oprot)
-        d.addCallback(self._cbProcess, request, tmo)
-        return server.NOT_DONE_YET

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
deleted file mode 100644
index a2f42a5..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
+++ /dev/null
@@ -1,248 +0,0 @@
-#
-# 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.
-#
-
-"""TZlibTransport provides a compressed transport and transport factory
-class, using the python standard library zlib module to implement
-data compression.
-"""
-
-from __future__ import division
-import zlib
-from cStringIO import StringIO
-from TTransport import TTransportBase, CReadableTransport
-
-
-class TZlibTransportFactory(object):
-  """Factory transport that builds zlib compressed transports.
-
-  This factory caches the last single client/transport that it was passed
-  and returns the same TZlibTransport object that was created.
-
-  This caching means the TServer class will get the _same_ transport
-  object for both input and output transports from this factory.
-  (For non-threaded scenarios only, since the cache only holds one object)
-
-  The purpose of this caching is to allocate only one TZlibTransport where
-  only one is really needed (since it must have separate read/write buffers),
-  and makes the statistics from getCompSavings() and getCompRatio()
-  easier to understand.
-  """
-  # class scoped cache of last transport given and zlibtransport returned
-  _last_trans = None
-  _last_z = None
-
-  def getTransport(self, trans, compresslevel=9):
-    """Wrap a transport, trans, with the TZlibTransport
-    compressed transport class, returning a new
-    transport to the caller.
-
-    @param compresslevel: The zlib compression level, ranging
-    from 0 (no compression) to 9 (best compression).  Defaults to 9.
-    @type compresslevel: int
-
-    This method returns a TZlibTransport which wraps the
-    passed C{trans} TTransport derived instance.
-    """
-    if trans == self._last_trans:
-      return self._last_z
-    ztrans = TZlibTransport(trans, compresslevel)
-    self._last_trans = trans
-    self._last_z = ztrans
-    return ztrans
-
-
-class TZlibTransport(TTransportBase, CReadableTransport):
-  """Class that wraps a transport with zlib, compressing writes
-  and decompresses reads, using the python standard
-  library zlib module.
-  """
-  # Read buffer size for the python fastbinary C extension,
-  # the TBinaryProtocolAccelerated class.
-  DEFAULT_BUFFSIZE = 4096
-
-  def __init__(self, trans, compresslevel=9):
-    """Create a new TZlibTransport, wrapping C{trans}, another
-    TTransport derived object.
-
-    @param trans: A thrift transport object, i.e. a TSocket() object.
-    @type trans: TTransport
-    @param compresslevel: The zlib compression level, ranging
-    from 0 (no compression) to 9 (best compression).  Default is 9.
-    @type compresslevel: int
-    """
-    self.__trans = trans
-    self.compresslevel = compresslevel
-    self.__rbuf = StringIO()
-    self.__wbuf = StringIO()
-    self._init_zlib()
-    self._init_stats()
-
-  def _reinit_buffers(self):
-    """Internal method to initialize/reset the internal StringIO objects
-    for read and write buffers.
-    """
-    self.__rbuf = StringIO()
-    self.__wbuf = StringIO()
-
-  def _init_stats(self):
-    """Internal method to reset the internal statistics counters
-    for compression ratios and bandwidth savings.
-    """
-    self.bytes_in = 0
-    self.bytes_out = 0
-    self.bytes_in_comp = 0
-    self.bytes_out_comp = 0
-
-  def _init_zlib(self):
-    """Internal method for setting up the zlib compression and
-    decompression objects.
-    """
-    self._zcomp_read = zlib.decompressobj()
-    self._zcomp_write = zlib.compressobj(self.compresslevel)
-
-  def getCompRatio(self):
-    """Get the current measured compression ratios (in,out) from
-    this transport.
-
-    Returns a tuple of:
-    (inbound_compression_ratio, outbound_compression_ratio)
-
-    The compression ratios are computed as:
-        compressed / uncompressed
-
-    E.g., data that compresses by 10x will have a ratio of: 0.10
-    and data that compresses to half of ts original size will
-    have a ratio of 0.5
-
-    None is returned if no bytes have yet been processed in
-    a particular direction.
-    """
-    r_percent, w_percent = (None, None)
-    if self.bytes_in > 0:
-      r_percent = self.bytes_in_comp / self.bytes_in
-    if self.bytes_out > 0:
-      w_percent = self.bytes_out_comp / self.bytes_out
-    return (r_percent, w_percent)
-
-  def getCompSavings(self):
-    """Get the current count of saved bytes due to data
-    compression.
-
-    Returns a tuple of:
-    (inbound_saved_bytes, outbound_saved_bytes)
-
-    Note: if compression is actually expanding your
-    data (only likely with very tiny thrift objects), then
-    the values returned will be negative.
-    """
-    r_saved = self.bytes_in - self.bytes_in_comp
-    w_saved = self.bytes_out - self.bytes_out_comp
-    return (r_saved, w_saved)
-
-  def isOpen(self):
-    """Return the underlying transport's open status"""
-    return self.__trans.isOpen()
-
-  def open(self):
-    """Open the underlying transport"""
-    self._init_stats()
-    return self.__trans.open()
-
-  def listen(self):
-    """Invoke the underlying transport's listen() method"""
-    self.__trans.listen()
-
-  def accept(self):
-    """Accept connections on the underlying transport"""
-    return self.__trans.accept()
-
-  def close(self):
-    """Close the underlying transport,"""
-    self._reinit_buffers()
-    self._init_zlib()
-    return self.__trans.close()
-
-  def read(self, sz):
-    """Read up to sz bytes from the decompressed bytes buffer, and
-    read from the underlying transport if the decompression
-    buffer is empty.
-    """
-    ret = self.__rbuf.read(sz)
-    if len(ret) > 0:
-      return ret
-    # keep reading from transport until something comes back
-    while True:
-      if self.readComp(sz):
-        break
-    ret = self.__rbuf.read(sz)
-    return ret
-
-  def readComp(self, sz):
-    """Read compressed data from the underlying transport, then
-    decompress it and append it to the internal StringIO read buffer
-    """
-    zbuf = self.__trans.read(sz)
-    zbuf = self._zcomp_read.unconsumed_tail + zbuf
-    buf = self._zcomp_read.decompress(zbuf)
-    self.bytes_in += len(zbuf)
-    self.bytes_in_comp += len(buf)
-    old = self.__rbuf.read()
-    self.__rbuf = StringIO(old + buf)
-    if len(old) + len(buf) == 0:
-      return False
-    return True
-
-  def write(self, buf):
-    """Write some bytes, putting them into the internal write
-    buffer for eventual compression.
-    """
-    self.__wbuf.write(buf)
-
-  def flush(self):
-    """Flush any queued up data in the write buffer and ensure the
-    compression buffer is flushed out to the underlying transport
-    """
-    wout = self.__wbuf.getvalue()
-    if len(wout) > 0:
-      zbuf = self._zcomp_write.compress(wout)
-      self.bytes_out += len(wout)
-      self.bytes_out_comp += len(zbuf)
-    else:
-      zbuf = ''
-    ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH)
-    self.bytes_out_comp += len(ztail)
-    if (len(zbuf) + len(ztail)) > 0:
-      self.__wbuf = StringIO()
-      self.__trans.write(zbuf + ztail)
-    self.__trans.flush()
-
-  @property
-  def cstringio_buf(self):
-    """Implement the CReadableTransport interface"""
-    return self.__rbuf
-
-  def cstringio_refill(self, partialread, reqlen):
-    """Implement the CReadableTransport interface for refill"""
-    retstring = partialread
-    if reqlen < self.DEFAULT_BUFFSIZE:
-      retstring += self.read(self.DEFAULT_BUFFSIZE)
-    while len(retstring) < reqlen:
-      retstring += self.read(reqlen - len(retstring))
-    self.__rbuf = StringIO(retstring)
-    return self.__rbuf

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py
deleted file mode 100644
index c9596d9..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# 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__ = ['TTransport', 'TSocket', 'THttpClient', 'TZlibTransport']


[50/50] [abbrv] git commit: Merge remote-tracking branch 'upstream/master'

Posted by ni...@apache.org.
Merge remote-tracking branch 'upstream/master'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/882e92a8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/882e92a8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/882e92a8

Branch: refs/heads/master
Commit: 882e92a86979655fb6008119a78b91b0cdac4ead
Parents: 5408bb7 5d24241
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sun Oct 12 00:04:35 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sun Oct 12 00:04:35 2014 +0530

----------------------------------------------------------------------
 .../apache/stratos/rest/endpoint/services/ServiceUtils.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[35/50] [abbrv] git commit: Fixed issues found when testing with Docker container

Posted by ni...@apache.org.
Fixed issues found when testing with Docker container


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/191c4c14
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/191c4c14
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/191c4c14

Branch: refs/heads/master
Commit: 191c4c1472363f18ef504abbf603619518d26aa7
Parents: b061371
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 20:13:08 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Fri Oct 10 20:13:08 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.conf                     |  2 +-
 .../cartridge-agent/logging.ini                    |  2 +-
 .../modules/config/cartridgeagentconfiguration.py  | 17 ++++++++++++-----
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/191c4c14/tools/python-cartridge-agent/cartridge-agent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.conf b/tools/python-cartridge-agent/cartridge-agent/agent.conf
index cb7c686..1bb65d8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.conf
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.conf
@@ -38,7 +38,7 @@ monitoring.server.secure.port         =MONITORING-SERVER-SECURE-PORT
 monitoring.server.admin.username      =MONITORING-SERVER-ADMIN-USERNAME
 monitoring.server.admin.password      =MONITORING-SERVER-ADMIN-PASSWORD
 log.file.paths                        =LOG_FILE_PATHS
-APP_PATH                              =APP_PATH
+APP_PATH                              =APP-PATH
 super.tenant.repository.path          =/repository/deployment/server/
 tenant.repository.path                =/repository/tenants/
 extension.instance.started            =instance-started.sh

http://git-wip-us.apache.org/repos/asf/stratos/blob/191c4c14/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
index 2bd3ab4..3e49a96 100644
--- a/tools/python-cartridge-agent/cartridge-agent/logging.ini
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -33,7 +33,7 @@ args=tuple()
 
 [handler_log_file]
 class=logging.FileHandler
-level=INFO
+level=LOG_LEVEL
 formatter=default
 args=("agent.log", "w")
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/191c4c14/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index f3376cf..95c4169 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -114,7 +114,7 @@ class CartridgeAgentConfiguration:
                 self.cluster_id = self.read_property(cartridgeagentconstants.CLUSTER_ID)
                 self.network_partition_id = self.read_property(cartridgeagentconstants.NETWORK_PARTITION_ID)
                 self.partition_id = self.read_property(cartridgeagentconstants.PARTITION_ID)
-                self.member_id = self.get_member_id(cartridgeagentconstants.MEMBER_ID, self.cluster_id)
+                self.member_id = self.get_member_id(cartridgeagentconstants.MEMBER_ID)
                 self.cartridge_key = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
                 self.app_path = self.read_property(cartridgeagentconstants.APP_PATH)
                 self.repo_url = self.read_property(cartridgeagentconstants.REPO_URL)
@@ -122,12 +122,12 @@ class CartridgeAgentConfiguration:
 
                 try:
                     self.log_file_paths = str(
-                        self.read_property(cartridgeagentconstants.CLUSTER_ID)).strip().split("|")
+                        self.read_property(cartridgeagentconstants.LOG_FILE_PATHS)).strip().split("|")
                 except ParameterNotFoundException as ex:
                     self.log.debug("Cannot read log file path : %r" % ex.get_message())
                     self.log_file_paths = None
 
-                is_multi_str = self.read_property(cartridgeagentconstants.CLUSTER_ID)
+                is_multi_str = self.read_property(cartridgeagentconstants.MULTITENANT)
                 self.is_multitenant = True if str(is_multi_str).lower().strip() == "true" else False
 
                 try:
@@ -270,6 +270,7 @@ class CartridgeAgentConfiguration:
             """
 
             param_file = self.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
+            self.log.debug("Param file path : %r" % param_file)
 
             try:
                 if param_file is not None:
@@ -302,12 +303,18 @@ class CartridgeAgentConfiguration:
                 self.log.debug("Has key: %r" % property_key)
                 temp_str = self.properties.get("agent", property_key)
                 if temp_str != "" and temp_str is not None:
-                    return str(temp_str).strip()
+                    if str(temp_str).strip().lower() == "null":
+                        return ""
+                    else:
+                        return str(temp_str).strip()
 
             if property_key in self.payload_params:
                 temp_str = self.payload_params[property_key]
                 if temp_str != "" and temp_str is not None:
-                    return str(temp_str).strip()
+                    if str(temp_str).strip().lower() == "null":
+                        return ""
+                    else:
+                        return str(temp_str).strip()
 
             if critical:
                 raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)


[25/50] [abbrv] Fixed path issues in thrift python client

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService.py
new file mode 100644
index 0000000..4a5a252
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService.py
@@ -0,0 +1,1143 @@
+#
+# 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
+
+try:
+  from ...thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class Iface:
+  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 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["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_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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
+      result.ade = ade
+    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
+      result.mtd = mtd
+    except Exception.ttypes.ThriftStreamDefinitionException, tde:
+      result.tde = tde
+    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
+      result.tnde = tnde
+    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
+      result.ue = ue
+    except Exception.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 Exception.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 Exception.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 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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
+    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
+    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
+          self.ade.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
+          self.mtd.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
+          self.tde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
+          self.tnde.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
+    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
+          self.ue.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRUCT:
+          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/__init__.py
new file mode 100644
index 0000000..38575a6
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..37ac241
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
new file mode 100755
index 0000000..46757bf
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from ThriftSecureEventTransmissionService.ttypes import *
+
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string connect(string userName, string password)'
+  print '  void disconnect(string sessionId)'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftSecureEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'connect':
+  if len(args) != 2:
+    print 'connect requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.connect(args[0],args[1],))
+
+elif cmd == 'disconnect':
+  if len(args) != 1:
+    print 'disconnect requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.disconnect(args[0],))
+
+elif cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()


[32/50] [abbrv] git commit: Removed unnecessary configuration fields in agent.conf Added placeholder values in the agent.conf and logging.ini

Posted by ni...@apache.org.
Removed unnecessary configuration fields in agent.conf
Added placeholder values in the agent.conf and logging.ini


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/19f9227f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/19f9227f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/19f9227f

Branch: refs/heads/master
Commit: 19f9227f7b5905261586985c195d97f222716ca3
Parents: 8200385
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 12:55:48 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Fri Oct 10 12:55:48 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.conf                  | 25 +++++++++-----------
 .../cartridge-agent/logging.ini                 |  2 +-
 .../modules/util/cartridgeagentconstants.py     |  1 -
 3 files changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/19f9227f/tools/python-cartridge-agent/cartridge-agent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.conf b/tools/python-cartridge-agent/cartridge-agent/agent.conf
index 57e9992..cb7c686 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.conf
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.conf
@@ -18,22 +18,19 @@
 [agent]
 mb.ip                                 =MB-IP
 mb.port                               =MB-PORT
-listen.address                        =localhost
+listen.address                        =LISTEN_ADDR
 thrift.receiver.ip                    =CEP-IP
 thrift.receiver.port                  =CEP-PORT
-agent.root                            =
-param.file.path                       =/tmp/payload/launch-params
-extensions.dir                        =/extensions
-cep.stats.publisher.enabled           =true
-lb.private.ip                         =
-lb.public.ip                          =
-javax.net.ssl.trustStore              =CERT-TRUSTSTORE
-javax.net.ssl.trustStorePassword      =TRUSTSTORE-PASSWORD
-enable.artifact.update                =true
-auto.commit                           =false
-auto.checkout                         =true
-artifact.update.interval              =15
-port.check.timeout                    =600
+param.file.path                       =/mnt/cartridge-agent/payload/launch-params
+extensions.dir                        =/mnt/cartridge-agent/extensions
+cep.stats.publisher.enabled           =ENABLE_HEALTH_PUBLISHER
+lb.private.ip                         =LB_PRIVATE_IP
+lb.public.ip                          =LB_PUBLIC_IP
+enable.artifact.update                =ENABLE_ARTFCT_UPDATE
+auto.commit                           =COMMIT_ENABLED
+auto.checkout                         =CHECKOUT_ENABLED
+artifact.update.interval              =ARTFCT_UPDATE_INT
+port.check.timeout                    =PORT_CHECK_TIMEOUT
 enable.data.publisher                 =ENABLE-DATA-PUBLISHER
 monitoring.server.ip                  =MONITORING-SERVER-IP
 monitoring.server.port                =MONITORING-SERVER-PORT

http://git-wip-us.apache.org/repos/asf/stratos/blob/19f9227f/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
index f1869f6..2bd3ab4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/logging.ini
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -47,6 +47,6 @@ args=("error.log", "w")
 keys=root
 
 [logger_root]
-level=DEBUG
+level=LOG_LEVEL
 formatter=default
 handlers=console,error_file,log_file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/19f9227f/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
index eb94f79..70afb30 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-JNDI_PROPERTIES_DIR = "jndi.properties.dir"
 PARAM_FILE_PATH = "param.file.path"
 EXTENSIONS_DIR = "extensions.dir"
 


[26/50] [abbrv] Fixed path issues in thrift python client

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
deleted file mode 100644
index 560ea38..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
+++ /dev/null
@@ -1,1493 +0,0 @@
-#
-# 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
-
-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 Exception.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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
-      result.ade = ade
-    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
-      result.mtd = mtd
-    except Exception.ttypes.ThriftStreamDefinitionException, tde:
-      result.tde = tde
-    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
-      result.tnde = tnde
-    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
-      result.ue = ue
-    except Exception.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 Exception.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 Exception.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', (Exception.ttypes.ThriftAuthenticationException, Exception.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 = Exception.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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
-    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
-    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
-          self.ade.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
-          self.mtd.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.STRUCT:
-          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
-          self.tde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
-          self.tnde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
-          self.ue.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
deleted file mode 100644
index c321ae1..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py
deleted file mode 100644
index 36943ba..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/constants.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# 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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py
deleted file mode 100644
index a0727f8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/ThriftSecureEventTransmissionService/ttypes.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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
-import Data.ttypes
-import Exception.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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen-py/__init__.py
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/ttypes.py
new file mode 100644
index 0000000..d76afca
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Data/ttypes.py
@@ -0,0 +1,320 @@
+#
+# 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 ...thrift.transport import TTransport
+from ...thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from ...thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+class ThriftAttributeType:
+  INT = 0
+  LONG = 1
+  FLOAT = 2
+  DOUBLE = 3
+  BOOL = 4
+  STRING = 5
+
+  _VALUES_TO_NAMES = {
+    0: "INT",
+    1: "LONG",
+    2: "FLOAT",
+    3: "DOUBLE",
+    4: "BOOL",
+    5: "STRING",
+  }
+
+  _NAMES_TO_VALUES = {
+    "INT": 0,
+    "LONG": 1,
+    "FLOAT": 2,
+    "DOUBLE": 3,
+    "BOOL": 4,
+    "STRING": 5,
+  }
+
+
+class ThriftAttribute:
+  """
+  Attributes:
+   - name
+   - attributeType
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'name', None, None, ), # 1
+    (2, TType.I32, 'attributeType', None, None, ), # 2
+  )
+
+  def __init__(self, name=None, attributeType=None,):
+    self.name = name
+    self.attributeType = attributeType
+
+  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.name = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.I32:
+          self.attributeType = iprot.readI32();
+        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('ThriftAttribute')
+    if self.name is not None:
+      oprot.writeFieldBegin('name', TType.STRING, 1)
+      oprot.writeString(self.name)
+      oprot.writeFieldEnd()
+    if self.attributeType is not None:
+      oprot.writeFieldBegin('attributeType', TType.I32, 2)
+      oprot.writeI32(self.attributeType)
+      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 ThriftEventBundle:
+  """
+  Attributes:
+   - sessionId
+   - eventNum
+   - intAttributeList
+   - longAttributeList
+   - doubleAttributeList
+   - boolAttributeList
+   - stringAttributeList
+   - arbitraryDataMapMap
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'sessionId', None, None, ), # 1
+    (2, TType.I32, 'eventNum', None, None, ), # 2
+    (3, TType.LIST, 'intAttributeList', (TType.I32,None), None, ), # 3
+    (4, TType.LIST, 'longAttributeList', (TType.I64,None), None, ), # 4
+    (5, TType.LIST, 'doubleAttributeList', (TType.DOUBLE,None), None, ), # 5
+    (6, TType.LIST, 'boolAttributeList', (TType.BOOL,None), None, ), # 6
+    (7, TType.LIST, 'stringAttributeList', (TType.STRING,None), None, ), # 7
+    (8, TType.MAP, 'arbitraryDataMapMap', (TType.I32,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 8
+  )
+
+  def __init__(self, sessionId=None, eventNum=None, intAttributeList=None, longAttributeList=None, doubleAttributeList=None, boolAttributeList=None, stringAttributeList=None, arbitraryDataMapMap=None,):
+    self.sessionId = sessionId
+    self.eventNum = eventNum
+    self.intAttributeList = intAttributeList
+    self.longAttributeList = longAttributeList
+    self.doubleAttributeList = doubleAttributeList
+    self.boolAttributeList = boolAttributeList
+    self.stringAttributeList = stringAttributeList
+    self.arbitraryDataMapMap = arbitraryDataMapMap
+
+  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.I32:
+          self.eventNum = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.LIST:
+          self.intAttributeList = []
+          (_etype3, _size0) = iprot.readListBegin()
+          for _i4 in xrange(_size0):
+            _elem5 = iprot.readI32();
+            self.intAttributeList.append(_elem5)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.LIST:
+          self.longAttributeList = []
+          (_etype9, _size6) = iprot.readListBegin()
+          for _i10 in xrange(_size6):
+            _elem11 = iprot.readI64();
+            self.longAttributeList.append(_elem11)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.LIST:
+          self.doubleAttributeList = []
+          (_etype15, _size12) = iprot.readListBegin()
+          for _i16 in xrange(_size12):
+            _elem17 = iprot.readDouble();
+            self.doubleAttributeList.append(_elem17)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TType.LIST:
+          self.boolAttributeList = []
+          (_etype21, _size18) = iprot.readListBegin()
+          for _i22 in xrange(_size18):
+            _elem23 = iprot.readBool();
+            self.boolAttributeList.append(_elem23)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TType.LIST:
+          self.stringAttributeList = []
+          (_etype27, _size24) = iprot.readListBegin()
+          for _i28 in xrange(_size24):
+            _elem29 = iprot.readString();
+            self.stringAttributeList.append(_elem29)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 8:
+        if ftype == TType.MAP:
+          self.arbitraryDataMapMap = {}
+          (_ktype31, _vtype32, _size30 ) = iprot.readMapBegin()
+          for _i34 in xrange(_size30):
+            _key35 = iprot.readI32();
+            _val36 = {}
+            (_ktype38, _vtype39, _size37 ) = iprot.readMapBegin()
+            for _i41 in xrange(_size37):
+              _key42 = iprot.readString();
+              _val43 = iprot.readString();
+              _val36[_key42] = _val43
+            iprot.readMapEnd()
+            self.arbitraryDataMapMap[_key35] = _val36
+          iprot.readMapEnd()
+        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('ThriftEventBundle')
+    if self.sessionId is not None:
+      oprot.writeFieldBegin('sessionId', TType.STRING, 1)
+      oprot.writeString(self.sessionId)
+      oprot.writeFieldEnd()
+    if self.eventNum is not None:
+      oprot.writeFieldBegin('eventNum', TType.I32, 2)
+      oprot.writeI32(self.eventNum)
+      oprot.writeFieldEnd()
+    if self.intAttributeList is not None:
+      oprot.writeFieldBegin('intAttributeList', TType.LIST, 3)
+      oprot.writeListBegin(TType.I32, len(self.intAttributeList))
+      for iter44 in self.intAttributeList:
+        oprot.writeI32(iter44)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.longAttributeList is not None:
+      oprot.writeFieldBegin('longAttributeList', TType.LIST, 4)
+      oprot.writeListBegin(TType.I64, len(self.longAttributeList))
+      for iter45 in self.longAttributeList:
+        oprot.writeI64(iter45)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.doubleAttributeList is not None:
+      oprot.writeFieldBegin('doubleAttributeList', TType.LIST, 5)
+      oprot.writeListBegin(TType.DOUBLE, len(self.doubleAttributeList))
+      for iter46 in self.doubleAttributeList:
+        oprot.writeDouble(iter46)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.boolAttributeList is not None:
+      oprot.writeFieldBegin('boolAttributeList', TType.LIST, 6)
+      oprot.writeListBegin(TType.BOOL, len(self.boolAttributeList))
+      for iter47 in self.boolAttributeList:
+        oprot.writeBool(iter47)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.stringAttributeList is not None:
+      oprot.writeFieldBegin('stringAttributeList', TType.LIST, 7)
+      oprot.writeListBegin(TType.STRING, len(self.stringAttributeList))
+      for iter48 in self.stringAttributeList:
+        oprot.writeString(iter48)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.arbitraryDataMapMap is not None:
+      oprot.writeFieldBegin('arbitraryDataMapMap', TType.MAP, 8)
+      oprot.writeMapBegin(TType.I32, TType.MAP, len(self.arbitraryDataMapMap))
+      for kiter49,viter50 in self.arbitraryDataMapMap.items():
+        oprot.writeI32(kiter49)
+        oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter50))
+        for kiter51,viter52 in viter50.items():
+          oprot.writeString(kiter51)
+          oprot.writeString(viter52)
+        oprot.writeMapEnd()
+      oprot.writeMapEnd()
+      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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/__init__.py
new file mode 100644
index 0000000..adefd8e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/ttypes.py
new file mode 100644
index 0000000..9fbb1ce
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/Exception/ttypes.py
@@ -0,0 +1,473 @@
+#
+# 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 ...thrift.transport import TTransport
+from ...thrift.protocol import TBinaryProtocol, TProtocol
+try:
+  from ...thrift.protocol import fastbinary
+except:
+  fastbinary = None
+
+
+
+class ThriftStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftNoStreamDefinitionExistException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftNoStreamDefinitionExistException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftDifferentStreamDefinitionAlreadyDefinedException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftDifferentStreamDefinitionAlreadyDefinedException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftMalformedStreamDefinitionException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftMalformedStreamDefinitionException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftUndefinedEventTypeException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftUndefinedEventTypeException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftSessionExpiredException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftSessionExpiredException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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 ThriftAuthenticationException(TException):
+  """
+  Attributes:
+   - message
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'message', None, None, ), # 1
+  )
+
+  def __init__(self, message=None,):
+    self.message = message
+
+  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.message = 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('ThriftAuthenticationException')
+    if self.message is not None:
+      oprot.writeFieldBegin('message', TType.STRING, 1)
+      oprot.writeString(self.message)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.message is None:
+      raise TProtocol.TProtocolException(message='Required field message is unset!')
+    return
+
+
+  def __str__(self):
+    return repr(self)
+
+  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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
new file mode 100755
index 0000000..0d18f58
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.1)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+#  options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+from ThriftEventTransmissionService import ThriftEventTransmissionService
+from ThriftEventTransmissionService.ttypes import *
+
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+  print ''
+  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+  print ''
+  print 'Functions:'
+  print '  string defineStream(string sessionId, string streamDefinition)'
+  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
+  print '  void publish(ThriftEventBundle eventBundle)'
+  print '  bool deleteStreamById(string sessionId, string streamId)'
+  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
+  print ''
+  sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+  parts = sys.argv[argi+1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  argi += 2
+
+if sys.argv[argi] == '-u':
+  url = urlparse(sys.argv[argi+1])
+  parts = url[1].split(':')
+  host = parts[0]
+  if len(parts) > 1:
+    port = int(parts[1])
+  else:
+    port = 80
+  uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
+  http = True
+  argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+  framed = True
+  argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+  transport = THttpClient.THttpClient(host, port, uri)
+else:
+  socket = TSocket.TSocket(host, port)
+  if framed:
+    transport = TTransport.TFramedTransport(socket)
+  else:
+    transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = ThriftEventTransmissionService.Client(protocol)
+transport.open()
+
+if cmd == 'defineStream':
+  if len(args) != 2:
+    print 'defineStream requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.defineStream(args[0],args[1],))
+
+elif cmd == 'findStreamId':
+  if len(args) != 3:
+    print 'findStreamId requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
+
+elif cmd == 'publish':
+  if len(args) != 1:
+    print 'publish requires 1 args'
+    sys.exit(1)
+  pp.pprint(client.publish(eval(args[0]),))
+
+elif cmd == 'deleteStreamById':
+  if len(args) != 2:
+    print 'deleteStreamById requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamById(args[0],args[1],))
+
+elif cmd == 'deleteStreamByNameVersion':
+  if len(args) != 3:
+    print 'deleteStreamByNameVersion requires 3 args'
+    sys.exit(1)
+  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
+
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
+transport.close()


[45/50] [abbrv] git commit: Merge remote-tracking branch 'upstream/master'

Posted by ni...@apache.org.
Merge remote-tracking branch 'upstream/master'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/98396a7f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/98396a7f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/98396a7f

Branch: refs/heads/master
Commit: 98396a7f4a0c7e0b2a057c750c0725bf94a453c7
Parents: dc4d2ad c13d21c
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 22:01:46 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 22:01:46 2014 +0530

----------------------------------------------------------------------
 .../apache/stratos/cli/CommandLineService.java  |  12 +-
 .../java/org/apache/stratos/cli/RestClient.java |  12 +-
 .../stratos/cli/RestCommandLineService.java     | 796 +++++--------------
 .../apache/stratos/cli/StratosApplication.java  |  30 +-
 .../cli/commands/ActivateTenantCommand.java     |   6 +-
 .../cli/commands/AddDomainMappingCommand.java   |   6 +-
 .../stratos/cli/commands/AddTenantCommand.java  |   8 +-
 .../stratos/cli/commands/AddUserCommand.java    |   8 +-
 .../cli/commands/AutoscalePolicyCommand.java    |  66 --
 .../AutoscalingPolicyDeploymentCommand.java     | 138 ----
 .../commands/CartridgeDeploymentCommand.java    | 140 ----
 .../cli/commands/DeactivateTenantCommand.java   |   4 +-
 .../cli/commands/DeleteTenantCommand.java       |   4 +-
 .../stratos/cli/commands/DeleteUserCommand.java |   4 +-
 .../DeployAutoscalingPolicyCommand.java         | 138 ++++
 .../cli/commands/DeployCartridgeCommand.java    | 140 ++++
 .../commands/DeployDeploymentPolicyCommand.java | 138 ++++
 .../commands/DeployKubernetesGroupCommand.java  |  16 +-
 .../commands/DeployKubernetesHostCommand.java   |  16 +-
 .../cli/commands/DeployPartitionCommand.java    | 138 ++++
 .../cli/commands/DeployServiceCommand.java      | 139 ++++
 .../DeployServiceDeploymentCommand.java         | 139 ----
 .../cli/commands/DeploymentPolicyCommand.java   |  66 --
 .../DeploymentPolicyDeploymentCommand.java      | 138 ----
 .../DescribeAutoScalingPolicyCommand.java       |   4 +-
 .../cli/commands/DescribeCartridgeCommand.java  |   4 +-
 .../DescribeDeploymentPolicyCommand.java        |   6 +-
 .../cli/commands/DescribePartitionCommand.java  |   4 +-
 .../stratos/cli/commands/ExitCommand.java       |   9 +-
 .../stratos/cli/commands/HelpCommand.java       |   6 +-
 .../stratos/cli/commands/InfoCommand.java       |   4 +-
 .../stratos/cli/commands/ListAllTenants.java    |   4 +-
 .../stratos/cli/commands/ListAllUsers.java      |   4 +-
 .../commands/ListAutoscalePolicyCommand.java    |  66 ++
 .../ListCartridgeSubscriptionsCommand.java      |  95 +++
 .../cli/commands/ListCartridgesCommand.java     |   4 +-
 .../cli/commands/ListDeployServiceCommand.java  |   6 +-
 .../commands/ListDeploymentPolicyCommand.java   |  66 ++
 .../commands/ListKubernetesGroupsCommand.java   |   4 +-
 .../commands/ListKubernetesHostsCommand.java    |   4 +-
 .../stratos/cli/commands/ListMemberCommand.java |  10 +-
 .../cli/commands/ListPartitionCommand.java      |  65 ++
 .../ListSubscribedCartridgesCommand.java        |  10 +-
 .../stratos/cli/commands/PartitionCommand.java  |  65 --
 .../commands/PartitionDeploymentCommand.java    | 138 ----
 .../stratos/cli/commands/PoliciesCommand.java   |  71 --
 .../commands/RemoveDomainMappingCommand.java    |  75 --
 .../cli/commands/SubscribeCartridgeCommand.java | 307 +++++++
 .../stratos/cli/commands/SubscribeCommand.java  | 358 ---------
 .../SubscribedCartridgeInfoCommand.java         | 101 ---
 .../stratos/cli/commands/SyncCommand.java       |  17 +-
 .../UnDeployKubernetesGroupCommand.java         |   6 +-
 .../UndeployCartridgeDefinitionCommand.java     |   4 +-
 .../commands/UndeployKubernetesHostCommand.java |   4 +-
 .../UndeployServiceDefinitionCommand.java       |   4 +-
 .../cli/commands/UnsubscribeCommand.java        |  10 +-
 .../stratos/cli/exception/ErrorWrapper.java     |   4 +-
 .../apache/stratos/cli/utils/CliConstants.java  |   4 +-
 .../org/apache/stratos/cli/utils/CliUtils.java  | 147 ++++
 .../stratos/cli/utils/CommandLineUtils.java     | 147 ----
 .../stratos/kubernetes/client/model/Pod.java    |  23 +
 61 files changed, 1807 insertions(+), 2355 deletions(-)
----------------------------------------------------------------------



[22/50] [abbrv] Added new properties to the agent.conf Refactored modules and dependencies to avoid circular dependencies Added singleton to CartridgeAgentConfiguration by overriding __new__ Refactored hard coded strings to constants file Cleaned up file

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index ea85d44..64021a3 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -14,6 +14,11 @@ class HealthStatisticsPublisherManager(Thread):
     Read from an implementation of AbstractHealthStatisticsPublisher the value for memory usage and
     load average and publishes them as ThriftEvents to a CEP server
     """
+    STREAM_NAME = "cartridge_agent_health_stats"
+    STREAM_VERSION = "1.0.0"
+    STREAM_NICKNAME = "agent health stats"
+    STREAM_DESCRIPTION = "agent health stats"
+
     def __init__(self, publish_interval):
         """
         Initializes a new HealthStatistsPublisherManager with a given number of seconds as the interval
@@ -54,7 +59,13 @@ class HealthStatisticsPublisher:
         self.log = LogFactory().get_log(__name__)
         self.ports = []
         self.ports.append(CEPPublisherConfiguration.get_instance().server_port)
-        cartridgeagentutils.wait_until_ports_active(CEPPublisherConfiguration.get_instance().server_ip, self.ports)
+
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+        cartridgeagentutils.wait_until_ports_active(
+            CEPPublisherConfiguration.get_instance().server_ip,
+            self.ports,
+            int(self.cartridge_agent_config.read_property("port.check.timeout", critical=False)))
         cep_active = cartridgeagentutils.check_ports_active(CEPPublisherConfiguration.get_instance().server_ip, self.ports)
         if not cep_active:
             raise CEPPublisherException("CEP server not active. Health statistics publishing aborted.")
@@ -74,17 +85,17 @@ class HealthStatisticsPublisher:
         Create a StreamDefinition for publishing to CEP
         """
         stream_def = StreamDefinition()
-        stream_def.name = "cartridge_agent_health_stats"
-        stream_def.version = "1.0.0"
-        stream_def.nickname = "agent health stats"
-        stream_def.description = "agent health stats"
-
-        stream_def.add_payloaddata_attribute("cluster_id", "STRING")
-        stream_def.add_payloaddata_attribute("network_partition_id", "STRING")
-        stream_def.add_payloaddata_attribute("member_id", "STRING")
-        stream_def.add_payloaddata_attribute("partition_id", "STRING")
-        stream_def.add_payloaddata_attribute("health_description", "STRING")
-        stream_def.add_payloaddata_attribute("value", "DOUBLE")
+        stream_def.name = HealthStatisticsPublisherManager.STREAM_NAME
+        stream_def.version = HealthStatisticsPublisherManager.STREAM_VERSION
+        stream_def.nickname = HealthStatisticsPublisherManager.STREAM_NICKNAME
+        stream_def.description = HealthStatisticsPublisherManager.STREAM_DESCRIPTION
+
+        stream_def.add_payloaddata_attribute("cluster_id", StreamDefinition.STRING)
+        stream_def.add_payloaddata_attribute("network_partition_id", StreamDefinition.STRING)
+        stream_def.add_payloaddata_attribute("member_id", StreamDefinition.STRING)
+        stream_def.add_payloaddata_attribute("partition_id", StreamDefinition.STRING)
+        stream_def.add_payloaddata_attribute("health_description", StreamDefinition.STRING)
+        stream_def.add_payloaddata_attribute("value", StreamDefinition.DOUBLE)
 
         return stream_def
 
@@ -95,10 +106,10 @@ class HealthStatisticsPublisher:
         """
 
         event = ThriftEvent()
-        event.payloadData.append(CartridgeAgentConfiguration.cluster_id)
-        event.payloadData.append(CartridgeAgentConfiguration.network_partition_id)
-        event.payloadData.append(CartridgeAgentConfiguration.member_id)
-        event.payloadData.append(CartridgeAgentConfiguration.partition_id)
+        event.payloadData.append(self.cartridge_agent_config.cluster_id)
+        event.payloadData.append(self.cartridge_agent_config.network_partition_id)
+        event.payloadData.append(self.cartridge_agent_config.member_id)
+        event.payloadData.append(self.cartridge_agent_config.partition_id)
         event.payloadData.append(cartridgeagentconstants.MEMORY_CONSUMPTION)
         event.payloadData.append(memory_usage)
 
@@ -112,10 +123,10 @@ class HealthStatisticsPublisher:
         """
 
         event = ThriftEvent()
-        event.payloadData.append(CartridgeAgentConfiguration.cluster_id)
-        event.payloadData.append(CartridgeAgentConfiguration.network_partition_id)
-        event.payloadData.append(CartridgeAgentConfiguration.member_id)
-        event.payloadData.append(CartridgeAgentConfiguration.partition_id)
+        event.payloadData.append(self.cartridge_agent_config.cluster_id)
+        event.payloadData.append(self.cartridge_agent_config.network_partition_id)
+        event.payloadData.append(self.cartridge_agent_config.member_id)
+        event.payloadData.append(self.cartridge_agent_config.partition_id)
         event.payloadData.append(cartridgeagentconstants.LOAD_AVERAGE)
         event.payloadData.append(load_avg)
 
@@ -173,28 +184,35 @@ class CEPPublisherConfiguration:
         self.admin_password = None
         self.read_config()
 
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
     def read_config(self):
-        self.enabled = True if CartridgeAgentConfiguration.read_property("cep.stats.publisher.enabled", False).strip().lower() == "true" else False
+        self.enabled = True if self.cartridge_agent_config.read_property(
+           cartridgeagentconstants.CEP_PUBLISHER_ENABLED, False).strip().lower() == "true" else False
         if not self.enabled:
             CEPPublisherConfiguration.log.info("CEP Publisher disabled")
             return
 
         CEPPublisherConfiguration.log.info("CEP Publisher enabled")
 
-        self.server_ip = CartridgeAgentConfiguration.read_property("thrift.receiver.ip", False)
+        self.server_ip = self.cartridge_agent_config.read_property(
+            cartridgeagentconstants.CEP_RECEIVER_IP, False)
         if self.server_ip.strip() == "":
-            raise RuntimeError("System property not found: thrift.receiver.ip")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_RECEIVER_IP)
 
-        self.server_port = CartridgeAgentConfiguration.read_property("thrift.receiver.port", False)
+        self.server_port = self.cartridge_agent_config.read_property(
+            cartridgeagentconstants.CEP_RECEIVER_PORT, False)
         if self.server_port.strip() == "":
-            raise RuntimeError("System property not found: thrift.receiver.port")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_RECEIVER_PORT)
 
-        self.admin_username = CartridgeAgentConfiguration.read_property("thrift.server.admin.username", False)
+        self.admin_username = self.cartridge_agent_config.read_property(
+            cartridgeagentconstants.CEP_SERVER_ADMIN_USERNAME, False)
         if self.admin_username.strip() == "":
-            raise RuntimeError("System property not found: thrift.server.admin.username")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_SERVER_ADMIN_USERNAME)
 
-        self.admin_password = CartridgeAgentConfiguration.read_property("thrift.server.admin.password", False)
+        self.admin_password = self.cartridge_agent_config.read_property(
+            cartridgeagentconstants.CEP_SERVER_ADMIN_PASSWORD, False)
         if self.admin_password.strip() == "":
-            raise RuntimeError("System property not found: thrift.server.admin.password")
+            raise RuntimeError("System property not found: " + cartridgeagentconstants.CEP_SERVER_ADMIN_PASSWORD)
 
         CEPPublisherConfiguration.log.info("CEP Publisher configuration initialized")

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 260d67d..9b4d819 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -24,15 +24,15 @@ def publish_instance_started_event():
     global started, log
     if not started:
         log.info("Publishing instance started event")
-        service_name = CartridgeAgentConfiguration.service_name
-        cluster_id = CartridgeAgentConfiguration.cluster_id
-        network_partition_id = CartridgeAgentConfiguration.network_partition_id
-        parition_id = CartridgeAgentConfiguration.partition_id
-        member_id = CartridgeAgentConfiguration.member_id
+        service_name = CartridgeAgentConfiguration().service_name
+        cluster_id = CartridgeAgentConfiguration().cluster_id
+        network_partition_id = CartridgeAgentConfiguration().network_partition_id
+        parition_id = CartridgeAgentConfiguration().partition_id
+        member_id = CartridgeAgentConfiguration().member_id
 
         instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                       member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceStartedEvent")
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + cartridgeagentconstants.INSTANCE_STARTED_EVENT)
         publisher.publish(instance_started_event)
         started = True
         log.info("Instance started event published")
@@ -44,15 +44,15 @@ def publish_instance_activated_event():
     global activated, log
     if not activated:
         log.info("Publishing instance activated event")
-        service_name = CartridgeAgentConfiguration.service_name
-        cluster_id = CartridgeAgentConfiguration.cluster_id
-        network_partition_id = CartridgeAgentConfiguration.network_partition_id
-        parition_id = CartridgeAgentConfiguration.partition_id
-        member_id = CartridgeAgentConfiguration.member_id
+        service_name = CartridgeAgentConfiguration().service_name
+        cluster_id = CartridgeAgentConfiguration().cluster_id
+        network_partition_id = CartridgeAgentConfiguration().network_partition_id
+        parition_id = CartridgeAgentConfiguration().partition_id
+        member_id = CartridgeAgentConfiguration().member_id
 
         instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceActivatedEvent")
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + cartridgeagentconstants.INSTANCE_ACTIVATED_EVENT)
         publisher.publish(instance_activated_event)
 
         log.info("Instance activated event published")
@@ -60,7 +60,7 @@ def publish_instance_activated_event():
 
         if CEPPublisherConfiguration.get_instance().enabled:
             interval_default = 15  # seconds
-            interval = CartridgeAgentConfiguration.read_property("stats.notifier.interval")
+            interval = CartridgeAgentConfiguration().read_property("stats.notifier.interval")
             if interval is not None and len(interval) > 0:
                 try:
                     interval = int(interval)
@@ -85,16 +85,16 @@ def publish_maintenance_mode_event():
     if not maintenance:
         log.info("Publishing instance maintenance mode event")
 
-        service_name = CartridgeAgentConfiguration.service_name
-        cluster_id = CartridgeAgentConfiguration.cluster_id
-        network_partition_id = CartridgeAgentConfiguration.network_partition_id
-        parition_id = CartridgeAgentConfiguration.partition_id
-        member_id = CartridgeAgentConfiguration.member_id
+        service_name = CartridgeAgentConfiguration().service_name
+        cluster_id = CartridgeAgentConfiguration().cluster_id
+        network_partition_id = CartridgeAgentConfiguration().network_partition_id
+        parition_id = CartridgeAgentConfiguration().partition_id
+        member_id = CartridgeAgentConfiguration().member_id
 
         instance_maintenance_mode_event = InstanceMaintenanceModeEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
 
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceMaintenanceModeEvent")
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + cartridgeagentconstants.INSTANCE_MAINTENANCE_MODE_EVENT)
         publisher.publish(instance_maintenance_mode_event)
 
         maintenance = True
@@ -108,16 +108,16 @@ def publish_instance_ready_to_shutdown_event():
     if not ready_to_shutdown:
         log.info("Publishing instance activated event")
 
-        service_name = CartridgeAgentConfiguration.service_name
-        cluster_id = CartridgeAgentConfiguration.cluster_id
-        network_partition_id = CartridgeAgentConfiguration.network_partition_id
-        parition_id = CartridgeAgentConfiguration.partition_id
-        member_id = CartridgeAgentConfiguration.member_id
+        service_name = CartridgeAgentConfiguration().service_name
+        cluster_id = CartridgeAgentConfiguration().cluster_id
+        network_partition_id = CartridgeAgentConfiguration().network_partition_id
+        parition_id = CartridgeAgentConfiguration().partition_id
+        member_id = CartridgeAgentConfiguration().member_id
 
         instance_shutdown_event = InstanceReadyToShutdownEvent(service_name, cluster_id, network_partition_id, parition_id,
                                                           member_id)
 
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + "InstanceReadyToShutdownEvent")
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC + cartridgeagentconstants.INSTANCE_READY_TO_SHUTDOWN_EVENT)
         publisher.publish(instance_shutdown_event)
 
         ready_to_shutdown = True
@@ -140,14 +140,8 @@ class EventPublisher:
     def __init__(self, topic):
         self.__topic = topic
 
-    """
-    msgs = [{'topic': "instance/status/InstanceStartedEvent", 'payload': instance_started_event.to_JSON()}]
-    #publish.single("instance", instance_started_event.to_JSON(), hostname="localhost", port=1883)
-    publish.multiple(msgs, "localhost", 1883)
-    """
-
     def publish(self, event):
-        mb_ip = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MB_IP)
-        mb_port = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MB_PORT)
+        mb_ip = CartridgeAgentConfiguration().read_property(cartridgeagentconstants.MB_IP)
+        mb_port = CartridgeAgentConfiguration().read_property(cartridgeagentconstants.MB_PORT)
         payload = event.to_json()
         publish.single(self.__topic, payload, hostname=mb_ip, port=mb_port)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index 46fe18a..da60d7d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -1,11 +1,6 @@
-import logging
 import threading
 import paho.mqtt.client as mqtt
 
-from .. util import cartridgeagentconstants
-from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from .. util.log import LogFactory
-
 
 class EventSubscriber(threading.Thread):
     """
@@ -13,7 +8,7 @@ class EventSubscriber(threading.Thread):
     register event handlers for various events.
     """
 
-    def __init__(self, topic):
+    def __init__(self, topic, ip, port):
         threading.Thread.__init__(self)
 
         #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
@@ -27,16 +22,16 @@ class EventSubscriber(threading.Thread):
 
         self.__subscribed = False
 
+        self.__ip = ip
+        self.__port = port
+
     def run(self):
         self.__mb_client = mqtt.Client()
         self.__mb_client.on_connect = self.on_connect
         self.__mb_client.on_message = self.on_message
 
-        mb_ip = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MB_IP)
-        mb_port = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MB_PORT)
-
-        self.log.debug("Connecting to the message broker with address %r:%r" % (mb_ip, mb_port))
-        self.__mb_client.connect(mb_ip, mb_port, 60)
+        self.log.debug("Connecting to the message broker with address %r:%r" % (self.__ip, self.__port))
+        self.__mb_client.connect(self.__ip, self.__port, 60)
         self.__subscribed = True
         self.__mb_client.loop_forever()
 
@@ -79,3 +74,6 @@ class EventSubscriber(threading.Thread):
         :rtype: bool
         """
         return self.__subscribed
+
+
+from .. util.log import LogFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 5d92306..4a13765 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -247,8 +247,10 @@ class Cluster:
         return member_id in self.member_map
 
     def __str__(self):
-        return "Cluster [serviceName=%r, clusterId=%r, autoscalePolicyName=%r, deploymentPolicyName=%r, hostNames=%r, tenantRange=%r, isLbCluster=%r, properties=%r]" % \
-               (self.service_name, self.cluster_id, self.autoscale_policy_name, self.deployment_policy_name, self.hostnames, self.tenant_range, self.is_lb_cluster, self.properties)
+        return "Cluster [serviceName=" + self.service_name + ", clusterId=" + self.cluster_id \
+               + ", autoscalePolicyName=" + self.autoscale_policy_name + ", deploymentPolicyName=" \
+               + self.deployment_policy_name + ", hostNames=" + self.hostnames + ", tenantRange=" + self.tenant_range \
+               + ", isLbCluster=" + self.is_lb_cluster + ", properties=" + self.properties + "]"
 
     def tenant_id_in_range(self, tenant_id):
         """

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
index 3d6dea1..7265c15 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -5,15 +5,6 @@ EXTENSIONS_DIR = "extensions.dir"
 MB_IP = "mb.ip"
 MB_PORT = "mb.port"
 
-INSTANCE_STARTED_SH = "instance-started.sh"
-START_SERVERS_SH = "start-servers.sh"
-INSTANCE_ACTIVATED_SH = "instance-activated.sh"
-ARTIFACTS_UPDATED_SH = "artifacts-updated.sh"
-CLEAN_UP_SH = "clean.sh"
-MOUNT_VOLUMES_SH = "mount_volumes.sh"
-SUBSCRIPTION_DOMAIN_ADDED_SH = "subscription-domain-added.sh"
-SUBSCRIPTION_DOMAIN_REMOVED_SH = "subscription-domain-removed.sh"
-
 CARTRIDGE_KEY = "CARTRIDGE_KEY"
 APP_PATH = "APP_PATH"
 SERVICE_GROUP = "SERIVCE_GROUP"
@@ -29,6 +20,7 @@ PORTS = "PORTS"
 DEPLOYMENT = "DEPLOYMENT"
 MANAGER_SERVICE_TYPE = "MANAGER_SERVICE_TYPE"
 WORKER_SERVICE_TYPE = "WORKER_SERVICE_TYPE"
+PERSISTENCE_MAPPING = "PERSISTENCE_MAPPING"
 
 # stratos.sh environment variables keys
 LOG_FILE_PATHS = "LOG_FILE_PATHS"
@@ -87,6 +79,41 @@ TOPOLOGY_TOPIC = "topology/#"
 TENANT_TOPIC = "tenant/#"
 INSTANCE_STATUS_TOPIC = "instance/status/"
 
-
 #Messaging Model
-TENANT_RANGE_DELIMITER = "-"
\ No newline at end of file
+TENANT_RANGE_DELIMITER = "-"
+
+INSTANCE_STARTED_EVENT = "InstanceStartedEvent"
+INSTANCE_ACTIVATED_EVENT = "InstanceActivatedEvent"
+INSTANCE_MAINTENANCE_MODE_EVENT = "InstanceMaintenanceModeEvent"
+INSTANCE_READY_TO_SHUTDOWN_EVENT = "InstanceReadyToShutdownEvent"
+
+PUBLISHER_SERVICE_NAME = "publisher"
+APISTORE_SERVICE_NAME = "apistore"
+APIMANAGER_SERVICE_NAME = "apim"
+GATEWAY_SERVICE_NAME = "gatewaymgt"
+GATEWAY_MGT_SERVICE_NAME = "gateway"
+KEY_MANAGER_SERVICE_NAME = "keymanager"
+
+PRIMARY = "PRIMARY"
+MIN_COUNT = "MIN_COUNT"
+
+#multi tenant constants
+INVALID_TENANT_ID = "-1"
+SUPER_TENANT_ID = "-1234"
+
+DATE_FORMAT = "%Y.%m.%d"
+
+PORT_CHECK_TIMEOUT = "port.check.timeout"
+
+CEP_PUBLISHER_ENABLED = "cep.stats.publisher.enabled"
+CEP_RECEIVER_IP = "thrift.receiver.ip"
+CEP_RECEIVER_PORT = "thrift.receiver.port"
+CEP_SERVER_ADMIN_USERNAME = "thrift.server.admin.username"
+CEP_SERVER_ADMIN_PASSWORD = "thrift.server.admin.password"
+
+MONITORING_PUBLISHER_ENABLED = "enable.data.publisher"
+MONITORING_RECEIVER_IP = "monitoring.server.ip"
+MONITORING_RECEIVER_PORT = "monitoring.server.port"
+MONITORING_RECEIVER_SECURE_PORT = "monitoring.server.secure.port"
+MONITORING_SERVER_ADMIN_USERNAME = "monitoring.server.admin.username"
+MONITORING_SERVER_ADMIN_PASSWORD = "monitoring.server.admin.password"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index d9916da..81b2b92 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -6,7 +6,6 @@ import time
 import socket
 import shutil
 
-from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 import cartridgeagentconstants
 from log import LogFactory
 
@@ -16,6 +15,16 @@ log = LogFactory().get_log(__name__)
 
 current_milli_time = lambda: int(round(time.time() * 1000))
 
+extension_handler = None
+
+
+def get_extension_handler():
+    global extension_handler
+    if extension_handler is None:
+        extension_handler = defaultextensionhandler.DefaultExtensionHandler()
+
+    return extension_handler
+
 
 def decrypt_password(pass_str, secret):
     """
@@ -75,14 +84,14 @@ def delete_folder_tree(path):
         log.exception("Deletion of folder path %r failed." % path)
 
 
-def wait_until_ports_active(ip_address, ports):
+def wait_until_ports_active(ip_address, ports, ports_check_timeout=600000):
     """
     Blocks until the given list of ports become active
     :param str ip_address: Ip address of the member to be checked
     :param list[str] ports: List of ports to be checked
+    :param int ports_check_timeout: The timeout in milliseconds, defaults to 1000*60*10
     :return: void
     """
-    ports_check_timeout = CartridgeAgentConfiguration.read_property("port.check.timeout", critical=False)
     if ports_check_timeout is None:
         ports_check_timeout = 1000 * 60 * 10
 
@@ -160,4 +169,17 @@ def get_carbon_server_property(property_key):
     :rtype : str
     """
 
-    raise NotImplementedError
\ No newline at end of file
+    raise NotImplementedError
+
+
+def get_working_dir():
+    """
+    Returns the base directory of the cartridge agent.
+    :return: Base working dir path
+    :rtype : str
+    """
+    #"/path/to/cartridge-agent/modules/util/".split("modules") returns ["/path/to/cartridge-agent/", "/util"]
+    return os.path.abspath(os.path.dirname(__file__)).split("modules")[0]
+
+
+from ..extensions import defaultextensionhandler

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index a694ff1..487def4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -3,17 +3,18 @@ import os
 import subprocess
 import time
 
-from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from .. topology.topologycontext import *
 from log import LogFactory
 
 log = LogFactory().get_log(__name__)
 
+cartridge_agent_config = cartridgeagentconfiguration.CartridgeAgentConfiguration()
+
 
 def execute_copy_artifact_extension(source, destination):
     try:
         log.debug("Executing artifacts copy extension")
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACTS_COPY_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.ARTIFACTS_COPY_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command + " " + source + " " + destination)
@@ -26,7 +27,8 @@ def execute_instance_started_extension(env_params):
     try:
         log.debug("Executing instance started extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.INSTANCE_STARTED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.INSTANCE_STARTED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -40,7 +42,8 @@ def execute_instance_started_extension(env_params):
 def execute_instance_activated_extension():
     try:
         log.debug("Executing instance activated extension")
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.INSTANCE_ACTIVATED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.INSTANCE_ACTIVATED_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command)
@@ -53,7 +56,8 @@ def execute_artifacts_updated_extension(env_params):
     try:
         log.debug("Executing artifacts updated extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACTS_UPDATED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.ARTIFACTS_UPDATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -68,7 +72,8 @@ def execute_subscription_domain_added_extension(env_params):
     try:
         log.debug("Executing subscription domain added extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -83,7 +88,8 @@ def execute_subscription_domain_removed_extension(env_params):
     try:
         log.debug("Executing subscription domain removed extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -98,7 +104,8 @@ def execute_start_servers_extension(env_params):
     try:
         log.debug("Executing start servers extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.START_SERVERS_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.START_SERVERS_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -113,7 +120,8 @@ def execute_complete_topology_extension(env_params):
     try:
         log.debug("Executing complete topology extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.COMPLETE_TOPOLOGY_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.COMPLETE_TOPOLOGY_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -128,7 +136,8 @@ def execute_complete_tenant_extension(env_params):
     try:
         log.debug("Executing complete tenant extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.COMPLETE_TENANT_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.COMPLETE_TENANT_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -143,7 +152,8 @@ def execute_tenant_subscribed_extension(env_params):
     try:
         log.debug("Executing tenant subscribed extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.TENANT_SUBSCRIBED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.TENANT_SUBSCRIBED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -158,7 +168,8 @@ def execute_tenant_unsubscribed_extension(env_params):
     try:
         log.debug("Executing tenant unsubscribed extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.TENANT_UNSUBSCRIBED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.TENANT_UNSUBSCRIBED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -173,7 +184,8 @@ def execute_member_terminated_extension(env_params):
     try:
         log.debug("Executing member terminated extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_TERMINATED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.MEMBER_TERMINATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -188,7 +200,8 @@ def execute_member_suspended_extension(env_params):
     try:
         log.debug("Executing member suspended extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_SUSPENDED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.MEMBER_SUSPENDED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -198,11 +211,13 @@ def execute_member_suspended_extension(env_params):
     except:
         log.exception("Could not execute member suspended extension")
 
+
 def execute_member_started_extension(env_params):
     try:
         log.debug("Executing member started extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_STARTED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.MEMBER_STARTED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -240,7 +255,7 @@ def check_topology_consistency(service_name, cluster_id, member_id):
 
 
 def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
-    cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
+    cluster_id_in_payload = cartridge_agent_config.cluster_id
     if cluster_id_in_payload is None:
         return False
 
@@ -254,7 +269,7 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
     if cluster_id_in_payload == lb_cluster_id:
         return True
 
-    service_group_in_payload = CartridgeAgentConfiguration.service_group
+    service_group_in_payload = cartridge_agent_config.service_group
     if service_group_in_payload is not None:
         service_properties = topology.get_service(service_name).properties
         if service_properties is None:
@@ -262,19 +277,27 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
 
         member_service_group = service_properties[cartridgeagentconstants.SERVICE_GROUP_TOPOLOGY_KEY]
         if member_service_group is not None and member_service_group == service_group_in_payload:
-            if service_name == CartridgeAgentConfiguration.service_name:
+            if service_name == cartridge_agent_config.service_name:
                 log.debug("Service names are same")
                 return True
-            elif "apistore" == CartridgeAgentConfiguration.service_name and service_name == "publisher":
+            elif cartridgeagentconstants.APISTORE_SERVICE_NAME == \
+                    cartridge_agent_config.service_name \
+                    and service_name == cartridgeagentconstants.PUBLISHER_SERVICE_NAME:
                 log.debug("Service name in payload is [store]. Serivce name in event is [%r] " % service_name)
                 return True
-            elif "publisher" == CartridgeAgentConfiguration.service_name and service_name == "apistore":
+            elif cartridgeagentconstants.PUBLISHER_SERVICE_NAME == \
+                    cartridge_agent_config.service_name \
+                    and service_name == cartridgeagentconstants.APISTORE_SERVICE_NAME:
                 log.debug("Service name in payload is [publisher]. Serivce name in event is [%r] " % service_name)
                 return True
-            elif cartridgeagentconstants.DEPLOYMENT_WORKER == CartridgeAgentConfiguration.deployment and service_name == CartridgeAgentConfiguration.manager_service_name:
+            elif cartridgeagentconstants.DEPLOYMENT_WORKER == \
+                    cartridge_agent_config.deployment \
+                    and service_name == cartridge_agent_config.manager_service_name:
                 log.debug("Deployment is worker. Worker's manager service name & service name in event are same")
                 return True
-            elif cartridgeagentconstants.DEPLOYMENT_MANAGER == CartridgeAgentConfiguration.deployment  and service_name == CartridgeAgentConfiguration.worker_service_name:
+            elif cartridgeagentconstants.DEPLOYMENT_MANAGER == \
+                    cartridge_agent_config.deployment  \
+                    and service_name == cartridge_agent_config.worker_service_name:
                 log.debug("Deployment is manager. Manager's worker service name & service name in event are same")
                 return True
 
@@ -284,7 +307,8 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
 def execute_volume_mount_extension(persistance_mappings_payload):
     try:
         log.debug("Executing volume mounting extension: [payload] %r" % persistance_mappings_payload)
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MOUNT_VOLUMES_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.MOUNT_VOLUMES_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command + " " + persistance_mappings_payload)
@@ -296,7 +320,8 @@ def execute_volume_mount_extension(persistance_mappings_payload):
 def execute_cleanup_extension():
     try:
         log.debug("Executing cleanup extension")
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.CLEAN_UP_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.CLEAN_UP_SCRIPT, False)
         command = prepare_command(script_name)
 
         output, errors = execute_command(command)
@@ -309,7 +334,8 @@ def execute_member_activated_extension(env_params):
     try:
         log.debug("Executing member activated extension")
 
-        script_name = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.MEMBER_ACTIVATED_SCRIPT, False)
+        script_name = cartridge_agent_config.read_property(
+            cartridgeagentconstants.MEMBER_ACTIVATED_SCRIPT, False)
         command = prepare_command(script_name)
         env_params = add_payload_parameters(env_params)
         env_params = clean_process_parameters(env_params)
@@ -321,11 +347,13 @@ def execute_member_activated_extension(env_params):
 
 
 def prepare_command(script_name):
-    extensions_dir = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR, False)
+    extensions_dir = cartridge_agent_config.read_property(
+        cartridgeagentconstants.EXTENSIONS_DIR, False)
     if extensions_dir.strip() == "":
         raise RuntimeError("System property not found: %r" % cartridgeagentconstants.EXTENSIONS_DIR)
 
-    file_path = extensions_dir + script_name if str(extensions_dir).endswith("/") else extensions_dir + "/" + script_name
+    file_path = extensions_dir + script_name if str(extensions_dir).endswith("/") \
+        else extensions_dir + "/" + script_name
 
     if os.path.isfile(file_path):
         return file_path
@@ -354,32 +382,35 @@ def add_payload_parameters(env_params):
     :return: Dictionary with updated parameters
     :rtype: dict[str, str]
     """
-    env_params["STRATOS_APP_PATH"] = CartridgeAgentConfiguration.app_path
-    env_params["STRATOS_PARAM_FILE_PATH"] = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH, False)
-    env_params["STRATOS_SERVICE_NAME"] = CartridgeAgentConfiguration.service_name
-    env_params["STRATOS_TENANT_ID"] = CartridgeAgentConfiguration.tenant_id
-    env_params["STRATOS_CARTRIDGE_KEY"] = CartridgeAgentConfiguration.cartridge_key
-    env_params["STRATOS_LB_CLUSTER_ID"] = CartridgeAgentConfiguration.lb_cluster_id
-    env_params["STRATOS_CLUSTER_ID"] = CartridgeAgentConfiguration.cluster_id
-    env_params["STRATOS_NETWORK_PARTITION_ID"] = CartridgeAgentConfiguration.network_partition_id
-    env_params["STRATOS_PARTITION_ID"] = CartridgeAgentConfiguration.partition_id
-    env_params["STRATOS_PERSISTENCE_MAPPINGS"] = CartridgeAgentConfiguration.persistence_mappings
-    env_params["STRATOS_REPO_URL"] = CartridgeAgentConfiguration.repo_url
-
-    lb_cluster_id_in_payload = CartridgeAgentConfiguration.lb_cluster_id
+    env_params["STRATOS_APP_PATH"] = cartridge_agent_config.app_path
+    env_params["STRATOS_PARAM_FILE_PATH"] = cartridge_agent_config.read_property(
+        cartridgeagentconstants.PARAM_FILE_PATH, False)
+    env_params["STRATOS_SERVICE_NAME"] = cartridge_agent_config.service_name
+    env_params["STRATOS_TENANT_ID"] = cartridge_agent_config.tenant_id
+    env_params["STRATOS_CARTRIDGE_KEY"] = cartridge_agent_config.cartridge_key
+    env_params["STRATOS_LB_CLUSTER_ID"] = cartridge_agent_config.lb_cluster_id
+    env_params["STRATOS_CLUSTER_ID"] = cartridge_agent_config.cluster_id
+    env_params["STRATOS_NETWORK_PARTITION_ID"] = \
+        cartridge_agent_config.network_partition_id
+    env_params["STRATOS_PARTITION_ID"] = cartridge_agent_config.partition_id
+    env_params["STRATOS_PERSISTENCE_MAPPINGS"] = \
+        cartridge_agent_config.persistence_mappings
+    env_params["STRATOS_REPO_URL"] = cartridge_agent_config.repo_url
+
+    lb_cluster_id_in_payload = cartridge_agent_config.lb_cluster_id
     member_ips = get_lb_member_ip(lb_cluster_id_in_payload)
     if member_ips is not None:
         env_params["STRATOS_LB_IP"] = member_ips[0]
         env_params["STRATOS_LB_PUBLIC_IP"] = member_ips[1]
     else:
-        env_params["STRATOS_LB_IP"] = CartridgeAgentConfiguration.lb_private_ip
-        env_params["STRATOS_LB_PUBLIC_IP"] = CartridgeAgentConfiguration.lb_public_ip
+        env_params["STRATOS_LB_IP"] = cartridge_agent_config.lb_private_ip
+        env_params["STRATOS_LB_PUBLIC_IP"] = cartridge_agent_config.lb_public_ip
 
     topology = TopologyContext.get_topology()
     if topology.initialized:
-        service = topology.get_service(CartridgeAgentConfiguration.service_name)
-        cluster = service.get_cluster(CartridgeAgentConfiguration.cluster_id)
-        member_id_in_payload = CartridgeAgentConfiguration.member_id
+        service = topology.get_service(cartridge_agent_config.service_name)
+        cluster = service.get_cluster(cartridge_agent_config.cluster_id)
+        member_id_in_payload = cartridge_agent_config.member_id
         add_properties(service.properties, env_params, "SERVICE_PROPERTY")
         add_properties(cluster.properties, env_params, "CLUSTER_PROPERTY")
         add_properties(cluster.get_member(member_id_in_payload).properties, env_params, "MEMBER_PROPERTY")
@@ -439,3 +470,7 @@ def execute_command(command, env_params=None):
         raise RuntimeError("Command execution failed: \n %r" % errors)
 
     return output, errors
+
+
+from .. config import cartridgeagentconfiguration
+from .. topology.topologycontext import *
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/511aedfa/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
index 83b1f50..b6fec95 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
@@ -10,7 +10,7 @@ class LogFactory(object):
     class __LogFactory:
         def __init__(self):
             self.logs = {}
-            logging_conf = os.path.join(os.path.dirname(__file__), "logging.ini")
+            logging_conf = os.path.abspath(os.path.dirname(__file__)).split("modules")[0] + "logging.ini"
             logging.config.fileConfig(logging_conf)
 
         def get_log(self, name):


[34/50] [abbrv] git commit: Strip strings when read from the configuration files Fixed set_attr() value

Posted by ni...@apache.org.
Strip strings when read from the configuration files
Fixed set_attr() value


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b0613711
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b0613711
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b0613711

Branch: refs/heads/master
Commit: b06137113e33de69eae66abd7a3b7d3fc661f291
Parents: 1c69a9a
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 13:54:56 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Fri Oct 10 13:54:56 2014 +0530

----------------------------------------------------------------------
 .../modules/config/cartridgeagentconfiguration.py           | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b0613711/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index fde28e8..f3376cf 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -302,17 +302,18 @@ class CartridgeAgentConfiguration:
                 self.log.debug("Has key: %r" % property_key)
                 temp_str = self.properties.get("agent", property_key)
                 if temp_str != "" and temp_str is not None:
-                    return temp_str
+                    return str(temp_str).strip()
 
             if property_key in self.payload_params:
                 temp_str = self.payload_params[property_key]
                 if temp_str != "" and temp_str is not None:
-                    return temp_str
+                    return str(temp_str).strip()
 
             if critical:
                 raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
 
     instance = None
+    """ :type : __CartridgeAgentConfiguration"""
 
     # def __new__(cls, *args, **kwargs):
     #     if not CartridgeAgentConfiguration.instance:
@@ -327,8 +328,8 @@ class CartridgeAgentConfiguration:
     def __getattr__(self, name):
         return getattr(self.instance, name)
 
-    def __setattr__(self, name):
-        return setattr(self.instance, name)
+    def __setattr__(self, name, value):
+        return setattr(self.instance, name, value)
 
 
 from ..exception.parameternotfoundexception import ParameterNotFoundException


[11/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
deleted file mode 100644
index 7550811..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/logpublisher/logpublisher.py
+++ /dev/null
@@ -1,71 +0,0 @@
-from ..thriftcom.Publisher import *
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-import json
-
-
-def get_valid_tenant_id(tenant_id):
-    raise NotImplementedError
-
-
-def get_alias(cluster_id):
-    raise NotImplementedError
-
-
-def get_current_date():
-    raise NotImplementedError
-
-ip = '192.168.1.2'	# IP address of the server
-port = 7711		# Thrift listen port of the server
-username = 'admin'	# username
-password = 'admin' 	# passowrd
-
-# Initialize publisher with ip and port of server
-publisher = Publisher(ip, port)
-
-# Connect to server with username and password
-publisher.connect(username, password)
-
-# Define stream definition
-valid_tenant_id = get_valid_tenant_id(CartridgeAgentConfiguration.tenant_id)
-alias = get_alias(CartridgeAgentConfiguration.cluster_id)
-stream_name = "logs." + valid_tenant_id + "." \
-              + alias + "." + get_current_date()
-
-stream_version = "1.0.0"
-payload_data = '{"name": "tenantID", "type": "STRING"}, {"name": "serverName", "type": "STRING"}, {"name": "appName", "type": "STRING"}, {"name": "logTime", "type": "STRING"}, {"name": "priority", "type": "STRING"}, {"name": "message", "type": "STRING"}, {"name": "logger", "type": "STRING"}, {"name": "ip", "type": "STRING"}, {"name": "instance", "type": "STRING"}, {"name": "stacktrace", "type": "STRING"}'
-
-meta_data = '{"name": "memberId", "type": "STRING"}'
-
-streamDefinition = "{ 'name': '" + stream_name + "', 'version':'" + stream_version + \
-                   "', 'metaData':'" + meta_data + \
-                   "', 'payloadData':'" + payload_data + "' }"
-
-# streamDefinition = "{ 'name': '" + stream_name + "', 'version':'" + stream_version + \
-#                    "', 'payloadData':'" + json.dumps(payload_data) + "' }"
-
-publisher.defineStream(streamDefinition)
-
-#compile the event
-event = EventBundle()
-#add meta data
-event.addStringAttribute(CartridgeAgentConfiguration.member_id)
-#add correlation data
-
-#add payload data
-event.addStringAttribute(valid_tenant_id)
-event.addStringAttribute(alias)
-event.addStringAttribute("")
-event.addStringAttribute(get_current_date())
-event.addStringAttribute("")
-event.addStringAttribute("this line")
-event.addStringAttribute("")
-event.addStringAttribute("")
-event.addStringAttribute(CartridgeAgentConfiguration.member_id)
-event.addStringAttribute("")
-
-# Publish sample message
-publisher.publish(event)
-
-# Disconnect
-publisher.disconnect()
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
deleted file mode 100644
index 7ede910..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/Publisher.py
+++ /dev/null
@@ -1,94 +0,0 @@
-import time
-import sys
-
-sys.path.append("gen-py")
-
-from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
-from ThriftSecureEventTransmissionService.ttypes import *
-
-from thrift import Thrift
-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(1)
-        event.addLongAttribute(time.time() * 1000)
-        event.addStringAttribute(self.streamId)
-        #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 Data.ttypes.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/__init__.py
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
deleted file mode 100644
index adefd8e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
deleted file mode 100644
index 35216c6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/constants.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# 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 ttypes import *
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
deleted file mode 100644
index 642c550..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Data/ttypes.py
+++ /dev/null
@@ -1,320 +0,0 @@
-#
-# 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 thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-class ThriftAttributeType:
-  INT = 0
-  LONG = 1
-  FLOAT = 2
-  DOUBLE = 3
-  BOOL = 4
-  STRING = 5
-
-  _VALUES_TO_NAMES = {
-    0: "INT",
-    1: "LONG",
-    2: "FLOAT",
-    3: "DOUBLE",
-    4: "BOOL",
-    5: "STRING",
-  }
-
-  _NAMES_TO_VALUES = {
-    "INT": 0,
-    "LONG": 1,
-    "FLOAT": 2,
-    "DOUBLE": 3,
-    "BOOL": 4,
-    "STRING": 5,
-  }
-
-
-class ThriftAttribute:
-  """
-  Attributes:
-   - name
-   - attributeType
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'name', None, None, ), # 1
-    (2, TType.I32, 'attributeType', None, None, ), # 2
-  )
-
-  def __init__(self, name=None, attributeType=None,):
-    self.name = name
-    self.attributeType = attributeType
-
-  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.name = iprot.readString();
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.I32:
-          self.attributeType = iprot.readI32();
-        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('ThriftAttribute')
-    if self.name is not None:
-      oprot.writeFieldBegin('name', TType.STRING, 1)
-      oprot.writeString(self.name)
-      oprot.writeFieldEnd()
-    if self.attributeType is not None:
-      oprot.writeFieldBegin('attributeType', TType.I32, 2)
-      oprot.writeI32(self.attributeType)
-      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 ThriftEventBundle:
-  """
-  Attributes:
-   - sessionId
-   - eventNum
-   - intAttributeList
-   - longAttributeList
-   - doubleAttributeList
-   - boolAttributeList
-   - stringAttributeList
-   - arbitraryDataMapMap
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'sessionId', None, None, ), # 1
-    (2, TType.I32, 'eventNum', None, None, ), # 2
-    (3, TType.LIST, 'intAttributeList', (TType.I32,None), None, ), # 3
-    (4, TType.LIST, 'longAttributeList', (TType.I64,None), None, ), # 4
-    (5, TType.LIST, 'doubleAttributeList', (TType.DOUBLE,None), None, ), # 5
-    (6, TType.LIST, 'boolAttributeList', (TType.BOOL,None), None, ), # 6
-    (7, TType.LIST, 'stringAttributeList', (TType.STRING,None), None, ), # 7
-    (8, TType.MAP, 'arbitraryDataMapMap', (TType.I32,None,TType.MAP,(TType.STRING,None,TType.STRING,None)), None, ), # 8
-  )
-
-  def __init__(self, sessionId=None, eventNum=None, intAttributeList=None, longAttributeList=None, doubleAttributeList=None, boolAttributeList=None, stringAttributeList=None, arbitraryDataMapMap=None,):
-    self.sessionId = sessionId
-    self.eventNum = eventNum
-    self.intAttributeList = intAttributeList
-    self.longAttributeList = longAttributeList
-    self.doubleAttributeList = doubleAttributeList
-    self.boolAttributeList = boolAttributeList
-    self.stringAttributeList = stringAttributeList
-    self.arbitraryDataMapMap = arbitraryDataMapMap
-
-  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.I32:
-          self.eventNum = iprot.readI32();
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.LIST:
-          self.intAttributeList = []
-          (_etype3, _size0) = iprot.readListBegin()
-          for _i4 in xrange(_size0):
-            _elem5 = iprot.readI32();
-            self.intAttributeList.append(_elem5)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.LIST:
-          self.longAttributeList = []
-          (_etype9, _size6) = iprot.readListBegin()
-          for _i10 in xrange(_size6):
-            _elem11 = iprot.readI64();
-            self.longAttributeList.append(_elem11)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 5:
-        if ftype == TType.LIST:
-          self.doubleAttributeList = []
-          (_etype15, _size12) = iprot.readListBegin()
-          for _i16 in xrange(_size12):
-            _elem17 = iprot.readDouble();
-            self.doubleAttributeList.append(_elem17)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 6:
-        if ftype == TType.LIST:
-          self.boolAttributeList = []
-          (_etype21, _size18) = iprot.readListBegin()
-          for _i22 in xrange(_size18):
-            _elem23 = iprot.readBool();
-            self.boolAttributeList.append(_elem23)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 7:
-        if ftype == TType.LIST:
-          self.stringAttributeList = []
-          (_etype27, _size24) = iprot.readListBegin()
-          for _i28 in xrange(_size24):
-            _elem29 = iprot.readString();
-            self.stringAttributeList.append(_elem29)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
-      elif fid == 8:
-        if ftype == TType.MAP:
-          self.arbitraryDataMapMap = {}
-          (_ktype31, _vtype32, _size30 ) = iprot.readMapBegin()
-          for _i34 in xrange(_size30):
-            _key35 = iprot.readI32();
-            _val36 = {}
-            (_ktype38, _vtype39, _size37 ) = iprot.readMapBegin()
-            for _i41 in xrange(_size37):
-              _key42 = iprot.readString();
-              _val43 = iprot.readString();
-              _val36[_key42] = _val43
-            iprot.readMapEnd()
-            self.arbitraryDataMapMap[_key35] = _val36
-          iprot.readMapEnd()
-        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('ThriftEventBundle')
-    if self.sessionId is not None:
-      oprot.writeFieldBegin('sessionId', TType.STRING, 1)
-      oprot.writeString(self.sessionId)
-      oprot.writeFieldEnd()
-    if self.eventNum is not None:
-      oprot.writeFieldBegin('eventNum', TType.I32, 2)
-      oprot.writeI32(self.eventNum)
-      oprot.writeFieldEnd()
-    if self.intAttributeList is not None:
-      oprot.writeFieldBegin('intAttributeList', TType.LIST, 3)
-      oprot.writeListBegin(TType.I32, len(self.intAttributeList))
-      for iter44 in self.intAttributeList:
-        oprot.writeI32(iter44)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.longAttributeList is not None:
-      oprot.writeFieldBegin('longAttributeList', TType.LIST, 4)
-      oprot.writeListBegin(TType.I64, len(self.longAttributeList))
-      for iter45 in self.longAttributeList:
-        oprot.writeI64(iter45)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.doubleAttributeList is not None:
-      oprot.writeFieldBegin('doubleAttributeList', TType.LIST, 5)
-      oprot.writeListBegin(TType.DOUBLE, len(self.doubleAttributeList))
-      for iter46 in self.doubleAttributeList:
-        oprot.writeDouble(iter46)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.boolAttributeList is not None:
-      oprot.writeFieldBegin('boolAttributeList', TType.LIST, 6)
-      oprot.writeListBegin(TType.BOOL, len(self.boolAttributeList))
-      for iter47 in self.boolAttributeList:
-        oprot.writeBool(iter47)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.stringAttributeList is not None:
-      oprot.writeFieldBegin('stringAttributeList', TType.LIST, 7)
-      oprot.writeListBegin(TType.STRING, len(self.stringAttributeList))
-      for iter48 in self.stringAttributeList:
-        oprot.writeString(iter48)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
-    if self.arbitraryDataMapMap is not None:
-      oprot.writeFieldBegin('arbitraryDataMapMap', TType.MAP, 8)
-      oprot.writeMapBegin(TType.I32, TType.MAP, len(self.arbitraryDataMapMap))
-      for kiter49,viter50 in self.arbitraryDataMapMap.items():
-        oprot.writeI32(kiter49)
-        oprot.writeMapBegin(TType.STRING, TType.STRING, len(viter50))
-        for kiter51,viter52 in viter50.items():
-          oprot.writeString(kiter51)
-          oprot.writeString(viter52)
-        oprot.writeMapEnd()
-      oprot.writeMapEnd()
-      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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
deleted file mode 100644
index adefd8e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
deleted file mode 100644
index 35216c6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/constants.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# 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 ttypes import *
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
deleted file mode 100644
index c69fb5e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/Exception/ttypes.py
+++ /dev/null
@@ -1,473 +0,0 @@
-#
-# 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 thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-
-class ThriftStreamDefinitionException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftStreamDefinitionException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftNoStreamDefinitionExistException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftNoStreamDefinitionExistException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftDifferentStreamDefinitionAlreadyDefinedException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftDifferentStreamDefinitionAlreadyDefinedException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftMalformedStreamDefinitionException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftMalformedStreamDefinitionException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftUndefinedEventTypeException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftUndefinedEventTypeException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftSessionExpiredException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftSessionExpiredException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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 ThriftAuthenticationException(TException):
-  """
-  Attributes:
-   - message
-  """
-
-  thrift_spec = (
-    None, # 0
-    (1, TType.STRING, 'message', None, None, ), # 1
-  )
-
-  def __init__(self, message=None,):
-    self.message = message
-
-  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.message = 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('ThriftAuthenticationException')
-    if self.message is not None:
-      oprot.writeFieldBegin('message', TType.STRING, 1)
-      oprot.writeString(self.message)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  def validate(self):
-    if self.message is None:
-      raise TProtocol.TProtocolException(message='Required field message is unset!')
-    return
-
-
-  def __str__(self):
-    return repr(self)
-
-  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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
deleted file mode 100755
index d17fbcc..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService-remote
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env python
-#
-# Autogenerated by Thrift Compiler (0.9.1)
-#
-# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-#
-#  options string: py
-#
-
-import sys
-import pprint
-from urlparse import urlparse
-from thrift.transport import TTransport
-from thrift.transport import TSocket
-from thrift.transport import THttpClient
-from thrift.protocol import TBinaryProtocol
-
-from ThriftEventTransmissionService import ThriftEventTransmissionService
-from ThriftEventTransmissionService.ttypes import *
-
-if len(sys.argv) <= 1 or sys.argv[1] == '--help':
-  print ''
-  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
-  print ''
-  print 'Functions:'
-  print '  string defineStream(string sessionId, string streamDefinition)'
-  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
-  print '  void publish(ThriftEventBundle eventBundle)'
-  print '  bool deleteStreamById(string sessionId, string streamId)'
-  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
-  print ''
-  sys.exit(0)
-
-pp = pprint.PrettyPrinter(indent = 2)
-host = 'localhost'
-port = 9090
-uri = ''
-framed = False
-http = False
-argi = 1
-
-if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  argi += 2
-
-if sys.argv[argi] == '-u':
-  url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  else:
-    port = 80
-  uri = url[2]
-  if url[4]:
-    uri += '?%s' % url[4]
-  http = True
-  argi += 2
-
-if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
-  framed = True
-  argi += 1
-
-cmd = sys.argv[argi]
-args = sys.argv[argi+1:]
-
-if http:
-  transport = THttpClient.THttpClient(host, port, uri)
-else:
-  socket = TSocket.TSocket(host, port)
-  if framed:
-    transport = TTransport.TFramedTransport(socket)
-  else:
-    transport = TTransport.TBufferedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(transport)
-client = ThriftEventTransmissionService.Client(protocol)
-transport.open()
-
-if cmd == 'defineStream':
-  if len(args) != 2:
-    print 'defineStream requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.defineStream(args[0],args[1],))
-
-elif cmd == 'findStreamId':
-  if len(args) != 3:
-    print 'findStreamId requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
-
-elif cmd == 'publish':
-  if len(args) != 1:
-    print 'publish requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.publish(eval(args[0]),))
-
-elif cmd == 'deleteStreamById':
-  if len(args) != 2:
-    print 'deleteStreamById requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamById(args[0],args[1],))
-
-elif cmd == 'deleteStreamByNameVersion':
-  if len(args) != 3:
-    print 'deleteStreamByNameVersion requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
-
-else:
-  print 'Unrecognized method %s' % cmd
-  sys.exit(1)
-
-transport.close()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
deleted file mode 100644
index c5994d7..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ThriftEventTransmissionService.py
+++ /dev/null
@@ -1,1144 +0,0 @@
-#
-# 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 ttypes import *
-from thrift.Thrift import TProcessor
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-try:
-  from thrift.protocol import fastbinary
-except:
-  fastbinary = None
-
-
-class Iface:
-  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 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["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_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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
-      result.ade = ade
-    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
-      result.mtd = mtd
-    except Exception.ttypes.ThriftStreamDefinitionException, tde:
-      result.tde = tde
-    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
-      result.tnde = tnde
-    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
-      result.ue = ue
-    except Exception.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 Exception.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 Exception.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 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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
-    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
-    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
-          self.ade.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
-          self.mtd.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.STRUCT:
-          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
-          self.tde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
-          self.tnde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
-          self.ue.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
deleted file mode 100644
index 38575a6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants', 'ThriftEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
deleted file mode 100644
index 35216c6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/constants.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# 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 ttypes import *
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py
deleted file mode 100644
index a0727f8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftEventTransmissionService/ttypes.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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
-import Data.ttypes
-import Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
deleted file mode 100755
index 2187bfa..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService-remote
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-#
-# Autogenerated by Thrift Compiler (0.9.1)
-#
-# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-#
-#  options string: py
-#
-
-import sys
-import pprint
-from urlparse import urlparse
-from thrift.transport import TTransport
-from thrift.transport import TSocket
-from thrift.transport import THttpClient
-from thrift.protocol import TBinaryProtocol
-
-from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
-from ThriftSecureEventTransmissionService.ttypes import *
-
-if len(sys.argv) <= 1 or sys.argv[1] == '--help':
-  print ''
-  print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
-  print ''
-  print 'Functions:'
-  print '  string connect(string userName, string password)'
-  print '  void disconnect(string sessionId)'
-  print '  string defineStream(string sessionId, string streamDefinition)'
-  print '  string findStreamId(string sessionId, string streamName, string streamVersion)'
-  print '  void publish(ThriftEventBundle eventBundle)'
-  print '  bool deleteStreamById(string sessionId, string streamId)'
-  print '  bool deleteStreamByNameVersion(string sessionId, string streamName, string streamVersion)'
-  print ''
-  sys.exit(0)
-
-pp = pprint.PrettyPrinter(indent = 2)
-host = 'localhost'
-port = 9090
-uri = ''
-framed = False
-http = False
-argi = 1
-
-if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  argi += 2
-
-if sys.argv[argi] == '-u':
-  url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':')
-  host = parts[0]
-  if len(parts) > 1:
-    port = int(parts[1])
-  else:
-    port = 80
-  uri = url[2]
-  if url[4]:
-    uri += '?%s' % url[4]
-  http = True
-  argi += 2
-
-if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
-  framed = True
-  argi += 1
-
-cmd = sys.argv[argi]
-args = sys.argv[argi+1:]
-
-if http:
-  transport = THttpClient.THttpClient(host, port, uri)
-else:
-  socket = TSocket.TSocket(host, port)
-  if framed:
-    transport = TTransport.TFramedTransport(socket)
-  else:
-    transport = TTransport.TBufferedTransport(socket)
-protocol = TBinaryProtocol.TBinaryProtocol(transport)
-client = ThriftSecureEventTransmissionService.Client(protocol)
-transport.open()
-
-if cmd == 'connect':
-  if len(args) != 2:
-    print 'connect requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.connect(args[0],args[1],))
-
-elif cmd == 'disconnect':
-  if len(args) != 1:
-    print 'disconnect requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.disconnect(args[0],))
-
-elif cmd == 'defineStream':
-  if len(args) != 2:
-    print 'defineStream requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.defineStream(args[0],args[1],))
-
-elif cmd == 'findStreamId':
-  if len(args) != 3:
-    print 'findStreamId requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.findStreamId(args[0],args[1],args[2],))
-
-elif cmd == 'publish':
-  if len(args) != 1:
-    print 'publish requires 1 args'
-    sys.exit(1)
-  pp.pprint(client.publish(eval(args[0]),))
-
-elif cmd == 'deleteStreamById':
-  if len(args) != 2:
-    print 'deleteStreamById requires 2 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamById(args[0],args[1],))
-
-elif cmd == 'deleteStreamByNameVersion':
-  if len(args) != 3:
-    print 'deleteStreamByNameVersion requires 3 args'
-    sys.exit(1)
-  pp.pprint(client.deleteStreamByNameVersion(args[0],args[1],args[2],))
-
-else:
-  print 'Unrecognized method %s' % cmd
-  sys.exit(1)
-
-transport.close()


[49/50] [abbrv] git commit: Fixed issue in member started event extension method0

Posted by ni...@apache.org.
Fixed issue in member started event extension method0


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5408bb76
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5408bb76
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5408bb76

Branch: refs/heads/master
Commit: 5408bb7677f096df02618e38e890def7b052f624
Parents: 2891c08
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 23:41:56 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 23:41:56 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/modules/extensions/defaultextensionhandler.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/5408bb76/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 1884f83..c22266f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -377,7 +377,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
         service = topology.get_service(member_started_event.service_name)
         cluster = service.get_cluster(member_started_event.cluster_id)
         started_member = cluster.get_member(member_started_event.member_id)
-        lb_cluster_id = cluster.get_member(member_started_event.cluster_id).lb_cluster_id
+        lb_cluster_id = cluster.get_member(member_started_event.member_id).lb_cluster_id
 
         #check whether started member is within the same cluster, LB cluster or service group
         if extensionutils.is_relevant_member_event(


[09/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
deleted file mode 100644
index cdec607..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TCompactProtocol.py
+++ /dev/null
@@ -1,403 +0,0 @@
-#
-# 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 TProtocol import *
-from struct import pack, unpack
-
-__all__ = ['TCompactProtocol', 'TCompactProtocolFactory']
-
-CLEAR = 0
-FIELD_WRITE = 1
-VALUE_WRITE = 2
-CONTAINER_WRITE = 3
-BOOL_WRITE = 4
-FIELD_READ = 5
-CONTAINER_READ = 6
-VALUE_READ = 7
-BOOL_READ = 8
-
-
-def make_helper(v_from, container):
-  def helper(func):
-    def nested(self, *args, **kwargs):
-      assert self.state in (v_from, container), (self.state, v_from, container)
-      return func(self, *args, **kwargs)
-    return nested
-  return helper
-writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
-reader = make_helper(VALUE_READ, CONTAINER_READ)
-
-
-def makeZigZag(n, bits):
-  return (n << 1) ^ (n >> (bits - 1))
-
-
-def fromZigZag(n):
-  return (n >> 1) ^ -(n & 1)
-
-
-def writeVarint(trans, n):
-  out = []
-  while True:
-    if n & ~0x7f == 0:
-      out.append(n)
-      break
-    else:
-      out.append((n & 0xff) | 0x80)
-      n = n >> 7
-  trans.write(''.join(map(chr, out)))
-
-
-def readVarint(trans):
-  result = 0
-  shift = 0
-  while True:
-    x = trans.readAll(1)
-    byte = ord(x)
-    result |= (byte & 0x7f) << shift
-    if byte >> 7 == 0:
-      return result
-    shift += 7
-
-
-class CompactType:
-  STOP = 0x00
-  TRUE = 0x01
-  FALSE = 0x02
-  BYTE = 0x03
-  I16 = 0x04
-  I32 = 0x05
-  I64 = 0x06
-  DOUBLE = 0x07
-  BINARY = 0x08
-  LIST = 0x09
-  SET = 0x0A
-  MAP = 0x0B
-  STRUCT = 0x0C
-
-CTYPES = {TType.STOP: CompactType.STOP,
-          TType.BOOL: CompactType.TRUE,  # used for collection
-          TType.BYTE: CompactType.BYTE,
-          TType.I16: CompactType.I16,
-          TType.I32: CompactType.I32,
-          TType.I64: CompactType.I64,
-          TType.DOUBLE: CompactType.DOUBLE,
-          TType.STRING: CompactType.BINARY,
-          TType.STRUCT: CompactType.STRUCT,
-          TType.LIST: CompactType.LIST,
-          TType.SET: CompactType.SET,
-          TType.MAP: CompactType.MAP
-          }
-
-TTYPES = {}
-for k, v in CTYPES.items():
-  TTYPES[v] = k
-TTYPES[CompactType.FALSE] = TType.BOOL
-del k
-del v
-
-
-class TCompactProtocol(TProtocolBase):
-  """Compact implementation of the Thrift protocol driver."""
-
-  PROTOCOL_ID = 0x82
-  VERSION = 1
-  VERSION_MASK = 0x1f
-  TYPE_MASK = 0xe0
-  TYPE_SHIFT_AMOUNT = 5
-
-  def __init__(self, trans):
-    TProtocolBase.__init__(self, trans)
-    self.state = CLEAR
-    self.__last_fid = 0
-    self.__bool_fid = None
-    self.__bool_value = None
-    self.__structs = []
-    self.__containers = []
-
-  def __writeVarint(self, n):
-    writeVarint(self.trans, n)
-
-  def writeMessageBegin(self, name, type, seqid):
-    assert self.state == CLEAR
-    self.__writeUByte(self.PROTOCOL_ID)
-    self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
-    self.__writeVarint(seqid)
-    self.__writeString(name)
-    self.state = VALUE_WRITE
-
-  def writeMessageEnd(self):
-    assert self.state == VALUE_WRITE
-    self.state = CLEAR
-
-  def writeStructBegin(self, name):
-    assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
-    self.__structs.append((self.state, self.__last_fid))
-    self.state = FIELD_WRITE
-    self.__last_fid = 0
-
-  def writeStructEnd(self):
-    assert self.state == FIELD_WRITE
-    self.state, self.__last_fid = self.__structs.pop()
-
-  def writeFieldStop(self):
-    self.__writeByte(0)
-
-  def __writeFieldHeader(self, type, fid):
-    delta = fid - self.__last_fid
-    if 0 < delta <= 15:
-      self.__writeUByte(delta << 4 | type)
-    else:
-      self.__writeByte(type)
-      self.__writeI16(fid)
-    self.__last_fid = fid
-
-  def writeFieldBegin(self, name, type, fid):
-    assert self.state == FIELD_WRITE, self.state
-    if type == TType.BOOL:
-      self.state = BOOL_WRITE
-      self.__bool_fid = fid
-    else:
-      self.state = VALUE_WRITE
-      self.__writeFieldHeader(CTYPES[type], fid)
-
-  def writeFieldEnd(self):
-    assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
-    self.state = FIELD_WRITE
-
-  def __writeUByte(self, byte):
-    self.trans.write(pack('!B', byte))
-
-  def __writeByte(self, byte):
-    self.trans.write(pack('!b', byte))
-
-  def __writeI16(self, i16):
-    self.__writeVarint(makeZigZag(i16, 16))
-
-  def __writeSize(self, i32):
-    self.__writeVarint(i32)
-
-  def writeCollectionBegin(self, etype, size):
-    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
-    if size <= 14:
-      self.__writeUByte(size << 4 | CTYPES[etype])
-    else:
-      self.__writeUByte(0xf0 | CTYPES[etype])
-      self.__writeSize(size)
-    self.__containers.append(self.state)
-    self.state = CONTAINER_WRITE
-  writeSetBegin = writeCollectionBegin
-  writeListBegin = writeCollectionBegin
-
-  def writeMapBegin(self, ktype, vtype, size):
-    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
-    if size == 0:
-      self.__writeByte(0)
-    else:
-      self.__writeSize(size)
-      self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
-    self.__containers.append(self.state)
-    self.state = CONTAINER_WRITE
-
-  def writeCollectionEnd(self):
-    assert self.state == CONTAINER_WRITE, self.state
-    self.state = self.__containers.pop()
-  writeMapEnd = writeCollectionEnd
-  writeSetEnd = writeCollectionEnd
-  writeListEnd = writeCollectionEnd
-
-  def writeBool(self, bool):
-    if self.state == BOOL_WRITE:
-      if bool:
-        ctype = CompactType.TRUE
-      else:
-        ctype = CompactType.FALSE
-      self.__writeFieldHeader(ctype, self.__bool_fid)
-    elif self.state == CONTAINER_WRITE:
-      if bool:
-        self.__writeByte(CompactType.TRUE)
-      else:
-        self.__writeByte(CompactType.FALSE)
-    else:
-      raise AssertionError("Invalid state in compact protocol")
-
-  writeByte = writer(__writeByte)
-  writeI16 = writer(__writeI16)
-
-  @writer
-  def writeI32(self, i32):
-    self.__writeVarint(makeZigZag(i32, 32))
-
-  @writer
-  def writeI64(self, i64):
-    self.__writeVarint(makeZigZag(i64, 64))
-
-  @writer
-  def writeDouble(self, dub):
-    self.trans.write(pack('!d', dub))
-
-  def __writeString(self, s):
-    self.__writeSize(len(s))
-    self.trans.write(s)
-  writeString = writer(__writeString)
-
-  def readFieldBegin(self):
-    assert self.state == FIELD_READ, self.state
-    type = self.__readUByte()
-    if type & 0x0f == TType.STOP:
-      return (None, 0, 0)
-    delta = type >> 4
-    if delta == 0:
-      fid = self.__readI16()
-    else:
-      fid = self.__last_fid + delta
-    self.__last_fid = fid
-    type = type & 0x0f
-    if type == CompactType.TRUE:
-      self.state = BOOL_READ
-      self.__bool_value = True
-    elif type == CompactType.FALSE:
-      self.state = BOOL_READ
-      self.__bool_value = False
-    else:
-      self.state = VALUE_READ
-    return (None, self.__getTType(type), fid)
-
-  def readFieldEnd(self):
-    assert self.state in (VALUE_READ, BOOL_READ), self.state
-    self.state = FIELD_READ
-
-  def __readUByte(self):
-    result, = unpack('!B', self.trans.readAll(1))
-    return result
-
-  def __readByte(self):
-    result, = unpack('!b', self.trans.readAll(1))
-    return result
-
-  def __readVarint(self):
-    return readVarint(self.trans)
-
-  def __readZigZag(self):
-    return fromZigZag(self.__readVarint())
-
-  def __readSize(self):
-    result = self.__readVarint()
-    if result < 0:
-      raise TException("Length < 0")
-    return result
-
-  def readMessageBegin(self):
-    assert self.state == CLEAR
-    proto_id = self.__readUByte()
-    if proto_id != self.PROTOCOL_ID:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-          'Bad protocol id in the message: %d' % proto_id)
-    ver_type = self.__readUByte()
-    type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT
-    version = ver_type & self.VERSION_MASK
-    if version != self.VERSION:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-          'Bad version: %d (expect %d)' % (version, self.VERSION))
-    seqid = self.__readVarint()
-    name = self.__readString()
-    return (name, type, seqid)
-
-  def readMessageEnd(self):
-    assert self.state == CLEAR
-    assert len(self.__structs) == 0
-
-  def readStructBegin(self):
-    assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
-    self.__structs.append((self.state, self.__last_fid))
-    self.state = FIELD_READ
-    self.__last_fid = 0
-
-  def readStructEnd(self):
-    assert self.state == FIELD_READ
-    self.state, self.__last_fid = self.__structs.pop()
-
-  def readCollectionBegin(self):
-    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
-    size_type = self.__readUByte()
-    size = size_type >> 4
-    type = self.__getTType(size_type)
-    if size == 15:
-      size = self.__readSize()
-    self.__containers.append(self.state)
-    self.state = CONTAINER_READ
-    return type, size
-  readSetBegin = readCollectionBegin
-  readListBegin = readCollectionBegin
-
-  def readMapBegin(self):
-    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
-    size = self.__readSize()
-    types = 0
-    if size > 0:
-      types = self.__readUByte()
-    vtype = self.__getTType(types)
-    ktype = self.__getTType(types >> 4)
-    self.__containers.append(self.state)
-    self.state = CONTAINER_READ
-    return (ktype, vtype, size)
-
-  def readCollectionEnd(self):
-    assert self.state == CONTAINER_READ, self.state
-    self.state = self.__containers.pop()
-  readSetEnd = readCollectionEnd
-  readListEnd = readCollectionEnd
-  readMapEnd = readCollectionEnd
-
-  def readBool(self):
-    if self.state == BOOL_READ:
-      return self.__bool_value == CompactType.TRUE
-    elif self.state == CONTAINER_READ:
-      return self.__readByte() == CompactType.TRUE
-    else:
-      raise AssertionError("Invalid state in compact protocol: %d" %
-                           self.state)
-
-  readByte = reader(__readByte)
-  __readI16 = __readZigZag
-  readI16 = reader(__readZigZag)
-  readI32 = reader(__readZigZag)
-  readI64 = reader(__readZigZag)
-
-  @reader
-  def readDouble(self):
-    buff = self.trans.readAll(8)
-    val, = unpack('!d', buff)
-    return val
-
-  def __readString(self):
-    len = self.__readSize()
-    return self.trans.readAll(len)
-  readString = reader(__readString)
-
-  def __getTType(self, byte):
-    return TTYPES[byte & 0x0f]
-
-
-class TCompactProtocolFactory:
-  def __init__(self):
-    pass
-
-  def getProtocol(self, trans):
-    return TCompactProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
deleted file mode 100644
index 3048197..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TJSONProtocol.py
+++ /dev/null
@@ -1,550 +0,0 @@
-#
-# 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 TProtocol import TType, TProtocolBase, TProtocolException
-import base64
-import json
-import math
-
-__all__ = ['TJSONProtocol',
-           'TJSONProtocolFactory',
-           'TSimpleJSONProtocol',
-           'TSimpleJSONProtocolFactory']
-
-VERSION = 1
-
-COMMA = ','
-COLON = ':'
-LBRACE = '{'
-RBRACE = '}'
-LBRACKET = '['
-RBRACKET = ']'
-QUOTE = '"'
-BACKSLASH = '\\'
-ZERO = '0'
-
-ESCSEQ = '\\u00'
-ESCAPE_CHAR = '"\\bfnrt'
-ESCAPE_CHAR_VALS = ['"', '\\', '\b', '\f', '\n', '\r', '\t']
-NUMERIC_CHAR = '+-.0123456789Ee'
-
-CTYPES = {TType.BOOL:       'tf',
-          TType.BYTE:       'i8',
-          TType.I16:        'i16',
-          TType.I32:        'i32',
-          TType.I64:        'i64',
-          TType.DOUBLE:     'dbl',
-          TType.STRING:     'str',
-          TType.STRUCT:     'rec',
-          TType.LIST:       'lst',
-          TType.SET:        'set',
-          TType.MAP:        'map'}
-
-JTYPES = {}
-for key in CTYPES.keys():
-  JTYPES[CTYPES[key]] = key
-
-
-class JSONBaseContext(object):
-
-  def __init__(self, protocol):
-    self.protocol = protocol
-    self.first = True
-
-  def doIO(self, function):
-    pass
-  
-  def write(self):
-    pass
-
-  def read(self):
-    pass
-
-  def escapeNum(self):
-    return False
-
-  def __str__(self):
-    return self.__class__.__name__
-
-
-class JSONListContext(JSONBaseContext):
-    
-  def doIO(self, function):
-    if self.first is True:
-      self.first = False
-    else:
-      function(COMMA)
-
-  def write(self):
-    self.doIO(self.protocol.trans.write)
-
-  def read(self):
-    self.doIO(self.protocol.readJSONSyntaxChar)
-
-
-class JSONPairContext(JSONBaseContext):
-  
-  def __init__(self, protocol):
-    super(JSONPairContext, self).__init__(protocol)
-    self.colon = True
-
-  def doIO(self, function):
-    if self.first:
-      self.first = False
-      self.colon = True
-    else:
-      function(COLON if self.colon else COMMA)
-      self.colon = not self.colon
-
-  def write(self):
-    self.doIO(self.protocol.trans.write)
-
-  def read(self):
-    self.doIO(self.protocol.readJSONSyntaxChar)
-
-  def escapeNum(self):
-    return self.colon
-
-  def __str__(self):
-    return '%s, colon=%s' % (self.__class__.__name__, self.colon)
-
-
-class LookaheadReader():
-  hasData = False
-  data = ''
-
-  def __init__(self, protocol):
-    self.protocol = protocol
-
-  def read(self):
-    if self.hasData is True:
-      self.hasData = False
-    else:
-      self.data = self.protocol.trans.read(1)
-    return self.data
-
-  def peek(self):
-    if self.hasData is False:
-      self.data = self.protocol.trans.read(1)
-    self.hasData = True
-    return self.data
-
-class TJSONProtocolBase(TProtocolBase):
-
-  def __init__(self, trans):
-    TProtocolBase.__init__(self, trans)
-    self.resetWriteContext()
-    self.resetReadContext()
-
-  def resetWriteContext(self):
-    self.context = JSONBaseContext(self)
-    self.contextStack = [self.context]
-
-  def resetReadContext(self):
-    self.resetWriteContext()
-    self.reader = LookaheadReader(self)
-
-  def pushContext(self, ctx):
-    self.contextStack.append(ctx)
-    self.context = ctx
-
-  def popContext(self):
-    self.contextStack.pop()
-    if self.contextStack:
-      self.context = self.contextStack[-1]
-    else:
-      self.context = JSONBaseContext(self)
-
-  def writeJSONString(self, string):
-    self.context.write()
-    self.trans.write(json.dumps(string))
-
-  def writeJSONNumber(self, number):
-    self.context.write()
-    jsNumber = str(number)
-    if self.context.escapeNum():
-      jsNumber = "%s%s%s" % (QUOTE, jsNumber,  QUOTE)
-    self.trans.write(jsNumber)
-
-  def writeJSONBase64(self, binary):
-    self.context.write()
-    self.trans.write(QUOTE)
-    self.trans.write(base64.b64encode(binary))
-    self.trans.write(QUOTE)
-
-  def writeJSONObjectStart(self):
-    self.context.write()
-    self.trans.write(LBRACE)
-    self.pushContext(JSONPairContext(self))
-
-  def writeJSONObjectEnd(self):
-    self.popContext()
-    self.trans.write(RBRACE)
-
-  def writeJSONArrayStart(self):
-    self.context.write()
-    self.trans.write(LBRACKET)
-    self.pushContext(JSONListContext(self))
-
-  def writeJSONArrayEnd(self):
-    self.popContext()
-    self.trans.write(RBRACKET)
-
-  def readJSONSyntaxChar(self, character):
-    current = self.reader.read()
-    if character != current:
-      raise TProtocolException(TProtocolException.INVALID_DATA,
-                               "Unexpected character: %s" % current)
-
-  def readJSONString(self, skipContext):
-    string = []
-    if skipContext is False:
-      self.context.read()
-    self.readJSONSyntaxChar(QUOTE)
-    while True:
-      character = self.reader.read()
-      if character == QUOTE:
-        break
-      if character == ESCSEQ[0]:
-        character = self.reader.read()
-        if character == ESCSEQ[1]:
-          self.readJSONSyntaxChar(ZERO)
-          self.readJSONSyntaxChar(ZERO)
-          character = json.JSONDecoder().decode('"\u00%s"' % self.trans.read(2))
-        else:
-          off = ESCAPE_CHAR.find(character)
-          if off == -1:
-            raise TProtocolException(TProtocolException.INVALID_DATA,
-                                     "Expected control char")
-          character = ESCAPE_CHAR_VALS[off]
-      string.append(character)
-    return ''.join(string)
-
-  def isJSONNumeric(self, character):
-    return (True if NUMERIC_CHAR.find(character) != - 1 else False)
-
-  def readJSONQuotes(self):
-    if (self.context.escapeNum()):
-      self.readJSONSyntaxChar(QUOTE)
-
-  def readJSONNumericChars(self):
-    numeric = []
-    while True:
-      character = self.reader.peek()
-      if self.isJSONNumeric(character) is False:
-        break
-      numeric.append(self.reader.read())
-    return ''.join(numeric)
-
-  def readJSONInteger(self):
-    self.context.read()
-    self.readJSONQuotes()
-    numeric = self.readJSONNumericChars()
-    self.readJSONQuotes()
-    try:
-      return int(numeric)
-    except ValueError:
-      raise TProtocolException(TProtocolException.INVALID_DATA,
-                               "Bad data encounted in numeric data")
-
-  def readJSONDouble(self):
-    self.context.read()
-    if self.reader.peek() == QUOTE:
-      string  = self.readJSONString(True)
-      try:
-        double = float(string)
-        if (self.context.escapeNum is False and
-            not math.isinf(double) and
-            not math.isnan(double)):
-          raise TProtocolException(TProtocolException.INVALID_DATA,
-                                   "Numeric data unexpectedly quoted")
-        return double
-      except ValueError:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Bad data encounted in numeric data")
-    else:
-      if self.context.escapeNum() is True:
-        self.readJSONSyntaxChar(QUOTE)
-      try:
-        return float(self.readJSONNumericChars())
-      except ValueError:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Bad data encounted in numeric data")
-
-  def readJSONBase64(self):
-    string = self.readJSONString(False)
-    return base64.b64decode(string)
-
-  def readJSONObjectStart(self):
-    self.context.read()
-    self.readJSONSyntaxChar(LBRACE)
-    self.pushContext(JSONPairContext(self))
-
-  def readJSONObjectEnd(self):
-    self.readJSONSyntaxChar(RBRACE)
-    self.popContext()
-
-  def readJSONArrayStart(self):
-    self.context.read()
-    self.readJSONSyntaxChar(LBRACKET)
-    self.pushContext(JSONListContext(self))
-
-  def readJSONArrayEnd(self):
-    self.readJSONSyntaxChar(RBRACKET)
-    self.popContext()
-
-
-class TJSONProtocol(TJSONProtocolBase):
-
-  def readMessageBegin(self):
-    self.resetReadContext()
-    self.readJSONArrayStart()
-    if self.readJSONInteger() != VERSION:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-                               "Message contained bad version.")
-    name = self.readJSONString(False)
-    typen = self.readJSONInteger()
-    seqid = self.readJSONInteger()
-    return (name, typen, seqid)
-
-  def readMessageEnd(self):
-    self.readJSONArrayEnd()
-
-  def readStructBegin(self):
-    self.readJSONObjectStart()
-
-  def readStructEnd(self):
-    self.readJSONObjectEnd()
-
-  def readFieldBegin(self):
-    character = self.reader.peek()
-    ttype = 0
-    id = 0
-    if character == RBRACE:
-      ttype = TType.STOP
-    else:
-      id = self.readJSONInteger()
-      self.readJSONObjectStart()
-      ttype = JTYPES[self.readJSONString(False)]
-    return (None, ttype, id)
-
-  def readFieldEnd(self):
-    self.readJSONObjectEnd()
-
-  def readMapBegin(self):
-    self.readJSONArrayStart()
-    keyType = JTYPES[self.readJSONString(False)]
-    valueType = JTYPES[self.readJSONString(False)]
-    size = self.readJSONInteger()
-    self.readJSONObjectStart()
-    return (keyType, valueType, size)
-
-  def readMapEnd(self):
-    self.readJSONObjectEnd()
-    self.readJSONArrayEnd()
-
-  def readCollectionBegin(self):
-    self.readJSONArrayStart()
-    elemType = JTYPES[self.readJSONString(False)]
-    size = self.readJSONInteger()
-    return (elemType, size)
-  readListBegin = readCollectionBegin
-  readSetBegin = readCollectionBegin
-
-  def readCollectionEnd(self):
-    self.readJSONArrayEnd()
-  readSetEnd = readCollectionEnd
-  readListEnd = readCollectionEnd
-
-  def readBool(self):
-    return (False if self.readJSONInteger() == 0 else True)
-
-  def readNumber(self):
-    return self.readJSONInteger()
-  readByte = readNumber
-  readI16 = readNumber
-  readI32 = readNumber
-  readI64 = readNumber
-
-  def readDouble(self):
-    return self.readJSONDouble()
-
-  def readString(self):
-    return self.readJSONString(False)
-
-  def readBinary(self):
-    return self.readJSONBase64()
-
-  def writeMessageBegin(self, name, request_type, seqid):
-    self.resetWriteContext()
-    self.writeJSONArrayStart()
-    self.writeJSONNumber(VERSION)
-    self.writeJSONString(name)
-    self.writeJSONNumber(request_type)
-    self.writeJSONNumber(seqid)
-
-  def writeMessageEnd(self):
-    self.writeJSONArrayEnd()
-
-  def writeStructBegin(self, name):
-    self.writeJSONObjectStart()
-
-  def writeStructEnd(self):
-    self.writeJSONObjectEnd()
-
-  def writeFieldBegin(self, name, ttype, id):
-    self.writeJSONNumber(id)
-    self.writeJSONObjectStart()
-    self.writeJSONString(CTYPES[ttype])
-
-  def writeFieldEnd(self):
-    self.writeJSONObjectEnd()
-
-  def writeFieldStop(self):
-    pass
-
-  def writeMapBegin(self, ktype, vtype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[ktype])
-    self.writeJSONString(CTYPES[vtype])
-    self.writeJSONNumber(size)
-    self.writeJSONObjectStart()
-
-  def writeMapEnd(self):
-    self.writeJSONObjectEnd()
-    self.writeJSONArrayEnd()
-    
-  def writeListBegin(self, etype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[etype])
-    self.writeJSONNumber(size)
-    
-  def writeListEnd(self):
-    self.writeJSONArrayEnd()
-
-  def writeSetBegin(self, etype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[etype])
-    self.writeJSONNumber(size)
-    
-  def writeSetEnd(self):
-    self.writeJSONArrayEnd()
-
-  def writeBool(self, boolean):
-    self.writeJSONNumber(1 if boolean is True else 0)
-
-  def writeInteger(self, integer):
-    self.writeJSONNumber(integer)
-  writeByte = writeInteger
-  writeI16 = writeInteger
-  writeI32 = writeInteger
-  writeI64 = writeInteger
-
-  def writeDouble(self, dbl):
-    self.writeJSONNumber(dbl)
-
-  def writeString(self, string):
-    self.writeJSONString(string)
-    
-  def writeBinary(self, binary):
-    self.writeJSONBase64(binary)
-
-
-class TJSONProtocolFactory:
-
-  def getProtocol(self, trans):
-    return TJSONProtocol(trans)
-
-
-class TSimpleJSONProtocol(TJSONProtocolBase):
-    """Simple, readable, write-only JSON protocol.
-    
-    Useful for interacting with scripting languages.
-    """
-
-    def readMessageBegin(self):
-        raise NotImplementedError()
-    
-    def readMessageEnd(self):
-        raise NotImplementedError()
-    
-    def readStructBegin(self):
-        raise NotImplementedError()
-    
-    def readStructEnd(self):
-        raise NotImplementedError()
-    
-    def writeMessageBegin(self, name, request_type, seqid):
-        self.resetWriteContext()
-    
-    def writeMessageEnd(self):
-        pass
-    
-    def writeStructBegin(self, name):
-        self.writeJSONObjectStart()
-    
-    def writeStructEnd(self):
-        self.writeJSONObjectEnd()
-      
-    def writeFieldBegin(self, name, ttype, fid):
-        self.writeJSONString(name)
-    
-    def writeFieldEnd(self):
-        pass
-    
-    def writeMapBegin(self, ktype, vtype, size):
-        self.writeJSONObjectStart()
-    
-    def writeMapEnd(self):
-        self.writeJSONObjectEnd()
-    
-    def _writeCollectionBegin(self, etype, size):
-        self.writeJSONArrayStart()
-    
-    def _writeCollectionEnd(self):
-        self.writeJSONArrayEnd()
-    writeListBegin = _writeCollectionBegin
-    writeListEnd = _writeCollectionEnd
-    writeSetBegin = _writeCollectionBegin
-    writeSetEnd = _writeCollectionEnd
-
-    def writeInteger(self, integer):
-        self.writeJSONNumber(integer)
-    writeByte = writeInteger
-    writeI16 = writeInteger
-    writeI32 = writeInteger
-    writeI64 = writeInteger
-    
-    def writeBool(self, boolean):
-        self.writeJSONNumber(1 if boolean is True else 0)
-
-    def writeDouble(self, dbl):
-        self.writeJSONNumber(dbl)
-    
-    def writeString(self, string):
-        self.writeJSONString(string)
-      
-    def writeBinary(self, binary):
-        self.writeJSONBase64(binary)
-
-
-class TSimpleJSONProtocolFactory(object):
-
-    def getProtocol(self, trans):
-        return TSimpleJSONProtocol(trans)

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
deleted file mode 100644
index dc2b095..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TProtocol.py
+++ /dev/null
@@ -1,406 +0,0 @@
-#
-# 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.Thrift import *
-
-
-class TProtocolException(TException):
-  """Custom Protocol Exception class"""
-
-  UNKNOWN = 0
-  INVALID_DATA = 1
-  NEGATIVE_SIZE = 2
-  SIZE_LIMIT = 3
-  BAD_VERSION = 4
-
-  def __init__(self, type=UNKNOWN, message=None):
-    TException.__init__(self, message)
-    self.type = type
-
-
-class TProtocolBase:
-  """Base class for Thrift protocol driver."""
-
-  def __init__(self, trans):
-    self.trans = trans
-
-  def writeMessageBegin(self, name, ttype, seqid):
-    pass
-
-  def writeMessageEnd(self):
-    pass
-
-  def writeStructBegin(self, name):
-    pass
-
-  def writeStructEnd(self):
-    pass
-
-  def writeFieldBegin(self, name, ttype, fid):
-    pass
-
-  def writeFieldEnd(self):
-    pass
-
-  def writeFieldStop(self):
-    pass
-
-  def writeMapBegin(self, ktype, vtype, size):
-    pass
-
-  def writeMapEnd(self):
-    pass
-
-  def writeListBegin(self, etype, size):
-    pass
-
-  def writeListEnd(self):
-    pass
-
-  def writeSetBegin(self, etype, size):
-    pass
-
-  def writeSetEnd(self):
-    pass
-
-  def writeBool(self, bool_val):
-    pass
-
-  def writeByte(self, byte):
-    pass
-
-  def writeI16(self, i16):
-    pass
-
-  def writeI32(self, i32):
-    pass
-
-  def writeI64(self, i64):
-    pass
-
-  def writeDouble(self, dub):
-    pass
-
-  def writeString(self, str_val):
-    pass
-
-  def readMessageBegin(self):
-    pass
-
-  def readMessageEnd(self):
-    pass
-
-  def readStructBegin(self):
-    pass
-
-  def readStructEnd(self):
-    pass
-
-  def readFieldBegin(self):
-    pass
-
-  def readFieldEnd(self):
-    pass
-
-  def readMapBegin(self):
-    pass
-
-  def readMapEnd(self):
-    pass
-
-  def readListBegin(self):
-    pass
-
-  def readListEnd(self):
-    pass
-
-  def readSetBegin(self):
-    pass
-
-  def readSetEnd(self):
-    pass
-
-  def readBool(self):
-    pass
-
-  def readByte(self):
-    pass
-
-  def readI16(self):
-    pass
-
-  def readI32(self):
-    pass
-
-  def readI64(self):
-    pass
-
-  def readDouble(self):
-    pass
-
-  def readString(self):
-    pass
-
-  def skip(self, ttype):
-    if ttype == TType.STOP:
-      return
-    elif ttype == TType.BOOL:
-      self.readBool()
-    elif ttype == TType.BYTE:
-      self.readByte()
-    elif ttype == TType.I16:
-      self.readI16()
-    elif ttype == TType.I32:
-      self.readI32()
-    elif ttype == TType.I64:
-      self.readI64()
-    elif ttype == TType.DOUBLE:
-      self.readDouble()
-    elif ttype == TType.STRING:
-      self.readString()
-    elif ttype == TType.STRUCT:
-      name = self.readStructBegin()
-      while True:
-        (name, ttype, id) = self.readFieldBegin()
-        if ttype == TType.STOP:
-          break
-        self.skip(ttype)
-        self.readFieldEnd()
-      self.readStructEnd()
-    elif ttype == TType.MAP:
-      (ktype, vtype, size) = self.readMapBegin()
-      for i in xrange(size):
-        self.skip(ktype)
-        self.skip(vtype)
-      self.readMapEnd()
-    elif ttype == TType.SET:
-      (etype, size) = self.readSetBegin()
-      for i in xrange(size):
-        self.skip(etype)
-      self.readSetEnd()
-    elif ttype == TType.LIST:
-      (etype, size) = self.readListBegin()
-      for i in xrange(size):
-        self.skip(etype)
-      self.readListEnd()
-
-  # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
-  _TTYPE_HANDLERS = (
-       (None, None, False),  # 0 TType.STOP
-       (None, None, False),  # 1 TType.VOID # TODO: handle void?
-       ('readBool', 'writeBool', False),  # 2 TType.BOOL
-       ('readByte',  'writeByte', False),  # 3 TType.BYTE and I08
-       ('readDouble', 'writeDouble', False),  # 4 TType.DOUBLE
-       (None, None, False),  # 5 undefined
-       ('readI16', 'writeI16', False),  # 6 TType.I16
-       (None, None, False),  # 7 undefined
-       ('readI32', 'writeI32', False),  # 8 TType.I32
-       (None, None, False),  # 9 undefined
-       ('readI64', 'writeI64', False),  # 10 TType.I64
-       ('readString', 'writeString', False),  # 11 TType.STRING and UTF7
-       ('readContainerStruct', 'writeContainerStruct', True),  # 12 *.STRUCT
-       ('readContainerMap', 'writeContainerMap', True),  # 13 TType.MAP
-       ('readContainerSet', 'writeContainerSet', True),  # 14 TType.SET
-       ('readContainerList', 'writeContainerList', True),  # 15 TType.LIST
-       (None, None, False),  # 16 TType.UTF8 # TODO: handle utf8 types?
-       (None, None, False)  # 17 TType.UTF16 # TODO: handle utf16 types?
-      )
-
-  def readFieldByTType(self, ttype, spec):
-    try:
-      (r_handler, w_handler, is_container) = self._TTYPE_HANDLERS[ttype]
-    except IndexError:
-      raise TProtocolException(type=TProtocolException.INVALID_DATA,
-                               message='Invalid field type %d' % (ttype))
-    if r_handler is None:
-      raise TProtocolException(type=TProtocolException.INVALID_DATA,
-                               message='Invalid field type %d' % (ttype))
-    reader = getattr(self, r_handler)
-    if not is_container:
-      return reader()
-    return reader(spec)
-
-  def readContainerList(self, spec):
-    results = []
-    ttype, tspec = spec[0], spec[1]
-    r_handler = self._TTYPE_HANDLERS[ttype][0]
-    reader = getattr(self, r_handler)
-    (list_type, list_len) = self.readListBegin()
-    if tspec is None:
-      # list values are simple types
-      for idx in xrange(list_len):
-        results.append(reader())
-    else:
-      # this is like an inlined readFieldByTType
-      container_reader = self._TTYPE_HANDLERS[list_type][0]
-      val_reader = getattr(self, container_reader)
-      for idx in xrange(list_len):
-        val = val_reader(tspec)
-        results.append(val)
-    self.readListEnd()
-    return results
-
-  def readContainerSet(self, spec):
-    results = set()
-    ttype, tspec = spec[0], spec[1]
-    r_handler = self._TTYPE_HANDLERS[ttype][0]
-    reader = getattr(self, r_handler)
-    (set_type, set_len) = self.readSetBegin()
-    if tspec is None:
-      # set members are simple types
-      for idx in xrange(set_len):
-        results.add(reader())
-    else:
-      container_reader = self._TTYPE_HANDLERS[set_type][0]
-      val_reader = getattr(self, container_reader)
-      for idx in xrange(set_len):
-        results.add(val_reader(tspec))
-    self.readSetEnd()
-    return results
-
-  def readContainerStruct(self, spec):
-    (obj_class, obj_spec) = spec
-    obj = obj_class()
-    obj.read(self)
-    return obj
-
-  def readContainerMap(self, spec):
-    results = dict()
-    key_ttype, key_spec = spec[0], spec[1]
-    val_ttype, val_spec = spec[2], spec[3]
-    (map_ktype, map_vtype, map_len) = self.readMapBegin()
-    # TODO: compare types we just decoded with thrift_spec and
-    # abort/skip if types disagree
-    key_reader = getattr(self, self._TTYPE_HANDLERS[key_ttype][0])
-    val_reader = getattr(self, self._TTYPE_HANDLERS[val_ttype][0])
-    # list values are simple types
-    for idx in xrange(map_len):
-      if key_spec is None:
-        k_val = key_reader()
-      else:
-        k_val = self.readFieldByTType(key_ttype, key_spec)
-      if val_spec is None:
-        v_val = val_reader()
-      else:
-        v_val = self.readFieldByTType(val_ttype, val_spec)
-      # this raises a TypeError with unhashable keys types
-      # i.e. this fails: d=dict(); d[[0,1]] = 2
-      results[k_val] = v_val
-    self.readMapEnd()
-    return results
-
-  def readStruct(self, obj, thrift_spec):
-    self.readStructBegin()
-    while True:
-      (fname, ftype, fid) = self.readFieldBegin()
-      if ftype == TType.STOP:
-        break
-      try:
-        field = thrift_spec[fid]
-      except IndexError:
-        self.skip(ftype)
-      else:
-        if field is not None and ftype == field[1]:
-          fname = field[2]
-          fspec = field[3]
-          val = self.readFieldByTType(ftype, fspec)
-          setattr(obj, fname, val)
-        else:
-          self.skip(ftype)
-      self.readFieldEnd()
-    self.readStructEnd()
-
-  def writeContainerStruct(self, val, spec):
-    val.write(self)
-
-  def writeContainerList(self, val, spec):
-    self.writeListBegin(spec[0], len(val))
-    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
-    e_writer = getattr(self, w_handler)
-    if not is_container:
-      for elem in val:
-        e_writer(elem)
-    else:
-      for elem in val:
-        e_writer(elem, spec[1])
-    self.writeListEnd()
-
-  def writeContainerSet(self, val, spec):
-    self.writeSetBegin(spec[0], len(val))
-    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]]
-    e_writer = getattr(self, w_handler)
-    if not is_container:
-      for elem in val:
-        e_writer(elem)
-    else:
-      for elem in val:
-        e_writer(elem, spec[1])
-    self.writeSetEnd()
-
-  def writeContainerMap(self, val, spec):
-    k_type = spec[0]
-    v_type = spec[2]
-    ignore, ktype_name, k_is_container = self._TTYPE_HANDLERS[k_type]
-    ignore, vtype_name, v_is_container = self._TTYPE_HANDLERS[v_type]
-    k_writer = getattr(self, ktype_name)
-    v_writer = getattr(self, vtype_name)
-    self.writeMapBegin(k_type, v_type, len(val))
-    for m_key, m_val in val.iteritems():
-      if not k_is_container:
-        k_writer(m_key)
-      else:
-        k_writer(m_key, spec[1])
-      if not v_is_container:
-        v_writer(m_val)
-      else:
-        v_writer(m_val, spec[3])
-    self.writeMapEnd()
-
-  def writeStruct(self, obj, thrift_spec):
-    self.writeStructBegin(obj.__class__.__name__)
-    for field in thrift_spec:
-      if field is None:
-        continue
-      fname = field[2]
-      val = getattr(obj, fname)
-      if val is None:
-        # skip writing out unset fields
-        continue
-      fid = field[0]
-      ftype = field[1]
-      fspec = field[3]
-      # get the writer method for this value
-      self.writeFieldBegin(fname, ftype, fid)
-      self.writeFieldByTType(ftype, val, fspec)
-      self.writeFieldEnd()
-    self.writeFieldStop()
-    self.writeStructEnd()
-
-  def writeFieldByTType(self, ttype, val, spec):
-    r_handler, w_handler, is_container = self._TTYPE_HANDLERS[ttype]
-    writer = getattr(self, w_handler)
-    if is_container:
-      writer(val, spec)
-    else:
-      writer(val)
-
-
-class TProtocolFactory:
-  def getProtocol(self, trans):
-    pass

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py
deleted file mode 100644
index 7eefb45..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# 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__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol', 'TJSONProtocol', 'TProtocol']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
deleted file mode 100644
index 2ce5660..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/fastbinary.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/*
- * 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.
- */
-
-#include <Python.h>
-#include "cStringIO.h"
-#include <stdint.h>
-#ifndef _WIN32
-# include <stdbool.h>
-# include <netinet/in.h>
-#else
-# include <WinSock2.h>
-# pragma comment (lib, "ws2_32.lib")
-# define BIG_ENDIAN (4321)
-# define LITTLE_ENDIAN (1234)
-# define BYTE_ORDER LITTLE_ENDIAN
-# if defined(_MSC_VER) && _MSC_VER < 1600
-   typedef int _Bool;
-#  define bool _Bool
-#  define false 0 
-#  define true 1
-# endif
-# define inline __inline
-#endif
-
-/* Fix endianness issues on Solaris */
-#if defined (__SVR4) && defined (__sun)
- #if defined(__i386) && !defined(__i386__)
-  #define __i386__
- #endif
-
- #ifndef BIG_ENDIAN
-  #define BIG_ENDIAN (4321)
- #endif
- #ifndef LITTLE_ENDIAN
-  #define LITTLE_ENDIAN (1234)
- #endif
-
- /* I386 is LE, even on Solaris */
- #if !defined(BYTE_ORDER) && defined(__i386__)
-  #define BYTE_ORDER LITTLE_ENDIAN
- #endif
-#endif
-
-// TODO(dreiss): defval appears to be unused.  Look into removing it.
-// TODO(dreiss): Make parse_spec_args recursive, and cache the output
-//               permanently in the object.  (Malloc and orphan.)
-// TODO(dreiss): Why do we need cStringIO for reading, why not just char*?
-//               Can cStringIO let us work with a BufferedTransport?
-// TODO(dreiss): Don't ignore the rv from cwrite (maybe).
-
-/* ====== BEGIN UTILITIES ====== */
-
-#define INIT_OUTBUF_SIZE 128
-
-// Stolen out of TProtocol.h.
-// It would be a huge pain to have both get this from one place.
-typedef enum TType {
-  T_STOP       = 0,
-  T_VOID       = 1,
-  T_BOOL       = 2,
-  T_BYTE       = 3,
-  T_I08        = 3,
-  T_I16        = 6,
-  T_I32        = 8,
-  T_U64        = 9,
-  T_I64        = 10,
-  T_DOUBLE     = 4,
-  T_STRING     = 11,
-  T_UTF7       = 11,
-  T_STRUCT     = 12,
-  T_MAP        = 13,
-  T_SET        = 14,
-  T_LIST       = 15,
-  T_UTF8       = 16,
-  T_UTF16      = 17
-} TType;
-
-#ifndef __BYTE_ORDER
-# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
-#  define __BYTE_ORDER BYTE_ORDER
-#  define __LITTLE_ENDIAN LITTLE_ENDIAN
-#  define __BIG_ENDIAN BIG_ENDIAN
-# else
-#  error "Cannot determine endianness"
-# endif
-#endif
-
-// Same comment as the enum.  Sorry.
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define ntohll(n) (n)
-# define htonll(n) (n)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-# if defined(__GNUC__) && defined(__GLIBC__)
-#  include <byteswap.h>
-#  define ntohll(n) bswap_64(n)
-#  define htonll(n) bswap_64(n)
-# else /* GNUC & GLIBC */
-#  define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) )
-#  define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) )
-# endif /* GNUC & GLIBC */
-#else /* __BYTE_ORDER */
-# error "Can't define htonll or ntohll!"
-#endif
-
-// Doing a benchmark shows that interning actually makes a difference, amazingly.
-#define INTERN_STRING(value) _intern_ ## value
-
-#define INT_CONV_ERROR_OCCURRED(v) ( ((v) == -1) && PyErr_Occurred() )
-#define CHECK_RANGE(v, min, max) ( ((v) <= (max)) && ((v) >= (min)) )
-
-// Py_ssize_t was not defined before Python 2.5
-#if (PY_VERSION_HEX < 0x02050000)
-typedef int Py_ssize_t;
-#endif
-
-/**
- * A cache of the spec_args for a set or list,
- * so we don't have to keep calling PyTuple_GET_ITEM.
- */
-typedef struct {
-  TType element_type;
-  PyObject* typeargs;
-} SetListTypeArgs;
-
-/**
- * A cache of the spec_args for a map,
- * so we don't have to keep calling PyTuple_GET_ITEM.
- */
-typedef struct {
-  TType ktag;
-  TType vtag;
-  PyObject* ktypeargs;
-  PyObject* vtypeargs;
-} MapTypeArgs;
-
-/**
- * A cache of the spec_args for a struct,
- * so we don't have to keep calling PyTuple_GET_ITEM.
- */
-typedef struct {
-  PyObject* klass;
-  PyObject* spec;
-} StructTypeArgs;
-
-/**
- * A cache of the item spec from a struct specification,
- * so we don't have to keep calling PyTuple_GET_ITEM.
- */
-typedef struct {
-  int tag;
-  TType type;
-  PyObject* attrname;
-  PyObject* typeargs;
-  PyObject* defval;
-} StructItemSpec;
-
-/**
- * A cache of the two key attributes of a CReadableTransport,
- * so we don't have to keep calling PyObject_GetAttr.
- */
-typedef struct {
-  PyObject* stringiobuf;
-  PyObject* refill_callable;
-} DecodeBuffer;
-
-/** Pointer to interned string to speed up attribute lookup. */
-static PyObject* INTERN_STRING(cstringio_buf);
-/** Pointer to interned string to speed up attribute lookup. */
-static PyObject* INTERN_STRING(cstringio_refill);
-
-static inline bool
-check_ssize_t_32(Py_ssize_t len) {
-  // error from getting the int
-  if (INT_CONV_ERROR_OCCURRED(len)) {
-    return false;
-  }
-  if (!CHECK_RANGE(len, 0, INT32_MAX)) {
-    PyErr_SetString(PyExc_OverflowError, "string size out of range");
-    return false;
-  }
-  return true;
-}
-
-static inline bool
-parse_pyint(PyObject* o, int32_t* ret, int32_t min, int32_t max) {
-  long val = PyInt_AsLong(o);
-
-  if (INT_CONV_ERROR_OCCURRED(val)) {
-    return false;
-  }
-  if (!CHECK_RANGE(val, min, max)) {
-    PyErr_SetString(PyExc_OverflowError, "int out of range");
-    return false;
-  }
-
-  *ret = (int32_t) val;
-  return true;
-}
-
-
-/* --- FUNCTIONS TO PARSE STRUCT SPECIFICATOINS --- */
-
-static bool
-parse_set_list_args(SetListTypeArgs* dest, PyObject* typeargs) {
-  if (PyTuple_Size(typeargs) != 2) {
-    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for list/set type args");
-    return false;
-  }
-
-  dest->element_type = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
-  if (INT_CONV_ERROR_OCCURRED(dest->element_type)) {
-    return false;
-  }
-
-  dest->typeargs = PyTuple_GET_ITEM(typeargs, 1);
-
-  return true;
-}
-
-static bool
-parse_map_args(MapTypeArgs* dest, PyObject* typeargs) {
-  if (PyTuple_Size(typeargs) != 4) {
-    PyErr_SetString(PyExc_TypeError, "expecting 4 arguments for typeargs to map");
-    return false;
-  }
-
-  dest->ktag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 0));
-  if (INT_CONV_ERROR_OCCURRED(dest->ktag)) {
-    return false;
-  }
-
-  dest->vtag = PyInt_AsLong(PyTuple_GET_ITEM(typeargs, 2));
-  if (INT_CONV_ERROR_OCCURRED(dest->vtag)) {
-    return false;
-  }
-
-  dest->ktypeargs = PyTuple_GET_ITEM(typeargs, 1);
-  dest->vtypeargs = PyTuple_GET_ITEM(typeargs, 3);
-
-  return true;
-}
-
-static bool
-parse_struct_args(StructTypeArgs* dest, PyObject* typeargs) {
-  if (PyTuple_Size(typeargs) != 2) {
-    PyErr_SetString(PyExc_TypeError, "expecting tuple of size 2 for struct args");
-    return false;
-  }
-
-  dest->klass = PyTuple_GET_ITEM(typeargs, 0);
-  dest->spec = PyTuple_GET_ITEM(typeargs, 1);
-
-  return true;
-}
-
-static int
-parse_struct_item_spec(StructItemSpec* dest, PyObject* spec_tuple) {
-
-  // i'd like to use ParseArgs here, but it seems to be a bottleneck.
-  if (PyTuple_Size(spec_tuple) != 5) {
-    PyErr_SetString(PyExc_TypeError, "expecting 5 arguments for spec tuple");
-    return false;
-  }
-
-  dest->tag = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 0));
-  if (INT_CONV_ERROR_OCCURRED(dest->tag)) {
-    return false;
-  }
-
-  dest->type = PyInt_AsLong(PyTuple_GET_ITEM(spec_tuple, 1));
-  if (INT_CONV_ERROR_OCCURRED(dest->type)) {
-    return false;
-  }
-
-  dest->attrname = PyTuple_GET_ITEM(spec_tuple, 2);
-  dest->typeargs = PyTuple_GET_ITEM(spec_tuple, 3);
-  dest->defval = PyTuple_GET_ITEM(spec_tuple, 4);
-  return true;
-}
-
-/* ====== END UTILITIES ====== */
-
-
-/* ====== BEGIN WRITING FUNCTIONS ====== */
-
-/* --- LOW-LEVEL WRITING FUNCTIONS --- */
-
-static void writeByte(PyObject* outbuf, int8_t val) {
-  int8_t net = val;
-  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int8_t));
-}
-
-static void writeI16(PyObject* outbuf, int16_t val) {
-  int16_t net = (int16_t)htons(val);
-  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int16_t));
-}
-
-static void writeI32(PyObject* outbuf, int32_t val) {
-  int32_t net = (int32_t)htonl(val);
-  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int32_t));
-}
-
-static void writeI64(PyObject* outbuf, int64_t val) {
-  int64_t net = (int64_t)htonll(val);
-  PycStringIO->cwrite(outbuf, (char*)&net, sizeof(int64_t));
-}
-
-static void writeDouble(PyObject* outbuf, double dub) {
-  // Unfortunately, bitwise_cast doesn't work in C.  Bad C!
-  union {
-    double f;
-    int64_t t;
-  } transfer;
-  transfer.f = dub;
-  writeI64(outbuf, transfer.t);
-}
-
-
-/* --- MAIN RECURSIVE OUTPUT FUCNTION -- */
-
-static int
-output_val(PyObject* output, PyObject* value, TType type, PyObject* typeargs) {
-  /*
-   * Refcounting Strategy:
-   *
-   * We assume that elements of the thrift_spec tuple are not going to be
-   * mutated, so we don't ref count those at all. Other than that, we try to
-   * keep a reference to all the user-created objects while we work with them.
-   * output_val assumes that a reference is already held. The *caller* is
-   * responsible for handling references
-   */
-
-  switch (type) {
-
-  case T_BOOL: {
-    int v = PyObject_IsTrue(value);
-    if (v == -1) {
-      return false;
-    }
-
-    writeByte(output, (int8_t) v);
-    break;
-  }
-  case T_I08: {
-    int32_t val;
-
-    if (!parse_pyint(value, &val, INT8_MIN, INT8_MAX)) {
-      return false;
-    }
-
-    writeByte(output, (int8_t) val);
-    break;
-  }
-  case T_I16: {
-    int32_t val;
-
-    if (!parse_pyint(value, &val, INT16_MIN, INT16_MAX)) {
-      return false;
-    }
-
-    writeI16(output, (int16_t) val);
-    break;
-  }
-  case T_I32: {
-    int32_t val;
-
-    if (!parse_pyint(value, &val, INT32_MIN, INT32_MAX)) {
-      return false;
-    }
-
-    writeI32(output, val);
-    break;
-  }
-  case T_I64: {
-    int64_t nval = PyLong_AsLongLong(value);
-
-    if (INT_CONV_ERROR_OCCURRED(nval)) {
-      return false;
-    }
-
-    if (!CHECK_RANGE(nval, INT64_MIN, INT64_MAX)) {
-      PyErr_SetString(PyExc_OverflowError, "int out of range");
-      return false;
-    }
-
-    writeI64(output, nval);
-    break;
-  }
-
-  case T_DOUBLE: {
-    double nval = PyFloat_AsDouble(value);
-    if (nval == -1.0 && PyErr_Occurred()) {
-      return false;
-    }
-
-    writeDouble(output, nval);
-    break;
-  }
-
-  case T_STRING: {
-    Py_ssize_t len = PyString_Size(value);
-
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    writeI32(output, (int32_t) len);
-    PycStringIO->cwrite(output, PyString_AsString(value), (int32_t) len);
-    break;
-  }
-
-  case T_LIST:
-  case T_SET: {
-    Py_ssize_t len;
-    SetListTypeArgs parsedargs;
-    PyObject *item;
-    PyObject *iterator;
-
-    if (!parse_set_list_args(&parsedargs, typeargs)) {
-      return false;
-    }
-
-    len = PyObject_Length(value);
-
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    writeByte(output, parsedargs.element_type);
-    writeI32(output, (int32_t) len);
-
-    iterator =  PyObject_GetIter(value);
-    if (iterator == NULL) {
-      return false;
-    }
-
-    while ((item = PyIter_Next(iterator))) {
-      if (!output_val(output, item, parsedargs.element_type, parsedargs.typeargs)) {
-        Py_DECREF(item);
-        Py_DECREF(iterator);
-        return false;
-      }
-      Py_DECREF(item);
-    }
-
-    Py_DECREF(iterator);
-
-    if (PyErr_Occurred()) {
-      return false;
-    }
-
-    break;
-  }
-
-  case T_MAP: {
-    PyObject *k, *v;
-    Py_ssize_t pos = 0;
-    Py_ssize_t len;
-
-    MapTypeArgs parsedargs;
-
-    len = PyDict_Size(value);
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    if (!parse_map_args(&parsedargs, typeargs)) {
-      return false;
-    }
-
-    writeByte(output, parsedargs.ktag);
-    writeByte(output, parsedargs.vtag);
-    writeI32(output, len);
-
-    // TODO(bmaurer): should support any mapping, not just dicts
-    while (PyDict_Next(value, &pos, &k, &v)) {
-      // TODO(dreiss): Think hard about whether these INCREFs actually
-      //               turn any unsafe scenarios into safe scenarios.
-      Py_INCREF(k);
-      Py_INCREF(v);
-
-      if (!output_val(output, k, parsedargs.ktag, parsedargs.ktypeargs)
-          || !output_val(output, v, parsedargs.vtag, parsedargs.vtypeargs)) {
-        Py_DECREF(k);
-        Py_DECREF(v);
-        return false;
-      }
-      Py_DECREF(k);
-      Py_DECREF(v);
-    }
-    break;
-  }
-
-  // TODO(dreiss): Consider breaking this out as a function
-  //               the way we did for decode_struct.
-  case T_STRUCT: {
-    StructTypeArgs parsedargs;
-    Py_ssize_t nspec;
-    Py_ssize_t i;
-
-    if (!parse_struct_args(&parsedargs, typeargs)) {
-      return false;
-    }
-
-    nspec = PyTuple_Size(parsedargs.spec);
-
-    if (nspec == -1) {
-      return false;
-    }
-
-    for (i = 0; i < nspec; i++) {
-      StructItemSpec parsedspec;
-      PyObject* spec_tuple;
-      PyObject* instval = NULL;
-
-      spec_tuple = PyTuple_GET_ITEM(parsedargs.spec, i);
-      if (spec_tuple == Py_None) {
-        continue;
-      }
-
-      if (!parse_struct_item_spec (&parsedspec, spec_tuple)) {
-        return false;
-      }
-
-      instval = PyObject_GetAttr(value, parsedspec.attrname);
-
-      if (!instval) {
-        return false;
-      }
-
-      if (instval == Py_None) {
-        Py_DECREF(instval);
-        continue;
-      }
-
-      writeByte(output, (int8_t) parsedspec.type);
-      writeI16(output, parsedspec.tag);
-
-      if (!output_val(output, instval, parsedspec.type, parsedspec.typeargs)) {
-        Py_DECREF(instval);
-        return false;
-      }
-
-      Py_DECREF(instval);
-    }
-
-    writeByte(output, (int8_t)T_STOP);
-    break;
-  }
-
-  case T_STOP:
-  case T_VOID:
-  case T_UTF16:
-  case T_UTF8:
-  case T_U64:
-  default:
-    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
-    return false;
-
-  }
-
-  return true;
-}
-
-
-/* --- TOP-LEVEL WRAPPER FOR OUTPUT -- */
-
-static PyObject *
-encode_binary(PyObject *self, PyObject *args) {
-  PyObject* enc_obj;
-  PyObject* type_args;
-  PyObject* buf;
-  PyObject* ret = NULL;
-
-  if (!PyArg_ParseTuple(args, "OO", &enc_obj, &type_args)) {
-    return NULL;
-  }
-
-  buf = PycStringIO->NewOutput(INIT_OUTBUF_SIZE);
-  if (output_val(buf, enc_obj, T_STRUCT, type_args)) {
-    ret = PycStringIO->cgetvalue(buf);
-  }
-
-  Py_DECREF(buf);
-  return ret;
-}
-
-/* ====== END WRITING FUNCTIONS ====== */
-
-
-/* ====== BEGIN READING FUNCTIONS ====== */
-
-/* --- LOW-LEVEL READING FUNCTIONS --- */
-
-static void
-free_decodebuf(DecodeBuffer* d) {
-  Py_XDECREF(d->stringiobuf);
-  Py_XDECREF(d->refill_callable);
-}
-
-static bool
-decode_buffer_from_obj(DecodeBuffer* dest, PyObject* obj) {
-  dest->stringiobuf = PyObject_GetAttr(obj, INTERN_STRING(cstringio_buf));
-  if (!dest->stringiobuf) {
-    return false;
-  }
-
-  if (!PycStringIO_InputCheck(dest->stringiobuf)) {
-    free_decodebuf(dest);
-    PyErr_SetString(PyExc_TypeError, "expecting stringio input");
-    return false;
-  }
-
-  dest->refill_callable = PyObject_GetAttr(obj, INTERN_STRING(cstringio_refill));
-
-  if(!dest->refill_callable) {
-    free_decodebuf(dest);
-    return false;
-  }
-
-  if (!PyCallable_Check(dest->refill_callable)) {
-    free_decodebuf(dest);
-    PyErr_SetString(PyExc_TypeError, "expecting callable");
-    return false;
-  }
-
-  return true;
-}
-
-static bool readBytes(DecodeBuffer* input, char** output, int len) {
-  int read;
-
-  // TODO(dreiss): Don't fear the malloc.  Think about taking a copy of
-  //               the partial read instead of forcing the transport
-  //               to prepend it to its buffer.
-
-  read = PycStringIO->cread(input->stringiobuf, output, len);
-
-  if (read == len) {
-    return true;
-  } else if (read == -1) {
-    return false;
-  } else {
-    PyObject* newiobuf;
-
-    // using building functions as this is a rare codepath
-    newiobuf = PyObject_CallFunction(
-        input->refill_callable, "s#i", *output, read, len, NULL);
-    if (newiobuf == NULL) {
-      return false;
-    }
-
-    // must do this *AFTER* the call so that we don't deref the io buffer
-    Py_CLEAR(input->stringiobuf);
-    input->stringiobuf = newiobuf;
-
-    read = PycStringIO->cread(input->stringiobuf, output, len);
-
-    if (read == len) {
-      return true;
-    } else if (read == -1) {
-      return false;
-    } else {
-      // TODO(dreiss): This could be a valid code path for big binary blobs.
-      PyErr_SetString(PyExc_TypeError,
-          "refill claimed to have refilled the buffer, but didn't!!");
-      return false;
-    }
-  }
-}
-
-static int8_t readByte(DecodeBuffer* input) {
-  char* buf;
-  if (!readBytes(input, &buf, sizeof(int8_t))) {
-    return -1;
-  }
-
-  return *(int8_t*) buf;
-}
-
-static int16_t readI16(DecodeBuffer* input) {
-  char* buf;
-  if (!readBytes(input, &buf, sizeof(int16_t))) {
-    return -1;
-  }
-
-  return (int16_t) ntohs(*(int16_t*) buf);
-}
-
-static int32_t readI32(DecodeBuffer* input) {
-  char* buf;
-  if (!readBytes(input, &buf, sizeof(int32_t))) {
-    return -1;
-  }
-  return (int32_t) ntohl(*(int32_t*) buf);
-}
-
-
-static int64_t readI64(DecodeBuffer* input) {
-  char* buf;
-  if (!readBytes(input, &buf, sizeof(int64_t))) {
-    return -1;
-  }
-
-  return (int64_t) ntohll(*(int64_t*) buf);
-}
-
-static double readDouble(DecodeBuffer* input) {
-  union {
-    int64_t f;
-    double t;
-  } transfer;
-
-  transfer.f = readI64(input);
-  if (transfer.f == -1) {
-    return -1;
-  }
-  return transfer.t;
-}
-
-static bool
-checkTypeByte(DecodeBuffer* input, TType expected) {
-  TType got = readByte(input);
-  if (INT_CONV_ERROR_OCCURRED(got)) {
-    return false;
-  }
-
-  if (expected != got) {
-    PyErr_SetString(PyExc_TypeError, "got wrong ttype while reading field");
-    return false;
-  }
-  return true;
-}
-
-static bool
-skip(DecodeBuffer* input, TType type) {
-#define SKIPBYTES(n) \
-  do { \
-    if (!readBytes(input, &dummy_buf, (n))) { \
-      return false; \
-    } \
-  } while(0)
-
-  char* dummy_buf;
-
-  switch (type) {
-
-  case T_BOOL:
-  case T_I08: SKIPBYTES(1); break;
-  case T_I16: SKIPBYTES(2); break;
-  case T_I32: SKIPBYTES(4); break;
-  case T_I64:
-  case T_DOUBLE: SKIPBYTES(8); break;
-
-  case T_STRING: {
-    // TODO(dreiss): Find out if these check_ssize_t32s are really necessary.
-    int len = readI32(input);
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-    SKIPBYTES(len);
-    break;
-  }
-
-  case T_LIST:
-  case T_SET: {
-    TType etype;
-    int len, i;
-
-    etype = readByte(input);
-    if (etype == -1) {
-      return false;
-    }
-
-    len = readI32(input);
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    for (i = 0; i < len; i++) {
-      if (!skip(input, etype)) {
-        return false;
-      }
-    }
-    break;
-  }
-
-  case T_MAP: {
-    TType ktype, vtype;
-    int len, i;
-
-    ktype = readByte(input);
-    if (ktype == -1) {
-      return false;
-    }
-
-    vtype = readByte(input);
-    if (vtype == -1) {
-      return false;
-    }
-
-    len = readI32(input);
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    for (i = 0; i < len; i++) {
-      if (!(skip(input, ktype) && skip(input, vtype))) {
-        return false;
-      }
-    }
-    break;
-  }
-
-  case T_STRUCT: {
-    while (true) {
-      TType type;
-
-      type = readByte(input);
-      if (type == -1) {
-        return false;
-      }
-
-      if (type == T_STOP)
-        break;
-
-      SKIPBYTES(2); // tag
-      if (!skip(input, type)) {
-        return false;
-      }
-    }
-    break;
-  }
-
-  case T_STOP:
-  case T_VOID:
-  case T_UTF16:
-  case T_UTF8:
-  case T_U64:
-  default:
-    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
-    return false;
-
-  }
-
-  return true;
-
-#undef SKIPBYTES
-}
-
-
-/* --- HELPER FUNCTION FOR DECODE_VAL --- */
-
-static PyObject*
-decode_val(DecodeBuffer* input, TType type, PyObject* typeargs);
-
-static bool
-decode_struct(DecodeBuffer* input, PyObject* output, PyObject* spec_seq) {
-  int spec_seq_len = PyTuple_Size(spec_seq);
-  if (spec_seq_len == -1) {
-    return false;
-  }
-
-  while (true) {
-    TType type;
-    int16_t tag;
-    PyObject* item_spec;
-    PyObject* fieldval = NULL;
-    StructItemSpec parsedspec;
-
-    type = readByte(input);
-    if (type == -1) {
-      return false;
-    }
-    if (type == T_STOP) {
-      break;
-    }
-    tag = readI16(input);
-    if (INT_CONV_ERROR_OCCURRED(tag)) {
-      return false;
-    }
-    if (tag >= 0 && tag < spec_seq_len) {
-      item_spec = PyTuple_GET_ITEM(spec_seq, tag);
-    } else {
-      item_spec = Py_None;
-    }
-
-    if (item_spec == Py_None) {
-      if (!skip(input, type)) {
-        return false;
-      } else {
-        continue;
-      }
-    }
-
-    if (!parse_struct_item_spec(&parsedspec, item_spec)) {
-      return false;
-    }
-    if (parsedspec.type != type) {
-      if (!skip(input, type)) {
-        PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading and can't be skipped");
-        return false;
-      } else {
-        continue;
-      }
-    }
-
-    fieldval = decode_val(input, parsedspec.type, parsedspec.typeargs);
-    if (fieldval == NULL) {
-      return false;
-    }
-
-    if (PyObject_SetAttr(output, parsedspec.attrname, fieldval) == -1) {
-      Py_DECREF(fieldval);
-      return false;
-    }
-    Py_DECREF(fieldval);
-  }
-  return true;
-}
-
-
-/* --- MAIN RECURSIVE INPUT FUCNTION --- */
-
-// Returns a new reference.
-static PyObject*
-decode_val(DecodeBuffer* input, TType type, PyObject* typeargs) {
-  switch (type) {
-
-  case T_BOOL: {
-    int8_t v = readByte(input);
-    if (INT_CONV_ERROR_OCCURRED(v)) {
-      return NULL;
-    }
-
-    switch (v) {
-    case 0: Py_RETURN_FALSE;
-    case 1: Py_RETURN_TRUE;
-    // Don't laugh.  This is a potentially serious issue.
-    default: PyErr_SetString(PyExc_TypeError, "boolean out of range"); return NULL;
-    }
-    break;
-  }
-  case T_I08: {
-    int8_t v = readByte(input);
-    if (INT_CONV_ERROR_OCCURRED(v)) {
-      return NULL;
-    }
-
-    return PyInt_FromLong(v);
-  }
-  case T_I16: {
-    int16_t v = readI16(input);
-    if (INT_CONV_ERROR_OCCURRED(v)) {
-      return NULL;
-    }
-    return PyInt_FromLong(v);
-  }
-  case T_I32: {
-    int32_t v = readI32(input);
-    if (INT_CONV_ERROR_OCCURRED(v)) {
-      return NULL;
-    }
-    return PyInt_FromLong(v);
-  }
-
-  case T_I64: {
-    int64_t v = readI64(input);
-    if (INT_CONV_ERROR_OCCURRED(v)) {
-      return NULL;
-    }
-    // TODO(dreiss): Find out if we can take this fastpath always when
-    //               sizeof(long) == sizeof(long long).
-    if (CHECK_RANGE(v, LONG_MIN, LONG_MAX)) {
-      return PyInt_FromLong((long) v);
-    }
-
-    return PyLong_FromLongLong(v);
-  }
-
-  case T_DOUBLE: {
-    double v = readDouble(input);
-    if (v == -1.0 && PyErr_Occurred()) {
-      return false;
-    }
-    return PyFloat_FromDouble(v);
-  }
-
-  case T_STRING: {
-    Py_ssize_t len = readI32(input);
-    char* buf;
-    if (!readBytes(input, &buf, len)) {
-      return NULL;
-    }
-
-    return PyString_FromStringAndSize(buf, len);
-  }
-
-  case T_LIST:
-  case T_SET: {
-    SetListTypeArgs parsedargs;
-    int32_t len;
-    PyObject* ret = NULL;
-    int i;
-
-    if (!parse_set_list_args(&parsedargs, typeargs)) {
-      return NULL;
-    }
-
-    if (!checkTypeByte(input, parsedargs.element_type)) {
-      return NULL;
-    }
-
-    len = readI32(input);
-    if (!check_ssize_t_32(len)) {
-      return NULL;
-    }
-
-    ret = PyList_New(len);
-    if (!ret) {
-      return NULL;
-    }
-
-    for (i = 0; i < len; i++) {
-      PyObject* item = decode_val(input, parsedargs.element_type, parsedargs.typeargs);
-      if (!item) {
-        Py_DECREF(ret);
-        return NULL;
-      }
-      PyList_SET_ITEM(ret, i, item);
-    }
-
-    // TODO(dreiss): Consider biting the bullet and making two separate cases
-    //               for list and set, avoiding this post facto conversion.
-    if (type == T_SET) {
-      PyObject* setret;
-#if (PY_VERSION_HEX < 0x02050000)
-      // hack needed for older versions
-      setret = PyObject_CallFunctionObjArgs((PyObject*)&PySet_Type, ret, NULL);
-#else
-      // official version
-      setret = PySet_New(ret);
-#endif
-      Py_DECREF(ret);
-      return setret;
-    }
-    return ret;
-  }
-
-  case T_MAP: {
-    int32_t len;
-    int i;
-    MapTypeArgs parsedargs;
-    PyObject* ret = NULL;
-
-    if (!parse_map_args(&parsedargs, typeargs)) {
-      return NULL;
-    }
-
-    if (!checkTypeByte(input, parsedargs.ktag)) {
-      return NULL;
-    }
-    if (!checkTypeByte(input, parsedargs.vtag)) {
-      return NULL;
-    }
-
-    len = readI32(input);
-    if (!check_ssize_t_32(len)) {
-      return false;
-    }
-
-    ret = PyDict_New();
-    if (!ret) {
-      goto error;
-    }
-
-    for (i = 0; i < len; i++) {
-      PyObject* k = NULL;
-      PyObject* v = NULL;
-      k = decode_val(input, parsedargs.ktag, parsedargs.ktypeargs);
-      if (k == NULL) {
-        goto loop_error;
-      }
-      v = decode_val(input, parsedargs.vtag, parsedargs.vtypeargs);
-      if (v == NULL) {
-        goto loop_error;
-      }
-      if (PyDict_SetItem(ret, k, v) == -1) {
-        goto loop_error;
-      }
-
-      Py_DECREF(k);
-      Py_DECREF(v);
-      continue;
-
-      // Yuck!  Destructors, anyone?
-      loop_error:
-      Py_XDECREF(k);
-      Py_XDECREF(v);
-      goto error;
-    }
-
-    return ret;
-
-    error:
-    Py_XDECREF(ret);
-    return NULL;
-  }
-
-  case T_STRUCT: {
-    StructTypeArgs parsedargs;
-	PyObject* ret;
-    if (!parse_struct_args(&parsedargs, typeargs)) {
-      return NULL;
-    }
-
-    ret = PyObject_CallObject(parsedargs.klass, NULL);
-    if (!ret) {
-      return NULL;
-    }
-
-    if (!decode_struct(input, ret, parsedargs.spec)) {
-      Py_DECREF(ret);
-      return NULL;
-    }
-
-    return ret;
-  }
-
-  case T_STOP:
-  case T_VOID:
-  case T_UTF16:
-  case T_UTF8:
-  case T_U64:
-  default:
-    PyErr_SetString(PyExc_TypeError, "Unexpected TType");
-    return NULL;
-  }
-}
-
-
-/* --- TOP-LEVEL WRAPPER FOR INPUT -- */
-
-static PyObject*
-decode_binary(PyObject *self, PyObject *args) {
-  PyObject* output_obj = NULL;
-  PyObject* transport = NULL;
-  PyObject* typeargs = NULL;
-  StructTypeArgs parsedargs;
-  DecodeBuffer input = {0, 0};
-  
-  if (!PyArg_ParseTuple(args, "OOO", &output_obj, &transport, &typeargs)) {
-    return NULL;
-  }
-
-  if (!parse_struct_args(&parsedargs, typeargs)) {
-    return NULL;
-  }
-
-  if (!decode_buffer_from_obj(&input, transport)) {
-    return NULL;
-  }
-
-  if (!decode_struct(&input, output_obj, parsedargs.spec)) {
-    free_decodebuf(&input);
-    return NULL;
-  }
-
-  free_decodebuf(&input);
-
-  Py_RETURN_NONE;
-}
-
-/* ====== END READING FUNCTIONS ====== */
-
-
-/* -- PYTHON MODULE SETUP STUFF --- */
-
-static PyMethodDef ThriftFastBinaryMethods[] = {
-
-  {"encode_binary",  encode_binary, METH_VARARGS, ""},
-  {"decode_binary",  decode_binary, METH_VARARGS, ""},
-
-  {NULL, NULL, 0, NULL}        /* Sentinel */
-};
-
-PyMODINIT_FUNC
-initfastbinary(void) {
-#define INIT_INTERN_STRING(value) \
-  do { \
-    INTERN_STRING(value) = PyString_InternFromString(#value); \
-    if(!INTERN_STRING(value)) return; \
-  } while(0)
-
-  INIT_INTERN_STRING(cstringio_buf);
-  INIT_INTERN_STRING(cstringio_refill);
-#undef INIT_INTERN_STRING
-
-  PycString_IMPORT;
-  if (PycStringIO == NULL) return;
-
-  (void) Py_InitModule("thrift.protocol.fastbinary", ThriftFastBinaryMethods);
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
deleted file mode 100644
index be54bab..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/THttpServer.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# 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 BaseHTTPServer
-
-from thrift.server import TServer
-from thrift.transport import TTransport
-
-
-class ResponseException(Exception):
-  """Allows handlers to override the HTTP response
-
-  Normally, THttpServer always sends a 200 response.  If a handler wants
-  to override this behavior (e.g., to simulate a misconfigured or
-  overloaded web server during testing), it can raise a ResponseException.
-  The function passed to the constructor will be called with the
-  RequestHandler as its only argument.
-  """
-  def __init__(self, handler):
-    self.handler = handler
-
-
-class THttpServer(TServer.TServer):
-  """A simple HTTP-based Thrift server
-
-  This class is not very performant, but it is useful (for example) for
-  acting as a mock version of an Apache-based PHP Thrift endpoint.
-  """
-  def __init__(self,
-               processor,
-               server_address,
-               inputProtocolFactory,
-               outputProtocolFactory=None,
-               server_class=BaseHTTPServer.HTTPServer):
-    """Set up protocol factories and HTTP server.
-
-    See BaseHTTPServer for server_address.
-    See TServer for protocol factories.
-    """
-    if outputProtocolFactory is None:
-      outputProtocolFactory = inputProtocolFactory
-
-    TServer.TServer.__init__(self, processor, None, None, None,
-        inputProtocolFactory, outputProtocolFactory)
-
-    thttpserver = self
-
-    class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler):
-      def do_POST(self):
-        # Don't care about the request path.
-        itrans = TTransport.TFileObjectTransport(self.rfile)
-        otrans = TTransport.TFileObjectTransport(self.wfile)
-        itrans = TTransport.TBufferedTransport(
-          itrans, int(self.headers['Content-Length']))
-        otrans = TTransport.TMemoryBuffer()
-        iprot = thttpserver.inputProtocolFactory.getProtocol(itrans)
-        oprot = thttpserver.outputProtocolFactory.getProtocol(otrans)
-        try:
-          thttpserver.processor.process(iprot, oprot)
-        except ResponseException, exn:
-          exn.handler(self)
-        else:
-          self.send_response(200)
-          self.send_header("content-type", "application/x-thrift")
-          self.end_headers()
-          self.wfile.write(otrans.getvalue())
-
-    self.httpd = server_class(server_address, RequestHander)
-
-  def serve(self):
-    self.httpd.serve_forever()

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
deleted file mode 100644
index fa478d0..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TNonblockingServer.py
+++ /dev/null
@@ -1,346 +0,0 @@
-#
-# 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.
-#
-"""Implementation of non-blocking server.
-
-The main idea of the server is to receive and send requests
-only from the main thread.
-
-The thread poool should be sized for concurrent tasks, not
-maximum connections
-"""
-import threading
-import socket
-import Queue
-import select
-import struct
-import logging
-
-from thrift.transport import TTransport
-from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
-
-__all__ = ['TNonblockingServer']
-
-
-class Worker(threading.Thread):
-    """Worker is a small helper to process incoming connection."""
-
-    def __init__(self, queue):
-        threading.Thread.__init__(self)
-        self.queue = queue
-
-    def run(self):
-        """Process queries from task queue, stop if processor is None."""
-        while True:
-            try:
-                processor, iprot, oprot, otrans, callback = self.queue.get()
-                if processor is None:
-                    break
-                processor.process(iprot, oprot)
-                callback(True, otrans.getvalue())
-            except Exception:
-                logging.exception("Exception while processing request")
-                callback(False, '')
-
-WAIT_LEN = 0
-WAIT_MESSAGE = 1
-WAIT_PROCESS = 2
-SEND_ANSWER = 3
-CLOSED = 4
-
-
-def locked(func):
-    """Decorator which locks self.lock."""
-    def nested(self, *args, **kwargs):
-        self.lock.acquire()
-        try:
-            return func(self, *args, **kwargs)
-        finally:
-            self.lock.release()
-    return nested
-
-
-def socket_exception(func):
-    """Decorator close object on socket.error."""
-    def read(self, *args, **kwargs):
-        try:
-            return func(self, *args, **kwargs)
-        except socket.error:
-            self.close()
-    return read
-
-
-class Connection:
-    """Basic class is represented connection.
-
-    It can be in state:
-        WAIT_LEN --- connection is reading request len.
-        WAIT_MESSAGE --- connection is reading request.
-        WAIT_PROCESS --- connection has just read whole request and
-                         waits for call ready routine.
-        SEND_ANSWER --- connection is sending answer string (including length
-                        of answer).
-        CLOSED --- socket was closed and connection should be deleted.
-    """
-    def __init__(self, new_socket, wake_up):
-        self.socket = new_socket
-        self.socket.setblocking(False)
-        self.status = WAIT_LEN
-        self.len = 0
-        self.message = ''
-        self.lock = threading.Lock()
-        self.wake_up = wake_up
-
-    def _read_len(self):
-        """Reads length of request.
-
-        It's a safer alternative to self.socket.recv(4)
-        """
-        read = self.socket.recv(4 - len(self.message))
-        if len(read) == 0:
-            # if we read 0 bytes and self.message is empty, then
-            # the client closed the connection
-            if len(self.message) != 0:
-                logging.error("can't read frame size from socket")
-            self.close()
-            return
-        self.message += read
-        if len(self.message) == 4:
-            self.len, = struct.unpack('!i', self.message)
-            if self.len < 0:
-                logging.error("negative frame size, it seems client "
-                              "doesn't use FramedTransport")
-                self.close()
-            elif self.len == 0:
-                logging.error("empty frame, it's really strange")
-                self.close()
-            else:
-                self.message = ''
-                self.status = WAIT_MESSAGE
-
-    @socket_exception
-    def read(self):
-        """Reads data from stream and switch state."""
-        assert self.status in (WAIT_LEN, WAIT_MESSAGE)
-        if self.status == WAIT_LEN:
-            self._read_len()
-            # go back to the main loop here for simplicity instead of
-            # falling through, even though there is a good chance that
-            # the message is already available
-        elif self.status == WAIT_MESSAGE:
-            read = self.socket.recv(self.len - len(self.message))
-            if len(read) == 0:
-                logging.error("can't read frame from socket (get %d of "
-                              "%d bytes)" % (len(self.message), self.len))
-                self.close()
-                return
-            self.message += read
-            if len(self.message) == self.len:
-                self.status = WAIT_PROCESS
-
-    @socket_exception
-    def write(self):
-        """Writes data from socket and switch state."""
-        assert self.status == SEND_ANSWER
-        sent = self.socket.send(self.message)
-        if sent == len(self.message):
-            self.status = WAIT_LEN
-            self.message = ''
-            self.len = 0
-        else:
-            self.message = self.message[sent:]
-
-    @locked
-    def ready(self, all_ok, message):
-        """Callback function for switching state and waking up main thread.
-
-        This function is the only function witch can be called asynchronous.
-
-        The ready can switch Connection to three states:
-            WAIT_LEN if request was oneway.
-            SEND_ANSWER if request was processed in normal way.
-            CLOSED if request throws unexpected exception.
-
-        The one wakes up main thread.
-        """
-        assert self.status == WAIT_PROCESS
-        if not all_ok:
-            self.close()
-            self.wake_up()
-            return
-        self.len = ''
-        if len(message) == 0:
-            # it was a oneway request, do not write answer
-            self.message = ''
-            self.status = WAIT_LEN
-        else:
-            self.message = struct.pack('!i', len(message)) + message
-            self.status = SEND_ANSWER
-        self.wake_up()
-
-    @locked
-    def is_writeable(self):
-        """Return True if connection should be added to write list of select"""
-        return self.status == SEND_ANSWER
-
-    # it's not necessary, but...
-    @locked
-    def is_readable(self):
-        """Return True if connection should be added to read list of select"""
-        return self.status in (WAIT_LEN, WAIT_MESSAGE)
-
-    @locked
-    def is_closed(self):
-        """Returns True if connection is closed."""
-        return self.status == CLOSED
-
-    def fileno(self):
-        """Returns the file descriptor of the associated socket."""
-        return self.socket.fileno()
-
-    def close(self):
-        """Closes connection"""
-        self.status = CLOSED
-        self.socket.close()
-
-
-class TNonblockingServer:
-    """Non-blocking server."""
-
-    def __init__(self,
-                 processor,
-                 lsocket,
-                 inputProtocolFactory=None,
-                 outputProtocolFactory=None,
-                 threads=10):
-        self.processor = processor
-        self.socket = lsocket
-        self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory()
-        self.out_protocol = outputProtocolFactory or self.in_protocol
-        self.threads = int(threads)
-        self.clients = {}
-        self.tasks = Queue.Queue()
-        self._read, self._write = socket.socketpair()
-        self.prepared = False
-        self._stop = False
-
-    def setNumThreads(self, num):
-        """Set the number of worker threads that should be created."""
-        # implement ThreadPool interface
-        assert not self.prepared, "Can't change number of threads after start"
-        self.threads = num
-
-    def prepare(self):
-        """Prepares server for serve requests."""
-        if self.prepared:
-            return
-        self.socket.listen()
-        for _ in xrange(self.threads):
-            thread = Worker(self.tasks)
-            thread.setDaemon(True)
-            thread.start()
-        self.prepared = True
-
-    def wake_up(self):
-        """Wake up main thread.
-
-        The server usualy waits in select call in we should terminate one.
-        The simplest way is using socketpair.
-
-        Select always wait to read from the first socket of socketpair.
-
-        In this case, we can just write anything to the second socket from
-        socketpair.
-        """
-        self._write.send('1')
-
-    def stop(self):
-        """Stop the server.
-
-        This method causes the serve() method to return.  stop() may be invoked
-        from within your handler, or from another thread.
-
-        After stop() is called, serve() will return but the server will still
-        be listening on the socket.  serve() may then be called again to resume
-        processing requests.  Alternatively, close() may be called after
-        serve() returns to close the server socket and shutdown all worker
-        threads.
-        """
-        self._stop = True
-        self.wake_up()
-
-    def _select(self):
-        """Does select on open connections."""
-        readable = [self.socket.handle.fileno(), self._read.fileno()]
-        writable = []
-        for i, connection in self.clients.items():
-            if connection.is_readable():
-                readable.append(connection.fileno())
-            if connection.is_writeable():
-                writable.append(connection.fileno())
-            if connection.is_closed():
-                del self.clients[i]
-        return select.select(readable, writable, readable)
-
-    def handle(self):
-        """Handle requests.
-
-        WARNING! You must call prepare() BEFORE calling handle()
-        """
-        assert self.prepared, "You have to call prepare before handle"
-        rset, wset, xset = self._select()
-        for readable in rset:
-            if readable == self._read.fileno():
-                # don't care i just need to clean readable flag
-                self._read.recv(1024)
-            elif readable == self.socket.handle.fileno():
-                client = self.socket.accept().handle
-                self.clients[client.fileno()] = Connection(client,
-                                                           self.wake_up)
-            else:
-                connection = self.clients[readable]
-                connection.read()
-                if connection.status == WAIT_PROCESS:
-                    itransport = TTransport.TMemoryBuffer(connection.message)
-                    otransport = TTransport.TMemoryBuffer()
-                    iprot = self.in_protocol.getProtocol(itransport)
-                    oprot = self.out_protocol.getProtocol(otransport)
-                    self.tasks.put([self.processor, iprot, oprot,
-                                    otransport, connection.ready])
-        for writeable in wset:
-            self.clients[writeable].write()
-        for oob in xset:
-            self.clients[oob].close()
-            del self.clients[oob]
-
-    def close(self):
-        """Closes the server."""
-        for _ in xrange(self.threads):
-            self.tasks.put([None, None, None, None, None])
-        self.socket.close()
-        self.prepared = False
-
-    def serve(self):
-        """Serve requests.
-
-        Serve requests forever, or until stop() is called.
-        """
-        self._stop = False
-        self.prepare()
-        while not self._stop:
-            self.handle()


[37/50] [abbrv] git commit: Merge remote-tracking branch 'upstream/master'

Posted by ni...@apache.org.
Merge remote-tracking branch 'upstream/master'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c3551c98
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c3551c98
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c3551c98

Branch: refs/heads/master
Commit: c3551c984be67c7a711d1acbde683e7f11095764
Parents: e78b861 fd0f922
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 16:44:23 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 16:44:23 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/KubernetesClusterContext.java    |  176 ++-
 .../stratos/autoscaler/MemberStatsContext.java  |   23 +
 .../cloud/controller/CloudControllerClient.java |   62 +-
 .../monitor/ClusterMonitorFactory.java          |   24 +-
 .../monitor/KubernetesClusterMonitor.java       |   33 +-
 .../KubernetesServiceClusterMonitor.java        |  112 +-
 .../autoscaler/monitor/VMLbClusterMonitor.java  |    6 +-
 .../monitor/VMServiceClusterMonitor.java        |    5 +-
 .../rule/AutoscalerRuleEvaluator.java           |   24 +-
 .../autoscaler/rule/RuleTasksDelegator.java     |   84 ++
 .../stratos/cartridge/agent/CartridgeAgent.java |    2 +-
 .../config/CartridgeAgentConfiguration.java     |   24 +-
 .../apache/stratos/cli/GenericRestClient.java   |    2 +-
 .../java/org/apache/stratos/cli/RestClient.java |  313 ++++--
 .../stratos/cli/RestCommandLineService.java     |  858 +++++++--------
 .../apache/stratos/cli/StratosApplication.java  |    8 +-
 .../cli/beans/kubernetes/KubernetesGroup.java   |   44 +
 .../beans/kubernetes/KubernetesGroupList.java   |   37 +
 .../cli/beans/kubernetes/KubernetesHost.java    |   53 +
 .../beans/kubernetes/KubernetesHostList.java    |   37 +
 .../commands/ListKubernetesGroupsCommand.java   |   66 ++
 .../commands/ListKubernetesHostsCommand.java    |   67 ++
 .../stratos/cli/commands/SubscribeCommand.java  |   48 +
 .../UnDeployKubernetesGroupCommand.java         |    6 +-
 .../stratos/cli/exception/ErrorWrapper.java     |   48 +
 .../stratos/cli/exception/ExceptionMapper.java  |   43 +
 .../stratos/cli/utils/CommandLineUtils.java     |   33 +
 .../controller/axiom/AxiomXpathParserUtil.java  |   20 +-
 .../concurrent/ScheduledThreadExecutor.java     |   78 ++
 .../exception/InvalidIaasProviderException.java |    2 -
 .../MemberTerminationFailedException.java       |   48 +
 ...inerClusterContextToKubernetesContainer.java |  141 +++
 ...tainerClusterContextToKubernetesService.java |   64 ++
 ...erClusterContextToReplicationController.java |   90 ++
 .../MemberContextToKubernetesContainer.java     |  147 ---
 .../MemberContextToKubernetesService.java       |   65 --
 .../MemberContextToReplicationController.java   |   90 --
 .../functions/PodToMemberContext.java           |   46 +
 .../impl/CloudControllerServiceImpl.java        |  724 +++++++++----
 .../interfaces/CloudControllerService.java      |   49 +-
 .../internal/CloudControllerDSComponent.java    |   30 +-
 .../jcloud/ComputeServiceBuilderUtil.java       |    1 -
 .../pojo/ContainerClusterContext.java           |   87 ++
 .../cloud/controller/pojo/MemberContext.java    |   29 +-
 .../runtime/FasterLookUpDataHolder.java         |   70 +-
 .../controller/util/CloudControllerUtil.java    |   14 +-
 .../controller/util/PodActivationWatcher.java   |   80 ++
 .../common/constants/StratosConstants.java      |    7 +
 .../pom.xml                                     |    2 +-
 .../kubernetes/client/KubernetesApiClient.java  |  202 ++--
 .../KubernetesAPIClientInterface.java           |    8 +
 .../client/rest/KubernetesResponse.java         |   56 +
 .../client/rest/KubernetesResponseHandler.java  |   66 ++
 .../kubernetes/client/rest/RestClient.java      |  119 +--
 .../pom.xml                                     |   19 +
 .../modules/distribution/src/assembly/bin.xml   |   22 +-
 .../src/main/conf/container-mincheck.drl        |   72 ++
 .../src/main/conf/container-scaling.drl         |  163 +++
 .../distribution/src/main/conf/log4j.properties |    6 +-
 .../main/resources/CloudControllerService.wsdl  | 1003 ++++++++++--------
 60 files changed, 3939 insertions(+), 1919 deletions(-)
----------------------------------------------------------------------



[17/50] [abbrv] git commit: Implemented default health stat reader logic

Posted by ni...@apache.org.
Implemented default health stat reader logic


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2d9f1ece
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2d9f1ece
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2d9f1ece

Branch: refs/heads/master
Commit: 2d9f1eced6ca95fb6f63eb8d3c4e54c8a407009b
Parents: 1c2f046
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:28:37 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:28 2014 +0530

----------------------------------------------------------------------
 .../modules/healthstatspublisher/healthstats.py               | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/2d9f1ece/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index f647106..d631b82 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -1,6 +1,8 @@
 from threading import Thread
 import time
 import logging
+import psutil
+import os
 
 from abstracthealthstatisticspublisher import *
 from ..databridge.agent import *
@@ -138,11 +140,12 @@ class DefaultHealthStatisticsReader(AbstractHealthStatisticsReader):
 
     @staticmethod
     def __read_mem_usage():
-        raise NotImplementedError
+        return psutil.virtual_memory().percent
 
     @staticmethod
     def __read_load_avg():
-        raise NotImplementedError
+        (one, five, fifteen) = os.getloadavg()
+        return one
 
 
 class CEPPublisherConfiguration:


[31/50] [abbrv] git commit: Added Apache v2.0 license header

Posted by ni...@apache.org.
Added Apache v2.0 license header


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/82003851
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/82003851
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/82003851

Branch: refs/heads/master
Commit: 820038513b1b67620a7f791c02f090803aa17429
Parents: 29f35bd
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 16:24:52 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 16:24:52 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/__init__.py                  | 16 ++++++++++++++++
 .../cartridge-agent/agent.conf                   | 17 +++++++++++++++++
 .../cartridge-agent/agent.py                     | 17 +++++++++++++++++
 .../cartridge-agent/logging.ini                  | 18 ++++++++++++++++++
 .../cartridge-agent/modules/__init__.py          | 16 ++++++++++++++++
 .../modules/artifactmgt/__init__.py              | 17 +++++++++++++++++
 .../modules/artifactmgt/git/__init__.py          | 17 +++++++++++++++++
 .../modules/artifactmgt/git/agentgithandler.py   | 17 +++++++++++++++++
 .../modules/artifactmgt/git/gitrepository.py     | 17 +++++++++++++++++
 .../modules/artifactmgt/repositoryinformation.py | 17 +++++++++++++++++
 .../cartridge-agent/modules/config/__init__.py   | 17 +++++++++++++++++
 .../config/cartridgeagentconfiguration.py        | 17 +++++++++++++++++
 .../modules/databridge/__init__.py               | 17 +++++++++++++++++
 .../cartridge-agent/modules/databridge/agent.py  | 17 +++++++++++++++++
 .../modules/databridge/thrift/__init__.py        | 17 +++++++++++++++++
 .../modules/databridge/thrift/publisher.py       | 17 +++++++++++++++++
 .../modules/datapublisher/__init__.py            | 19 ++++++++++++++++++-
 .../modules/datapublisher/exception/__init__.py  | 18 +++++++++++++++++-
 .../exception/datapublisherexception.py          | 17 +++++++++++++++++
 .../modules/datapublisher/logpublisher.py        | 17 +++++++++++++++++
 .../modules/event/instance/__init__.py           | 16 ++++++++++++++++
 .../modules/event/instance/notifier/__init__.py  | 17 +++++++++++++++++
 .../modules/event/instance/notifier/events.py    | 17 +++++++++++++++++
 .../modules/event/instance/status/__init__.py    | 17 +++++++++++++++++
 .../modules/event/instance/status/events.py      | 17 +++++++++++++++++
 .../modules/event/tenant/__init__.py             | 16 ++++++++++++++++
 .../modules/event/tenant/events.py               | 17 +++++++++++++++++
 .../modules/event/topology/__init__.py           | 17 +++++++++++++++++
 .../modules/event/topology/events.py             | 17 +++++++++++++++++
 .../modules/exception/__init__.py                | 16 ++++++++++++++++
 .../exception/parameternotfoundexception.py      | 17 +++++++++++++++++
 .../modules/extensions/__init__.py               | 16 ++++++++++++++++
 .../extensions/abstractextensionhandler.py       | 17 +++++++++++++++++
 .../extensions/defaultextensionhandler.py        | 17 +++++++++++++++++
 .../modules/healthstatspublisher/__init__.py     | 16 ++++++++++++++++
 .../abstracthealthstatisticspublisher.py         | 17 +++++++++++++++++
 .../modules/healthstatspublisher/healthstats.py  | 17 +++++++++++++++++
 .../modules/publisher/__init__.py                | 16 ++++++++++++++++
 .../modules/publisher/cartridgeagentpublisher.py | 17 +++++++++++++++++
 .../modules/subscriber/__init__.py               | 17 +++++++++++++++++
 .../modules/subscriber/eventsubscriber.py        | 17 +++++++++++++++++
 .../cartridge-agent/modules/tenant/__init__.py   | 16 ++++++++++++++++
 .../modules/tenant/tenantcontext.py              | 17 +++++++++++++++++
 .../cartridge-agent/modules/topology/__init__.py | 16 ++++++++++++++++
 .../modules/topology/topologycontext.py          | 17 +++++++++++++++++
 .../cartridge-agent/modules/util/__init__.py     | 16 ++++++++++++++++
 .../modules/util/asyncscheduledtask.py           | 17 +++++++++++++++++
 .../modules/util/cartridgeagentconstants.py      | 17 +++++++++++++++++
 .../modules/util/cartridgeagentutils.py          | 17 +++++++++++++++++
 .../modules/util/extensionutils.py               | 17 +++++++++++++++++
 .../cartridge-agent/modules/util/log.py          | 17 +++++++++++++++++
 51 files changed, 858 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/__init__.py b/tools/python-cartridge-agent/cartridge-agent/__init__.py
index e69de29..d216be4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/__init__.py
@@ -0,0 +1,16 @@
+# 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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.conf b/tools/python-cartridge-agent/cartridge-agent/agent.conf
index 0161b7d..57e9992 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.conf
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.conf
@@ -1,3 +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.
+
 [agent]
 mb.ip                                 =MB-IP
 mb.port                               =MB-PORT

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.py b/tools/python-cartridge-agent/cartridge-agent/agent.py
index 1d16c99..c2976a8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -1,4 +1,21 @@
 #!/usr/bin/env python
+# 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 threading
 
 from modules.exception.parameternotfoundexception import ParameterNotFoundException

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
index c3e9e2c..f1869f6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/logging.ini
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -1,3 +1,21 @@
+# 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.
+
+
 [formatters]
 keys=default
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/__init__.py
index e69de29..d216be4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/__init__.py
@@ -0,0 +1,16 @@
+# 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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
index 5353b8f..9e95be0 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -1,3 +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.
+
 from threading import current_thread, Thread
 from git import *
 from gittle import Gittle, GittleAuth  # GitPython and Gittle are both used at the time being for pros and cons of both

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
index b7445d5..98a8a44 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
@@ -1,3 +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.
+
 from ...util.asyncscheduledtask import AsyncScheduledTask
 from gittle import Gittle
 from git import *

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
index 2d6ae0b..b67eada 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
@@ -1,3 +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.
+
 class RepositoryInformation:
     """
     Holds repository information to be used in artifact management

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 415a54e..17b6c78 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -1,3 +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.
+
 import ConfigParser
 import logging
 import os

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
index e229af1..c1a6c5c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
@@ -1,3 +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.
+
 from thrift.publisher import *
 from ..util.log import *
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
index 7c09d40..99d9f1f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
@@ -1,3 +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.
+
 import time
 import sys
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
index 0de6991..a595c84 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/__init__.py
@@ -1 +1,18 @@
-__author__ = 'chamilad'
+# 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.
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
index 0de6991..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/__init__.py
@@ -1 +1,17 @@
-__author__ = 'chamilad'
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
index 444c2c1..fc4bfc9 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/exception/datapublisherexception.py
@@ -1,3 +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.
+
 class DataPublisherException(Exception):
     """
     Exception to be used during log publishing operations

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index f58b6eb..cf91736 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -1,3 +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.
+
 import os
 import datetime
 from threading import Thread, current_thread

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py
index 91e0367..707f4a1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py
@@ -1,3 +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.
+
 import json
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py
index 774b111..c000c55 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py
@@ -1,3 +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.
+
 import json
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
index 5cb838d..def2b64 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
@@ -1,3 +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.
+
 import json
 from ... tenant.tenantcontext import *
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 2886099..65a6cf2 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -1,3 +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.
+
 import json
 
 from ... topology.topologycontext import *

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
index 720f458..88deafd 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
@@ -1,3 +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.
+
 class ParameterNotFoundException(Exception):
     """
     Exception raised when a property is not present in the configuration or the payload

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
index 765d3bc..3202341 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/abstractextensionhandler.py
@@ -1,3 +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.
+
 class AbstractExtensionHandler:
 
     def on_instance_started_event(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index c91a559..b5e1d1e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -1,3 +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.
+
 import time
 
 from abstractextensionhandler import AbstractExtensionHandler

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
index eaf8546..685344d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/abstracthealthstatisticspublisher.py
@@ -1,3 +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.
+
 class AbstractHealthStatisticsReader:
     """
     Abstract class to implement to create a custom health stat reader

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index 64021a3..ddc2543 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -1,3 +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.
+
 from threading import Thread
 import time
 import psutil

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
index 9b4d819..89321b4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -1,3 +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.
+
 import logging
 
 import paho.mqtt.publish as publish

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
index e69de29..2456923 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
index da60d7d..bc026dd 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -1,3 +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.
+
 import threading
 import paho.mqtt.client as mqtt
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/tenant/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
index 43bea0b..202bd35 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
@@ -1,3 +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.
+
 class Tenant:
     """
     Object type representing the tenant details of a single tenant

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/topology/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
index 81314d2..8f81802 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -1,3 +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.
+
 from ..util import cartridgeagentconstants
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
index e69de29..13a8339 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
@@ -0,0 +1,16 @@
+# 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.

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
index 85f8c3e..9fdde1e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
@@ -1,3 +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.
+
 import time
 from threading import Thread
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
index 7265c15..eb94f79 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -1,3 +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.
+
 JNDI_PROPERTIES_DIR = "jndi.properties.dir"
 PARAM_FILE_PATH = "param.file.path"
 EXTENSIONS_DIR = "extensions.dir"

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
index 7a7a4fe..556a348 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -1,3 +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.
+
 from Crypto.Cipher import AES
 import base64
 import os

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 9cf8ba3..e686fce 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -1,3 +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.
+
 import logging
 import os
 import subprocess

http://git-wip-us.apache.org/repos/asf/stratos/blob/82003851/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
index ff8e9d4..9bad214 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
@@ -1,3 +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.
+
 import logging
 import logging.config
 import os


[38/50] [abbrv] git commit: Fixed optional parameters being read as mandatory Fixed dependancy issue in extension handler Fixed deploymentPolicy, partitionId, and networkPartitionId being read in a container env

Posted by ni...@apache.org.
Fixed optional parameters being read as mandatory
Fixed dependancy issue in extension handler
Fixed deploymentPolicy, partitionId, and networkPartitionId being read in a container env


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4955598b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4955598b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4955598b

Branch: refs/heads/master
Commit: 4955598b05f584bce24c8b2e0f7dfe4193a94c39
Parents: c3551c9
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 17:34:39 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 17:34:39 2014 +0530

----------------------------------------------------------------------
 .../modules/config/cartridgeagentconfiguration.py     | 14 +++++++-------
 .../cartridge-agent/modules/event/topology/events.py  |  6 +++---
 .../modules/extensions/defaultextensionhandler.py     |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4955598b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
index 95c4169..6a0525e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -98,7 +98,7 @@ class CartridgeAgentConfiguration:
             self.__read_parameter_file()
 
             try:
-                service_group = self.payload_params[cartridgeagentconstants.SERVICE_GROUP] \
+                self.service_group = self.payload_params[cartridgeagentconstants.SERVICE_GROUP] \
                     if cartridgeagentconstants.SERVICE_GROUP in self.payload_params \
                     else None
 
@@ -112,12 +112,12 @@ class CartridgeAgentConfiguration:
 
                 self.service_name = self.read_property(cartridgeagentconstants.SERVICE_NAME)
                 self.cluster_id = self.read_property(cartridgeagentconstants.CLUSTER_ID)
-                self.network_partition_id = self.read_property(cartridgeagentconstants.NETWORK_PARTITION_ID)
-                self.partition_id = self.read_property(cartridgeagentconstants.PARTITION_ID)
+                self.network_partition_id = self.read_property(cartridgeagentconstants.NETWORK_PARTITION_ID, False)
+                self.partition_id = self.read_property(cartridgeagentconstants.PARTITION_ID, False)
                 self.member_id = self.get_member_id(cartridgeagentconstants.MEMBER_ID)
                 self.cartridge_key = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
-                self.app_path = self.read_property(cartridgeagentconstants.APP_PATH)
-                self.repo_url = self.read_property(cartridgeagentconstants.REPO_URL)
+                self.app_path = self.read_property(cartridgeagentconstants.APP_PATH, False)
+                self.repo_url = self.read_property(cartridgeagentconstants.REPO_URL, False)
                 self.ports = str(self.read_property(cartridgeagentconstants.PORTS)).split("|")
 
                 try:
@@ -163,8 +163,8 @@ class CartridgeAgentConfiguration:
                     self.is_internal_repo = False
 
                 self.tenant_id = self.read_property(cartridgeagentconstants.TENANT_ID)
-                self.lb_cluster_id = self.read_property(cartridgeagentconstants.LB_CLUSTER_ID)
-                self.min_count = self.read_property(cartridgeagentconstants.MIN_INSTANCE_COUNT)
+                self.lb_cluster_id = self.read_property(cartridgeagentconstants.LB_CLUSTER_ID, False)
+                self.min_count = self.read_property(cartridgeagentconstants.MIN_INSTANCE_COUNT, False)
                 self.lb_private_ip = self.read_property(cartridgeagentconstants.LB_PRIVATE_IP, False)
                 self.lb_public_ip = self.read_property(cartridgeagentconstants.LB_PUBLIC_IP, False)
                 self.tenant_repository_path = self.read_property(cartridgeagentconstants.TENANT_REPO_PATH, False)

http://git-wip-us.apache.org/repos/asf/stratos/blob/4955598b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 65a6cf2..e8853ec 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -156,7 +156,7 @@ class CompleteTopologyEvent:
                     cluster_str = service_str["clusterIdClusterMap"][cluster_id]
                     cl_service_name = cluster_str["serviceName"]
                     cl_autoscale_policy_name = cluster_str["autoscalePolicyName"]
-                    cl_deployment_policy_name = cluster_str["deploymentPolicyName"]
+                    cl_deployment_policy_name = cluster_str["deploymentPolicyName"] if "deploymentPolicyName" in cluster_str else None
 
                     cluster_obj = Cluster(cl_service_name, cluster_id, cl_deployment_policy_name, cl_autoscale_policy_name)
                     cluster_obj.hostnames = cluster_str["hostNames"]
@@ -172,8 +172,8 @@ class CompleteTopologyEvent:
                         member_str = cluster_str["memberMap"][member_id]
                         mm_service_name = member_str["serviceName"]
                         mm_cluster_id = member_str["clusterId"]
-                        mm_network_partition_id = member_str["networkPartitionId"]
-                        mm_partition_id = member_str["partitionId"]
+                        mm_network_partition_id = member_str["networkPartitionId"] if "networkPartitionId" in member_str else None
+                        mm_partition_id = member_str["partitionId"] if "partitionId" in member_str else None
 
                         member_obj = Member(mm_service_name, mm_cluster_id, mm_network_partition_id, mm_partition_id, member_id)
                         member_obj.member_public_ip = member_str["memberPublicIp"]

http://git-wip-us.apache.org/repos/asf/stratos/blob/4955598b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index b5e1d1e..4c36e55 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -18,6 +18,7 @@
 import time
 
 from abstractextensionhandler import AbstractExtensionHandler
+from ..util import extensionutils, cartridgeagentutils
 
 
 class DefaultExtensionHandler(AbstractExtensionHandler):
@@ -754,7 +755,6 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 from ..artifactmgt.git import agentgithandler
 from ..artifactmgt.repositoryinformation import RepositoryInformation
 from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import extensionutils
 from ..publisher import cartridgeagentpublisher
 from ..exception.parameternotfoundexception import ParameterNotFoundException
 from ..topology.topologycontext import *


[40/50] [abbrv] git commit: Fixed trying to get tenantRange irrespective of single or multitenant cartridge

Posted by ni...@apache.org.
Fixed trying to get tenantRange irrespective of single or multitenant cartridge


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d23da987
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d23da987
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d23da987

Branch: refs/heads/master
Commit: d23da987b487c9a6d69711e8670fd73c0b35eae6
Parents: c4c5f75
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 18:51:38 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 18:51:38 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/modules/event/topology/events.py               | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d23da987/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index e8853ec..3b0a97c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -160,7 +160,7 @@ class CompleteTopologyEvent:
 
                     cluster_obj = Cluster(cl_service_name, cluster_id, cl_deployment_policy_name, cl_autoscale_policy_name)
                     cluster_obj.hostnames = cluster_str["hostNames"]
-                    cluster_obj.tenant_range = cluster_str["tenantRange"]
+                    cluster_obj.tenant_range = cluster_str["tenantRange"] if "tenantRange" in cluster_str else None
                     cluster_obj.is_lb_cluster = cluster_str["isLbCluster"]
                     cluster_obj.status = cluster_str["status"]
                     cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"]


[19/50] [abbrv] git commit: Introduced LogFactory to centralize log management

Posted by ni...@apache.org.
Introduced LogFactory to centralize log management


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/fa48ec1c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fa48ec1c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fa48ec1c

Branch: refs/heads/master
Commit: fa48ec1c699eb45db620f7e41cd7fe016e927223
Parents: 850fd05
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 19:51:24 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Thu Oct 9 15:40:41 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/logging.ini                 | 34 ++++++++++++++++++
 .../cartridge-agent/modules/databridge/agent.py |  5 ++-
 .../modules/datapublisher/logpublisher.py       |  7 ++--
 .../modules/healthstatspublisher/healthstats.py | 10 ++----
 .../cartridge-agent/modules/util/log.py         | 38 ++++++++++++++++++++
 5 files changed, 79 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/fa48ec1c/tools/python-cartridge-agent/cartridge-agent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/logging.ini b/tools/python-cartridge-agent/cartridge-agent/logging.ini
new file mode 100644
index 0000000..cf6bc7d
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/logging.ini
@@ -0,0 +1,34 @@
+[formatters]
+keys=default
+
+[formatter_default]
+format=%(asctime)s:%(levelname)s:%(message)s
+class=logging.Formatter
+
+[handlers]
+keys=console, error_file
+
+[handler_console]
+class=logging.StreamHandler
+formatter=default
+args=tuple()
+
+[handler_log_file]
+class=logging.FileHandler
+level=ERROR
+formatter=default
+args=("agent.log", "w")
+
+[handler_error_file]
+class=logging.FileHandler
+level=ERROR
+formatter=default
+args=("error.log", "w")
+
+[loggers]
+keys=root
+
+[logger_root]
+level=DEBUG
+formatter=default
+handlers=console,error_file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/fa48ec1c/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
index 7a8a0dc..b65a2be 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/agent.py
@@ -1,5 +1,5 @@
 from thrift.publisher import *
-import logging
+from ..util.log import *
 
 
 class StreamDefinition:
@@ -88,8 +88,7 @@ class ThriftPublisher:
     """
     Handles publishing events to BAM/CEP through thrift using the provided address and credentials
     """
-    logging.basicConfig(level=logging.DEBUG)
-    log = logging.getLogger(__name__)
+    log = LogFactory().get_log(__name__)
 
     def __init__(self, ip, port, username, password, stream_definition):
         """

http://git-wip-us.apache.org/repos/asf/stratos/blob/fa48ec1c/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
index d2769d9..d5cdc01 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/datapublisher/logpublisher.py
@@ -1,6 +1,5 @@
 import os
 import datetime
-import logging
 from threading import Thread, current_thread
 
 from ..databridge.agent import *
@@ -14,8 +13,7 @@ class LogPublisher(Thread):
     def __init__(self, file_path, stream_definition, tenant_id, alias, date_time, member_id):
         Thread.__init__(self)
 
-        logging.basicConfig(level=logging.DEBUG)
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
 
         self.file_path = file_path
         self.thrift_publisher = ThriftPublisher(
@@ -192,8 +190,7 @@ class DataPublisherConfiguration:
     """
 
     __instance = None
-    logging.basicConfig(level=logging.DEBUG)
-    log = logging.getLogger(__name__)
+    log = LogFactory().get_log(__name__)
 
     @staticmethod
     def get_instance():

http://git-wip-us.apache.org/repos/asf/stratos/blob/fa48ec1c/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
index 953c0fc..ea85d44 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/healthstatspublisher/healthstats.py
@@ -1,6 +1,5 @@
 from threading import Thread
 import time
-import logging
 import psutil
 import os
 
@@ -23,8 +22,7 @@ class HealthStatisticsPublisherManager(Thread):
         """
         Thread.__init__(self)
 
-        logging.basicConfig(level=logging.DEBUG)
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
 
         self.publish_interval = publish_interval
         """:type : int"""
@@ -53,8 +51,7 @@ class HealthStatisticsPublisher:
     Publishes memory usage and load average to thrift server
     """
     def __init__(self):
-        logging.basicConfig(level=logging.DEBUG)
-        self.log = logging.getLogger(__name__)
+        self.log = LogFactory().get_log(__name__)
         self.ports = []
         self.ports.append(CEPPublisherConfiguration.get_instance().server_port)
         cartridgeagentutils.wait_until_ports_active(CEPPublisherConfiguration.get_instance().server_ip, self.ports)
@@ -154,8 +151,7 @@ class CEPPublisherConfiguration:
     """
 
     __instance = None
-    logging.basicConfig(level=logging.DEBUG)
-    log = logging.getLogger(__name__)
+    log = LogFactory().get_log(__name__)
 
     @staticmethod
     def get_instance():

http://git-wip-us.apache.org/repos/asf/stratos/blob/fa48ec1c/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
new file mode 100644
index 0000000..83b1f50
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/log.py
@@ -0,0 +1,38 @@
+import logging
+import logging.config
+import os
+
+
+class LogFactory(object):
+    """
+    Singleton implementation for handling logging in CartridgeAgent
+    """
+    class __LogFactory:
+        def __init__(self):
+            self.logs = {}
+            logging_conf = os.path.join(os.path.dirname(__file__), "logging.ini")
+            logging.config.fileConfig(logging_conf)
+
+        def get_log(self, name):
+            if name not in self.logs:
+                self.logs[name] = logging.getLogger(name)
+
+            return self.logs[name]
+
+    instance = None
+
+    def __new__(cls, *args, **kwargs):
+        if not LogFactory.instance:
+            LogFactory.instance = LogFactory.__LogFactory()
+
+        return LogFactory.instance
+
+    def get_log(self, name):
+        """
+        Returns a logger class with the specified channel name. Creates a new logger if one doesn't exists for the
+        specified channel
+        :param str name: Channel name
+        :return: The logger class
+        :rtype: RootLogger
+        """
+        self.instance.get_log(name)
\ No newline at end of file


[36/50] [abbrv] git commit: Merge remote-tracking branch 'upstream/master'

Posted by ni...@apache.org.
Merge remote-tracking branch 'upstream/master'


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e78b861a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e78b861a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e78b861a

Branch: refs/heads/master
Commit: e78b861a202036adcb95568ccff11a61d2fe6a65
Parents: 191c4c1 0f41d01
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 20:56:36 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Fri Oct 10 20:56:36 2014 +0530

----------------------------------------------------------------------
 .../apache/stratos/cli/GenericRestClient.java   |   4 +-
 .../java/org/apache/stratos/cli/RestClient.java |  35 ++--
 .../stratos/cli/RestCommandLineService.java     | 190 ++++++++++++++++++-
 .../apache/stratos/cli/StratosApplication.java  |  58 ++----
 .../commands/DeployKubernetesGroupCommand.java  | 108 +++++++++++
 .../commands/DeployKubernetesHostCommand.java   | 108 +++++++++++
 .../UnDeployKubernetesGroupCommand.java         |  78 ++++++++
 .../commands/UndeployKubernetesHostCommand.java |  76 ++++++++
 .../stratos/cli/utils/CommandLineUtils.java     |  20 ++
 .../internal/ADCManagementServerComponent.java  |   4 +-
 .../manager/listener/TenantUserRoleCreator.java |  22 +--
 .../manager/user/mgt/StratosUserManager.java    | 139 +++++++-------
 .../mgt/exception/UserManagementException.java  |  41 ----
 .../mgt/exception/UserManagerException.java     |  39 ++++
 .../stratos/manager/utils/UserRoleCreator.java  |  47 ++---
 .../rest/endpoint/services/ServiceUtils.java    |  84 --------
 .../rest/endpoint/services/StratosAdmin.java    |  82 ++++++--
 17 files changed, 825 insertions(+), 310 deletions(-)
----------------------------------------------------------------------



[10/50] [abbrv] Refactored thrift communication module Added databridge additional classes Completed log publishing from agent

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
deleted file mode 100644
index 9d44d71..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
+++ /dev/null
@@ -1,1494 +0,0 @@
-#
-# 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 ttypes import *
-from thrift.Thrift import TProcessor
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol, TProtocol
-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 Exception.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 Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, ade:
-      result.ade = ade
-    except Exception.ttypes.ThriftMalformedStreamDefinitionException, mtd:
-      result.mtd = mtd
-    except Exception.ttypes.ThriftStreamDefinitionException, tde:
-      result.tde = tde
-    except Exception.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 Exception.ttypes.ThriftNoStreamDefinitionExistException, tnde:
-      result.tnde = tnde
-    except Exception.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 Exception.ttypes.ThriftUndefinedEventTypeException, ue:
-      result.ue = ue
-    except Exception.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 Exception.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 Exception.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', (Exception.ttypes.ThriftAuthenticationException, Exception.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 = Exception.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', (Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException, Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'mtd', (Exception.ttypes.ThriftMalformedStreamDefinitionException, Exception.ttypes.ThriftMalformedStreamDefinitionException.thrift_spec), None, ), # 2
-    (3, TType.STRUCT, 'tde', (Exception.ttypes.ThriftStreamDefinitionException, Exception.ttypes.ThriftStreamDefinitionException.thrift_spec), None, ), # 3
-    (4, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftDifferentStreamDefinitionAlreadyDefinedException()
-          self.ade.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.mtd = Exception.ttypes.ThriftMalformedStreamDefinitionException()
-          self.mtd.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 3:
-        if ftype == TType.STRUCT:
-          self.tde = Exception.ttypes.ThriftStreamDefinitionException()
-          self.tde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 4:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftNoStreamDefinitionExistException, Exception.ttypes.ThriftNoStreamDefinitionExistException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftNoStreamDefinitionExistException()
-          self.tnde.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftUndefinedEventTypeException, Exception.ttypes.ThriftUndefinedEventTypeException.thrift_spec), None, ), # 1
-    (2, TType.STRUCT, 'se', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.ttypes.ThriftUndefinedEventTypeException()
-          self.ue.read(iprot)
-        else:
-          iprot.skip(ftype)
-      elif fid == 2:
-        if ftype == TType.STRUCT:
-          self.se = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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', (Exception.ttypes.ThriftSessionExpiredException, Exception.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 = Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
deleted file mode 100644
index c321ae1..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
deleted file mode 100644
index 35216c6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/constants.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# 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 ttypes import *
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py
deleted file mode 100644
index a0727f8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/ThriftSecureEventTransmissionService/ttypes.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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
-import Data.ttypes
-import Exception.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/gen-py/__init__.py
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/stratos/blob/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py
deleted file mode 100644
index da8d283..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSCons.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# 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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py
deleted file mode 100644
index 8a58d89..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TSerialization.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# 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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py
deleted file mode 100644
index af309c3..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/TTornado.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#
-# 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 thrift.transport import TTransport
-from thrift.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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py
deleted file mode 100644
index 9890af7..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/Thrift.py
+++ /dev/null
@@ -1,170 +0,0 @@
-#
-# 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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py
deleted file mode 100644
index 48d659c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/__init__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# 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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py
deleted file mode 100644
index 6cbd5f3..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBase.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# 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.Thrift import *
-from thrift.protocol import TBinaryProtocol
-from thrift.transport import TTransport
-
-try:
-  from thrift.protocol 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/700a6d26/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
deleted file mode 100644
index 6fdd08c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/protocol/TBinaryProtocol.py
+++ /dev/null
@@ -1,260 +0,0 @@
-#
-# 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 TProtocol import *
-from struct import pack, unpack
-
-
-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)


[04/50] [abbrv] Added WSO2 CEP/BAM Python data publisher Wrote a sample log publisher

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
new file mode 100644
index 0000000..7a695a8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TProcessPoolServer.py
@@ -0,0 +1,118 @@
+#
+# 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 logging
+from multiprocessing import  Process, Value, Condition, reduction
+
+from TServer import TServer
+from thrift.transport.TTransport import TTransportException
+
+
+class TProcessPoolServer(TServer):
+    """Server with a fixed size pool of worker subprocesses to service requests
+
+    Note that if you need shared state between the handlers - it's up to you!
+    Written by Dvir Volk, doat.com
+    """
+    def __init__(self, *args):
+        TServer.__init__(self, *args)
+        self.numWorkers = 10
+        self.workers = []
+        self.isRunning = Value('b', False)
+        self.stopCondition = Condition()
+        self.postForkCallback = None
+
+    def setPostForkCallback(self, callback):
+        if not callable(callback):
+            raise TypeError("This is not a callback!")
+        self.postForkCallback = callback
+
+    def setNumWorkers(self, num):
+        """Set the number of worker threads that should be created"""
+        self.numWorkers = num
+
+    def workerProcess(self):
+        """Loop getting clients from the shared queue and process them"""
+        if self.postForkCallback:
+            self.postForkCallback()
+
+        while self.isRunning.value:
+            try:
+                client = self.serverTransport.accept()
+                self.serveClient(client)
+            except (KeyboardInterrupt, SystemExit):
+                return 0
+            except Exception, x:
+                logging.exception(x)
+
+    def serveClient(self, client):
+        """Process input/output from a client for as long as possible"""
+        itrans = self.inputTransportFactory.getTransport(client)
+        otrans = self.outputTransportFactory.getTransport(client)
+        iprot = self.inputProtocolFactory.getProtocol(itrans)
+        oprot = self.outputProtocolFactory.getProtocol(otrans)
+
+        try:
+            while True:
+                self.processor.process(iprot, oprot)
+        except TTransportException, tx:
+            pass
+        except Exception, x:
+            logging.exception(x)
+
+        itrans.close()
+        otrans.close()
+
+    def serve(self):
+        """Start workers and put into queue"""
+        # this is a shared state that can tell the workers to exit when False
+        self.isRunning.value = True
+
+        # first bind and listen to the port
+        self.serverTransport.listen()
+
+        # fork the children
+        for i in range(self.numWorkers):
+            try:
+                w = Process(target=self.workerProcess)
+                w.daemon = True
+                w.start()
+                self.workers.append(w)
+            except Exception, x:
+                logging.exception(x)
+
+        # wait until the condition is set by stop()
+        while True:
+            self.stopCondition.acquire()
+            try:
+                self.stopCondition.wait()
+                break
+            except (SystemExit, KeyboardInterrupt):
+                break
+            except Exception, x:
+                logging.exception(x)
+
+        self.isRunning.value = False
+
+    def stop(self):
+        self.isRunning.value = False
+        self.stopCondition.acquire()
+        self.stopCondition.notify()
+        self.stopCondition.release()

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
new file mode 100644
index 0000000..2f24842
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/TServer.py
@@ -0,0 +1,269 @@
+#
+# 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 Queue
+import logging
+import os
+import sys
+import threading
+import traceback
+
+from thrift.Thrift import TProcessor
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+
+class TServer:
+  """Base interface for a server, which must have a serve() method.
+
+  Three constructors for all servers:
+  1) (processor, serverTransport)
+  2) (processor, serverTransport, transportFactory, protocolFactory)
+  3) (processor, serverTransport,
+      inputTransportFactory, outputTransportFactory,
+      inputProtocolFactory, outputProtocolFactory)
+  """
+  def __init__(self, *args):
+    if (len(args) == 2):
+      self.__initArgs__(args[0], args[1],
+                        TTransport.TTransportFactoryBase(),
+                        TTransport.TTransportFactoryBase(),
+                        TBinaryProtocol.TBinaryProtocolFactory(),
+                        TBinaryProtocol.TBinaryProtocolFactory())
+    elif (len(args) == 4):
+      self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3])
+    elif (len(args) == 6):
+      self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5])
+
+  def __initArgs__(self, processor, serverTransport,
+                   inputTransportFactory, outputTransportFactory,
+                   inputProtocolFactory, outputProtocolFactory):
+    self.processor = processor
+    self.serverTransport = serverTransport
+    self.inputTransportFactory = inputTransportFactory
+    self.outputTransportFactory = outputTransportFactory
+    self.inputProtocolFactory = inputProtocolFactory
+    self.outputProtocolFactory = outputProtocolFactory
+
+  def serve(self):
+    pass
+
+
+class TSimpleServer(TServer):
+  """Simple single-threaded server that just pumps around one transport."""
+
+  def __init__(self, *args):
+    TServer.__init__(self, *args)
+
+  def serve(self):
+    self.serverTransport.listen()
+    while True:
+      client = self.serverTransport.accept()
+      itrans = self.inputTransportFactory.getTransport(client)
+      otrans = self.outputTransportFactory.getTransport(client)
+      iprot = self.inputProtocolFactory.getProtocol(itrans)
+      oprot = self.outputProtocolFactory.getProtocol(otrans)
+      try:
+        while True:
+          self.processor.process(iprot, oprot)
+      except TTransport.TTransportException, tx:
+        pass
+      except Exception, x:
+        logging.exception(x)
+
+      itrans.close()
+      otrans.close()
+
+
+class TThreadedServer(TServer):
+  """Threaded server that spawns a new thread per each connection."""
+
+  def __init__(self, *args, **kwargs):
+    TServer.__init__(self, *args)
+    self.daemon = kwargs.get("daemon", False)
+
+  def serve(self):
+    self.serverTransport.listen()
+    while True:
+      try:
+        client = self.serverTransport.accept()
+        t = threading.Thread(target=self.handle, args=(client,))
+        t.setDaemon(self.daemon)
+        t.start()
+      except KeyboardInterrupt:
+        raise
+      except Exception, x:
+        logging.exception(x)
+
+  def handle(self, client):
+    itrans = self.inputTransportFactory.getTransport(client)
+    otrans = self.outputTransportFactory.getTransport(client)
+    iprot = self.inputProtocolFactory.getProtocol(itrans)
+    oprot = self.outputProtocolFactory.getProtocol(otrans)
+    try:
+      while True:
+        self.processor.process(iprot, oprot)
+    except TTransport.TTransportException, tx:
+      pass
+    except Exception, x:
+      logging.exception(x)
+
+    itrans.close()
+    otrans.close()
+
+
+class TThreadPoolServer(TServer):
+  """Server with a fixed size pool of threads which service requests."""
+
+  def __init__(self, *args, **kwargs):
+    TServer.__init__(self, *args)
+    self.clients = Queue.Queue()
+    self.threads = 10
+    self.daemon = kwargs.get("daemon", False)
+
+  def setNumThreads(self, num):
+    """Set the number of worker threads that should be created"""
+    self.threads = num
+
+  def serveThread(self):
+    """Loop around getting clients from the shared queue and process them."""
+    while True:
+      try:
+        client = self.clients.get()
+        self.serveClient(client)
+      except Exception, x:
+        logging.exception(x)
+
+  def serveClient(self, client):
+    """Process input/output from a client for as long as possible"""
+    itrans = self.inputTransportFactory.getTransport(client)
+    otrans = self.outputTransportFactory.getTransport(client)
+    iprot = self.inputProtocolFactory.getProtocol(itrans)
+    oprot = self.outputProtocolFactory.getProtocol(otrans)
+    try:
+      while True:
+        self.processor.process(iprot, oprot)
+    except TTransport.TTransportException, tx:
+      pass
+    except Exception, x:
+      logging.exception(x)
+
+    itrans.close()
+    otrans.close()
+
+  def serve(self):
+    """Start a fixed number of worker threads and put client into a queue"""
+    for i in range(self.threads):
+      try:
+        t = threading.Thread(target=self.serveThread)
+        t.setDaemon(self.daemon)
+        t.start()
+      except Exception, x:
+        logging.exception(x)
+
+    # Pump the socket for clients
+    self.serverTransport.listen()
+    while True:
+      try:
+        client = self.serverTransport.accept()
+        self.clients.put(client)
+      except Exception, x:
+        logging.exception(x)
+
+
+class TForkingServer(TServer):
+  """A Thrift server that forks a new process for each request
+
+  This is more scalable than the threaded server as it does not cause
+  GIL contention.
+
+  Note that this has different semantics from the threading server.
+  Specifically, updates to shared variables will no longer be shared.
+  It will also not work on windows.
+
+  This code is heavily inspired by SocketServer.ForkingMixIn in the
+  Python stdlib.
+  """
+  def __init__(self, *args):
+    TServer.__init__(self, *args)
+    self.children = []
+
+  def serve(self):
+    def try_close(file):
+      try:
+        file.close()
+      except IOError, e:
+        logging.warning(e, exc_info=True)
+
+    self.serverTransport.listen()
+    while True:
+      client = self.serverTransport.accept()
+      try:
+        pid = os.fork()
+
+        if pid:  # parent
+          # add before collect, otherwise you race w/ waitpid
+          self.children.append(pid)
+          self.collect_children()
+
+          # Parent must close socket or the connection may not get
+          # closed promptly
+          itrans = self.inputTransportFactory.getTransport(client)
+          otrans = self.outputTransportFactory.getTransport(client)
+          try_close(itrans)
+          try_close(otrans)
+        else:
+          itrans = self.inputTransportFactory.getTransport(client)
+          otrans = self.outputTransportFactory.getTransport(client)
+
+          iprot = self.inputProtocolFactory.getProtocol(itrans)
+          oprot = self.outputProtocolFactory.getProtocol(otrans)
+
+          ecode = 0
+          try:
+            try:
+              while True:
+                self.processor.process(iprot, oprot)
+            except TTransport.TTransportException, tx:
+              pass
+            except Exception, e:
+              logging.exception(e)
+              ecode = 1
+          finally:
+            try_close(itrans)
+            try_close(otrans)
+
+          os._exit(ecode)
+
+      except TTransport.TTransportException, tx:
+        pass
+      except Exception, x:
+        logging.exception(x)
+
+  def collect_children(self):
+    while self.children:
+      try:
+        pid, status = os.waitpid(0, os.WNOHANG)
+      except os.error:
+        pid = None
+
+      if pid:
+        self.children.remove(pid)
+      else:
+        break

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__init__.py
new file mode 100644
index 0000000..1bf6e25
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/server/__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__ = ['TServer', 'TNonblockingServer']

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
new file mode 100644
index 0000000..ea80a1a
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/THttpClient.py
@@ -0,0 +1,149 @@
+#
+# 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 httplib
+import os
+import socket
+import sys
+import urllib
+import urlparse
+import warnings
+
+from cStringIO import StringIO
+
+from TTransport import *
+
+
+class THttpClient(TTransportBase):
+  """Http implementation of TTransport base."""
+
+  def __init__(self, uri_or_host, port=None, path=None):
+    """THttpClient supports two different types constructor parameters.
+
+    THttpClient(host, port, path) - deprecated
+    THttpClient(uri)
+
+    Only the second supports https.
+    """
+    if port is not None:
+      warnings.warn(
+        "Please use the THttpClient('http://host:port/path') syntax",
+        DeprecationWarning,
+        stacklevel=2)
+      self.host = uri_or_host
+      self.port = port
+      assert path
+      self.path = path
+      self.scheme = 'http'
+    else:
+      parsed = urlparse.urlparse(uri_or_host)
+      self.scheme = parsed.scheme
+      assert self.scheme in ('http', 'https')
+      if self.scheme == 'http':
+        self.port = parsed.port or httplib.HTTP_PORT
+      elif self.scheme == 'https':
+        self.port = parsed.port or httplib.HTTPS_PORT
+      self.host = parsed.hostname
+      self.path = parsed.path
+      if parsed.query:
+        self.path += '?%s' % parsed.query
+    self.__wbuf = StringIO()
+    self.__http = None
+    self.__timeout = None
+    self.__custom_headers = None
+
+  def open(self):
+    if self.scheme == 'http':
+      self.__http = httplib.HTTP(self.host, self.port)
+    else:
+      self.__http = httplib.HTTPS(self.host, self.port)
+
+  def close(self):
+    self.__http.close()
+    self.__http = None
+
+  def isOpen(self):
+    return self.__http is not None
+
+  def setTimeout(self, ms):
+    if not hasattr(socket, 'getdefaulttimeout'):
+      raise NotImplementedError
+
+    if ms is None:
+      self.__timeout = None
+    else:
+      self.__timeout = ms / 1000.0
+
+  def setCustomHeaders(self, headers):
+    self.__custom_headers = headers
+
+  def read(self, sz):
+    return self.__http.file.read(sz)
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def __withTimeout(f):
+    def _f(*args, **kwargs):
+      orig_timeout = socket.getdefaulttimeout()
+      socket.setdefaulttimeout(args[0].__timeout)
+      result = f(*args, **kwargs)
+      socket.setdefaulttimeout(orig_timeout)
+      return result
+    return _f
+
+  def flush(self):
+    if self.isOpen():
+      self.close()
+    self.open()
+
+    # Pull data out of buffer
+    data = self.__wbuf.getvalue()
+    self.__wbuf = StringIO()
+
+    # HTTP request
+    self.__http.putrequest('POST', self.path)
+
+    # Write headers
+    self.__http.putheader('Host', self.host)
+    self.__http.putheader('Content-Type', 'application/x-thrift')
+    self.__http.putheader('Content-Length', str(len(data)))
+
+    if not self.__custom_headers or 'User-Agent' not in self.__custom_headers:
+      user_agent = 'Python/THttpClient'
+      script = os.path.basename(sys.argv[0])
+      if script:
+        user_agent = '%s (%s)' % (user_agent, urllib.quote(script))
+      self.__http.putheader('User-Agent', user_agent)
+
+    if self.__custom_headers:
+        for key, val in self.__custom_headers.iteritems():
+            self.__http.putheader(key, val)
+
+    self.__http.endheaders()
+
+    # Write payload
+    self.__http.send(data)
+
+    # Get reply to flush the request
+    self.code, self.message, self.headers = self.__http.getreply()
+
+  # Decorate if we know how to timeout
+  if hasattr(socket, 'getdefaulttimeout'):
+    flush = __withTimeout(flush)

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
new file mode 100644
index 0000000..81e0984
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSSLSocket.py
@@ -0,0 +1,214 @@
+#
+# 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 os
+import socket
+import ssl
+
+from thrift.transport import TSocket
+from thrift.transport.TTransport import TTransportException
+
+
+class TSSLSocket(TSocket.TSocket):
+  """
+  SSL implementation of client-side TSocket
+
+  This class creates outbound sockets wrapped using the
+  python standard ssl module for encrypted connections.
+
+  The protocol used is set using the class variable
+  SSL_VERSION, which must be one of ssl.PROTOCOL_* and
+  defaults to  ssl.PROTOCOL_TLSv1 for greatest security.
+  """
+  SSL_VERSION = ssl.PROTOCOL_TLSv1
+
+  def __init__(self,
+               host='localhost',
+               port=9090,
+               validate=True,
+               ca_certs=None,
+               keyfile=None,
+               certfile=None,
+               unix_socket=None):
+    """Create SSL TSocket
+
+    @param validate: Set to False to disable SSL certificate validation
+    @type validate: bool
+    @param ca_certs: Filename to the Certificate Authority pem file, possibly a
+    file downloaded from: http://curl.haxx.se/ca/cacert.pem  This is passed to
+    the ssl_wrap function as the 'ca_certs' parameter.
+    @type ca_certs: str
+    @param keyfile: The private key
+    @type keyfile: str
+    @param certfile: The cert file
+    @type certfile: str
+    
+    Raises an IOError exception if validate is True and the ca_certs file is
+    None, not present or unreadable.
+    """
+    self.validate = validate
+    self.is_valid = False
+    self.peercert = None
+    if not validate:
+      self.cert_reqs = ssl.CERT_NONE
+    else:
+      self.cert_reqs = ssl.CERT_REQUIRED
+    self.ca_certs = ca_certs
+    self.keyfile = keyfile
+    self.certfile = certfile
+    if validate:
+      if ca_certs is None or not os.access(ca_certs, os.R_OK):
+        raise IOError('Certificate Authority ca_certs file "%s" '
+                      'is not readable, cannot validate SSL '
+                      'certificates.' % (ca_certs))
+    TSocket.TSocket.__init__(self, host, port, unix_socket)
+
+  def open(self):
+    try:
+      res0 = self._resolveAddr()
+      for res in res0:
+        sock_family, sock_type = res[0:2]
+        ip_port = res[4]
+        plain_sock = socket.socket(sock_family, sock_type)
+        self.handle = ssl.wrap_socket(plain_sock,
+                                      ssl_version=self.SSL_VERSION,
+                                      do_handshake_on_connect=True,
+                                      ca_certs=self.ca_certs,
+                                      keyfile=self.keyfile,
+                                      certfile=self.certfile,
+                                      cert_reqs=self.cert_reqs)
+        self.handle.settimeout(self._timeout)
+        try:
+          self.handle.connect(ip_port)
+        except socket.error, e:
+          if res is not res0[-1]:
+            continue
+          else:
+            raise e
+        break
+    except socket.error, e:
+      if self._unix_socket:
+        message = 'Could not connect to secure socket %s: %s' \
+                % (self._unix_socket, e)
+      else:
+        message = 'Could not connect to %s:%d: %s' % (self.host, self.port, e)
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message=message)
+    if self.validate:
+      self._validate_cert()
+
+  def _validate_cert(self):
+    """internal method to validate the peer's SSL certificate, and to check the
+    commonName of the certificate to ensure it matches the hostname we
+    used to make this connection.  Does not support subjectAltName records
+    in certificates.
+
+    raises TTransportException if the certificate fails validation.
+    """
+    cert = self.handle.getpeercert()
+    self.peercert = cert
+    if 'subject' not in cert:
+      raise TTransportException(
+        type=TTransportException.NOT_OPEN,
+        message='No SSL certificate found from %s:%s' % (self.host, self.port))
+    fields = cert['subject']
+    for field in fields:
+      # ensure structure we get back is what we expect
+      if not isinstance(field, tuple):
+        continue
+      cert_pair = field[0]
+      if len(cert_pair) < 2:
+        continue
+      cert_key, cert_value = cert_pair[0:2]
+      if cert_key != 'commonName':
+        continue
+      certhost = cert_value
+      # this check should be performed by some sort of Access Manager
+      if certhost == self.host:
+        # success, cert commonName matches desired hostname
+        self.is_valid = True
+        return
+      else:
+        raise TTransportException(
+          type=TTransportException.UNKNOWN,
+          message='Hostname we connected to "%s" doesn\'t match certificate '
+                  'provided commonName "%s"' % (self.host, certhost))
+    raise TTransportException(
+      type=TTransportException.UNKNOWN,
+      message='Could not validate SSL certificate from '
+              'host "%s".  Cert=%s' % (self.host, cert))
+
+
+class TSSLServerSocket(TSocket.TServerSocket):
+  """SSL implementation of TServerSocket
+
+  This uses the ssl module's wrap_socket() method to provide SSL
+  negotiated encryption.
+  """
+  SSL_VERSION = ssl.PROTOCOL_TLSv1
+
+  def __init__(self,
+               host=None,
+               port=9090,
+               certfile='cert.pem',
+               unix_socket=None):
+    """Initialize a TSSLServerSocket
+
+    @param certfile: filename of the server certificate, defaults to cert.pem
+    @type certfile: str
+    @param host: The hostname or IP to bind the listen socket to,
+                 i.e. 'localhost' for only allowing local network connections.
+                 Pass None to bind to all interfaces.
+    @type host: str
+    @param port: The port to listen on for inbound connections.
+    @type port: int
+    """
+    self.setCertfile(certfile)
+    TSocket.TServerSocket.__init__(self, host, port)
+
+  def setCertfile(self, certfile):
+    """Set or change the server certificate file used to wrap new connections.
+
+    @param certfile: The filename of the server certificate,
+                     i.e. '/etc/certs/server.pem'
+    @type certfile: str
+
+    Raises an IOError exception if the certfile is not present or unreadable.
+    """
+    if not os.access(certfile, os.R_OK):
+      raise IOError('No such certfile found: %s' % (certfile))
+    self.certfile = certfile
+
+  def accept(self):
+    plain_client, addr = self.handle.accept()
+    try:
+      client = ssl.wrap_socket(plain_client, certfile=self.certfile,
+                      server_side=True, ssl_version=self.SSL_VERSION)
+    except ssl.SSLError, ssl_exc:
+      # failed handshake/ssl wrap, close socket to client
+      plain_client.close()
+      # raise ssl_exc
+      # We can't raise the exception, because it kills most TServer derived
+      # serve() methods.
+      # Instead, return None, and let the TServer instance deal with it in
+      # other exception handling.  (but TSimpleServer dies anyway)
+      return None
+    result = TSocket.TSocket()
+    result.setHandle(client)
+    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
new file mode 100644
index 0000000..9e2b384
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TSocket.py
@@ -0,0 +1,176 @@
+#
+# 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 errno
+import os
+import socket
+import sys
+
+from TTransport import *
+
+
+class TSocketBase(TTransportBase):
+  def _resolveAddr(self):
+    if self._unix_socket is not None:
+      return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None,
+               self._unix_socket)]
+    else:
+      return socket.getaddrinfo(self.host,
+                                self.port,
+                                socket.AF_UNSPEC,
+                                socket.SOCK_STREAM,
+                                0,
+                                socket.AI_PASSIVE | socket.AI_ADDRCONFIG)
+
+  def close(self):
+    if self.handle:
+      self.handle.close()
+      self.handle = None
+
+
+class TSocket(TSocketBase):
+  """Socket implementation of TTransport base."""
+
+  def __init__(self, host='localhost', port=9090, unix_socket=None):
+    """Initialize a TSocket
+
+    @param host(str)  The host to connect to.
+    @param port(int)  The (TCP) port to connect to.
+    @param unix_socket(str)  The filename of a unix socket to connect to.
+                             (host and port will be ignored.)
+    """
+    self.host = host
+    self.port = port
+    self.handle = None
+    self._unix_socket = unix_socket
+    self._timeout = None
+
+  def setHandle(self, h):
+    self.handle = h
+
+  def isOpen(self):
+    return self.handle is not None
+
+  def setTimeout(self, ms):
+    if ms is None:
+      self._timeout = None
+    else:
+      self._timeout = ms / 1000.0
+
+    if self.handle is not None:
+      self.handle.settimeout(self._timeout)
+
+  def open(self):
+    try:
+      res0 = self._resolveAddr()
+      for res in res0:
+        self.handle = socket.socket(res[0], res[1])
+        self.handle.settimeout(self._timeout)
+        try:
+          self.handle.connect(res[4])
+        except socket.error, e:
+          if res is not res0[-1]:
+            continue
+          else:
+            raise e
+        break
+    except socket.error, e:
+      if self._unix_socket:
+        message = 'Could not connect to socket %s' % self._unix_socket
+      else:
+        message = 'Could not connect to %s:%d' % (self.host, self.port)
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message=message)
+
+  def read(self, sz):
+    try:
+      buff = self.handle.recv(sz)
+    except socket.error, e:
+      if (e.args[0] == errno.ECONNRESET and
+          (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))):
+        # freebsd and Mach don't follow POSIX semantic of recv
+        # and fail with ECONNRESET if peer performed shutdown.
+        # See corresponding comment and code in TSocket::read()
+        # in lib/cpp/src/transport/TSocket.cpp.
+        self.close()
+        # Trigger the check to raise the END_OF_FILE exception below.
+        buff = ''
+      else:
+        raise
+    if len(buff) == 0:
+      raise TTransportException(type=TTransportException.END_OF_FILE,
+                                message='TSocket read 0 bytes')
+    return buff
+
+  def write(self, buff):
+    if not self.handle:
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message='Transport not open')
+    sent = 0
+    have = len(buff)
+    while sent < have:
+      plus = self.handle.send(buff)
+      if plus == 0:
+        raise TTransportException(type=TTransportException.END_OF_FILE,
+                                  message='TSocket sent 0 bytes')
+      sent += plus
+      buff = buff[plus:]
+
+  def flush(self):
+    pass
+
+
+class TServerSocket(TSocketBase, TServerTransportBase):
+  """Socket implementation of TServerTransport base."""
+
+  def __init__(self, host=None, port=9090, unix_socket=None):
+    self.host = host
+    self.port = port
+    self._unix_socket = unix_socket
+    self.handle = None
+
+  def listen(self):
+    res0 = self._resolveAddr()
+    for res in res0:
+      if res[0] is socket.AF_INET6 or res is res0[-1]:
+        break
+
+    # We need remove the old unix socket if the file exists and
+    # nobody is listening on it.
+    if self._unix_socket:
+      tmp = socket.socket(res[0], res[1])
+      try:
+        tmp.connect(res[4])
+      except socket.error, err:
+        eno, message = err.args
+        if eno == errno.ECONNREFUSED:
+          os.unlink(res[4])
+
+    self.handle = socket.socket(res[0], res[1])
+    self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+    if hasattr(self.handle, 'settimeout'):
+      self.handle.settimeout(None)
+    self.handle.bind(res[4])
+    self.handle.listen(128)
+
+  def accept(self):
+    client, addr = self.handle.accept()
+    result = TSocket()
+    result.setHandle(client)
+    return result

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
new file mode 100644
index 0000000..4481371
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTransport.py
@@ -0,0 +1,330 @@
+#
+# 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
+from struct import pack, unpack
+from thrift.Thrift import TException
+
+
+class TTransportException(TException):
+  """Custom Transport Exception class"""
+
+  UNKNOWN = 0
+  NOT_OPEN = 1
+  ALREADY_OPEN = 2
+  TIMED_OUT = 3
+  END_OF_FILE = 4
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
+
+class TTransportBase:
+  """Base class for Thrift transport layer."""
+
+  def isOpen(self):
+    pass
+
+  def open(self):
+    pass
+
+  def close(self):
+    pass
+
+  def read(self, sz):
+    pass
+
+  def readAll(self, sz):
+    buff = ''
+    have = 0
+    while (have < sz):
+      chunk = self.read(sz - have)
+      have += len(chunk)
+      buff += chunk
+
+      if len(chunk) == 0:
+        raise EOFError()
+
+    return buff
+
+  def write(self, buf):
+    pass
+
+  def flush(self):
+    pass
+
+
+# This class should be thought of as an interface.
+class CReadableTransport:
+  """base class for transports that are readable from C"""
+
+  # TODO(dreiss): Think about changing this interface to allow us to use
+  #               a (Python, not c) StringIO instead, because it allows
+  #               you to write after reading.
+
+  # NOTE: This is a classic class, so properties will NOT work
+  #       correctly for setting.
+  @property
+  def cstringio_buf(self):
+    """A cStringIO buffer that contains the current chunk we are reading."""
+    pass
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Refills cstringio_buf.
+
+    Returns the currently used buffer (which can but need not be the same as
+    the old cstringio_buf). partialread is what the C code has read from the
+    buffer, and should be inserted into the buffer before any more reads.  The
+    return value must be a new, not borrowed reference.  Something along the
+    lines of self._buf should be fine.
+
+    If reqlen bytes can't be read, throw EOFError.
+    """
+    pass
+
+
+class TServerTransportBase:
+  """Base class for Thrift server transports."""
+
+  def listen(self):
+    pass
+
+  def accept(self):
+    pass
+
+  def close(self):
+    pass
+
+
+class TTransportFactoryBase:
+  """Base class for a Transport Factory"""
+
+  def getTransport(self, trans):
+    return trans
+
+
+class TBufferedTransportFactory:
+  """Factory transport that builds buffered transports"""
+
+  def getTransport(self, trans):
+    buffered = TBufferedTransport(trans)
+    return buffered
+
+
+class TBufferedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and buffers its I/O.
+
+  The implementation uses a (configurable) fixed-size read buffer
+  but buffers all writes until a flush is performed.
+  """
+  DEFAULT_BUFFER = 4096
+
+  def __init__(self, trans, rbuf_size=DEFAULT_BUFFER):
+    self.__trans = trans
+    self.__wbuf = StringIO()
+    self.__rbuf = StringIO("")
+    self.__rbuf_size = rbuf_size
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
+    return self.__rbuf.read(sz)
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    out = self.__wbuf.getvalue()
+    # reset wbuf before write/flush to preserve state on underlying failure
+    self.__wbuf = StringIO()
+    self.__trans.write(out)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    retstring = partialread
+    if reqlen < self.__rbuf_size:
+      # try to make a read of as much as we can.
+      retstring += self.__trans.read(self.__rbuf_size)
+
+    # but make sure we do read reqlen bytes.
+    if len(retstring) < reqlen:
+      retstring += self.__trans.readAll(reqlen - len(retstring))
+
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf
+
+
+class TMemoryBuffer(TTransportBase, CReadableTransport):
+  """Wraps a cStringIO object as a TTransport.
+
+  NOTE: Unlike the C++ version of this class, you cannot write to it
+        then immediately read from it.  If you want to read from a
+        TMemoryBuffer, you must either pass a string to the constructor.
+  TODO(dreiss): Make this work like the C++ version.
+  """
+
+  def __init__(self, value=None):
+    """value -- a value to read from for stringio
+
+    If value is set, this will be a transport for reading,
+    otherwise, it is for writing"""
+    if value is not None:
+      self._buffer = StringIO(value)
+    else:
+      self._buffer = StringIO()
+
+  def isOpen(self):
+    return not self._buffer.closed
+
+  def open(self):
+    pass
+
+  def close(self):
+    self._buffer.close()
+
+  def read(self, sz):
+    return self._buffer.read(sz)
+
+  def write(self, buf):
+    self._buffer.write(buf)
+
+  def flush(self):
+    pass
+
+  def getvalue(self):
+    return self._buffer.getvalue()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self._buffer
+
+  def cstringio_refill(self, partialread, reqlen):
+    # only one shot at reading...
+    raise EOFError()
+
+
+class TFramedTransportFactory:
+  """Factory transport that builds framed transports"""
+
+  def getTransport(self, trans):
+    framed = TFramedTransport(trans)
+    return framed
+
+
+class TFramedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and frames its I/O when writing."""
+
+  def __init__(self, trans,):
+    self.__trans = trans
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.readFrame()
+    return self.__rbuf.read(sz)
+
+  def readFrame(self):
+    buff = self.__trans.readAll(4)
+    sz, = unpack('!i', buff)
+    self.__rbuf = StringIO(self.__trans.readAll(sz))
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    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 = pack("!i", wsz) + wout
+    self.__trans.write(buf)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, prefix, reqlen):
+    # self.__rbuf will already be empty here because fastbinary doesn't
+    # ask for a refill until the previous buffer is empty.  Therefore,
+    # we can start reading new frames immediately.
+    while len(prefix) < reqlen:
+      self.readFrame()
+      prefix += self.__rbuf.getvalue()
+    self.__rbuf = StringIO(prefix)
+    return self.__rbuf
+
+
+class TFileObjectTransport(TTransportBase):
+  """Wraps a file-like object to make it work as a Thrift transport."""
+
+  def __init__(self, fileobj):
+    self.fileobj = fileobj
+
+  def isOpen(self):
+    return True
+
+  def close(self):
+    self.fileobj.close()
+
+  def read(self, sz):
+    return self.fileobj.read(sz)
+
+  def write(self, buf):
+    self.fileobj.write(buf)
+
+  def flush(self):
+    self.fileobj.flush()

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
new file mode 100644
index 0000000..3ce3eb2
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TTwisted.py
@@ -0,0 +1,221 @@
+#
+# 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
+
+from zope.interface import implements, Interface, Attribute
+from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \
+    connectionDone
+from twisted.internet import defer
+from twisted.protocols import basic
+from twisted.python import log
+from twisted.web import server, resource, http
+
+from thrift.transport import TTransport
+
+
+class TMessageSenderTransport(TTransport.TTransportBase):
+
+    def __init__(self):
+        self.__wbuf = StringIO()
+
+    def write(self, buf):
+        self.__wbuf.write(buf)
+
+    def flush(self):
+        msg = self.__wbuf.getvalue()
+        self.__wbuf = StringIO()
+        self.sendMessage(msg)
+
+    def sendMessage(self, message):
+        raise NotImplementedError
+
+
+class TCallbackTransport(TMessageSenderTransport):
+
+    def __init__(self, func):
+        TMessageSenderTransport.__init__(self)
+        self.func = func
+
+    def sendMessage(self, message):
+        self.func(message)
+
+
+class ThriftClientProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self._client_class = client_class
+        self._iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self._oprot_factory = iprot_factory
+        else:
+            self._oprot_factory = oprot_factory
+
+        self.recv_map = {}
+        self.started = defer.Deferred()
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def connectionMade(self):
+        tmo = TCallbackTransport(self.dispatch)
+        self.client = self._client_class(tmo, self._oprot_factory)
+        self.started.callback(self.client)
+
+    def connectionLost(self, reason=connectionDone):
+        for k, v in self.client._reqs.iteritems():
+            tex = TTransport.TTransportException(
+                type=TTransport.TTransportException.END_OF_FILE,
+                message='Connection closed')
+            v.errback(tex)
+
+    def stringReceived(self, frame):
+        tr = TTransport.TMemoryBuffer(frame)
+        iprot = self._iprot_factory.getProtocol(tr)
+        (fname, mtype, rseqid) = iprot.readMessageBegin()
+
+        try:
+            method = self.recv_map[fname]
+        except KeyError:
+            method = getattr(self.client, 'recv_' + fname)
+            self.recv_map[fname] = method
+
+        method(iprot, mtype, rseqid)
+
+
+class ThriftServerProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def processError(self, error):
+        self.transport.loseConnection()
+
+    def processOk(self, _, tmo):
+        msg = tmo.getvalue()
+
+        if len(msg) > 0:
+            self.dispatch(msg)
+
+    def stringReceived(self, frame):
+        tmi = TTransport.TMemoryBuffer(frame)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.factory.iprot_factory.getProtocol(tmi)
+        oprot = self.factory.oprot_factory.getProtocol(tmo)
+
+        d = self.factory.processor.process(iprot, oprot)
+        d.addCallbacks(self.processOk, self.processError,
+            callbackArgs=(tmo,))
+
+
+class IThriftServerFactory(Interface):
+
+    processor = Attribute("Thrift processor")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class IThriftClientFactory(Interface):
+
+    client_class = Attribute("Thrift client class")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class ThriftServerFactory(ServerFactory):
+
+    implements(IThriftServerFactory)
+
+    protocol = ThriftServerProtocol
+
+    def __init__(self, processor, iprot_factory, oprot_factory=None):
+        self.processor = processor
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+
+class ThriftClientFactory(ClientFactory):
+
+    implements(IThriftClientFactory)
+
+    protocol = ThriftClientProtocol
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self.client_class = client_class
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+    def buildProtocol(self, addr):
+        p = self.protocol(self.client_class, self.iprot_factory,
+            self.oprot_factory)
+        p.factory = self
+        return p
+
+
+class ThriftResource(resource.Resource):
+
+    allowedMethods = ('POST',)
+
+    def __init__(self, processor, inputProtocolFactory,
+        outputProtocolFactory=None):
+        resource.Resource.__init__(self)
+        self.inputProtocolFactory = inputProtocolFactory
+        if outputProtocolFactory is None:
+            self.outputProtocolFactory = inputProtocolFactory
+        else:
+            self.outputProtocolFactory = outputProtocolFactory
+        self.processor = processor
+
+    def getChild(self, path, request):
+        return self
+
+    def _cbProcess(self, _, request, tmo):
+        msg = tmo.getvalue()
+        request.setResponseCode(http.OK)
+        request.setHeader("content-type", "application/x-thrift")
+        request.write(msg)
+        request.finish()
+
+    def render_POST(self, request):
+        request.content.seek(0, 0)
+        data = request.content.read()
+        tmi = TTransport.TMemoryBuffer(data)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.inputProtocolFactory.getProtocol(tmi)
+        oprot = self.outputProtocolFactory.getProtocol(tmo)
+
+        d = self.processor.process(iprot, oprot)
+        d.addCallback(self._cbProcess, request, tmo)
+        return server.NOT_DONE_YET

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
new file mode 100644
index 0000000..a2f42a5
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/TZlibTransport.py
@@ -0,0 +1,248 @@
+#
+# 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.
+#
+
+"""TZlibTransport provides a compressed transport and transport factory
+class, using the python standard library zlib module to implement
+data compression.
+"""
+
+from __future__ import division
+import zlib
+from cStringIO import StringIO
+from TTransport import TTransportBase, CReadableTransport
+
+
+class TZlibTransportFactory(object):
+  """Factory transport that builds zlib compressed transports.
+
+  This factory caches the last single client/transport that it was passed
+  and returns the same TZlibTransport object that was created.
+
+  This caching means the TServer class will get the _same_ transport
+  object for both input and output transports from this factory.
+  (For non-threaded scenarios only, since the cache only holds one object)
+
+  The purpose of this caching is to allocate only one TZlibTransport where
+  only one is really needed (since it must have separate read/write buffers),
+  and makes the statistics from getCompSavings() and getCompRatio()
+  easier to understand.
+  """
+  # class scoped cache of last transport given and zlibtransport returned
+  _last_trans = None
+  _last_z = None
+
+  def getTransport(self, trans, compresslevel=9):
+    """Wrap a transport, trans, with the TZlibTransport
+    compressed transport class, returning a new
+    transport to the caller.
+
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Defaults to 9.
+    @type compresslevel: int
+
+    This method returns a TZlibTransport which wraps the
+    passed C{trans} TTransport derived instance.
+    """
+    if trans == self._last_trans:
+      return self._last_z
+    ztrans = TZlibTransport(trans, compresslevel)
+    self._last_trans = trans
+    self._last_z = ztrans
+    return ztrans
+
+
+class TZlibTransport(TTransportBase, CReadableTransport):
+  """Class that wraps a transport with zlib, compressing writes
+  and decompresses reads, using the python standard
+  library zlib module.
+  """
+  # Read buffer size for the python fastbinary C extension,
+  # the TBinaryProtocolAccelerated class.
+  DEFAULT_BUFFSIZE = 4096
+
+  def __init__(self, trans, compresslevel=9):
+    """Create a new TZlibTransport, wrapping C{trans}, another
+    TTransport derived object.
+
+    @param trans: A thrift transport object, i.e. a TSocket() object.
+    @type trans: TTransport
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Default is 9.
+    @type compresslevel: int
+    """
+    self.__trans = trans
+    self.compresslevel = compresslevel
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+    self._init_zlib()
+    self._init_stats()
+
+  def _reinit_buffers(self):
+    """Internal method to initialize/reset the internal StringIO objects
+    for read and write buffers.
+    """
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def _init_stats(self):
+    """Internal method to reset the internal statistics counters
+    for compression ratios and bandwidth savings.
+    """
+    self.bytes_in = 0
+    self.bytes_out = 0
+    self.bytes_in_comp = 0
+    self.bytes_out_comp = 0
+
+  def _init_zlib(self):
+    """Internal method for setting up the zlib compression and
+    decompression objects.
+    """
+    self._zcomp_read = zlib.decompressobj()
+    self._zcomp_write = zlib.compressobj(self.compresslevel)
+
+  def getCompRatio(self):
+    """Get the current measured compression ratios (in,out) from
+    this transport.
+
+    Returns a tuple of:
+    (inbound_compression_ratio, outbound_compression_ratio)
+
+    The compression ratios are computed as:
+        compressed / uncompressed
+
+    E.g., data that compresses by 10x will have a ratio of: 0.10
+    and data that compresses to half of ts original size will
+    have a ratio of 0.5
+
+    None is returned if no bytes have yet been processed in
+    a particular direction.
+    """
+    r_percent, w_percent = (None, None)
+    if self.bytes_in > 0:
+      r_percent = self.bytes_in_comp / self.bytes_in
+    if self.bytes_out > 0:
+      w_percent = self.bytes_out_comp / self.bytes_out
+    return (r_percent, w_percent)
+
+  def getCompSavings(self):
+    """Get the current count of saved bytes due to data
+    compression.
+
+    Returns a tuple of:
+    (inbound_saved_bytes, outbound_saved_bytes)
+
+    Note: if compression is actually expanding your
+    data (only likely with very tiny thrift objects), then
+    the values returned will be negative.
+    """
+    r_saved = self.bytes_in - self.bytes_in_comp
+    w_saved = self.bytes_out - self.bytes_out_comp
+    return (r_saved, w_saved)
+
+  def isOpen(self):
+    """Return the underlying transport's open status"""
+    return self.__trans.isOpen()
+
+  def open(self):
+    """Open the underlying transport"""
+    self._init_stats()
+    return self.__trans.open()
+
+  def listen(self):
+    """Invoke the underlying transport's listen() method"""
+    self.__trans.listen()
+
+  def accept(self):
+    """Accept connections on the underlying transport"""
+    return self.__trans.accept()
+
+  def close(self):
+    """Close the underlying transport,"""
+    self._reinit_buffers()
+    self._init_zlib()
+    return self.__trans.close()
+
+  def read(self, sz):
+    """Read up to sz bytes from the decompressed bytes buffer, and
+    read from the underlying transport if the decompression
+    buffer is empty.
+    """
+    ret = self.__rbuf.read(sz)
+    if len(ret) > 0:
+      return ret
+    # keep reading from transport until something comes back
+    while True:
+      if self.readComp(sz):
+        break
+    ret = self.__rbuf.read(sz)
+    return ret
+
+  def readComp(self, sz):
+    """Read compressed data from the underlying transport, then
+    decompress it and append it to the internal StringIO read buffer
+    """
+    zbuf = self.__trans.read(sz)
+    zbuf = self._zcomp_read.unconsumed_tail + zbuf
+    buf = self._zcomp_read.decompress(zbuf)
+    self.bytes_in += len(zbuf)
+    self.bytes_in_comp += len(buf)
+    old = self.__rbuf.read()
+    self.__rbuf = StringIO(old + buf)
+    if len(old) + len(buf) == 0:
+      return False
+    return True
+
+  def write(self, buf):
+    """Write some bytes, putting them into the internal write
+    buffer for eventual compression.
+    """
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    """Flush any queued up data in the write buffer and ensure the
+    compression buffer is flushed out to the underlying transport
+    """
+    wout = self.__wbuf.getvalue()
+    if len(wout) > 0:
+      zbuf = self._zcomp_write.compress(wout)
+      self.bytes_out += len(wout)
+      self.bytes_out_comp += len(zbuf)
+    else:
+      zbuf = ''
+    ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH)
+    self.bytes_out_comp += len(ztail)
+    if (len(zbuf) + len(ztail)) > 0:
+      self.__wbuf = StringIO()
+      self.__trans.write(zbuf + ztail)
+    self.__trans.flush()
+
+  @property
+  def cstringio_buf(self):
+    """Implement the CReadableTransport interface"""
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Implement the CReadableTransport interface for refill"""
+    retstring = partialread
+    if reqlen < self.DEFAULT_BUFFSIZE:
+      retstring += self.read(self.DEFAULT_BUFFSIZE)
+    while len(retstring) < reqlen:
+      retstring += self.read(reqlen - len(retstring))
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf

http://git-wip-us.apache.org/repos/asf/stratos/blob/f4b2b5c7/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__init__.py
new file mode 100644
index 0000000..c9596d9
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/thriftcom/thrift/transport/__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__ = ['TTransport', 'TSocket', 'THttpClient', 'TZlibTransport']


[24/50] [abbrv] Fixed path issues in thrift python client

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ThriftSecureEventTransmissionService.py
new file mode 100644
index 0000000..b8c13c1
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py
new file mode 100644
index 0000000..c321ae1
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/__init__.py
@@ -0,0 +1 @@
+__all__ = ['ttypes', 'constants', 'ThriftSecureEventTransmissionService']

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/constants.py
new file mode 100644
index 0000000..36943ba
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/ThriftSecureEventTransmissionService/ttypes.py
new file mode 100644
index 0000000..37ac241
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/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/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/gen/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
index fa0a636..7c09d40 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/publisher.py
@@ -1,10 +1,10 @@
 import time
 import sys
 
-sys.path.append("databridge/thrift/gen-py")
+sys.path.append("gen")
 
-from ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
-from ThriftSecureEventTransmissionService.ttypes import *
+from gen.ThriftSecureEventTransmissionService import ThriftSecureEventTransmissionService
+from gen.ThriftSecureEventTransmissionService.ttypes import *
 
 from thrift.transport import TSSLSocket
 from thrift.transport import TTransport

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
index af309c3..8d9f5ed 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/TTornado.py
@@ -22,8 +22,8 @@ import logging
 import socket
 import struct
 
-from thrift.transport import TTransport
-from thrift.transport.TTransport import TTransportException
+from .transport import TTransport
+from .transport.TTransport import TTransportException
 
 from tornado import gen
 from tornado import iostream

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
index 6cbd5f3..61b469b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TBase.py
@@ -17,12 +17,12 @@
 # under the License.
 #
 
-from thrift.Thrift import *
-from thrift.protocol import TBinaryProtocol
-from thrift.transport import TTransport
+from ..Thrift import *
+import TBinaryProtocol
+from ..transport import TTransport
 
 try:
-  from thrift.protocol import fastbinary
+  import fastbinary
 except:
   fastbinary = None
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
index dc2b095..0154641 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/protocol/TProtocol.py
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-from thrift.Thrift import *
+from ..Thrift import *
 
 
 class TProtocolException(TException):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
index be54bab..6ee18dd 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/THttpServer.py
@@ -19,8 +19,8 @@
 
 import BaseHTTPServer
 
-from thrift.server import TServer
-from thrift.transport import TTransport
+from ..server import TServer
+from ..transport import TTransport
 
 
 class ResponseException(Exception):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
index fa478d0..aa27991 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TNonblockingServer.py
@@ -31,8 +31,8 @@ import select
 import struct
 import logging
 
-from thrift.transport import TTransport
-from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
+from ..transport import TTransport
+from ..protocol.TBinaryProtocol import TBinaryProtocolFactory
 
 __all__ = ['TNonblockingServer']
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
index 2cd2189..74e142c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TProcessPoolServer.py
@@ -22,7 +22,7 @@ import logging
 from multiprocessing import  Process, Value, Condition
 
 from TServer import TServer
-from thrift.transport.TTransport import TTransportException
+from ..transport.TTransport import TTransportException
 
 
 class TProcessPoolServer(TServer):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
index 2f24842..3e44107 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/server/TServer.py
@@ -24,9 +24,9 @@ import sys
 import threading
 import traceback
 
-from thrift.Thrift import TProcessor
-from thrift.protocol import TBinaryProtocol
-from thrift.transport import TTransport
+from ..Thrift import TProcessor
+from ..protocol import TBinaryProtocol
+from ..transport import TTransport
 
 
 class TServer:

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
index 81e0984..df35be4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TSSLSocket.py
@@ -21,8 +21,8 @@ import os
 import socket
 import ssl
 
-from thrift.transport import TSocket
-from thrift.transport.TTransport import TTransportException
+import TSocket
+from TTransport import TTransportException
 
 
 class TSSLSocket(TSocket.TSocket):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
index 4481371..ed023d5 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTransport.py
@@ -19,7 +19,7 @@
 
 from cStringIO import StringIO
 from struct import pack, unpack
-from thrift.Thrift import TException
+from ..Thrift import TException
 
 
 class TTransportException(TException):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
index 3ce3eb2..6cdb172 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/databridge/thrift/thrift/transport/TTwisted.py
@@ -27,7 +27,7 @@ from twisted.protocols import basic
 from twisted.python import log
 from twisted.web import server, resource, http
 
-from thrift.transport import TTransport
+import TTransport
 
 
 class TMessageSenderTransport(TTransport.TTransportBase):

http://git-wip-us.apache.org/repos/asf/stratos/blob/105a09e9/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
index 487def4..013713b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -472,5 +472,4 @@ def execute_command(command, env_params=None):
     return output, errors
 
 
-from .. config import cartridgeagentconfiguration
 from .. topology.topologycontext import *
\ No newline at end of file