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 11:09:26 UTC

[01/50] [abbrv] git commit: AsyncScheduledTask for scheduled tasks with interval Artifact update task

Repository: stratos
Updated Branches:
  refs/heads/master f2252b7c5 -> fd0f922a0


AsyncScheduledTask for scheduled tasks with interval
Artifact update task


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

Branch: refs/heads/master
Commit: 6d3855929fb1311fe1a0ae278cb340ac2f676188
Parents: 4d93c97
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Sep 25 06:41:06 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../modules/artifactmgt/__init__.py             |  1 -
 .../modules/artifactmgt/git/agentgithandler.py  | 52 ++++++++++++++++++--
 .../modules/artifactmgt/git/gitrepository.py    |  2 +-
 .../cartridge-agent/modules/config/__init__.py  |  1 -
 .../cartridge-agent/modules/event/__init__.py   |  1 -
 .../modules/event/instance/__init__.py          |  1 -
 .../modules/event/instance/notifier/__init__.py |  1 -
 .../modules/event/instance/status/__init__.py   |  1 -
 .../modules/event/tenant/__init__.py            |  1 -
 .../modules/exception/__init__.py               |  1 -
 .../modules/extensions/__init__.py              |  1 -
 .../extensions/defaultextensionhandler.py       | 25 +++++++++-
 .../modules/subscriber/__init__.py              |  1 -
 .../modules/util/asyncscheduledtask.py          | 22 +++++++++
 14 files changed, 95 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 b1e49e4..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
@@ -1 +0,0 @@
-__all__=['repositoryinformation']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 a59e83c..8348569 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,14 +1,16 @@
 import logging
-from threading import current_thread
+from threading import current_thread, Thread
 
 from git import *
 
 from gitrepository import GitRepository
 from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from ... util import cartridgeagentutils
+from ... util.asyncscheduledtask import AsyncScheduledTask
 from ... artifactmgt.repositoryinformation import RepositoryInformation
 from ... extensions.defaultextensionhandler import DefaultExtensionHandler
 
+
 class AgentGitHandler:
     logging.basicConfig(level=logging.DEBUG)
     log = logging.getLogger(__name__)
@@ -130,7 +132,7 @@ class AgentGitHandler:
                 """
                 conflict_list = []
                 files_arr = str(ex).split("\n")
-                for file_index in range (1, len(files_arr)-2):
+                for file_index in range(1, len(files_arr)-2):
                     file_name = files_arr[file_index].strip()
                     conflict_list.append(file_name)
                     AgentGitHandler.log.debug("Added the file path %r to checkout from the remote repository" % file_name)
@@ -265,4 +267,48 @@ class AgentGitHandler:
             repo_path = git_local_repo_path
 
         AgentGitHandler.log.debug("Repo path returned : %r" % repo_path)
-        return repo_path
\ No newline at end of file
+        return repo_path
+
+    @staticmethod
+    def commit(repo_info):
+        raise NotImplementedError
+
+    @staticmethod
+    def schedule_artifact_update_scheduled_task(repo_info, auto_checkout, auto_commit, update_interval):
+        repo_context = AgentGitHandler.get_repo_context(repo_info.tenant_id)
+
+        if repo_context is None:
+            AgentGitHandler.log.error("Unable to schedule artifact sync task, repositoryContext null for tenant %r" % repo_info.tenant_id)
+            return
+
+        if repo_context.scheduled_update_task is None:
+            #TODO: make thread safe
+            artifact_update_task = ArtifactUpdateTask(repo_info, auto_checkout, auto_commit)
+            async_task = AsyncScheduledTask(update_interval, artifact_update_task)
+
+            repo_context.scheduled_update_task = async_task
+            async_task.start()
+            AgentGitHandler.log.info("Scheduled Artifact Synchronization Task for path %r" % repo_context.local_repo_path)
+        else:
+            AgentGitHandler.log.info("Artifact Synchronization Task for path %r already scheduled" % repo_context.local_repo_path)
+            
+
+class ArtifactUpdateTask(Thread):
+
+    def __init__(self, repo_info, auto_checkout, auto_commit):
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+        Thread.__init__(self)
+        self.repo_info = repo_info
+        self.auto_checkout = auto_checkout
+        self.auto_commit = auto_commit
+
+    def run(self):
+        try:
+            if self.auto_checkout:
+                AgentGitHandler.checkout(self.repo_info)
+        except:
+            self.log.exception()
+
+        if self.auto_commit:
+            AgentGitHandler.commit(self.repo_info)

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 568c275..0e60e2f 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
@@ -11,4 +11,4 @@ class GitRepository:
         self.repo_password = None
         self.is_multitenant = False
         self.commit_enabled = False
-        #scheduled update servicef
\ No newline at end of file
+        self.scheduled_update_task = None
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 836c3ab..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
@@ -1 +0,0 @@
-__all__=['cartridgeagentconfiguration']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/tools/python-cartridge-agent/cartridge-agent/modules/event/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/__init__.py
index 0de6991..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/__init__.py
@@ -1 +0,0 @@
-__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 0de6991..e69de29 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
@@ -1 +0,0 @@
-__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 3bcb310..e69de29 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
@@ -1 +0,0 @@
-__all__ = ['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 cd8b9d2..e69de29 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
@@ -1 +0,0 @@
-__all__=['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 cd8b9d2..e69de29 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
@@ -1 +0,0 @@
-__all__=['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 7f59666..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
@@ -1 +0,0 @@
-__all__ = ['parameternotfoundexception']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 33da048..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
@@ -1 +0,0 @@
-__all__=['defaultextensionhandler']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 505b59c..265034e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -5,6 +5,7 @@ from ..artifactmgt.repositoryinformation import RepositoryInformation
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. util import extensionutils, cartridgeagentconstants, cartridgeagentutils
 from .. publisher import cartridgeagentpublisher
+from .. exception.parameternotfoundexception import ParameterNotFoundException
 
 
 class DefaultExtensionHandler:
@@ -63,6 +64,7 @@ class DefaultExtensionHandler:
 
             #checkout code
             checkout_result = AgentGitHandler.checkout(repo_info)
+            #repo_context = checkout_result["repo_context"]
             #execute artifact updated extension
             env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": event.cluster_id,
                           "STRATOS_ARTIFACT_UPDATED_TENANT_ID": event.tenant_id,
@@ -73,12 +75,31 @@ class DefaultExtensionHandler:
 
             extensionutils.execute_artifacts_updated_extension(env_params)
 
-            #if !cloneExists publish instanceActivatedEvent
             if checkout_result["subscribe_run"]:
                 #publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 
-            #TODO: set artifact update task
+            update_artifacts = self.cartridge_agent_config.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE)
+            update_artifacts = True if str(update_artifacts).strip().lower() == "true" else False
+            if update_artifacts:
+                auto_commit = self.cartridge_agent_config.is_commits_enabled()
+                auto_checkout = self.cartridge_agent_config.is_checkout_enabled()
+
+                try:
+                    update_interval = len(self.cartridge_agent_config.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL))
+                except ParameterNotFoundException:
+                    self.log.exception("Invalid artifact sync interval specified ")
+                    update_interval = 10
+                except ValueError:
+                    self.log.exception("Invalid artifact sync interval specified ")
+                    update_interval = 10
+
+                self.log.info("Artifact updating task enabled, update interval: %r seconds" % update_interval)
+
+                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, update_interval)
 
     def on_artifact_update_scheduler_event(self, tenantId):
         pass

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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 27483e8..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
@@ -1 +0,0 @@
-__all__=['eventsubscriber']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6d385592/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
new file mode 100644
index 0000000..12ec849
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
@@ -0,0 +1,22 @@
+import time
+from threading import Thread
+
+
+class AsyncScheduledTask(Thread):
+    """
+    Executes a given task with a given interval until being terminated
+    """
+
+    def __init__(self, delay, task):
+        Thread.__init__(self)
+        self.delay = delay
+        self.task = task
+        self.terminated = False
+
+    def run(self):
+        while not self.terminated:
+            time.sleep(self.delay)
+            self.task.start()
+
+    def terminate(self):
+        self.terminated = True
\ No newline at end of file


[23/50] [abbrv] git commit: Completed start servers extension path

Posted by ni...@apache.org.
Completed start servers extension path


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

Branch: refs/heads/master
Commit: 8c9f74ea56bac33253da030dfbb14209e15dfbc5
Parents: 6b8fc6e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Sep 26 16:56:29 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 2014 +0530

----------------------------------------------------------------------
 .../modules/event/topology/events.py            |  4 ++
 .../extensions/defaultextensionhandler.py       | 61 +++++++++++++-------
 .../modules/topology/topologycontext.py         |  1 +
 .../modules/util/extensionutils.py              | 20 ++++++-
 4 files changed, 65 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8c9f74ea/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 10be3e2..e0f050f 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
@@ -123,6 +123,7 @@ class CompleteTopologyEvent:
                     cluster_obj.status = cluster_str["status"]
                     cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"]
                     cluster_obj.properties = cluster_str["properties"]
+                    cluster_obj.member_list_json = "["
 
                     #add member map
                     for member_id in cluster_str["memberMap"]:
@@ -139,6 +140,7 @@ class CompleteTopologyEvent:
                         member_obj.properties = member_str["properties"]
                         member_obj.lb_cluster_id = member_str["lbClusterId"]
                         member_obj.json_str = member_str
+                        cluster_obj.member_list_json += member_str + ","
 
                         #add port map
                         for mm_port_proxy in member_str["portMap"]:
@@ -146,6 +148,8 @@ 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/8c9f74ea/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 9135a8a..848f478 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -210,26 +210,47 @@ class DefaultExtensionHandler:
         pass
 
     def start_server_extension(self):
-        raise NotImplementedError
-        # 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()
-        #
-        # try:
-        # consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
-        #
-        # if not consistant:
-        # self.log.error("Topology is inconsistent...failed to execute start server event")
-        # return
-        #
-        #
-        # except:
-        # self.log.exception("Error processing start servers event")
-        # finally:
-        #     pass
+        #wait until complete topology message is received to get LB IP
+        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()
+
+        topology_consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
+
+        try:
+            if not topology_consistant:
+                self.log.error("Topology is inconsistent...failed to execute start server event")
+                return
+
+            topology = TopologyContext.get_topology()
+            service = topology.get_service(service_name_in_payload)
+            cluster = service.get_cluster(cluster_id_in_payload)
+
+            # store environment variable parameters to be passed to extension shell script
+            env_params = {}
+
+            # if clustering is enabled wait until all well known members have started
+            clustering_enabled = CartridgeAgentConfiguration.is_clustered
+            if clustering_enabled:
+                env_params["STRATOS_CLUSTERING"] = "true"
+                env_params["STRATOS_WK_MEMBER_COUNT"] = CartridgeAgentConfiguration.min_count
+
+
+                env_params["STRATOS_PRIMARY"] = "true" if CartridgeAgentConfiguration.is_primary else "false"
+
+                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
+
+            extensionutils.execute_start_servers_extension(env_params)
+
+        except:
+            self.log.exception("Error processing start servers event")
 
     def volume_mount_extension(self, persistence_mappings_payload):
         extensionutils.execute_volume_mount_extension(persistence_mappings_payload)

http://git-wip-us.apache.org/repos/asf/stratos/blob/8c9f74ea/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 7fee50d..73b6e3c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -122,6 +122,7 @@ class Cluster:
         self.status = None
         self.load_balancer_algorithm_name = None
         self.properties = {}
+        self.member_list_json = None
 
     def add_hostname(self, hostname):
         self.hostnames.append(hostname)

http://git-wip-us.apache.org/repos/asf/stratos/blob/8c9f74ea/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 267c608..70d9c44 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -1,6 +1,7 @@
 import logging
 import os
 import subprocess
+import time
 
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. topology.topologycontext import *
@@ -63,8 +64,25 @@ def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, doma
     raise NotImplementedError
 
 
+def execute_start_servers_extension(env_params):
+    try:
+        log.debug("Executing start servers extension")
+
+        script_name = cartridgeagentconstants.START_SERVERS_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Start servers script returned: %r" % output)
+    except:
+        log.exception("Could not execute start servers extension")
+
+
 def wait_for_complete_topology():
-    raise NotImplementedError
+    while not TopologyContext.topology.initialized:
+        log.info("Waiting for complete topology event...")
+        time.sleep(5)
 
 
 def check_topology_consistency(service_name, cluster_id, member_id):


[10/50] [abbrv] git commit: Added Tenant context handling base classes Implemented populating the CompleteTenantEvent object with the received json string Update tenant context on CompleteTenantEvent if not already initialized

Posted by ni...@apache.org.
Added Tenant context handling base classes
Implemented populating the CompleteTenantEvent object with the received json string
Update tenant context on CompleteTenantEvent if not already initialized


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

Branch: refs/heads/master
Commit: 8537cdfe076513d7b5568118ac9f974fed3fd299
Parents: f65c19a
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Sep 24 16:33:52 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    | 16 ++--
 .../modules/event/tenant/events.py              | 19 ++++-
 .../cartridge-agent/modules/tenant/__init__.py  |  0
 .../modules/tenant/tenantcontext.py             | 88 ++++++++++++++++++++
 4 files changed, 113 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/8537cdfe/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 0dfecb2..7b6a973 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -11,6 +11,7 @@ from modules.extensions.defaultextensionhandler import DefaultExtensionHandler
 from modules.publisher import cartridgeagentpublisher
 from modules.event.instance.notifier.events import *
 from modules.event.tenant.events import *
+from modules.tenant.tenantcontext import *
 
 
 class CartridgeAgent(threading.Thread):
@@ -27,7 +28,7 @@ class CartridgeAgent(threading.Thread):
 
         self.extension_handler = DefaultExtensionHandler()
 
-        self.__complete_tenant_initialized = False
+        self.__complete_tenant_event_received = False
 
     def run(self):
         self.log.info("Starting Cartridge Agent...")
@@ -96,8 +97,8 @@ class CartridgeAgent(threading.Thread):
 
         self.__instance_event_subscriber.register_handler("ArtifactUpdatedEvent", self.on_artifact_updated)
         self.__instance_event_subscriber.register_handler("InstanceCleanupMemberEvent", self.on_instance_cleanup_member)
-        self.__instance_event_subscriber.register_handler("InstanceCleanupClusterEvent",
-                                                          self.on_instance_cleanup_cluster)
+        self.__instance_event_subscriber.register_handler("InstanceCleanupClusterEvent", self.on_instance_cleanup_cluster)
+
         self.__instance_event_subscriber.start()
         self.log.info("Instance notifier event message receiver thread started")
 
@@ -153,8 +154,8 @@ class CartridgeAgent(threading.Thread):
 
     def register_tenant_event_listeners(self):
         self.log.debug("Starting tenant event message receiver thread")
-        self.__tenant_event_subscriber.register_handler("SubscriptionDomainAddedEvent",self.on_subscription_domain_added)
-        self.__tenant_event_subscriber.register_handler("SubscriptionDomainsRemovedEvent",self.on_subscription_domain_removed)
+        self.__tenant_event_subscriber.register_handler("SubscriptionDomainAddedEvent", self.on_subscription_domain_added)
+        self.__tenant_event_subscriber.register_handler("SubscriptionDomainsRemovedEvent", self.on_subscription_domain_removed)
         self.__tenant_event_subscriber.register_handler("CompleteTenantEvent", self.on_complete_tenant)
         self.__tenant_event_subscriber.register_handler("TenantSubscribedEvent", self.on_tenant_subscribed)
         self.__tenant_event_subscriber.register_handler("TenantUnSubscribedEvent", self.on_tenant_unsubscribed)
@@ -190,13 +191,14 @@ class CartridgeAgent(threading.Thread):
         # )
 
     def on_complete_tenant(self, msg):
-        if not self.__complete_tenant_initialized:
+        if not self.__complete_tenant_event_received:
             self.log.debug("Complete tenant event received")
             event_obj = CompleteTenantEvent.create_from_json(msg.payload)
+            TenantContext.update(event_obj.tenants)
 
             try:
                 self.extension_handler.onCompleteTenantEvent(event_obj)
-                self.__complete_tenant_initialized = True
+                self.__complete_tenant_event_received = True
             except:
                 self.log.exception("Error processing complete tenant event")
         else:

http://git-wip-us.apache.org/repos/asf/stratos/blob/8537cdfe/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 7395f7e..a08c4af 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,4 +1,5 @@
 import json
+from ... tenant.tenantcontext import *
 
 
 class SubscriptionDomainAddedEvent():
@@ -48,14 +49,26 @@ class SubscriptionDomainRemovedEvent:
 class CompleteTenantEvent:
 
     def __init__(self):
-        self.tenants = None
+        self.tenants = []
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = CompleteTenantEvent()
-
-        instance.tenants = json_obj["tenants"] if "tenants" in json_obj else None
+        instance.tenants = []
+
+        temp_tenants = json_obj["tenants"] if "tenants" in json_obj else None
+        if temp_tenants is not None:
+            for tenant_str in temp_tenants:
+                tenant_obj = Tenant(int(tenant_str["tenantId"]), tenant_str["tenantDomain"])
+                for service_name in tenant_str["serviceNameSubscriptionMap"]:
+                    sub_str = tenant_str["serviceNameSubscriptionMap"][service_name]
+                    sub = Subscription(sub_str["serviceName"], sub_str["clusterIds"])
+                    for domain_name in sub_str["subscriptionDomainMap"]:
+                        subdomain_str = sub_str["subscriptionDomainMap"][domain_name]
+                        sub.add_subscription_domain(domain_name, subdomain_str["applicationContext"])
+                    tenant_obj.add_subscription(sub);
+                instance.tenants.append(tenant_obj)
 
         return instance
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/8537cdfe/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
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/8537cdfe/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
new file mode 100644
index 0000000..53e340b
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
@@ -0,0 +1,88 @@
+class TenantContext:
+    tenants = {}
+    initialized = False
+    tenant_domains = {"carbon.super": Tenant(-1234, "carbon.super")}
+
+    @staticmethod
+    def add_tenant(tenant):
+        TenantContext.tenants[tenant.tenant_id] = tenant
+        TenantContext.tenant_domains[tenant.tenant_domain] = tenant
+
+    @staticmethod
+    def remove_tenant(tenant_id):
+        if tenant_id in TenantContext.tenants:
+            tenant = TenantContext.get_tenant(tenant_id)
+            TenantContext.tenants.pop(tenant.tenant_id)
+            TenantContext.tenant_domains.pop(tenant.tenant_domain)
+
+    @staticmethod
+    def update(tenants):
+        for tenant in tenants:
+            TenantContext.add_tenant(tenant)
+
+    @staticmethod
+    def get_tenant(tenant_id):
+        if tenant_id in TenantContext.tenants:
+            return TenantContext.tenants[tenant_id]
+
+        return None
+
+    @staticmethod
+    def get_tenant(tenant_domain):
+        if tenant_domain in TenantContext.tenant_domains:
+            return TenantContext.tenant_domains[tenant_domain]
+
+        return None
+
+
+class Tenant:
+
+    def __init__(self, tenant_id,  tenant_domain):
+        self.tenant_id = tenant_id
+        self.tenant_domain = tenant_domain
+        self.service_name_subscription_map = {}
+
+    def get_subscription(self, service_name):
+        if service_name in self.service_name_subscription_map:
+            return self.service_name_subscription_map[service_name]
+
+        return None
+
+    def is_subscribed(self, service_name):
+        return service_name in self.service_name_subscription_map
+
+    def add_subscription(self, subscription):
+        self.service_name_subscription_map[subscription.service_name] = subscription
+
+    def remove_subscription(self, service_name):
+        if service_name in self.service_name_subscription_map:
+            self.service_name_subscription_map.pop(service_name)
+
+
+class Subscription:
+
+    def __init__(self, service_name, cluster_ids):
+        self.service_name = service_name
+        self.cluster_ids = cluster_ids
+        self.subscription_domain_map = {}
+
+    def add_subscription_domain(self, domain_name, application_context):
+        self.subscription_domain_map[domain_name] = SubscriptionDomain(domain_name, application_context)
+
+    def remove_subscription_domain(self, domain_name):
+        if domain_name in self.subscription_domain_map:
+            self.subscription_domain_map.pop(domain_name)
+
+    def subscription_domain_exists(self, domain_name):
+        return domain_name in self.subscription_domain_map
+
+    def get_subscription_domains(self):
+        return self.subscription_domain_map.values()
+
+
+class SubscriptionDomain:
+
+    def __init__(self, domain_name, application_context):
+        self.domain_name = domain_name
+        self.application_context = application_context
+


[06/50] [abbrv] git commit: Fixed path issue for the agent.conf file

Posted by ni...@apache.org.
Fixed path issue for the agent.conf file


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

Branch: refs/heads/master
Commit: f65c19a77b1f761dcb830c19cc7b3e8fe7d715b9
Parents: ed08e2d
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Sep 23 23:44:51 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../modules/config/cartridgeagentconfiguration.py             | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f65c19a7/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 495d759..dea6ecc 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -1,5 +1,6 @@
 import ConfigParser
 import logging
+import os
 
 from .. util import cartridgeagentconstants
 from .. exception.parameternotfoundexception import ParameterNotFoundException
@@ -148,8 +149,11 @@ class CartridgeAgentConfiguration:
             :return:
             """
 
+            base_working_dir = os.path.abspath(os.path.dirname(__file__)).replace("modules/config", "")
+            conf_file_path = base_working_dir + "agent.conf"
+            self.log.debug("Config file path : %r" % conf_file_path)
             self.properties = ConfigParser.SafeConfigParser()
-            self.properties.read('agent.conf')
+            self.properties.read(conf_file_path)
 
         def __read_parameter_file(self):
             """
@@ -173,6 +177,7 @@ class CartridgeAgentConfiguration:
         def read_property(self, property_key):
 
             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


[16/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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()


[09/50] [abbrv] git commit: Topology context messaging model classes added

Posted by ni...@apache.org.
Topology context messaging model classes added


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

Branch: refs/heads/master
Commit: 4850c53dc4fe6fdb129f74336639a013e1a541be
Parents: 8537cdf
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Sep 24 22:11:39 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../modules/event/topology/__init__.py          |   0
 .../modules/event/topology/events.py            |  58 +++++
 .../modules/topology/__init__.py                |   0
 .../modules/topology/topologycontext.py         | 224 +++++++++++++++++++
 .../cartridge-agent/modules/util/__init__.py    |   1 -
 .../modules/util/cartridgeagentconstants.py     |   4 +
 .../modules/util/cartridgeagentutils.py         |  19 +-
 .../modules/util/extensionutils.py              |  45 +++-
 8 files changed, 347 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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
new file mode 100644
index 0000000..5990ea7
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -0,0 +1,58 @@
+import json
+
+
+class MemberActivatedEvent:
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = MemberActivatedEvent()
+
+
+class MemberTerminatedEvent:
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = MemberTerminatedEvent()
+
+
+class MemberSuspendedEvent:
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = MemberSuspendedEvent()
+
+
+class CompleteTopologyEvent:
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = CompleteTopologyEvent()
+
+
+class MemberStartedEvent:
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = MemberStartedEvent()
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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
new file mode 100644
index 0000000..1994d4c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -0,0 +1,224 @@
+from ..util import cartridgeagentutils, cartridgeagentconstants
+
+
+class TopologyContext:
+    topology = None
+    # TODO: read write locks, Lock() and RLock()
+
+    @staticmethod
+    def get_topology():
+        #TODO: thread-safety missing
+        if TopologyContext.topology is None:
+            TopologyContext.topology = Topology()
+        return TopologyContext.topology
+
+        # @staticmethod
+        # def update(topology):
+        #     TopologyContext.topology = topology
+        #     #TODO: persist in registry
+
+
+class Topology:
+    def __init__(self):
+        self.service_map = {}
+        self.initialized = False
+
+    def get_services(self):
+        return self.service_map.values()
+
+    def add_service(self, service):
+        self.service_map[service.service_name] = service
+
+    def add_services(self, services):
+        for service in services:
+            self.add_service(service)
+
+    def remove_service(self, service_name):
+        if service_name in self.service_map:
+            self.service_map.pop(service_name)
+
+    def service_exists(self, service_name):
+        return service_name in self.service_map
+
+    def clear(self):
+        self.service_map = {}
+
+    def __str__(self):
+        return "Topology [serviceMap= %r , initialized= %r ]" % (self.service_map, self.initialized)
+
+
+class Service:
+    def __init__(self, service_name, service_type):
+        self.service_name = service_name
+        self.service_type = service_type
+        self.cluster_id_cluster_map = {}
+        self.port_map = {}
+
+    def get_clusters(self):
+        return self.cluster_id_cluster_map.values()
+
+    def add_cluster(self, cluster):
+        self.cluster_id_cluster_map[cluster.cluster_id] = cluster
+
+    def remove_cluster(self, cluster_id):
+        if cluster_id in self.cluster_id_cluster_map:
+            self.cluster_id_cluster_map.pop(cluster_id)
+
+    def cluster_exists(self, cluster_id):
+        return cluster_id in self.cluster_id_cluster_map
+
+    def get_cluster(self, cluster_id):
+        if cluster_id in self.cluster_id_cluster_map:
+            return self.cluster_id_cluster_map[cluster_id]
+
+        return None
+
+    def get_ports(self):
+        return self.port_map.values()
+
+    def get_port(self, proxy):
+        if proxy in self.port_map:
+            return self.port_map[proxy]
+
+        return None
+
+    def add_port(self, port):
+        self.port_map[port.proxy] = port
+
+    def add_ports(self, ports):
+        for port in ports:
+            self.add_port(port)
+
+
+class Cluster:
+    def __init__(self, service_name, cluster_id, deployment_policy_name, autoscale_policy_name):
+        self.service_name = service_name
+        self.cluster_id = cluster_id
+        self.deployment_policy_name = deployment_policy_name
+        self.autoscale_policy_name = autoscale_policy_name
+        self.hostnames = []
+        self.member_map = {}
+
+        self.tenant_range = None
+        self.is_lb_cluster = False
+        self.status = None
+        self.load_balancer_algorithm_name = None
+        self.properties = {}
+
+    def add_hostname(self, hostname):
+        self.hostnames.append(hostname)
+
+    def set_tenant_range(self, tenant_range):
+        cartridgeagentutils.validate_tenant_range(tenant_range)
+        self.tenant_range = tenant_range
+
+    def get_members(self):
+        return self.member_map.values()
+
+    def add_member(self, member):
+        self.member_map[member.member_id] = member
+
+    def remove_member(self, member_id):
+        if self.member_exists(member_id):
+            self.member_map.pop(member_id)
+
+    def get_member(self, member_id):
+        if self.member_exists(member_id):
+            return self.member_map[member_id]
+
+        return None
+
+    def member_exists(self, member_id):
+        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)
+
+    def tenant_id_in_range(self, tenant_id):
+        if self.tenant_range is None:
+            return False
+
+        if self.tenant_range == "*":
+            return True
+        else:
+            arr = self.tenant_range.split(cartridgeagentconstants.TENANT_RANGE_DELIMITER)
+            tenant_start = int(arr[0])
+            if tenant_start <= tenant_id:
+                tenant_end = arr[1]
+                if tenant_end == "*":
+                    return True
+                else:
+                    if tenant_id <= int(tenant_end):
+                        return True
+
+        return False
+
+
+class Member:
+
+    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
+        self.service_name = service_name
+        self.cluster_id = cluster_id
+        self.network_partition_id = network_partition_id
+        self.partition_id = parition_id
+        self.member_id = member_id
+        self.port_map = {}
+
+        self.member_public_ip = None
+        self.status = None
+        self.member_ip = None
+        self.properties = {}
+        self.lb_cluster_id = None
+
+    def is_active(self):
+        return self.status == MemberStatus.Activated
+
+    def get_ports(self):
+        return self.port_map.values()
+
+    def get_port(self, proxy):
+        if proxy in self.port_map:
+            return self.port_map[proxy]
+
+        return None
+
+    def add_port(self, port):
+        self.port_map[port.proxy] = port
+
+    def add_ports(self, ports):
+        for port in ports:
+            self.add_port(port)
+
+
+class Port:
+
+    def __init__(self, protocol, value, proxy):
+        self.protocol = protocol
+        self.value = value
+        self.proxy = proxy
+
+    def __str__(self):
+        return "Port [protocol=%r, value=%r proxy=%r]" % (self.protocol, self.value, self.proxy)
+
+
+class ServiceType:
+    SingleTenant = 1
+    MultiTenant = 2
+
+
+class ClusterStatus:
+    Created = 1
+    In_Maintenance = 2
+    Removed = 3
+
+
+class MemberStatus:
+    Created = 1
+    Starting = 2
+    Activated = 3
+    In_Maintenance = 4
+    ReadyToShutDown = 5
+    Terminated = 6
+    Suspended = 0
+    ShuttingDown = 0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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 7051a3c..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
@@ -1 +0,0 @@
-__all__=['cartridgeagentconstants', 'cartridgeagentutils', 'extensionutils']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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 a2efe80..cf0199d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -86,3 +86,7 @@ HEALTH_STAT_TOPIC = "health/#"
 TOPOLOGY_TOPIC = "topology/#"
 TENANT_TOPIC = "tenant/#"
 INSTANCE_STATUS_TOPIC = "instance/#"
+
+
+#Messaging Model
+TENANT_RANGE_DELIMITER = "-"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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 e599ef8..25d3b8a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -6,6 +6,7 @@ import time
 import socket
 
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+import cartridgeagentconstants
 
 unpad = lambda s : s[0:-ord(s[-1])]
 logging.basicConfig(level=logging.DEBUG)
@@ -91,4 +92,20 @@ def check_ports_active(ip_address, ports):
             log.debug("Print %r is not active" % port)
             return False
 
-    return True
\ No newline at end of file
+    return True
+
+
+def validate_tenant_range(tenant_range):
+    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)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4850c53d/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 c2ecc52..3ce8964 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -1,15 +1,25 @@
 import logging
+import os
+
+import cartridgeagentconstants
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 
 logging.basicConfig(level=logging.DEBUG)
 log = logging.getLogger(__name__)
 
+cartridge_agent_configuration = CartridgeAgentConfiguration()
+
 
 def execute_copy_artifact_extension(source, destination):
     raise NotImplementedError
 
 
 def execute_instance_started_extention(env_params):
-    raise NotImplementedError
+    log.debug("Executing instance started extension")
+
+    script_name = cartridgeagentconstants.INSTANCE_STARTED_SCRIPT
+    command = prepare_command(script_name)
+
 
 
 def execute_instance_activated_extension():
@@ -37,4 +47,35 @@ def check_topology_consistency(service_name, cluster_id, member_id):
 
 
 def execute_volume_mount_extension(persistance_mappings_payload):
-    raise NotImplementedError
\ No newline at end of file
+    raise NotImplementedError
+
+
+def prepare_command(script_name):
+    extensions_dir = cartridge_agent_configuration.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
+    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
+
+    if os.path.isfile(file_path):
+        return file_path
+
+    raise IOError("Script file not found : %r" % file_path)
+
+
+def add_payload_parameters(params):
+    params["STRATOS_APP_PATH"] = cartridge_agent_configuration.get_app_path()
+    params["STRATOS_PARAM_FILE_PATH"] = cartridge_agent_configuration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+    params["STRATOS_SERVICE_NAME"] = cartridge_agent_configuration.get_service_name()
+    params["STRATOS_TENANT_ID"] = cartridge_agent_configuration.get_tenant_id()
+    params["STRATOS_CARTRIDGE_KEY"] = cartridge_agent_configuration.get_cartridge_key()
+    params["STRATOS_LB_CLUSTER_ID"] = cartridge_agent_configuration.get_lb_cluster_id()
+    params["STRATOS_CLUSTER_ID"] = cartridge_agent_configuration.get_cluster_id()
+    params["STRATOS_NETWORK_PARTITION_ID"] = cartridge_agent_configuration.get_network_partition_id()
+    params["STRATOS_PARTITION_ID"] = cartridge_agent_configuration.get_partition_id()
+    params["STRATOS_PERSISTENCE_MAPPINGS"] = cartridge_agent_configuration.get_persistance_mappings()
+    params["STRATOS_REPO_URL"] = cartridge_agent_configuration.get_repo_url()
+
+    lb_cluster_id_in_payload = cartridge_agent_configuration.get_lb_cluster_id()
+
+


[12/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/b93426d5
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b93426d5
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b93426d5

Branch: refs/heads/master
Commit: b93426d5b86afa7335faf728456b8d7055758bcc
Parents: 15d864a
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:06:26 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/b93426d5/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/b93426d5/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/b93426d5/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/b93426d5/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/b93426d5/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/b93426d5/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/b93426d5/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:


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

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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()


[19/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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: 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/9b825d01
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9b825d01
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9b825d01

Branch: refs/heads/master
Commit: 9b825d01617fe60f4e462522e94994d62aeca378
Parents: d524506
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 2 14:34:02 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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/9b825d01/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):


[29/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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()


[32/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/da2fb828
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/da2fb828
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/da2fb828

Branch: refs/heads/master
Commit: da2fb828f3e81003058c32bcba976d141a4884b5
Parents: 9c9639e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 16:12:54 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/da2fb828/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;
 


[17/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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'


[34/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/d5245061
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d5245061
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d5245061

Branch: refs/heads/master
Commit: d5245061d66a5ea9ca721e05d9238feb7a797b9e
Parents: 038cf1b
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 19:51:24 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/d5245061/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/d5245061/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/d5245061/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/d5245061/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/d5245061/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


[30/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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)


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

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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


[04/50] [abbrv] git commit: Git repository initialization and validation in Artifact management

Posted by ni...@apache.org.
Git repository initialization and validation in Artifact management


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

Branch: refs/heads/master
Commit: 93ad2aaa3ae4d6d6bf85418e55d914b69de87048
Parents: e5da07e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Sep 25 03:23:08 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../modules/artifactmgt/git/__init__.py         |  1 -
 .../modules/artifactmgt/git/agentgithandler.py  | 81 +++++++++++++++++---
 .../modules/artifactmgt/git/gitrepository.py    |  2 +-
 .../extensions/defaultextensionhandler.py       |  2 +-
 .../modules/publisher/__init__.py               |  1 -
 5 files changed, 73 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/93ad2aaa/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 372e725..e69de29 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
@@ -1 +0,0 @@
-__all__=['agentgithandler', 'gitrepository']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/93ad2aaa/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 fff1ae8..f9de8b4 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
@@ -2,7 +2,7 @@ import logging
 
 from git import *
 
-from gitrepository import GitRepositoryContext
+from gitrepository import GitRepository
 from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from ... util import cartridgeagentutils
 
@@ -25,17 +25,71 @@ class AgentGitHandler:
         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
-            cloned = True
+            subscribe_run = False
+            if AgentGitHandler.is_valid_git_repository(repo_context):
+                AgentGitHandler.log.debug("Existing git repository detected for tenant %r, no clone required" % repo_info.tenant_id)
+                AgentGitHandler.pull(repo_context)
+            else:
+                if not os.listdir(repo_context.local_repo_path):
+                    #empty dir, clone
+                    repo_context.repo = AgentGitHandler.clone(repo_info)
+                else:
+                    #not empty
+                    if AgentGitHandler.sync_initial_local_artifacts(repo_context):
+                        AgentGitHandler.pull(repo_context)
+                    else:
+                        repo_context = None
+
             #TODO: handle conflicts and errors using repo.git.pull(), status(), checkout() outputs
-            AgentGitHandler.log.debug("Existing git repository detected for tenant %r, no clone required" % repo_info.tenant_id)
-            AgentGitHandler.pull(repo_context)
+
         else:
             #subscribing run.. need to clone
-            cloned = False
-            repo_context = AgentGitHandler.create_git_repo_context(repo_info)
-            AgentGitHandler.clone(repo_context)
+            subscribe_run = True
+            repo_context = AgentGitHandler.clone(repo_context)
+
+        return {"subscribe_run": subscribe_run, "repo_context": repo_context}
+
+    @staticmethod
+    def sync_initial_local_artifacts(repo_context):
+        #init git repo
+        AgentGitHandler.init(repo_context.local_repo_path)
+
+        # add remote repos
+        return AgentGitHandler.add_remote(repo_context)
+
+    @staticmethod
+    def add_remote(repo_context):
+        try:
+            repo_context.repo.create_remote("origin", repo_context.repo_url)
+            repo_context.repo.git.fetch()
+            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))
+            return False
+
+    @staticmethod
+    def init(path):
+        try:
+            repo = Repo.init(path, mkdir=True)
+            repo.git.init()
+        except:
+            AgentGitHandler.log.exception("Initializing local repo at %r failed" % path)
+            raise Exception("Initializing local repo at %r failed" % path)
 
-        return {"cloned": cloned, "repo_context": repo_context}
+    @staticmethod
+    def is_valid_git_repository(repo_context):
+        if repo_context.cloned:
+            return True
+
+        for ref in repo_context.repo.refs:
+            try:
+                ref._get_object()
+            except ValueError:
+                #corrupt sha in the reference
+                return False
+
+        return True
 
     @staticmethod
     def pull(repo_context):
@@ -47,10 +101,13 @@ class AgentGitHandler:
 
 
     @staticmethod
-    def clone(repo_context):
+    def clone(repo_info):
+        repo_context = None
         try:
+            repo_context = AgentGitHandler.create_git_repo_context(repo_info)
             repo = Repo.clone_from(repo_context.repo_url, repo_context.local_repo_path)
             repo_context.cloned = True
+            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:
@@ -60,6 +117,8 @@ class AgentGitHandler:
                 cartridgeagentutils.create_dir(repo_context.local_repo_path)
             else:
                 AgentGitHandler.log.exception("Git clone operation for tenant %r failed" % repo_context.tenant_id)
+        finally:
+            return repo_context
 
     @staticmethod
     def add_repo_context(repo_context):
@@ -79,7 +138,7 @@ class AgentGitHandler:
 
     @staticmethod
     def create_git_repo_context(repo_info):
-        repo_context = GitRepositoryContext()
+        repo_context = GitRepository()
         repo_context.tenant_id = repo_info.tenant_id
         repo_context.local_repo_path = AgentGitHandler.get_repo_path_for_tenant(
             repo_info.tenant_id, repo_info.repo_path, repo_info.is_multitenant)
@@ -97,6 +156,8 @@ class AgentGitHandler:
 
         repo_context.cloned = False
 
+        repo_context.repo = None
+
         return repo_context
 
     # @staticmethod

http://git-wip-us.apache.org/repos/asf/stratos/blob/93ad2aaa/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 12ce591..26950ae 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,4 +1,4 @@
-class GitRepositoryContext:
+class GitRepository:
 
     def __init__(self):
         self.repo_url = None

http://git-wip-us.apache.org/repos/asf/stratos/blob/93ad2aaa/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 15e79bc..505b59c 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -74,7 +74,7 @@ class DefaultExtensionHandler:
             extensionutils.execute_artifacts_updated_extension(env_params)
 
             #if !cloneExists publish instanceActivatedEvent
-            if not checkout_result["cloned"]:
+            if checkout_result["subscribe_run"]:
                 #publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/93ad2aaa/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 923c1de..e69de29 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
@@ -1 +0,0 @@
-__all__=['cartridgeagentpublisher']
\ No newline at end of file


[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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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']


[21/50] [abbrv] git commit: Added clustering informaiton handling to the default extension handler Style changes to the default extension handler code Added get_service method to topology object

Posted by ni...@apache.org.
Added clustering informaiton handling to the default extension handler
Style changes to the default extension handler code
Added get_service method to topology object


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

Branch: refs/heads/master
Commit: 6b8fc6e4c36442bdf76b99a9b42e3ea57d453796
Parents: f535242
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Sep 26 16:19:15 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 2014 +0530

----------------------------------------------------------------------
 .../extensions/defaultextensionhandler.py       | 302 +++++++++++++++++--
 .../modules/topology/topologycontext.py         |  12 +
 .../modules/util/extensionutils.py              |   6 +-
 3 files changed, 288 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/6b8fc6e4/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 de841ce..9135a8a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -1,12 +1,12 @@
 import logging
 
-from .. artifactmgt.git.agentgithandler import AgentGitHandler
-from .. artifactmgt.repositoryinformation import RepositoryInformation
-from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from .. util import extensionutils, cartridgeagentconstants, cartridgeagentutils
-from .. publisher import cartridgeagentpublisher
-from .. exception.parameternotfoundexception import ParameterNotFoundException
-from .. topology.topologycontext import *
+from ..artifactmgt.git.agentgithandler import AgentGitHandler
+from ..artifactmgt.repositoryinformation import RepositoryInformation
+from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from ..util import extensionutils, cartridgeagentconstants, cartridgeagentutils
+from ..publisher import cartridgeagentpublisher
+from ..exception.parameternotfoundexception import ParameterNotFoundException
+from ..topology.topologycontext import *
 
 
 class DefaultExtensionHandler:
@@ -35,7 +35,8 @@ class DefaultExtensionHandler:
 
     def on_artifact_updated_event(self, artifacts_updated_event):
         self.log.info("Artifact update event received: [tenant] %r [cluster] %r [status] %r" %
-                      (artifacts_updated_event.tenant_id, artifacts_updated_event.cluster_id, artifacts_updated_event.status))
+                      (artifacts_updated_event.tenant_id, artifacts_updated_event.cluster_id,
+                       artifacts_updated_event.status))
 
         cluster_id_event = str(artifacts_updated_event.cluster_id).strip()
         cluster_id_payload = CartridgeAgentConfiguration.cluster_id
@@ -58,10 +59,10 @@ class DefaultExtensionHandler:
             repo_info = RepositoryInformation(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
                                               is_multitenant, commit_enabled)
 
-            #checkout code
+            # checkout code
             checkout_result = AgentGitHandler.checkout(repo_info)
-            #repo_context = checkout_result["repo_context"]
-            #execute artifact updated extension
+            # repo_context = checkout_result["repo_context"]
+            # execute artifact updated extension
             env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": artifacts_updated_event.cluster_id,
                           "STRATOS_ARTIFACT_UPDATED_TENANT_ID": artifacts_updated_event.tenant_id,
                           "STRATOS_ARTIFACT_UPDATED_REPO_URL": artifacts_updated_event.repo_url,
@@ -72,7 +73,7 @@ class DefaultExtensionHandler:
             extensionutils.execute_artifacts_updated_extension(env_params)
 
             if checkout_result["subscribe_run"]:
-                #publish instanceActivated
+                # publish instanceActivated
                 cartridgeagentpublisher.publish_instance_activated_event()
 
             update_artifacts = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ENABLE_ARTIFACT_UPDATE)
@@ -82,7 +83,8 @@ class DefaultExtensionHandler:
                 auto_checkout = CartridgeAgentConfiguration.is_checkout_enabled()
 
                 try:
-                    update_interval = len(CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL))
+                    update_interval = len(
+                        CartridgeAgentConfiguration.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL))
                 except ParameterNotFoundException:
                     self.log.exception("Invalid artifact sync interval specified ")
                     update_interval = 10
@@ -95,7 +97,8 @@ class DefaultExtensionHandler:
                 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, update_interval)
+                AgentGitHandler.schedule_artifact_update_scheduled_task(repo_info, auto_checkout, auto_commit,
+                                                                        update_interval)
 
     def on_artifact_update_scheduler_event(self, tenant_id):
         env_params = {}
@@ -111,20 +114,24 @@ class DefaultExtensionHandler:
 
     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))
+                      % (
+            member_activated_event.service_name, member_activated_event.cluster_id, member_activated_event.member_id))
 
-        consistant = extensionutils.check_topology_consistency(member_activated_event.service_name, member_activated_event.cluster_id, member_activated_event.member_id)
+        consistant = extensionutils.check_topology_consistency(member_activated_event.service_name,
+                                                               member_activated_event.cluster_id,
+                                                               member_activated_event.member_id)
         if not consistant:
             self.log.error("Topology is inconsistent...failed to execute member activated event")
             return
 
         topology = TopologyContext.get_topology()
-        service = topology.service_map[member_activated_event.service_name]
+        service = topology.get_service(member_activated_event.service_name)
         cluster = service.get_cluster(member_activated_event.cluster_id)
         member = cluster.get_member(member_activated_event.member_id)
         lb_cluster_id = member.lb_cluster_id
 
-        if extensionutils.is_relevant_member_event(member_activated_event.service_name, member_activated_event.cluster_id, lb_cluster_id)
+        if extensionutils.is_relevant_member_event(member_activated_event.service_name,
+                                                   member_activated_event.cluster_id, lb_cluster_id):
             env_params = {}
             env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_IP"] = member_activated_event.member_ip
             env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_ID"] = member_activated_event.member_id
@@ -144,7 +151,7 @@ class DefaultExtensionHandler:
             member_list_json = ""
             for member in members:
                 member_list_json += member.json_str + ","
-            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = member_list_json[:-1] # removing last comma
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = member_list_json[:-1]  # removing last comma
 
             member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
             if member_ips is not None and len(member_ips) > 1:
@@ -153,13 +160,14 @@ class DefaultExtensionHandler:
 
             env_params["STRATOS_TOPOLOGY_JSON"] = 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")
-            extensionutils.add_properties(member.properties, env_params,  "MEMBER_ACTIVATED_MEMBER_PROPERTY")
+            extensionutils.add_properties(service.properties, env_params, "MEMBER_ACTIVATED_SERVICE_PROPERTY")
+            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
 
-            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 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 ")
 
                 has_wk_ip_changed = True
@@ -211,15 +219,15 @@ class DefaultExtensionHandler:
         # member_id_in_payload = CartridgeAgentConfiguration.member_id()
         #
         # try:
-        #     consistant = 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:
-        #         self.log.error("Topology is inconsistent...failed to execute start server event")
-        #         return
+        # if not consistant:
+        # self.log.error("Topology is inconsistent...failed to execute start server event")
+        # return
         #
         #
         # except:
-        #     self.log.exception("Error processing start servers event")
+        # self.log.exception("Error processing start servers event")
         # finally:
         #     pass
 
@@ -253,4 +261,240 @@ class DefaultExtensionHandler:
         cartridgeagentpublisher.publish_instance_ready_to_shutdown_event()
 
     def is_wk_member_group_ready(self, env_params, min_count):
-        raise NotImplementedError
\ No newline at end of file
+        topology = TopologyContext.get_topology()
+        if topology is None or not topology.initialized:
+            return False
+
+        service_group_in_payload = CartridgeAgentConfiguration.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":
+
+                apistore_cluster_collection = topology.get_service("apistore").get_clusters()
+                publisher_cluster_collection = topology.get_service("publisher").get_clusters()
+
+                apistore_member_list = []
+                for member in apistore_cluster_collection[0].get_members():
+                    if member.status == MemberStatus.Starting or member.status == MemberStatus.Activated:
+                        apistore_member_list.append(member)
+                        self.wk_members.append(member)
+
+                if len(apistore_member_list) == 0:
+                    self.log.debug("API Store members not yet created")
+                    return False
+
+                apistore_member = apistore_member_list[0]
+                env_params["STRATOS_WK_APISTORE_MEMBER_IP"] = apistore_member.member_ip
+                self.log.debug("STRATOS_WK_APISTORE_MEMBER_IP: %r" % apistore_member.member_ip)
+
+                publisher_member_list = []
+                for member in publisher_cluster_collection[0].get_members():
+                    if member.status == MemberStatus.Starting or member.status == MemberStatus.Activated:
+                        publisher_member_list.append(member)
+                        self.wk_members.append(member)
+
+                if len(publisher_member_list) == 0:
+                    self.log.debug("API Publisher members not yet created")
+
+                publisher_member = publisher_member_list[0]
+                env_params["STRATOS_WK_PUBLISHER_MEMBER_IP"] = publisher_member.member_ip
+                self.log.debug("STRATOS_WK_PUBLISHER_MEMBER_IP: %r" % publisher_member.member_ip)
+
+                return True
+
+            elif CartridgeAgentConfiguration.service_name == "gatewaymgt" or \
+                    CartridgeAgentConfiguration.service_name == "gateway":
+
+                if CartridgeAgentConfiguration.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():
+
+                        self.log.info("Deployment pattern for the node: %r" % CartridgeAgentConfiguration.deployment)
+                        env_params["DEPLOYMENT"] = CartridgeAgentConfiguration.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":
+                return True
+
+        else:
+            if CartridgeAgentConfiguration.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():
+
+                    self.log.info("Deployment pattern for the node: %r" % CartridgeAgentConfiguration.deployment)
+                    env_params["DEPLOYMENT"] = CartridgeAgentConfiguration.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 = 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 \
+                        (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
+
+                    wk_members.append(member)
+                    self.wk_members.append(member)
+                    self.log.debug("Found WKA: STRATOS_WK_MEMBER_IP: " + member.member_ip)
+
+            if len(wk_members) >= min_count:
+                idx = 0
+                for member in wk_members:
+                    env_params["STRATOS_WK_MEMBER_" + idx + "_IP"] = member.member_ip
+                    self.log.debug("STRATOS_WK_MEMBER_" + idx + "_IP:" + member.member_ip)
+
+                    idx += 1
+
+                return True
+
+        return False
+
+    # generic worker manager separated clustering logic
+    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
+
+        # managerServiceName and workerServiceName both should not be null /empty
+        if manager_service_name is None or manager_service_name.strip() == "":
+            self.log.error("Manager service name [ " + manager_service_name + " ] is invalid")
+            return False
+
+        if worker_service_name is None or worker_service_name.strip() == "":
+            self.log.error("Worker service name [ " + worker_service_name + " ] is invalid")
+            return False
+
+        min_manager_instances_available = False
+        min_worker_instances_available = False
+
+        topology = TopologyContext.get_topology()
+        manager_service = topology.get_service(manager_service_name)
+        worker_service = topology.get_service(worker_service_name)
+
+        if manager_service is None:
+            self.log.warn("Service [ " + manager_service_name + " ] is not found")
+            return False
+
+        if worker_service is None:
+            self.log.warn("Service [ " + worker_service_name + " ] is not found")
+            return False
+
+        # manager clusters
+        manager_clusters = manager_service.get_clusters()
+        if manager_clusters is None or len(manager_clusters) == 0:
+            self.log.warn("No clusters found for service [ " + manager_service_name + " ]")
+            return False
+
+        manager_min_instance_count = 1
+        manager_min_instance_count_found = False
+
+        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 \
+                    (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
+
+                manager_wka_members.append(member)
+                self.wk_members.append(member)
+
+                # get the min instance count
+                if not manager_min_instance_count_found:
+                    manager_min_instance_count = self.get_min_instance_count_from_member(member)
+                    manager_min_instance_count_found = True
+                    self.log.info("Manager min instance count: " + manager_min_instance_count)
+
+        if len(manager_wka_members) >= manager_min_instance_count:
+            min_manager_instances_available = True
+            idx = 0
+            for member in manager_wka_members:
+                env_params["STRATOS_WK_MANAGER_MEMBER_" + idx + "_IP"] = member.member_ip
+                self.log.debug("STRATOS_WK_MANAGER_MEMBER_" + idx + "_IP: " + member.member_ip)
+                idx += 1
+
+            env_params["STRATOS_WK_MANAGER_MEMBER_COUNT"] = int(manager_min_instance_count)
+
+        # If all the manager members are non primary and is greate than or equal to mincount,
+        # minManagerInstancesAvailable should be true
+        all_managers_non_primary = True
+        for member in manager_clusters[0].get_members():
+            # get the min instance count
+            if not manager_min_instance_count_found:
+                manager_min_instance_count = self.get_min_instance_count_from_member(member)
+                manager_min_instance_count_found = True
+                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":
+                all_managers_non_primary = False
+                break
+
+        self.log.debug(
+            " allManagerNonPrimary & managerMinInstanceCount [" + all_managers_non_primary +
+            "], [" + manager_min_instance_count + "] ")
+
+        if all_managers_non_primary and len(manager_clusters) >= manager_min_instance_count:
+            min_manager_instances_available = True
+
+        # worker cluster
+        worker_clusters = worker_service.get_clusters()
+        if worker_clusters is None or len(worker_clusters) == 0:
+            self.log.warn("No clusters found for service [ " + worker_service_name + " ]")
+            return False
+
+        worker_min_instance_count = 1
+        worker_min_instance_count_found = False
+
+        worker_wka_members = []
+        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 \
+                    (member.status == MemberStatus.Starting or member.status == MemberStatus.Activated):
+
+                self.log.debug("Added worker member " + member.member_id)
+
+                worker_wka_members.append(member)
+                self.wk_members.append(member)
+
+                # get the min instance count
+                if not worker_min_instance_count_found:
+                    worker_min_instance_count = self.get_min_instance_count_from_member(member)
+                    worker_min_instance_count_found = True
+                    self.log.debug("Worker min instance count: " + worker_min_instance_count)
+
+        if len(worker_wka_members) >= worker_min_instance_count:
+            min_worker_instances_available = True
+            idx = 0
+            for member in worker_wka_members:
+                env_params["STRATOS_WK_WORKER_MEMBER_" + idx + "_IP"] = member.member_ip
+                self.log.debug("STRATOS_WK_WORKER_MEMBER_" + idx + "_IP: " + member.member_ip)
+                idx += 1
+
+            env_params["STRATOS_WK_WORKER_MEMBER_COUNT"] = int(worker_min_instance_count)
+
+        self.log.debug(
+            " Returnning values minManagerInstancesAvailable && minWorkerInstancesAvailable [" +
+            min_manager_instances_available + "],  [" + min_worker_instances_available + "] ")
+
+        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"])
+
+        return 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/6b8fc6e4/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 3ce4379..7fee50d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -31,6 +31,18 @@ class Topology:
     def get_services(self):
         return self.service_map.values()
 
+    def get_service(self, service_name):
+        """
+
+        :param str service_name: service name to be retrieved
+        :return: Service object of the service
+        :rtype: Service
+        """
+        if service_name in self.service_map:
+            return self.service_map[service_name]
+
+        return None
+
     def add_service(self, service):
         self.service_map[service.service_name] = service
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/6b8fc6e4/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 d1305b9..267c608 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -69,7 +69,7 @@ def wait_for_complete_topology():
 
 def check_topology_consistency(service_name, cluster_id, member_id):
     topology = TopologyContext.get_topology()
-    service = topology.service_map[service_name]
+    service = topology.get_service(service_name)
     if service is None:
         log.error("Service not found in topology [service] %r" % service_name)
         return False
@@ -104,7 +104,7 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
 
     service_group_in_payload = CartridgeAgentConfiguration.service_group
     if service_group_in_payload is not None:
-        service_properties = topology.service_map[service_name].properties
+        service_properties = topology.get_service(service_name).properties
         if service_properties is None:
             return False
 
@@ -211,7 +211,7 @@ def add_payload_parameters(params):
 
     topology = TopologyContext.get_topology()
     if topology.initialized:
-        service = topology.service_map[CartridgeAgentConfiguration.service_name]
+        service = topology.get_service(CartridgeAgentConfiguration.service_name)
         cluster = service.get_cluster(CartridgeAgentConfiguration.cluster_id)
         member_id_in_payload = CartridgeAgentConfiguration.member_id
         add_properties(service.properties, params, "SERVICE_PROPERTY")


[03/50] [abbrv] git commit: Completed following paths in extension and event handling cleanup status event publishing member activated instance and topology event classes deserialization from json few extension util methods json string added for Me

Posted by ni...@apache.org.
Completed following paths in extension and event handling
	cleanup
	status event publishing
	member activated
	instance and topology event classes deserialization from json
	few extension util methods
	json string added for Member and topology classes


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

Branch: refs/heads/master
Commit: f53524206f8db9ee3a2fe9b3428bc1b28756f2c2
Parents: e7d65de
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Sep 25 15:52:31 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |   2 +-
 .../modules/event/instance/status/events.py     |  40 +++++-
 .../modules/event/topology/events.py            |  67 ++++++++-
 .../extensions/defaultextensionhandler.py       | 141 +++++++++++++++----
 .../publisher/cartridgeagentpublisher.py        |  46 ++++++
 .../modules/topology/topologycontext.py         |   3 +
 .../modules/util/extensionutils.py              | 104 +++++++++++++-
 7 files changed, 368 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 2ed9835..1abe0f6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -117,7 +117,7 @@ class CartridgeAgent(threading.Thread):
         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.onInstanceCleanupMemberEvent(event_obj)
+            self.extension_handler.on_instance_cleanup_member_event(event_obj)
 
     def on_instance_cleanup_cluster(self, msg):
         event_obj = InstanceCleanupClusterEvent.create_from_json(msg.payload)

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 878667c..2f14477 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
@@ -10,7 +10,7 @@ class InstanceActivatedEvent:
         self.memberId = member_id
 
     def to_json(self):
-        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
+        return to_json(self)
 
 
 class InstanceStartedEvent:
@@ -22,4 +22,40 @@ class InstanceStartedEvent:
         self.memberId = member_id
 
     def to_json(self):
-        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
\ No newline at end of file
+        return to_json(self)
+
+
+class InstanceMaintenanceModeEvent:
+
+    def __init__(self, service_name, cluster_id, network_partition_id, partition_id, member_id):
+        self.serviceName = service_name
+        self.clusterId = cluster_id
+        self.networkPartitionId = network_partition_id
+        self.partitionId = partition_id
+        self.memberId = member_id
+
+    def to_json(self):
+        return to_json(self)
+
+
+class InstanceReadyToShutdownEvent:
+
+    def __init__(self, service_name, cluster_id, network_partition_id, partition_id, member_id):
+        self.serviceName = service_name
+        self.clusterId = cluster_id
+        self.networkPartitionId = network_partition_id
+        self.partitionId = partition_id
+        self.memberId = member_id
+
+    def to_json(self):
+        return to_json(self)
+
+
+def to_json(instance):
+    """
+    common function to serialize status event object
+    :param obj instance:
+    :return: serialized json string
+    :rtype str
+    """
+    return json.dumps(instance, default=lambda o: o.__dict__, sort_keys=True, indent=4)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 80a06ce..10be3e2 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
@@ -6,35 +6,81 @@ from ... topology.topologycontext import *
 class MemberActivatedEvent:
 
     def __init__(self):
-        pass
+        self.service_name = None
+        self.cluster_id = None
+        self.network_partition_id = None
+        self.partition_id = None
+        self.member_id = None
+        self.port_map = {}
+        self.member_ip = None
+
+    def get_port(self, proxy_port):
+        if proxy_port in self.port_map:
+            return self.port_map[proxy_port]
+
+        return None
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = MemberActivatedEvent()
 
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.network_partition_id = json_obj["networkPartitionId"] if "networkPartitionId" in json_obj else None
+        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
+        #instance.port_map = json_obj["portMap"] if "portMap" in json_obj else {}
+        instance.member_ip = json_obj["memberIp"] if "memberIp" in json_obj else None
+
+        for port_proxy in json_obj["portMap"]:
+            port_str = json_obj["portMap"][port_proxy]
+            port_obj = Port(port_str["protocol"], port_str["value"], port_proxy)
+            instance.port_map[port_proxy] = port_obj
+
 
 class MemberTerminatedEvent:
 
     def __init__(self):
-        pass
+        self.service_name = None
+        self.cluster_id = None
+        self.network_partition_id = None
+        self.partition_id = None
+        self.member_id = None
+        self.properties = {}
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = MemberTerminatedEvent()
 
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.network_partition_id = json_obj["networkPartitionId"] if "networkPartitionId" in json_obj else None
+        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
+
 
 class MemberSuspendedEvent:
 
     def __init__(self):
-        pass
+        self.service_name = None
+        self.cluster_id = None
+        self.network_partition_id = None
+        self.partition_id = None
+        self.member_id = None
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = MemberSuspendedEvent()
 
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.network_partition_id = json_obj["networkPartitionId"] if "networkPartitionId" in json_obj else None
+        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
+
 
 class CompleteTopologyEvent:
 
@@ -49,6 +95,7 @@ class CompleteTopologyEvent:
         topology_str = json_obj["topology"] if "topology" in json_obj else None
         if topology_str is not None:
             topology_obj = Topology()
+            topology_obj.json_str = topology_str
 
             #add service map
             for service_name in topology_str["serviceMap"]:
@@ -91,6 +138,7 @@ class CompleteTopologyEvent:
                         member_obj.member_ip = member_str["memberIp"]
                         member_obj.properties = member_str["properties"]
                         member_obj.lb_cluster_id = member_str["lbClusterId"]
+                        member_obj.json_str = member_str
 
                         #add port map
                         for mm_port_proxy in member_str["portMap"]:
@@ -108,11 +156,22 @@ class CompleteTopologyEvent:
 class MemberStartedEvent:
 
     def __init__(self):
-        pass
+        self.service_name = None
+        self.cluster_id = None
+        self.network_partition_id = None
+        self.partition_id = None
+        self.member_id = None
+        self.status = None
+        self.properties = {}
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = MemberStartedEvent()
 
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.network_partition_id = json_obj["networkPartitionId"] if "networkPartitionId" in json_obj else None
+        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
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 30122d3..de841ce 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -1,11 +1,12 @@
 import logging
 
-from ..artifactmgt.git.agentgithandler import AgentGitHandler
-from ..artifactmgt.repositoryinformation import RepositoryInformation
+from .. artifactmgt.git.agentgithandler import AgentGitHandler
+from .. artifactmgt.repositoryinformation import RepositoryInformation
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from .. util import extensionutils, cartridgeagentconstants, cartridgeagentutils
 from .. publisher import cartridgeagentpublisher
 from .. exception.parameternotfoundexception import ParameterNotFoundException
+from .. topology.topologycontext import *
 
 
 class DefaultExtensionHandler:
@@ -14,6 +15,7 @@ class DefaultExtensionHandler:
     def __init__(self):
         logging.basicConfig(level=logging.DEBUG)
         self.log = logging.getLogger(__name__)
+        self.wk_members = []
 
     def on_instance_started_event(self):
         try:
@@ -31,24 +33,24 @@ class DefaultExtensionHandler:
     def on_instance_activated_event(self):
         extensionutils.execute_instance_activated_extension()
 
-    def on_artifact_updated_event(self, event):
+    def on_artifact_updated_event(self, artifacts_updated_event):
         self.log.info("Artifact update event received: [tenant] %r [cluster] %r [status] %r" %
-                      (event.tenant_id, event.cluster_id, event.status))
+                      (artifacts_updated_event.tenant_id, artifacts_updated_event.cluster_id, artifacts_updated_event.status))
 
-        cluster_id_event = str(event.cluster_id).strip()
+        cluster_id_event = str(artifacts_updated_event.cluster_id).strip()
         cluster_id_payload = CartridgeAgentConfiguration.cluster_id
-        repo_url = str(event.repo_url).strip()
+        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
 
             secret = CartridgeAgentConfiguration.cartridge_key
-            repo_password = cartridgeagentutils.decrypt_password(event.repo_password, secret)
+            repo_password = cartridgeagentutils.decrypt_password(artifacts_updated_event.repo_password, secret)
 
-            repo_username = event.repo_username
-            tenant_id = event.tenant_id
+            repo_username = artifacts_updated_event.repo_username
+            tenant_id = artifacts_updated_event.tenant_id
             is_multitenant = CartridgeAgentConfiguration.is_multitenant()
-            commit_enabled = event.commit_enabled
+            commit_enabled = artifacts_updated_event.commit_enabled
 
             self.log.info("Executing git checkout")
 
@@ -60,12 +62,12 @@ class DefaultExtensionHandler:
             checkout_result = AgentGitHandler.checkout(repo_info)
             #repo_context = checkout_result["repo_context"]
             #execute artifact updated extension
-            env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": event.cluster_id,
-                          "STRATOS_ARTIFACT_UPDATED_TENANT_ID": event.tenant_id,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_URL": event.repo_url,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_PASSWORD": event.repo_password,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_USERNAME": event.repo_username,
-                          "STRATOS_ARTIFACT_UPDATED_STATUS": event.status}
+            env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": artifacts_updated_event.cluster_id,
+                          "STRATOS_ARTIFACT_UPDATED_TENANT_ID": artifacts_updated_event.tenant_id,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_URL": artifacts_updated_event.repo_url,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_PASSWORD": artifacts_updated_event.repo_password,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_USERNAME": artifacts_updated_event.repo_username,
+                          "STRATOS_ARTIFACT_UPDATED_STATUS": artifacts_updated_event.status}
 
             extensionutils.execute_artifacts_updated_extension(env_params)
 
@@ -95,17 +97,94 @@ class DefaultExtensionHandler:
 
                 AgentGitHandler.schedule_artifact_update_scheduled_task(repo_info, auto_checkout, auto_commit, update_interval)
 
-    def on_artifact_update_scheduler_event(self, tenantId):
-        pass
+    def on_artifact_update_scheduler_event(self, tenant_id):
+        env_params = {}
+        env_params["STRATOS_ARTIFACT_UPDATED_TENANT_ID"] = tenant_id
+        env_params["STRATOS_ARTIFACT_UPDATED_SCHEDULER"] = True
+        extensionutils.execute_artifacts_updated_extension(env_params)
 
     def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
-        pass
+        self.cleanup()
 
-    def onInstanceCleanupMemberEvent(self, instanceCleanupMemberEvent):
-        pass
+    def on_instance_cleanup_member_event(self, instanceCleanupMemberEvent):
+        self.cleanup()
 
-    def onMemberActivatedEvent(self, memberActivatedEvent):
-        pass
+    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))
+
+        consistant = extensionutils.check_topology_consistency(member_activated_event.service_name, member_activated_event.cluster_id, member_activated_event.member_id)
+        if not consistant:
+            self.log.error("Topology is inconsistent...failed to execute member activated event")
+            return
+
+        topology = TopologyContext.get_topology()
+        service = topology.service_map[member_activated_event.service_name]
+        cluster = service.get_cluster(member_activated_event.cluster_id)
+        member = cluster.get_member(member_activated_event.member_id)
+        lb_cluster_id = member.lb_cluster_id
+
+        if extensionutils.is_relevant_member_event(member_activated_event.service_name, member_activated_event.cluster_id, lb_cluster_id)
+            env_params = {}
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_IP"] = member_activated_event.member_ip
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_ID"] = member_activated_event.member_id
+            env_params["STRATOS_MEMBER_ACTIVATED_CLUSTER_ID"] = member_activated_event.cluster_id
+            env_params["STRATOS_MEMBER_ACTIVATED_LB_CLUSTER_ID"] = lb_cluster_id
+            env_params["STRATOS_MEMBER_ACTIVATED_NETWORK_PARTITION_ID"] = member_activated_event.network_partition_id
+            env_params["STRATOS_MEMBER_ACTIVATED_SERVICE_NAME"] = member_activated_event.service_name
+
+            ports = member_activated_event.port_map.values()
+            ports_str = ""
+            for port in ports:
+                ports_str += port.protocol + "," + port.value + "," + port.proxy + "|"
+
+            env_params["STRATOS_MEMBER_ACTIVATED_PORTS"] = ports_str
+
+            members = cluster.get_members()
+            member_list_json = ""
+            for member in members:
+                member_list_json += member.json_str + ","
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = member_list_json[:-1] # removing last comma
+
+            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
+
+            extensionutils.add_properties(service.properties, env_params,  "MEMBER_ACTIVATED_SERVICE_PROPERTY")
+            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
+
+            if member.properties is not None 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 ")
+
+                has_wk_ip_changed = True
+                for wk_member in self.wk_members:
+                    if wk_member.member_ip == member_activated_event.member_ip:
+                        has_wk_ip_changed = False
+
+                self.log.debug(" hasWKIpChanged %r" + has_wk_ip_changed)
+
+                min_count = int(CartridgeAgentConfiguration.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)
+
+                if has_wk_ip_changed and is_wk_member_grp_ready:
+                    self.log.debug("Setting env var STRATOS_UPDATE_WK_IP to true")
+                    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"] = CartridgeAgentConfiguration.min_count
+
+            extensionutils.execute_member_activated_extension(env_params)
+        else:
+            self.log.debug("Member activated event is not relevant...skipping agent extension")
 
     def onCompleteTopologyEvent(self, completeTopologyEvent):
         pass
@@ -160,4 +239,18 @@ class DefaultExtensionHandler:
         pass
 
     def onTenantUnSubscribedEvent(self, tenantUnSubscribedEvent):
-        pass
\ No newline at end of file
+        pass
+
+    def cleanup(self):
+        self.log.info("Executing cleaning up the data in the cartridge instance...")
+
+        cartridgeagentpublisher.publish_maintenance_mode_event()
+
+        extensionutils.execute_cleanup_extension()
+        self.log.info("cleaning up finished in the cartridge instance...")
+
+        self.log.info("publishing ready to shutdown event...")
+        cartridgeagentpublisher.publish_instance_ready_to_shutdown_event()
+
+    def is_wk_member_group_ready(self, env_params, min_count):
+        raise NotImplementedError
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 50e4b57..e239b0d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -63,6 +63,52 @@ def publish_instance_activated_event():
         log.warn("Instance already activated")
 
 
+def publish_maintenance_mode_event():
+    global maintenance, log
+    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
+
+        instance_maintenance_mode_event = InstanceMaintenanceModeEvent(service_name, cluster_id, network_partition_id, parition_id,
+                                                          member_id)
+
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher.publish(instance_maintenance_mode_event)
+
+        maintenance = True
+        log.info("Instance Maintenance mode event published")
+    else:
+        log.warn("Instance already in a Maintenance mode....")
+
+
+def publish_instance_ready_to_shutdown_event():
+    global ready_to_shutdown, log
+    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
+
+        instance_shutdown_event = InstanceReadyToShutdownEvent(service_name, cluster_id, network_partition_id, parition_id,
+                                                          member_id)
+
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher.publish(instance_shutdown_event)
+
+        ready_to_shutdown = True
+        log.info("Instance ReadyToShutDown event published")
+    else:
+        log.warn("Instance already in a ReadyToShutDown event....")
+
+
 def get_publisher(topic):
     if topic not in publishers:
         publishers[topic] = EventPublisher(topic)

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 9f4c5e3..3ce4379 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -21,10 +21,12 @@ class TopologyContext:
     def update(topology):
         TopologyContext.topology = topology
 
+
 class Topology:
     def __init__(self):
         self.service_map = {}
         self.initialized = False
+        self.json_str = None
 
     def get_services(self):
         return self.service_map.values()
@@ -180,6 +182,7 @@ class Member:
         self.member_ip = None
         self.properties = {}
         self.lb_cluster_id = None
+        self.json_str = None
 
     def is_active(self):
         return self.status == MemberStatus.Activated

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5352420/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 48aadc5..d1305b9 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -30,18 +30,29 @@ def execute_instance_started_extension(env_params):
 
 def execute_instance_activated_extension():
     try:
-        log.debug("Executing instance started extension")
+        log.debug("Executing instance activated extension")
         script_name = cartridgeagentconstants.INSTANCE_ACTIVATED_SCRIPT
         command = prepare_command(script_name)
 
-        output, error = execute_command(command)
+        output, errors = execute_command(command)
         log.debug("Instance activated script returned: %r" % output)
     except:
         log.exception("Could not execute instance activated extension")
 
 
 def execute_artifacts_updated_extension(env_params):
-    raise NotImplementedError
+    try:
+        log.debug("Executing artifacts updated extension")
+
+        script_name = cartridgeagentconstants.ARTIFACTS_UPDATED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Artifacts updated script returned: %r" % output)
+    except:
+        log.exception("Could not execute artifacts updated extension")
 
 
 def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
@@ -57,13 +68,98 @@ def wait_for_complete_topology():
 
 
 def check_topology_consistency(service_name, cluster_id, member_id):
-    raise NotImplementedError
+    topology = TopologyContext.get_topology()
+    service = topology.service_map[service_name]
+    if service is None:
+        log.error("Service not found in topology [service] %r" % service_name)
+        return False
+
+    cluster = service.get_cluster(cluster_id)
+    if cluster is None:
+        log.error("Cluster id not found in topology [cluster] %r" % cluster_id)
+        return False
+
+    activated_member = cluster.get_member(member_id)
+    if activated_member is None:
+        log.error("Member id not found in topology [member] %r" % member_id)
+        return False
+
+    return True
+
+
+def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
+    cluster_id_in_payload = CartridgeAgentConfiguration.cluster_id
+    if cluster_id_in_payload is None:
+        return False
+
+    topology = TopologyContext.get_topology()
+    if topology is None or not topology.initialized:
+        return False
+
+    if cluster_id_in_payload == cluster_id:
+        return True
+
+    if cluster_id_in_payload == lb_cluster_id:
+        return True
+
+    service_group_in_payload = CartridgeAgentConfiguration.service_group
+    if service_group_in_payload is not None:
+        service_properties = topology.service_map[service_name].properties
+        if service_properties is None:
+            return False
+
+        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:
+                log.debug("Service names are same")
+                return True
+            elif "apistore" == CartridgeAgentConfiguration.service_name and service_name == "publisher":
+                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":
+                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:
+                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:
+                log.debug("Deployment is manager. Manager's worker service name & service name in event are same")
+                return True
+
+    return False
 
 
 def execute_volume_mount_extension(persistance_mappings_payload):
     raise NotImplementedError
 
 
+def execute_cleanup_extension():
+    try:
+        log.debug("Executing cleanup extension")
+        script_name = cartridgeagentconstants.CLEAN_UP_SCRIPT
+        command = prepare_command(script_name)
+
+        output, errors = execute_command(command)
+        log.debug("Cleanup script returned: %r" % output)
+    except:
+        log.exception("Could not execute Cleanup extension")
+
+
+def execute_member_activated_extension(env_params):
+    try:
+        log.debug("Executing member activated extension")
+
+        script_name = cartridgeagentconstants.MEMBER_ACTIVATED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Member activated script returned: %r" % output)
+    except:
+        log.exception("Could not execute member activated extension")
+
+
 def prepare_command(script_name):
     extensions_dir = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.EXTENSIONS_DIR)
     if extensions_dir.strip() == "":


[50/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/a6f4dfa3
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/a6f4dfa3
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/a6f4dfa3

Branch: refs/heads/master
Commit: a6f4dfa303838c8ccb7aa7ca4da6dd07eace4292
Parents: af49e72
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 12:55:48 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:31 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/a6f4dfa3/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/a6f4dfa3/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/a6f4dfa3/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"
 


[37/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/0fda59b6
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0fda59b6
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0fda59b6

Branch: refs/heads/master
Commit: 0fda59b66225b1c7d68bf3669dfa088c0b26dc19
Parents: 9b825d0
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 2 14:59:38 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/0fda59b6/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/0fda59b6/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/0fda59b6/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/0fda59b6/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
         """


[48/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/14e199a9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/14e199a9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/14e199a9

Branch: refs/heads/master
Commit: 14e199a9e6fe4690d64cff34a3bd0ba0abef6acb
Parents: a6f4dfa
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 13:17:39 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:31 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/stratos/blob/14e199a9/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


[49/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/b3500dfd
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b3500dfd
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b3500dfd

Branch: refs/heads/master
Commit: b3500dfd48b657e1f81415ffda33bab6bc6acaa5
Parents: 14e199a
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 13:54:56 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:31 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/stratos/blob/b3500dfd/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


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

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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()


[05/50] [abbrv] git commit: Added CompleteTopologyEvent populating with the json string received from message broker Added implementation for on_complete_topology_event method Fixed bugs in topology context

Posted by ni...@apache.org.
Added CompleteTopologyEvent populating with the json string received from message broker
Added implementation for on_complete_topology_event method
Fixed bugs in topology context


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

Branch: refs/heads/master
Commit: e5da07e5bf1719e2467510ec0233d600900eaf89
Parents: 4850c53
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Sep 24 23:47:37 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    | 24 ++++++--
 .../modules/event/topology/events.py            | 62 +++++++++++++++++++-
 .../modules/topology/topologycontext.py         |  1 +
 3 files changed, 81 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e5da07e5/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 7b6a973..96b71a4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -4,14 +4,16 @@ import threading
 import time
 
 from modules.config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from modules.util import *
+from modules.util import cartridgeagentconstants, cartridgeagentutils
 from modules.exception.parameternotfoundexception import ParameterNotFoundException
 from modules.subscriber.eventsubscriber import EventSubscriber
 from modules.extensions.defaultextensionhandler import DefaultExtensionHandler
 from modules.publisher import cartridgeagentpublisher
 from modules.event.instance.notifier.events import *
 from modules.event.tenant.events import *
+from modules.event.topology.events import *
 from modules.tenant.tenantcontext import *
+from modules.topology.topologycontext import *
 
 
 class CartridgeAgent(threading.Thread):
@@ -28,7 +30,8 @@ class CartridgeAgent(threading.Thread):
 
         self.extension_handler = DefaultExtensionHandler()
 
-        self.__complete_tenant_event_received = False
+        self.__tenant_context_initialized = False
+        self.__topology_context_initialized = False
 
     def run(self):
         self.log.info("Starting Cartridge Agent...")
@@ -147,7 +150,18 @@ class CartridgeAgent(threading.Thread):
         raise NotImplementedError
 
     def on_complete_topology(self, msg):
-        raise NotImplementedError
+        if not self.__topology_context_initialized:
+            self.log.debug("Complete topology event received")
+            event_obj = CompleteTopologyEvent.create_from_json(msg.payload)
+            TopologyContext.update(event_obj.topology)
+            self.__topology_context_initialized = True
+            try:
+                self.extension_handler.onCompleteTopologyEvent(event_obj)
+            except:
+                self.log.exception("Error processing complete topology event")
+        else:
+            self.log.info("Complete topology event updating task disabled")
+
 
     def on_member_started(self, msg):
         raise NotImplementedError
@@ -191,14 +205,14 @@ class CartridgeAgent(threading.Thread):
         # )
 
     def on_complete_tenant(self, msg):
-        if not self.__complete_tenant_event_received:
+        if not self.__tenant_context_initialized:
             self.log.debug("Complete tenant event received")
             event_obj = CompleteTenantEvent.create_from_json(msg.payload)
             TenantContext.update(event_obj.tenants)
 
             try:
                 self.extension_handler.onCompleteTenantEvent(event_obj)
-                self.__complete_tenant_event_received = True
+                self.__tenant_context_initialized = True
             except:
                 self.log.exception("Error processing complete tenant event")
         else:

http://git-wip-us.apache.org/repos/asf/stratos/blob/e5da07e5/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 5990ea7..80a06ce 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,5 +1,7 @@
 import json
 
+from ... topology.topologycontext import *
+
 
 class MemberActivatedEvent:
 
@@ -37,13 +39,71 @@ class MemberSuspendedEvent:
 class CompleteTopologyEvent:
 
     def __init__(self):
-        pass
+        self.topology = None
 
     @staticmethod
     def create_from_json(json_str):
         json_obj = json.loads(json_str)
         instance = CompleteTopologyEvent()
 
+        topology_str = json_obj["topology"] if "topology" in json_obj else None
+        if topology_str is not None:
+            topology_obj = Topology()
+
+            #add service map
+            for service_name in topology_str["serviceMap"]:
+                service_str = topology_str["serviceMap"][service_name]
+
+                service_obj = Service(service_name, service_str["serviceType"])
+                service_obj.properties = service_str["properties"]
+                # add ports to port map
+                for port_proxy in service_str["portMap"]:
+                    port_str = service_str["portMap"][port_proxy]
+                    port_obj = Port(port_str["protocol"], port_str["value"], port_proxy)
+                    service_obj.add_port(port_obj)
+
+                #add cluster map
+                for cluster_id in service_str["clusterIdClusterMap"]:
+                    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"]
+
+                    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.is_lb_cluster = cluster_str["isLbCluster"]
+                    cluster_obj.status = cluster_str["status"]
+                    cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"]
+                    cluster_obj.properties = cluster_str["properties"]
+
+                    #add member map
+                    for member_id in cluster_str["memberMap"]:
+                        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"]
+
+                        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"]
+                        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"]
+
+                        #add port map
+                        for mm_port_proxy in member_str["portMap"]:
+                            mm_port_str = member_str["portMap"][port_proxy]
+                            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)
+                    service_obj.add_cluster(cluster_obj)
+                topology_obj.add_service(service_obj)
+            instance.topology = topology_obj
+
+        return instance
+
 
 class MemberStartedEvent:
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e5da07e5/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 1994d4c..4d118f1 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -53,6 +53,7 @@ class Service:
         self.service_type = service_type
         self.cluster_id_cluster_map = {}
         self.port_map = {}
+        self.properties = {}
 
     def get_clusters(self):
         return self.cluster_id_cluster_map.values()


[24/50] [abbrv] git commit: Completed DefaultExtensionHandler and extension util paths Fixed minor bugs Implemented event handler methods

Posted by ni...@apache.org.
Completed DefaultExtensionHandler and extension util paths
Fixed minor bugs
Implemented event handler methods


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

Branch: refs/heads/master
Commit: 71f827d0f22bd6e9178e84fde5328ca2f6ef48be
Parents: ccd6ab5
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Sep 26 20:07:04 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  61 ++--
 .../modules/artifactmgt/git/agentgithandler.py  |  31 +-
 .../modules/artifactmgt/git/gitrepository.py    |   5 +-
 .../modules/event/tenant/events.py              |   8 +-
 .../extensions/defaultextensionhandler.py       | 302 ++++++++++++++++---
 .../modules/util/cartridgeagentutils.py         |   5 +-
 .../modules/util/extensionutils.py              | 174 +++++++++--
 7 files changed, 481 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 60e9805..8ac6803 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -63,8 +63,6 @@ class CartridgeAgent(threading.Thread):
             self.extension_handler.on_instance_activated_event()
 
             cartridgeagentpublisher.publish_instance_activated_event()
-        else:
-            pass
 
         persistence_mappping_payload = CartridgeAgentConfiguration.persistence_mappings
         if persistence_mappping_payload is not None:
@@ -139,13 +137,28 @@ class CartridgeAgent(threading.Thread):
         self.log.info("Cartridge Agent topology receiver thread started")
 
     def on_member_activated(self, msg):
-        raise NotImplementedError
+        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)
+        except:
+            self.log.exception("Error processing member terminated event")
 
     def on_member_terminated(self, msg):
-        raise NotImplementedError
+        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)
+        except:
+            self.log.exception("Error processing member terminated event")
 
     def on_member_suspended(self, msg):
-        raise NotImplementedError
+        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)
+        except:
+            self.log.exception("Error processing member suspended event")
 
     def on_complete_topology(self, msg):
         if not self.__topology_context_initialized:
@@ -154,14 +167,19 @@ class CartridgeAgent(threading.Thread):
             TopologyContext.update(event_obj.topology)
             self.__topology_context_initialized = True
             try:
-                self.extension_handler.onCompleteTopologyEvent(event_obj)
+                self.extension_handler.on_complete_topology_event(event_obj)
             except:
                 self.log.exception("Error processing complete topology event")
         else:
             self.log.info("Complete topology event updating task disabled")
 
     def on_member_started(self, msg):
-        raise NotImplementedError
+        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)
+        except:
+            self.log.exception("Error processing member started event")
 
     def register_tenant_event_listeners(self):
         self.log.debug("Starting tenant event message receiver thread")
@@ -175,31 +193,20 @@ class CartridgeAgent(threading.Thread):
         self.log.info("Tenant event message receiver thread started")
 
     def on_subscription_domain_added(self, msg):
-        self.log.debug("Subscription domain added event received")
+        self.log.debug("Subscription domain added event received : %r" % msg.payload)
         event_obj = SubscriptionDomainAddedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.onSubscriptionDomainAddedEvent(event_obj)
+            self.extension_handler.on_subscription_domain_added_event(event_obj)
         except:
             self.log.exception("Error processing subscription domains added event")
-        # extensionutils.execute_subscription_domain_added_extension(
-        #     event_obj.tenant_id,
-        #     self.find_tenant_domain(event_obj.tenant_id),
-        #     event_obj.domain_name,
-        #     event_obj.application_context
-        # )
 
     def on_subscription_domain_removed(self, msg):
-        self.log.debug("Subscription domain removed event received")
+        self.log.debug("Subscription domain removed event received : %r" % msg.payload)
         event_obj = SubscriptionDomainRemovedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.onSubscriptionDomainRemovedEvent(event_obj)
+            self.extension_handler.on_subscription_domain_removed_event(event_obj)
         except:
             self.log.exception("Error processing subscription domains removed event")
-        # extensionutils.execute_subscription_domain_removed_extension(
-        #     event_obj.tenant_id,
-        #     self.find_tenant_domain(event_obj.tenant_id),
-        #     event_obj.domain_name
-        # )
 
     def on_complete_tenant(self, msg):
         if not self.__tenant_context_initialized:
@@ -208,7 +215,7 @@ class CartridgeAgent(threading.Thread):
             TenantContext.update(event_obj.tenants)
 
             try:
-                self.extension_handler.onCompleteTenantEvent(event_obj)
+                self.extension_handler.on_complete_tenant_event(event_obj)
                 self.__tenant_context_initialized = True
             except:
                 self.log.exception("Error processing complete tenant event")
@@ -216,18 +223,18 @@ class CartridgeAgent(threading.Thread):
             self.log.info("Complete tenant event updating task disabled")
 
     def on_tenant_subscribed(self, msg):
-        self.log.debug("Tenant subscribed event received")
+        self.log.debug("Tenant subscribed event received: %r" % msg.payload)
         event_obj = TenantSubscribedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.onTenantSubscribedEvent(event_obj)
+            self.extension_handler.on_tenant_subscribed_event(event_obj)
         except:
             self.log.exception("Error processing tenant subscribed event")
 
     def on_tenant_unsubscribed(self, msg):
-        self.log.debug("Tenant unSubscribed event received")
+        self.log.debug("Tenant unSubscribed event received: %r" % msg.payload)
         event_obj = TenantUnsubscribedEvent.create_from_json(msg.payload)
         try:
-            self.extension_handler.onTenantUnSubscribedEvent(event_obj)
+            self.extension_handler.on_tenant_unsubscribed_event(event_obj)
         except:
             self.log.exception("Error processing tenant unSubscribed event")
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 eda0f92..6671c48 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,7 @@ from git import *
 
 from gitrepository import GitRepository
 from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ... util import cartridgeagentutils
+from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
 from ... util.asyncscheduledtask import AsyncScheduledTask
 from ... artifactmgt.repositoryinformation import RepositoryInformation
 from ... extensions.defaultextensionhandler import DefaultExtensionHandler
@@ -184,6 +184,12 @@ class AgentGitHandler:
 
     @staticmethod
     def get_repo_context(tenant_id):
+        """
+
+        :param int tenant_id:
+        :return: GitRepository object
+        :rtype: GitRepository
+        """
         if tenant_id in AgentGitHandler.__git_repositories:
             return AgentGitHandler.__git_repositories[tenant_id]
 
@@ -290,6 +296,29 @@ class AgentGitHandler:
         else:
             AgentGitHandler.log.info("Artifact Synchronization Task for path %r already scheduled" % repo_context.local_repo_path)
 
+    @staticmethod
+    def remove_repo(tenant_id):
+        repo_context = AgentGitHandler.get_repo_context(tenant_id)
+
+        #stop artifact update task
+        repo_context.scheduled_update_task.terminate()
+
+        #remove git contents
+        cartridgeagentutils.delete_folder_tree(repo_context.local_repo_path)
+
+        AgentGitHandler.remove_repo_context(tenant_id)
+
+        if tenant_id == -1234:
+            if CartridgeAgentConfiguration.is_multitenant:
+                extensionutils.execute_copy_artifact_extension(
+                    cartridgeagentconstants.SUPERTENANT_TEMP_PATH,
+                    CartridgeAgentConfiguration.app_path + "/repository/deployment/server/"
+                )
+
+        AgentGitHandler.log.info("git repository deleted for tenant %r" % repo_context.tenant_id)
+
+        return True
+
 
 class ArtifactUpdateTask(Thread):
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 0e60e2f..92929b5 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,5 @@
+from ...util.asyncscheduledtask import AsyncScheduledTask
+
 class GitRepository:
 
     def __init__(self):
@@ -11,4 +13,5 @@ class GitRepository:
         self.repo_password = None
         self.is_multitenant = False
         self.commit_enabled = False
-        self.scheduled_update_task = None
\ No newline at end of file
+        self.scheduled_update_task = None
+        """:type : AsyncScheduledTask """
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 55a21a2..ce27f66 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
@@ -50,6 +50,7 @@ class CompleteTenantEvent:
 
     def __init__(self):
         self.tenants = []
+        self.tenant_list_json = None
 
     @staticmethod
     def create_from_json(json_str):
@@ -57,9 +58,10 @@ class CompleteTenantEvent:
         instance = CompleteTenantEvent()
         instance.tenants = []
 
-        temp_tenants = json_obj["tenants"] if "tenants" in json_obj else None
-        if temp_tenants is not None:
-            for tenant_str in temp_tenants:
+        tenants_str = json_obj["tenants"] if "tenants" in json_obj else None
+        instance.tenant_list_json = tenants_str
+        if tenants_str is not None:
+            for tenant_str in tenants_str:
                 tenant_obj = Tenant(int(tenant_str["tenantId"]), tenant_str["tenantDomain"])
                 for service_name in tenant_str["serviceNameSubscriptionMap"]:
                     sub_str = tenant_str["serviceNameSubscriptionMap"][service_name]

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 b9b1b13..0b6e523 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -1,12 +1,14 @@
 import logging
+import time
 
 from ..artifactmgt.git.agentgithandler import AgentGitHandler
 from ..artifactmgt.repositoryinformation import RepositoryInformation
 from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import extensionutils, cartridgeagentconstants, cartridgeagentutils
+from ..util import extensionutils
 from ..publisher import cartridgeagentpublisher
 from ..exception.parameternotfoundexception import ParameterNotFoundException
 from ..topology.topologycontext import *
+from ..tenant.tenantcontext import *
 
 
 class DefaultExtensionHandler:
@@ -101,9 +103,8 @@ class DefaultExtensionHandler:
                                                                         update_interval)
 
     def on_artifact_update_scheduler_event(self, tenant_id):
-        env_params = {}
-        env_params["STRATOS_ARTIFACT_UPDATED_TENANT_ID"] = tenant_id
-        env_params["STRATOS_ARTIFACT_UPDATED_SCHEDULER"] = True
+        env_params = {"STRATOS_ARTIFACT_UPDATED_TENANT_ID": tenant_id, "STRATOS_ARTIFACT_UPDATED_SCHEDULER": True}
+
         extensionutils.execute_artifacts_updated_extension(env_params)
 
     def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
@@ -114,13 +115,12 @@ class DefaultExtensionHandler:
 
     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))
+            % (member_activated_event.service_name, member_activated_event.cluster_id, member_activated_event.member_id))
 
-        consistant = extensionutils.check_topology_consistency(member_activated_event.service_name,
+        topology_consistent = extensionutils.check_topology_consistency(member_activated_event.service_name,
                                                                member_activated_event.cluster_id,
                                                                member_activated_event.member_id)
-        if not consistant:
+        if not topology_consistent:
             self.log.error("Topology is inconsistent...failed to execute member activated event")
             return
 
@@ -132,13 +132,13 @@ class DefaultExtensionHandler:
 
         if extensionutils.is_relevant_member_event(member_activated_event.service_name,
                                                    member_activated_event.cluster_id, lb_cluster_id):
-            env_params = {}
-            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_IP"] = member_activated_event.member_ip
-            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_ID"] = member_activated_event.member_id
-            env_params["STRATOS_MEMBER_ACTIVATED_CLUSTER_ID"] = member_activated_event.cluster_id
-            env_params["STRATOS_MEMBER_ACTIVATED_LB_CLUSTER_ID"] = lb_cluster_id
-            env_params["STRATOS_MEMBER_ACTIVATED_NETWORK_PARTITION_ID"] = member_activated_event.network_partition_id
-            env_params["STRATOS_MEMBER_ACTIVATED_SERVICE_NAME"] = member_activated_event.service_name
+
+            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}
 
             ports = member_activated_event.port_map.values()
             ports_str = ""
@@ -147,11 +147,7 @@ class DefaultExtensionHandler:
 
             env_params["STRATOS_MEMBER_ACTIVATED_PORTS"] = ports_str
 
-            members = cluster.get_members()
-            member_list_json = ""
-            for member in members:
-                member_list_json += member.json_str + ","
-            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = member_list_json[:-1]  # removing last comma
+            env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = 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:
@@ -167,7 +163,8 @@ class DefaultExtensionHandler:
             clustered = CartridgeAgentConfiguration.is_clustered
 
             if member.properties is not None and member.properties[
-                cartridgeagentconstants.CLUSTERING_PRIMARY_KEY] == "true" and clustered is not None and clustered:
+                    cartridgeagentconstants.CLUSTERING_PRIMARY_KEY] == "true" and clustered is not None and clustered:
+
                 self.log.debug(" If WK member is re-spawned, update axis2.xml ")
 
                 has_wk_ip_changed = True
@@ -194,20 +191,179 @@ class DefaultExtensionHandler:
         else:
             self.log.debug("Member activated event is not relevant...skipping agent extension")
 
-    def onCompleteTopologyEvent(self, completeTopologyEvent):
-        pass
+    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
+
+        extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
+
+        topology = complete_topology_event.get_topology()
+        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}
+
+        extensionutils.execute_complete_topology_extension(env_params)
+
+    def on_complete_tenant_event(self, complete_tenant_event):
+        self.log.debug("Complete tenant event received")
+
+        tenant_list_json = complete_tenant_event.tenant_list_json
+        self.log.debug("Complete tenants:" + tenant_list_json)
+
+        env_params = {"STRATOS_TENANT_LIST_JSON": tenant_list_json}
+
+        extensionutils.execute_complete_tenant_extension(env_params)
+
+    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)
+
+        topology_consistent = extensionutils.check_topology_consistency(
+            member_terminated_event.service_name,
+            member_terminated_event.cluster_id,
+            member_terminated_event.member_id
+        )
+
+        if not topology_consistent:
+            self.log.error("Topology is inconsistent...failed to execute member terminated event")
+            return
+
+        topology = TopologyContext.get_topology()
+        service = topology.get_service(member_terminated_event.service_name)
+        cluster = service.get_cluster(member_terminated_event.cluster_id)
+        terminated_member = cluster.get_member(member_terminated_event.member_id)
+        lb_cluster_id = cluster.get_member(member_terminated_event.cluster_id).lb_cluster_id
+
+        #check whether terminated member is within the same cluster, LB cluster or service group
+        if extensionutils.is_relevant_member_event(
+                member_terminated_event.service_name,
+                member_terminated_event.cluster_id,
+                lb_cluster_id):
+
+            env_params = {"STRATOS_MEMBER_TERMINATED_MEMBER_IP": terminated_member.member_ip,
+                          "STRATOS_MEMBER_TERMINATED_MEMBER_ID": member_terminated_event.member_id,
+                          "STRATOS_MEMBER_TERMINATED_CLUSTER_ID": member_terminated_event.cluster_id,
+                          "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}
+
+            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_TERMINATED_LB_IP"] = member_ips[0]
+                env_params["STRATOS_MEMBER_TERMINATED_LB_PUBLIC_IP"] = member_ips[1]
+
+            extensionutils.add_properties(service.properties, env_params, "MEMBER_TERMINATED_SERVICE_PROPERTY")
+            extensionutils.add_properties(cluster.properties, env_params, "MEMBER_TERMINATED_CLUSTER_PROPERTY")
+            extensionutils.add_properties(terminated_member.properties, env_params, "MEMBER_TERMINATED_MEMBER_PROPERTY")
+
+            extensionutils.execute_member_terminated_extension(env_params)
+
+        else:
+            self.log.debug("Member terminated event is not relevant...skipping agent extension")
+
+    def on_member_suspended_event(self, member_suspended_event):
+        self.log.info("Member suspended event received: [service] " + member_suspended_event.service_name +
+                      " [cluster] " + member_suspended_event.cluster_id + " [member] " + member_suspended_event.member_id)
+
+        topology_consistent = extensionutils.check_topology_consistency(
+            member_suspended_event.service_name,
+            member_suspended_event.cluster_id,
+            member_suspended_event.member_id
+        )
+
+        if not topology_consistent:
+            self.log.error("Topology is inconsistent...failed to execute member suspended event")
+            return
+
+        topology = TopologyContext.get_topology()
+        service = topology.get_service(member_suspended_event.service_name)
+        cluster = service.get_cluster(member_suspended_event.cluster_id)
+        suspended_member = cluster.get_member(member_suspended_event.member_id)
+        lb_cluster_id = cluster.get_member(member_suspended_event.cluster_id).lb_cluster_id
+
+        #check whether suspended member is within the same cluster, LB cluster or service group
+        if extensionutils.is_relevant_member_event(
+                member_suspended_event.service_name,
+                member_suspended_event.cluster_id,
+                lb_cluster_id):
+
+            env_params = {"STRATOS_MEMBER_SUSPENDED_MEMBER_IP": member_suspended_event.member_ip,
+                          "STRATOS_MEMBER_SUSPENDED_MEMBER_ID": member_suspended_event.member_id,
+                          "STRATOS_MEMBER_SUSPENDED_CLUSTER_ID": member_suspended_event.cluster_id,
+                          "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}
+
+            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_SUSPENDED_LB_IP"] = member_ips[0]
+                env_params["STRATOS_MEMBER_SUSPENDED_LB_PUBLIC_IP"] = member_ips[1]
 
-    def onCompleteTenantEvent(self, completeTenantEvent):
-        pass
+            extensionutils.add_properties(service.properties, env_params, "MEMBER_SUSPENDED_SERVICE_PROPERTY")
+            extensionutils.add_properties(cluster.properties, env_params, "MEMBER_SUSPENDED_CLUSTER_PROPERTY")
+            extensionutils.add_properties(suspended_member.properties, env_params, "MEMBER_SUSPENDED_MEMBER_PROPERTY")
 
-    def onMemberTerminatedEvent(self, memberTerminatedEvent):
-        pass
+            extensionutils.execute_member_suspended_extension(env_params)
+
+        else:
+            self.log.debug("Member suspended event is not relevant...skipping agent extension")
 
-    def onMemberSuspendedEvent(self, memberSuspendedEvent):
-        pass
+    def on_member_started_event(self, member_started_event):
+        self.log.info("Member started event received: [service] " + member_started_event.service_name +
+                      " [cluster] " + member_started_event.cluster_id + " [member] " + member_started_event.member_id)
 
-    def onMemberStartedEvent(self, memberStartedEvent):
-        pass
+        topology_consistent = extensionutils.check_topology_consistency(
+            member_started_event.service_name,
+            member_started_event.cluster_id,
+            member_started_event.member_id
+        )
+
+        if not topology_consistent:
+            self.log.error("Topology is inconsistent...failed to execute member started event")
+            return
+
+        topology = TopologyContext.get_topology()
+        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
+
+        #check whether started member is within the same cluster, LB cluster or service group
+        if extensionutils.is_relevant_member_event(
+                member_started_event.service_name,
+                member_started_event.cluster_id,
+                lb_cluster_id):
+
+            env_params = {"STRATOS_MEMBER_STARTED_MEMBER_IP": member_started_event.member_ip,
+                          "STRATOS_MEMBER_STARTED_MEMBER_ID": member_started_event.member_id,
+                          "STRATOS_MEMBER_STARTED_CLUSTER_ID": member_started_event.cluster_id,
+                          "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}
+
+            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_STARTED_LB_IP"] = member_ips[0]
+                env_params["STRATOS_MEMBER_STARTED_LB_PUBLIC_IP"] = member_ips[1]
+
+            extensionutils.add_properties(service.properties, env_params, "MEMBER_STARTED_SERVICE_PROPERTY")
+            extensionutils.add_properties(cluster.properties, env_params, "MEMBER_STARTED_CLUSTER_PROPERTY")
+            extensionutils.add_properties(started_member.properties, env_params, "MEMBER_STARTED_MEMBER_PROPERTY")
+
+            extensionutils.execute_member_started_extension(env_params)
+
+        else:
+            self.log.debug("Member started event is not relevant...skipping agent extension")
 
     def start_server_extension(self):
         #wait until complete topology message is received to get LB IP
@@ -254,20 +410,59 @@ class DefaultExtensionHandler:
     def volume_mount_extension(self, persistence_mappings_payload):
         extensionutils.execute_volume_mount_extension(persistence_mappings_payload)
 
-    def onSubscriptionDomainAddedEvent(self, subscriptionDomainAddedEvent):
-        pass
-
-    def onSubscriptionDomainRemovedEvent(self, subscriptionDomainRemovedEvent):
-        pass
-
-    def onCopyArtifactsExtension(self, src, des):
-        pass
-
-    def onTenantSubscribedEvent(self, tenantSubscribedEvent):
-        pass
+    def on_subscription_domain_added_event(self, subscription_domain_added_event):
+        tenant_domain = self.find_tenant_domain(subscription_domain_added_event.tenant_id)
+        self.log.info(
+            "Subscription domain added event received: [tenant-id] " + subscription_domain_added_event.tenant_id +
+            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscription_domain_added_event.domain_name +
+            " [application-context] " + subscription_domain_added_event.application_context
+        )
+
+        env_params = {"STRATOS_SUBSCRIPTION_SERVICE_NAME": subscription_domain_added_event.service_name,
+                      "STRATOS_SUBSCRIPTION_DOMAIN_NAME": subscription_domain_added_event.domain_name,
+                      "STRATOS_SUBSCRIPTION_TENANT_ID": int(subscription_domain_added_event.tenant_id),
+                      "STRATOS_SUBSCRIPTION_TENANT_DOMAIN": tenant_domain,
+                      "STRATOS_SUBSCRIPTION_APPLICATION_CONTEXT": subscription_domain_added_event.application_context}
+
+        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)
+        self.log.info(
+            "Subscription domain removed event received: [tenant-id] " + subscriptionDomainRemovedEvent.tenant_id +
+            " [tenant-domain] " + tenant_domain + " [domain-name] " + subscriptionDomainRemovedEvent.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),
+                      "STRATOS_SUBSCRIPTION_TENANT_DOMAIN": tenant_domain}
+
+        extensionutils.execute_subscription_domain_removed_extension(env_params)
+
+    def on_copy_artifacts_extension(self, src, des):
+        extensionutils.execute_copy_artifact_extension(src, des)
+
+    def on_tenant_subscribed_event(self, tenant_subscribed_event):
+        self.log.info(
+            "Tenant subscribed event received: [tenant] " + tenant_subscribed_event.tenant_id +
+            " [service] " + tenant_subscribed_event.service_name + " [cluster] " + tenant_subscribed_event.cluster_ids
+        )
+
+        extensionutils.execute_tenant_subscribed_extension({})
+
+    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
+        )
 
-    def onTenantUnSubscribedEvent(self, tenantUnSubscribedEvent):
-        pass
+        try:
+            if CartridgeAgentConfiguration.service_name == tenant_unsubscribed_event.service_name:
+                AgentGitHandler.remove_repo(tenant_unsubscribed_event.tenant_id)
+        except:
+            self.log.exception()
+        extensionutils.execute_tenant_unsubscribed_extension({})
 
     def cleanup(self):
         self.log.info("Executing cleaning up the data in the cartridge instance...")
@@ -517,4 +712,21 @@ class DefaultExtensionHandler:
         if "MIN_COUNT" in member.properties:
             return int(member.properties["MIN_COUNT"])
 
-        return 1
\ No newline at end of file
+        return 1
+
+    def find_tenant_domain(self, tenant_id):
+        tenant = TenantContext.get_tenant(tenant_id)
+        if tenant is None:
+            raise RuntimeError("Tenant could not be found: [tenant-id] %r" % tenant_id)
+
+        return tenant.tenant_domain
+
+    def wait_for_wk_members(self, env_params):
+        min_count = int(CartridgeAgentConfiguration.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

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 7a84e4d..444f9ac 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -76,10 +76,7 @@ def wait_until_ports_active(ip_address, ports):
         if duration > ports_check_timeout:
             return
 
-        try:
-            time.sleep(5)
-        except:
-            pass
+        time.sleep(5)
 
     log.info("Ports activated: [ip] %r [ports] %r" % (ip_address, ports))
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/71f827d0/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 e29b614..3ca4cc0 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -64,12 +64,34 @@ def execute_artifacts_updated_extension(env_params):
         log.exception("Could not execute artifacts updated extension")
 
 
-def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
-    raise NotImplementedError
+def execute_subscription_domain_added_extension(env_params):
+    try:
+        log.debug("Executing subscription domain added extension")
+
+        script_name = cartridgeagentconstants.SUBSCRIPTION_DOMAIN_ADDED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Subscription domain added script returned: %r" % output)
+    except:
+        log.exception("Could not execute subscription domain added extension")
+
+
+def execute_subscription_domain_removed_extension(env_params):
+    try:
+        log.debug("Executing subscription domain removed extension")
 
+        script_name = cartridgeagentconstants.SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
 
-def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, domain_name):
-    raise NotImplementedError
+        output, errors = execute_command(command, env_params)
+        log.debug("Subscription domain removed script returned: %r" % output)
+    except:
+        log.exception("Could not execute subscription domain removed extension")
 
 
 def execute_start_servers_extension(env_params):
@@ -87,6 +109,110 @@ def execute_start_servers_extension(env_params):
         log.exception("Could not execute start servers extension")
 
 
+def execute_complete_topology_extension(env_params):
+    try:
+        log.debug("Executing complete topology extension")
+
+        script_name = cartridgeagentconstants.COMPLETE_TOPOLOGY_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Complete topology script returned: %r" % output)
+    except:
+        log.exception("Could not execute complete topology extension")
+
+
+def execute_complete_tenant_extension(env_params):
+    try:
+        log.debug("Executing complete tenant extension")
+
+        script_name = cartridgeagentconstants.COMPLETE_TENANT_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Complete tenant script returned: %r" % output)
+    except:
+        log.exception("Could not execute complete tenant extension")
+
+
+def execute_tenant_subscribed_extension(env_params):
+    try:
+        log.debug("Executing tenant subscribed extension")
+
+        script_name = cartridgeagentconstants.TENANT_SUBSCRIBED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Tenant subscribed script returned: %r" % output)
+    except:
+        log.exception("Could not execute tenant subscribed extension")
+
+
+def execute_tenant_unsubscribed_extension(env_params):
+    try:
+        log.debug("Executing tenant unsubscribed extension")
+
+        script_name = cartridgeagentconstants.TENANT_UNSUBSCRIBED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Tenant unsubscribed script returned: %r" % output)
+    except:
+        log.exception("Could not execute tenant unsubscribed extension")
+
+
+def execute_member_terminated_extension(env_params):
+    try:
+        log.debug("Executing member terminated extension")
+
+        script_name = cartridgeagentconstants.MEMBER_TERMINATED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Member terminated script returned: %r" % output)
+    except:
+        log.exception("Could not execute member terminated extension")
+
+
+def execute_member_suspended_extension(env_params):
+    try:
+        log.debug("Executing member suspended extension")
+
+        script_name = cartridgeagentconstants.MEMBER_SUSPENDED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Member suspended script returned: %r" % output)
+    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 = cartridgeagentconstants.MEMBER_STARTED_SCRIPT
+        command = prepare_command(script_name)
+        env_params = add_payload_parameters(env_params)
+        env_params = clean_process_parameters(env_params)
+
+        output, errors = execute_command(command, env_params)
+        log.debug("Member started script returned: %r" % output)
+    except:
+        log.exception("Could not execute member started extension")
+
+
 def wait_for_complete_topology():
     while not TopologyContext.topology.initialized:
         log.info("Waiting for complete topology event...")
@@ -221,38 +347,38 @@ def clean_process_parameters(params):
     return params
 
 
-def add_payload_parameters(params):
-    params["STRATOS_APP_PATH"] = CartridgeAgentConfiguration.app_path
-    params["STRATOS_PARAM_FILE_PATH"] = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
-    params["STRATOS_SERVICE_NAME"] = CartridgeAgentConfiguration.service_name
-    params["STRATOS_TENANT_ID"] = CartridgeAgentConfiguration.tenant_id
-    params["STRATOS_CARTRIDGE_KEY"] = CartridgeAgentConfiguration.cartridge_key
-    params["STRATOS_LB_CLUSTER_ID"] = CartridgeAgentConfiguration.lb_cluster_id
-    params["STRATOS_CLUSTER_ID"] = CartridgeAgentConfiguration.cluster_id
-    params["STRATOS_NETWORK_PARTITION_ID"] = CartridgeAgentConfiguration.network_partition_id
-    params["STRATOS_PARTITION_ID"] = CartridgeAgentConfiguration.partition_id
-    params["STRATOS_PERSISTENCE_MAPPINGS"] = CartridgeAgentConfiguration.persistence_mappings
-    params["STRATOS_REPO_URL"] = CartridgeAgentConfiguration.repo_url
+def add_payload_parameters(env_params):
+    env_params["STRATOS_APP_PATH"] = CartridgeAgentConfiguration.app_path
+    env_params["STRATOS_PARAM_FILE_PATH"] = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+    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
     member_ips = get_lb_member_ip(lb_cluster_id_in_payload)
     if member_ips is not None:
-        params["STRATOS_LB_IP"] = member_ips[0]
-        params["STRATOS_LB_PUBLIC_IP"] = member_ips[1]
+        env_params["STRATOS_LB_IP"] = member_ips[0]
+        env_params["STRATOS_LB_PUBLIC_IP"] = member_ips[1]
     else:
-        params["STRATOS_LB_IP"] = CartridgeAgentConfiguration.lb_private_ip
-        params["STRATOS_LB_PUBLIC_IP"] = CartridgeAgentConfiguration.lb_public_ip
+        env_params["STRATOS_LB_IP"] = CartridgeAgentConfiguration.lb_private_ip
+        env_params["STRATOS_LB_PUBLIC_IP"] = CartridgeAgentConfiguration.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
-        add_properties(service.properties, params, "SERVICE_PROPERTY")
-        add_properties(cluster.properties, params, "CLUSTER_PROPERTY")
-        add_properties(cluster.get_member(member_id_in_payload).properties, params, "MEMBER_PROPERTY")
+        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")
 
-    return params
+    return env_params
 
 
 def add_properties(properties, params, prefix):


[36/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/9c9639e9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9c9639e9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9c9639e9

Branch: refs/heads/master
Commit: 9c9639e93ab1b74226f11b07207801efd6d11551
Parents: 599cbdc
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 12:25:04 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/9c9639e9/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/9c9639e9/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/9c9639e9/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/9c9639e9/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/9c9639e9/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/9c9639e9/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/9c9639e9/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


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

Posted by ni...@apache.org.
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/116d8f6f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/116d8f6f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/116d8f6f

Branch: refs/heads/master
Commit: 116d8f6f16cdda62b6c3e9065ae2b406ea1c196a
Parents: 59c1488
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sun Sep 28 14:06:48 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/116d8f6f/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/116d8f6f/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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()


[20/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/15d864ab
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/15d864ab
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/15d864ab

Branch: refs/heads/master
Commit: 15d864abb439eb67a06ffe8bb24f3053d7dba1d4
Parents: c2fad13
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 02:40:14 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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)


[22/50] [abbrv] git commit: Fixed style issues Added volume mount extension execution copy artifact extension

Posted by ni...@apache.org.
Fixed style issues
Added volume mount extension execution copy artifact extension


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

Branch: refs/heads/master
Commit: ccd6ab5fe987d55257425d2c5ee8cdf2dd1537b1
Parents: 8c9f74e
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Sep 26 17:30:27 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    | 256 -------------------
 .../cartridge-agent/extensionhandler.py         |  44 ----
 .../cartridge-agent/extensionhandler.pyc        | Bin 1987 -> 0 bytes
 .../modules/artifactmgt/git/agentgithandler.py  |   3 +-
 .../config/cartridgeagentconfiguration.py       | 141 +---------
 .../modules/event/tenant/events.py              |   2 +-
 .../modules/event/topology/events.py            |   2 +-
 .../extensions/defaultextensionhandler.py       |   1 -
 .../modules/tenant/tenantcontext.py             |  73 +++---
 .../modules/topology/topologycontext.py         |  44 ++--
 .../modules/util/cartridgeagentconstants.py     |   2 +-
 .../modules/util/cartridgeagentutils.py         |   4 +-
 .../modules/util/extensionutils.py              |  24 +-
 13 files changed, 86 insertions(+), 510 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 1abe0f6..60e9805 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -4,7 +4,6 @@ import threading
 import time
 
 from modules.config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from modules.util import cartridgeagentconstants, cartridgeagentutils
 from modules.exception.parameternotfoundexception import ParameterNotFoundException
 from modules.subscriber.eventsubscriber import EventSubscriber
 from modules.extensions.defaultextensionhandler import DefaultExtensionHandler
@@ -161,7 +160,6 @@ class CartridgeAgent(threading.Thread):
         else:
             self.log.info("Complete topology event updating task disabled")
 
-
     def on_member_started(self, msg):
         raise NotImplementedError
 
@@ -233,10 +231,6 @@ class CartridgeAgent(threading.Thread):
         except:
             self.log.exception("Error processing tenant unSubscribed event")
 
-    def find_tenant_domain(self, tenant_id):
-        # TODO: call to REST Api and get tenant information
-        raise NotImplementedError
-
 
 def main():
     cartridge_agent = CartridgeAgent()
@@ -245,253 +239,3 @@ def main():
 
 if __name__ == "__main__":
     main()
-# ========================================================
-#
-#
-# def runningSuspendScript():
-#     print "inside thread"
-#     os.system('./script.sh')
-#
-#
-# def MyThread2():
-#     pass
-#
-#
-# def listeningTopology():
-#     class MyListener(stomp.ConnectionListener):
-#         def on_error(self, headers, message):
-#             print('received an error %s' % message)
-#
-#         def on_message(self, headers, message):
-#             # print('received message\n %s'% message)
-#             for k, v in headers.iteritems():
-#                 print('header: key %s , value %s' % (k, v))
-#
-#                 if k == 'event-class-name':
-#                     print('event class name found')
-#                     if v == 'org.apache.stratos.messaging.event.topology.CompleteTopologyEvent':
-#                         print('CompleteTopologyEvent triggered')
-#                         print('received message\n %s' % message)
-#                     if v == 'org.apache.stratos.messaging.event.topology.MemberTerminatedEvent':
-#                         print('MemberTerminatedEvent triggered')
-#                     if v == 'org.apache.stratos.messaging.event.topology.ServiceCreatedEvent':
-#                         print('MemberTerminatedEvent triggered')
-#                     if v == 'org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent':
-#                         print('MemberTerminatedEvent triggered')
-#                         print('received message\n %s' % message)
-#                     if v == 'org.apache.stratos.messaging.event.topology.ClusterCreatedEvent':
-#                         print('MemberTerminatedEvent triggered')
-#                     if v == 'org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent':
-#                         print('MemberTerminatedEvent triggered')
-#                     else:
-#                         print('something else')
-#
-#
-#     dest = '/topic/topology'
-#     conn = stomp.Connection([('localhost', 61613)])
-#     print('set up Connection')
-#     conn.set_listener('somename', MyListener())
-#     print('Set up listener')
-#
-#     conn.start()
-#     print('started connection')
-#
-#     conn.connect(wait=True)
-#     print('connected')
-#     conn.subscribe(destination=dest, ack='auto')
-#     print('subscribed')
-#
-#
-# def listeningInstanceNotifier():
-#     instance_topic_client.on_connect = instance_notifier_connect
-#     instance_topic_client.on_message = instance_notifier_message
-#
-#     # mb_client.connect(readProperty("mb.ip"), properties.get("agent", "mb.port"), 60)
-#     instance_topic_client.connect("127.0.0.1", 1883, 60)
-#     instance_topic_client.loop_forever()
-#
-#
-# def instance_notifier_connect(client, userdata, flags, rc):
-#     print "Connected! Subscribing to instance/# topics"
-#     instance_topic_client.subscribe("instance/#")
-#
-#
-# def artifact_updated(msg):
-#     extensionhandler.onArtifactUpdatedEvent(extensionsDir, 'artifacts-updated.sh')
-#
-#
-# def instance_cleanup_member(msg):
-#     # if sd['MEMBER_ID'] == member_id_from_event:
-#     extensionhandler.onInstanceCleanupMemberEvent(extensionsDir, 'clean.sh')
-#
-#
-# def instance_cleanup_cluster(msg):
-#     # if cluster_id == cluster_id_from_event:
-#     extensionhandler.onInstanceCleanupMemberEvent(extensionsDir, 'clean.sh')
-#
-#
-# def instance_notifier_message(client, userdata, msg):
-#     print "Topic: %r\nContent:%r" % (msg.topic, msg.payload)
-#     event = msg.topic.rpartition('/')[2]
-#     print "Event: %r" % event
-#     if event == "ArtifactUpdatedEvent":
-#         # TODO: event details to be passed to the script
-#         print "ArtifactUpdatedEvent received"
-#         artifact_updated(msg)
-#     elif event == "InstanceCleanupMemberEvent":
-#         print "InstanceCleanupMemberEvent received"
-#         # TODO: event details to be passed to the script
-#         instance_cleanup_member(msg)
-#     elif event == "InstanceCleanupClusterEvent":
-#         print "InstanceCleanupClusterEvent received"
-#         # TODO: event details to be passed to the script
-#         instance_cleanup_cluster(msg)
-#     else:
-#         print "Unidentified event: %r" % event
-#
-#
-# def publishInstanceStartedEvent():
-#     instance_started_event = InstanceStartedEvent(service_name, cluster_id, sd['NETWORK_PARTITION_ID'],
-#                                                   sd['PARTITION_ID'], sd['MEMBER_ID'])
-#     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 checkPortsActive():
-#     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-#     result = sock.connect_ex(('127.0.0.1', 80))
-#     if result == 0:
-#         print "Port is open"
-#     else:
-#         print "Port is not open"
-#
-#
-# class InstanceStartedEvent:
-#     serviceName = ''
-#
-#     def __init__(self, serviceName, clusterId, networkPartitionId, partitionId, memberId):
-#         self.serviceName = serviceName
-#         self.clusterId = clusterId
-#         self.networkPartitionId = networkPartitionId
-#         self.partitionId = partitionId
-#         self.memberId = memberId
-#
-#     def to_JSON(self):
-#         return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
-#
-#
-# def onInstanceStartedEvent():
-#     print('on instance start up event')
-#     event = InstanceStartedEvent(service_name, cluster_id, '', '', tenant_id)
-#     print(event.to_JSON())
-#
-#
-# def onArtifactUpdatedEvent():
-#     print('on srtifcats update event')
-#
-# # Parse properties file
-# properties = ConfigParser.SafeConfigParser()
-# properties.read('agent.properties')
-#
-# # TODO: check from properties file
-# util.validateRequiredSystemProperties()
-#
-# payloadPath = sys.argv[1]
-# extensionsDir = sys.argv[2]
-# extensionhandler.onArtifactUpdatedEvent(extensionsDir, 'artifacts-updated.sh')
-#
-# fo = open(payloadPath, "r+")
-# str = fo.read(1000);
-#
-# print "Read String is : ", str
-#
-# sd = dict(u.split("=") for u in str.split(","))
-#
-# print [i for i in sd.keys()]
-#
-# print "HOST_NAME   ", sd['HOST_NAME']
-#
-# hostname = sd['HOST_NAME']
-# service_name = sd['SERVICE_NAME']
-# multitenant = sd['MULTITENANT']
-# tenant_id = sd['TENANT_ID']
-# tenantrange = sd['TENANT_RANGE']
-# cartridealies = sd['CARTRIDGE_ALIAS']
-# cluster_id = sd['CLUSTER_ID']
-# cartridge_key = sd['CARTRIDGE_KEY']
-# deployement = sd['DEPLOYMENT']
-# repourl = sd['REPO_URL']
-# ports = sd['PORTS']
-# puppetip = sd['PUPPET_IP']
-# puppethostname = sd['PUPPET_HOSTNAME']
-# puppetenv = sd['PUPPET_ENV']
-# persistance_mapping = sd['PERSISTENCE_MAPPING'] if 'PERSISTENCE_MAPPING' in sd else None
-#
-# if 'COMMIT_ENABLED' in sd:
-#     commitenabled = sd['COMMIT_ENABLED']
-#
-# if 'DB_HOST' in sd:
-#     dbhost = sd['DB_HOST']
-#
-# if multitenant == "true":
-#     app_path = sd['APP_PATH']
-# else:
-#     app_path = ""
-#
-# instance_topic_client = mqtt.Client()
-#
-# env_params = {}
-# env_params['STRATOS_APP_PATH'] = app_path
-# env_params['STRATOS_PARAM_FILE_PATH'] = readProperty("param.file.path")
-# env_params['STRATOS_SERVICE_NAME'] = service_name
-# env_params['STRATOS_TENANT_ID'] = tenant_id
-# env_params['STRATOS_CARTRIDGE_KEY'] = cartridge_key
-# env_params['STRATOS_LB_CLUSTER_ID'] = sd['LB_CLUSTER_ID']
-# env_params['STRATOS_CLUSTER_ID'] = cluster_id
-# env_params['STRATOS_NETWORK_PARTITION_ID'] = sd['NETWORK_PARTITION_ID']
-# env_params['STRATOS_PARTITION_ID'] = sd['PARTITION_ID']
-# env_params['STRATOS_PERSISTENCE_MAPPINGS'] = persistance_mapping
-# env_params['STRATOS_REPO_URL'] = sd['REPO_URL']
-# # envParams['STRATOS_LB_IP']=
-# # envParams['STRATOS_LB_PUBLIC_IP']=
-# # envParams['']=
-# # envParams['']=
-# # envParams['']=
-# # envParams['']=
-#
-# extensionhandler.onInstanceStartedEvent(extensionsDir, 'instance-started.sh', multitenant, 'artifacts-copy.sh.erb',
-#                                         app_path, env_params)
-#
-# t1 = threading.Thread(target=runningSuspendScript, args=[])
-#
-# t1.start()
-#
-# t2 = threading.Thread(target=listeningInstanceNotifier, args=[])
-#
-# t2.start()
-#
-# t3 = threading.Thread(target=listeningTopology, args=[])
-#
-# t3.start()
-#
-# onInstanceStartedEvent()
-#
-# checkPortsActive()
-#
-# publishInstanceStartedEvent()
-#
-# extensionhandler.startServerExtension()
-#
-#
-# def git(*args):
-#     return subprocess.check_call(['git'] + list(args))
-#
-# # examples
-# git("status")
-# git("clone", "git://git.xyz.com/platform/manifest.git", "-b", "jb_2.5")
-#
-#
-#
-#
-#

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
deleted file mode 100644
index adf3dd6..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# #!/usr/bin/env python
-# import stomp
-# import time
-# import logging
-# import sys
-# import random
-# import os
-# import threading
-# import socket
-# import json
-# from subprocess import Popen,PIPE
-#
-#
-# def onArtifactUpdatedEvent(extenstionpath,scriptname):
-#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-#     print Process.communicate() #now you should see your output
-#    # os.system()
-#
-# def onInstanceCleanupMemberEvent(extenstionpath,scriptname):
-#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-#     print Process.communicate()
-#
-# def onInstanceCleanupClusterEvent(extenstionpath,scriptname):
-#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-#     print Process.communicate()
-#
-# def startServerExtension():
-#     print('=================================startServerExtension')
-#
-# def onInstanceStartedEvent(extensionpath, scriptname, multitenant, copyartifactscriptname, apppath, envparams):
-#     print('=================================onInstanceStartedEvent')
-#     #if ismultitenant
-#     #   execute copy artifact extension
-#
-#     if multitenant == "true":
-#         Process = Popen([os.path.join(extensionpath, copyartifactscriptname), apppath + "/repository/deployment/server/", "/tmp/-1234/"], shell=True, stdin=PIPE, stderr=PIPE)
-#         print Process.communicate()
-#
-#     #addPayloadParams()
-#     Process = Popen([os.path.join(extensionpath, scriptname), envparams], shell=True, stdin=PIPE, stderr=PIPE)
-#     print Process.communicate()
-#
-#     #execute instance started extension with empty map
-#

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/tools/python-cartridge-agent/cartridge-agent/extensionhandler.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.pyc b/tools/python-cartridge-agent/cartridge-agent/extensionhandler.pyc
deleted file mode 100644
index 0dc2e36..0000000
Binary files a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.pyc and /dev/null differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 4d2ca87..eda0f92 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
@@ -131,7 +131,7 @@ class AgentGitHandler:
                 """
                 conflict_list = []
                 files_arr = str(ex).split("\n")
-                for file_index in range(1, len(files_arr)-2):
+                for file_index in range(1, len(files_arr) - 2):
                     file_name = files_arr[file_index].strip()
                     conflict_list.append(file_name)
                     AgentGitHandler.log.debug("Added the file path %r to checkout from the remote repository" % file_name)
@@ -223,7 +223,6 @@ class AgentGitHandler:
     # @staticmethod
     # def is_key_based_auth(repo_url, tenant_id):
 
-
     @staticmethod
     def get_repo_path_for_tenant(tenant_id, git_local_repo_path, is_multitenant):
         repo_path = ""

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 b7ddd41..c87f0c4 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -258,146 +258,9 @@ class CartridgeAgentConfiguration:
             if temp_str != "" and temp_str is not None:
                 return temp_str
 
-        if CartridgeAgentConfiguration.payload_params.has_key(property_key):
+        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
 
-        raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
-
-        # @staticmethod
-        # def get_service_name():
-        # return CartridgeAgentConfiguration.__service_name
-        #
-        # @staticmethod
-        # def get_cluster_id():
-        #     return CartridgeAgentConfiguration.__cluster_id
-        #
-        # @staticmethod
-        # def get_network_partition_id():
-        #     return CartridgeAgentConfiguration.__network_partition_id
-        #
-        # @staticmethod
-        # def get_partition_id():
-        #     return CartridgeAgentConfiguration.__partition_id
-        #
-        # @staticmethod
-        # def get_member_id():
-        #     return CartridgeAgentConfiguration.__member_id
-        #
-        # @staticmethod
-        # def get_cartridge_key():
-        #     return CartridgeAgentConfiguration.__cartridge_key
-        #
-        # @staticmethod
-        # def get_app_path():
-        #     return CartridgeAgentConfiguration.__app_path
-        #
-        # @staticmethod
-        # def get_repo_url():
-        #     return CartridgeAgentConfiguration.__repo_url
-        #
-        # @staticmethod
-        # def get_ports():
-        #     return CartridgeAgentConfiguration.__ports
-        #
-        # @staticmethod
-        # def get_log_file_paths():
-        #     return CartridgeAgentConfiguration.__log_file_paths
-        #
-        # @staticmethod
-        # def is_multitenant():
-        #     return CartridgeAgentConfiguration.__is_multitenant
-        #
-        # @staticmethod
-        # def get_persistance_mappings():
-        #     return CartridgeAgentConfiguration.__persistence_mappings
-        #
-        # @staticmethod
-        # def is_commits_enabled():
-        #     return CartridgeAgentConfiguration.__is_commits_enabled
-        #
-        # @staticmethod
-        # def get_listen_address():
-        #     return CartridgeAgentConfiguration.__listen_address
-        #
-        # @staticmethod
-        # def is_internal_repo():
-        #     return CartridgeAgentConfiguration.__is_internal_repo
-        #
-        # @staticmethod
-        # def get_tenant_id():
-        #     return CartridgeAgentConfiguration.__tenant_id
-        #
-        # @staticmethod
-        # def get_lb_cluster_id():
-        #     return CartridgeAgentConfiguration.__lb_cluster_id
-        #
-        # @staticmethod
-        # def get_service_group():
-        #     return CartridgeAgentConfiguration.__service_group
-        #
-        # @staticmethod
-        # def is_clustered():
-        #     return CartridgeAgentConfiguration.__is_clustered
-        #
-        # @staticmethod
-        # def get_min_count():
-        #     return CartridgeAgentConfiguration.__min_count
-        #
-        # @staticmethod
-        # def is_primary():
-        #     return CartridgeAgentConfiguration.__is_primary
-        #
-        # @staticmethod
-        # def get_lb_public_ip():
-        #     return CartridgeAgentConfiguration.__lb_public_ip
-        #
-        # @staticmethod
-        # def set_lb_public_ip(ip):
-        #     CartridgeAgentConfiguration.__lb_public_ip = ip
-        #
-        # @staticmethod
-        # def get_lb_private_ip():
-        #     return CartridgeAgentConfiguration.__lb_private_ip
-        #
-        # @staticmethod
-        # def set_lb_private_ip(ip):
-        #     CartridgeAgentConfiguration.__lb_private_ip = ip
-        #
-        # @staticmethod
-        # def get_deployment():
-        #     return CartridgeAgentConfiguration.__deployment
-        #
-        # @staticmethod
-        # def set_deployment(dep):
-        #     CartridgeAgentConfiguration.__deployment = dep
-        #
-        # @staticmethod
-        # def get_manager_service_name():
-        #     return CartridgeAgentConfiguration.__manager_service_name
-        #
-        # @staticmethod
-        # def set_manager_service_name(mgr):
-        #     CartridgeAgentConfiguration.__manager_service_name = mgr
-        #
-        # @staticmethod
-        # def get_worker_service_name():
-        #     return CartridgeAgentConfiguration.__worker_service_name
-        #
-        # @staticmethod
-        # def set_worker_service_name(wrkr):
-        #     CartridgeAgentConfiguration.__worker_service_name = wrkr
-        #
-        # @staticmethod
-        # def get_super_tenant_repo_path():
-        #     return CartridgeAgentConfiguration.__super_tenant_repository_path
-        #
-        # @staticmethod
-        # def get_tenant_repo_path():
-        #     return CartridgeAgentConfiguration.__tenant_repository_path
-        #
-        # @staticmethod
-        # def is_checkout_enabled():
-        #     return CartridgeAgentConfiguration.__is_checkout_enabled
-        #
+        raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 a08c4af..55a21a2 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
@@ -67,7 +67,7 @@ class CompleteTenantEvent:
                     for domain_name in sub_str["subscriptionDomainMap"]:
                         subdomain_str = sub_str["subscriptionDomainMap"][domain_name]
                         sub.add_subscription_domain(domain_name, subdomain_str["applicationContext"])
-                    tenant_obj.add_subscription(sub);
+                    tenant_obj.add_subscription(sub)
                 instance.tenants.append(tenant_obj)
 
         return instance

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 e0f050f..da07f68 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
@@ -144,7 +144,7 @@ class CompleteTopologyEvent:
 
                         #add port map
                         for mm_port_proxy in member_str["portMap"]:
-                            mm_port_str = member_str["portMap"][port_proxy]
+                            mm_port_str = member_str["portMap"][mm_port_proxy]
                             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)

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 848f478..b9b1b13 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -238,7 +238,6 @@ class DefaultExtensionHandler:
                 env_params["STRATOS_CLUSTERING"] = "true"
                 env_params["STRATOS_WK_MEMBER_COUNT"] = CartridgeAgentConfiguration.min_count
 
-
                 env_params["STRATOS_PRIMARY"] = "true" if CartridgeAgentConfiguration.is_primary else "false"
 
                 self.wait_for_wk_members(env_params)

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 53e340b..dd7bcc0 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
@@ -1,40 +1,3 @@
-class TenantContext:
-    tenants = {}
-    initialized = False
-    tenant_domains = {"carbon.super": Tenant(-1234, "carbon.super")}
-
-    @staticmethod
-    def add_tenant(tenant):
-        TenantContext.tenants[tenant.tenant_id] = tenant
-        TenantContext.tenant_domains[tenant.tenant_domain] = tenant
-
-    @staticmethod
-    def remove_tenant(tenant_id):
-        if tenant_id in TenantContext.tenants:
-            tenant = TenantContext.get_tenant(tenant_id)
-            TenantContext.tenants.pop(tenant.tenant_id)
-            TenantContext.tenant_domains.pop(tenant.tenant_domain)
-
-    @staticmethod
-    def update(tenants):
-        for tenant in tenants:
-            TenantContext.add_tenant(tenant)
-
-    @staticmethod
-    def get_tenant(tenant_id):
-        if tenant_id in TenantContext.tenants:
-            return TenantContext.tenants[tenant_id]
-
-        return None
-
-    @staticmethod
-    def get_tenant(tenant_domain):
-        if tenant_domain in TenantContext.tenant_domains:
-            return TenantContext.tenant_domains[tenant_domain]
-
-        return None
-
-
 class Tenant:
 
     def __init__(self, tenant_id,  tenant_domain):
@@ -86,3 +49,39 @@ class SubscriptionDomain:
         self.domain_name = domain_name
         self.application_context = application_context
 
+
+class TenantContext:
+    tenants = {}
+    initialized = False
+    tenant_domains = {"carbon.super": Tenant(-1234, "carbon.super")}
+
+    @staticmethod
+    def add_tenant(tenant):
+        TenantContext.tenants[tenant.tenant_id] = tenant
+        TenantContext.tenant_domains[tenant.tenant_domain] = tenant
+
+    @staticmethod
+    def remove_tenant(tenant_id):
+        if tenant_id in TenantContext.tenants:
+            tenant = TenantContext.get_tenant(tenant_id)
+            TenantContext.tenants.pop(tenant.tenant_id)
+            TenantContext.tenant_domains.pop(tenant.tenant_domain)
+
+    @staticmethod
+    def update(tenants):
+        for tenant in tenants:
+            TenantContext.add_tenant(tenant)
+
+    @staticmethod
+    def get_tenant(tenant_id):
+        if tenant_id in TenantContext.tenants:
+            return TenantContext.tenants[tenant_id]
+
+        return None
+
+    @staticmethod
+    def get_tenant_by_domain(tenant_domain):
+        if tenant_domain in TenantContext.tenant_domains:
+            return TenantContext.tenant_domains[tenant_domain]
+
+        return None
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 73b6e3c..dea8bed 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -1,27 +1,6 @@
 from ..util import cartridgeagentutils, cartridgeagentconstants
 
 
-class TopologyContext:
-    topology = None
-    # TODO: read write locks, Lock() and RLock()
-
-    @staticmethod
-    def get_topology():
-        #TODO: thread-safety missing
-        if TopologyContext.topology is None:
-            TopologyContext.topology = Topology()
-        return TopologyContext.topology
-
-        # @staticmethod
-        # def update(topology):
-        #     TopologyContext.topology = topology
-        #     #TODO: persist in registry
-
-    @staticmethod
-    def update(topology):
-        TopologyContext.topology = topology
-
-
 class Topology:
     def __init__(self):
         self.service_map = {}
@@ -247,4 +226,25 @@ class MemberStatus:
     ReadyToShutDown = 5
     Terminated = 6
     Suspended = 0
-    ShuttingDown = 0
\ No newline at end of file
+    ShuttingDown = 0
+
+
+class TopologyContext:
+    topology = None
+    # TODO: read write locks, Lock() and RLock()
+
+    @staticmethod
+    def get_topology():
+        #TODO: thread-safety missing
+        if TopologyContext.topology is None:
+            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

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 cf0199d..3b7f6c8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -23,7 +23,7 @@ LB_CLUSTER_ID = "LB_CLUSTER_ID"
 NETWORK_PARTITION_ID = "NETWORK_PARTITION_ID"
 PARTITION_ID = "PARTITION_ID"
 MEMBER_ID = "MEMBER_ID"
-TENANT_ID= "TENANT_ID"
+TENANT_ID = "TENANT_ID"
 REPO_URL = "REPO_URL"
 PORTS = "PORTS"
 DEPLOYMENT = "DEPLOYMENT"

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 ded3a6c..7a84e4d 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -9,7 +9,7 @@ import shutil
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 import cartridgeagentconstants
 
-unpad = lambda s : s[0:-ord(s[-1])]
+unpad = lambda s: s[0:-ord(s[-1])]
 logging.basicConfig(level=logging.DEBUG)
 log = logging.getLogger(__name__)
 
@@ -72,7 +72,7 @@ def wait_until_ports_active(ip_address, ports):
         log.info("Waiting for ports to be active: [ip] %r [ports] %r" % (ip_address, ports))
         active = check_ports_active(ip_address, ports)
         end_time = current_milli_time()
-        duration  = end_time - start_time
+        duration = end_time - start_time
         if duration > ports_check_timeout:
             return
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/ccd6ab5f/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 70d9c44..e29b614 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -11,7 +11,15 @@ log = logging.getLogger(__name__)
 
 
 def execute_copy_artifact_extension(source, destination):
-    raise NotImplementedError
+    try:
+        log.debug("Executing artifacts copy extension")
+        script_name = cartridgeagentconstants.ARTIFACTS_COPY_SCRIPT
+        command = prepare_command(script_name)
+
+        output, errors = execute_command(command + " " + source + " " + destination)
+        log.debug("Artifacts copy script returned: %r" % output)
+    except:
+        log.exception("Could not execute artifacts copy extension")
 
 
 def execute_instance_started_extension(env_params):
@@ -148,7 +156,15 @@ def is_relevant_member_event(service_name, cluster_id, lb_cluster_id):
 
 
 def execute_volume_mount_extension(persistance_mappings_payload):
-    raise NotImplementedError
+    try:
+        log.debug("Executing volume mounting extension: [payload] %r" % persistance_mappings_payload)
+        script_name = cartridgeagentconstants.MOUNT_VOLUMES_SCRIPT
+        command = prepare_command(script_name)
+
+        output, errors = execute_command(command + " " + persistance_mappings_payload)
+        log.debug("Volume mount script returned: %r" % output)
+    except:
+        log.exception("Could not execute Volume mount extension")
 
 
 def execute_cleanup_extension():
@@ -251,7 +267,7 @@ def add_properties(properties, params, prefix):
 
     for key in properties:
         params["STRATOS_" + prefix + "_" + key] = properties[key]
-        log.debug("Property added: [key] STRATOS_ " +  prefix + "_" + key + "[value] " + properties[key])
+        log.debug("Property added: [key] STRATOS_ " + prefix + "_" + key + "[value] " + properties[key])
 
 
 def get_lb_member_ip(lb_cluster_id):
@@ -288,4 +304,4 @@ def execute_command(command, env_params=None):
     if len(errors) > 0:
         raise RuntimeError("Command execution failed: \n %r" % errors)
 
-    return output, errors
\ No newline at end of file
+    return output, errors


[39/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/16b17eda
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/16b17eda
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/16b17eda

Branch: refs/heads/master
Commit: 16b17eda851fb8c50edc317826e3cc73555fac92
Parents: 0fda59b
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 03:06:50 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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


[45/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/87b2ba9f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/87b2ba9f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/87b2ba9f

Branch: refs/heads/master
Commit: 87b2ba9fc7a3d71d184de23b1af3b03082d07809
Parents: b93426d
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:28:37 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/stratos/blob/87b2ba9f/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:


[07/50] [abbrv] Restructured modules to suit relative imports

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..7395f7e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
@@ -0,0 +1,98 @@
+import json
+
+
+class SubscriptionDomainAddedEvent():
+
+    def __init__(self):
+        self.tenant_id = None
+        self.service_name = None
+        self.cluster_ids = None
+        self.domain_name = None
+        self.application_context = None
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = SubscriptionDomainAddedEvent()
+
+        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
+        instance.application_context = json_obj["applicationContext"] if "applicationContext" in json_obj else None
+
+        return instance
+
+
+class SubscriptionDomainRemovedEvent:
+
+    def __init__(self, tenant_id, service_name, cluster_ids, domain_name):
+        self.tenant_id = tenant_id
+        self.service_name = service_name
+        self.cluster_ids = cluster_ids
+        self.domain_name = domain_name
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = SubscriptionDomainRemovedEvent()
+
+        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
+
+        return instance
+
+
+class CompleteTenantEvent:
+
+    def __init__(self):
+        self.tenants = None
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = CompleteTenantEvent()
+
+        instance.tenants = json_obj["tenants"] if "tenants" in json_obj else None
+
+        return instance
+
+
+class TenantSubscribedEvent:
+
+    def __init__(self):
+        self.tenant_id = None
+        self.service_name = None
+        self.cluster_ids = None
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = TenantSubscribedEvent()
+
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+
+        return instance
+
+
+class TenantUnsubscribedEvent:
+
+    def __init__(self):
+        self.tenant_id = None
+        self.service_name = None
+        self.cluster_ids = None
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = TenantUnsubscribedEvent()
+
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+
+        return instance
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..7f59666
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
@@ -0,0 +1 @@
+__all__ = ['parameternotfoundexception']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc
new file mode 100644
index 0000000..d1603b5
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..a9a776e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
@@ -0,0 +1,9 @@
+class ParameterNotFoundException(Exception):
+    __message = None
+
+    def __init__(self, message):
+        Exception.__init__(self, message)
+        self.__message = message
+
+    def get_message(self):
+        return self.__message

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc
new file mode 100644
index 0000000..7a4c42c
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..33da048
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
@@ -0,0 +1 @@
+__all__=['defaultextensionhandler']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..15e79bc
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -0,0 +1,148 @@
+import logging
+
+from ..artifactmgt.git.agentgithandler import AgentGitHandler
+from ..artifactmgt.repositoryinformation import RepositoryInformation
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from .. util import extensionutils, cartridgeagentconstants, cartridgeagentutils
+from .. publisher import cartridgeagentpublisher
+
+
+class DefaultExtensionHandler:
+    log = None
+    cartridge_agent_config = None
+
+    def __init__(self):
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+        pass
+
+    def on_instance_started_event(self):
+        try:
+            self.log.debug("Processing instance started event...")
+            if self.cartridge_agent_config.is_multitenant():
+                artifact_source = "%r/repository/deployment/server/" % self.cartridge_agent_config.get_app_path()
+                artifact_dest = cartridgeagentconstants.SUPERTENANT_TEMP_PATH
+                extensionutils.execute_copy_artifact_extension(artifact_source, artifact_dest)
+
+            env_params = {}
+            extensionutils.execute_instance_started_extention(env_params)
+
+        except Exception:
+            self.log.exception("Error processing instance started event")
+
+    def on_instance_activated_event(self):
+        extensionutils.execute_instance_activated_extension()
+
+    def on_artifact_updated_event(self, event):
+        self.log.info("Artifact update event received: [tenant] %r [cluster] %r [status] %r" %
+                      (event.tenant_id, event.cluster_id, event.status))
+
+        cluster_id_event = str(event.cluster_id).strip()
+        cluster_id_payload = self.cartridge_agent_config.get_cluster_id()
+        repo_url = str(event.repo_url).strip()
+
+        if (repo_url != "") and (cluster_id_payload is not None) and (cluster_id_payload == cluster_id_event):
+            local_repo_path = self.cartridge_agent_config.get_app_path()
+
+            secret = self.cartridge_agent_config.get_cartridge_key()
+            repo_password = cartridgeagentutils.decrypt_password(event.repo_password, secret)
+
+            repo_username = event.repo_username
+            tenant_id = event.tenant_id
+            is_multitenant = self.cartridge_agent_config.is_multitenant()
+            commit_enabled = event.commit_enabled
+
+            self.log.info("Executing git checkout")
+
+            # create repo object
+            repo_info = RepositoryInformation(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
+                                              is_multitenant, commit_enabled)
+
+            #checkout code
+            checkout_result = AgentGitHandler.checkout(repo_info)
+            #execute artifact updated extension
+            env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": event.cluster_id,
+                          "STRATOS_ARTIFACT_UPDATED_TENANT_ID": event.tenant_id,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_URL": event.repo_url,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_PASSWORD": event.repo_password,
+                          "STRATOS_ARTIFACT_UPDATED_REPO_USERNAME": event.repo_username,
+                          "STRATOS_ARTIFACT_UPDATED_STATUS": event.status}
+
+            extensionutils.execute_artifacts_updated_extension(env_params)
+
+            #if !cloneExists publish instanceActivatedEvent
+            if not checkout_result["cloned"]:
+                #publish instanceActivated
+                cartridgeagentpublisher.publish_instance_activated_event()
+
+            #TODO: set artifact update task
+
+    def on_artifact_update_scheduler_event(self, tenantId):
+        pass
+
+    def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
+        pass
+
+    def onInstanceCleanupMemberEvent(self, instanceCleanupMemberEvent):
+        pass
+
+    def onMemberActivatedEvent(self, memberActivatedEvent):
+        pass
+
+    def onCompleteTopologyEvent(self, completeTopologyEvent):
+        pass
+
+    def onCompleteTenantEvent(self, completeTenantEvent):
+        pass
+
+    def onMemberTerminatedEvent(self, memberTerminatedEvent):
+        pass
+
+    def onMemberSuspendedEvent(self, memberSuspendedEvent):
+        pass
+
+    def onMemberStartedEvent(self, memberStartedEvent):
+        pass
+
+    def start_server_extension(self):
+        raise NotImplementedError
+        # extensionutils.wait_for_complete_topology()
+        # self.log.info("[start server extension] complete topology event received")
+        #
+        # service_name_in_payload = self.cartridge_agent_config.get_service_name()
+        # cluster_id_in_payload = self.cartridge_agent_config.get_cluster_id()
+        # member_id_in_payload = self.cartridge_agent_config.get_member_id()
+        #
+        # try:
+        #     consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
+        #
+        #     if not consistant:
+        #         self.log.error("Topology is inconsistent...failed to execute start server event")
+        #         return
+        #
+        #
+        # except:
+        #     self.log.exception("Error processing start servers event")
+        # finally:
+        #     pass
+
+    def volume_mount_extension(self, persistence_mappings_payload):
+        extensionutils.execute_volume_mount_extension(persistence_mappings_payload)
+
+    def onSubscriptionDomainAddedEvent(self, subscriptionDomainAddedEvent):
+        pass
+
+    def onSubscriptionDomainRemovedEvent(self, subscriptionDomainRemovedEvent):
+        pass
+
+    def onCopyArtifactsExtension(self, src, des):
+        pass
+
+    def onTenantSubscribedEvent(self, tenantSubscribedEvent):
+        pass
+
+    def onTenantUnSubscribedEvent(self, tenantUnSubscribedEvent):
+        pass
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..923c1de
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
@@ -0,0 +1 @@
+__all__=['cartridgeagentpublisher']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..959920d
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -0,0 +1,90 @@
+import logging
+
+import paho.mqtt.publish as publish
+
+from .. event.instance.status.events import *
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from .. util import cartridgeagentconstants
+
+
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+started = False
+activated = False
+ready_to_shutdown = False
+maintenance = False
+
+cartridge_agent_config = CartridgeAgentConfiguration()
+
+publishers = {}
+
+
+def publish_instance_started_event():
+    global started, log, cartridge_agent_config
+    if not started:
+        log.info("Publishing instance started event")
+        service_name = cartridge_agent_config.get_service_name()
+        cluster_id = cartridge_agent_config.get_cluster_id()
+        network_partition_id = cartridge_agent_config.get_network_partition_id()
+        parition_id = cartridge_agent_config.get_partition_id()
+        member_id = cartridge_agent_config.get_member_id()
+
+        instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
+                                                      member_id)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher.publish(instance_started_event)
+        started = True
+        log.info("Instance started event published")
+    else:
+        log.warn("Instance already started")
+
+
+def publish_instance_activated_event():
+    global activated, log, cartridge_agent_config
+    if not activated:
+        log.info("Publishing instance activated event")
+        service_name = cartridge_agent_config.get_service_name()
+        cluster_id = cartridge_agent_config.get_cluster_id()
+        network_partition_id = cartridge_agent_config.get_network_partition_id()
+        parition_id = cartridge_agent_config.get_partition_id()
+        member_id = cartridge_agent_config.get_member_id()
+
+        instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
+                                                          member_id)
+        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+        publisher.publish(instance_activated_event)
+
+        log.info("Instance activated event published")
+        log.info("Starting health statistics notifier")
+
+        # TODO: health stat publisher start()
+        activated = True
+        log.info("Health statistics notifier started")
+    else:
+        log.warn("Instance already activated")
+
+
+def get_publisher(topic):
+    if topic not in publishers:
+        publishers[topic] = EventPublisher(topic)
+
+    return publishers[topic]
+
+
+class EventPublisher:
+    def __init__(self, topic):
+        self.__topic = topic
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+    """
+    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 = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
+        mb_port = self.cartridge_agent_config.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/ed08e2d3/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
new file mode 100644
index 0000000..27483e8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
@@ -0,0 +1 @@
+__all__=['eventsubscriber']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..a8deb77
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -0,0 +1,62 @@
+import logging
+import threading
+import paho.mqtt.client as mqtt
+
+from .. util import cartridgeagentconstants
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+
+
+class EventSubscriber(threading.Thread):
+
+    def __init__(self, topic):
+        threading.Thread.__init__(self)
+
+        self.cartridge_agent_config = CartridgeAgentConfiguration()
+        #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
+        self.__event_handlers = {}
+
+        logging.basicConfig(level=logging.DEBUG)
+        self.log = logging.getLogger(__name__)
+
+        self.__mb_client = None
+
+        self.__topic = topic
+
+        self.__subscribed = False
+
+    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 = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
+        mb_port = self.cartridge_agent_config.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.__subscribed = True
+        self.__mb_client.loop_forever()
+
+    def register_handler(self, event, handler):
+        self.__event_handlers[event] = handler
+        self.log.debug("Registered handler for event %r" % event)
+
+    def on_connect(self, client, userdata, flags, rc):
+        self.log.debug("Connected to message broker.")
+        self.__mb_client.subscribe(self.__topic)
+        self.log.debug("Subscribed to %r" % self.__topic)
+
+    def on_message(self, client, userdata, msg):
+        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)
+
+    def is_subscribed(self):
+        return self.__subscribed

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..7051a3c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
@@ -0,0 +1 @@
+__all__=['cartridgeagentconstants', 'cartridgeagentutils', 'extensionutils']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc
new file mode 100644
index 0000000..2c921d6
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..a2efe80
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -0,0 +1,88 @@
+JNDI_PROPERTIES_DIR = "jndi.properties.dir"
+PARAM_FILE_PATH = "param.file.path"
+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"
+SERVICE_NAME = "SERVICE_NAME"
+CLUSTER_ID = "CLUSTER_ID"
+LB_CLUSTER_ID = "LB_CLUSTER_ID"
+NETWORK_PARTITION_ID = "NETWORK_PARTITION_ID"
+PARTITION_ID = "PARTITION_ID"
+MEMBER_ID = "MEMBER_ID"
+TENANT_ID= "TENANT_ID"
+REPO_URL = "REPO_URL"
+PORTS = "PORTS"
+DEPLOYMENT = "DEPLOYMENT"
+MANAGER_SERVICE_TYPE = "MANAGER_SERVICE_TYPE"
+WORKER_SERVICE_TYPE = "WORKER_SERVICE_TYPE"
+
+# stratos.sh environment variables keys
+LOG_FILE_PATHS = "LOG_FILE_PATHS"
+MEMORY_CONSUMPTION = "memory_consumption"
+LOAD_AVERAGE = "load_average"
+PORTS_NOT_OPEN = "ports_not_open"
+MULTITENANT = "MULTITENANT"
+CLUSTERING = "CLUSTERING"
+MIN_INSTANCE_COUNT = "MIN_COUNT"
+ENABLE_ARTIFACT_UPDATE = "enable.artifact.update"
+ARTIFACT_UPDATE_INTERVAL = "artifact.update.interval"
+COMMIT_ENABLED = "COMMIT_ENABLED"
+AUTO_COMMIT = "auto.commit"
+AUTO_CHECKOUT = "auto.checkout"
+LISTEN_ADDRESS = "listen.address"
+PROVIDER = "PROVIDER"
+INTERNAL = "internal"
+LB_PRIVATE_IP = "lb.private.ip"
+LB_PUBLIC_IP = "lb.public.ip"
+
+# stratos.sh extension points shell scripts names keys
+INSTANCE_STARTED_SCRIPT = "extension.instance.started"
+START_SERVERS_SCRIPT = "extension.start.servers"
+INSTANCE_ACTIVATED_SCRIPT = "extension.instance.activated"
+ARTIFACTS_UPDATED_SCRIPT = "extension.artifacts.updated"
+CLEAN_UP_SCRIPT = "extension.clean"
+MOUNT_VOLUMES_SCRIPT = "extension.mount.volumes"
+MEMBER_ACTIVATED_SCRIPT = "extension.member.activated"
+MEMBER_TERMINATED_SCRIPT = "extension.member.terminated"
+MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
+MEMBER_STARTED_SCRIPT = "extension.member.started"
+COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
+COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
+SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added"
+SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed"
+ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
+TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
+TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"
+
+SERVICE_GROUP_TOPOLOGY_KEY = "payload_parameter.SERIVCE_GROUP"
+CLUSTERING_TOPOLOGY_KEY = "payload_parameter.CLUSTERING"
+CLUSTERING_PRIMARY_KEY = "PRIMARY"
+
+SUPERTENANT_TEMP_PATH = "/tmp/-1234/"
+
+DEPLOYMENT_MANAGER = "manager"
+DEPLOYMENT_WORKER = "worker"
+DEPLOYMENT_DEFAULT = "default"
+SUPER_TENANT_REPO_PATH = "super.tenant.repository.path"
+TENANT_REPO_PATH = "tenant.repository.path"
+
+# topic names to subscribe
+INSTANCE_NOTIFIER_TOPIC = "instance/#"
+HEALTH_STAT_TOPIC = "health/#"
+TOPOLOGY_TOPIC = "topology/#"
+TENANT_TOPIC = "tenant/#"
+INSTANCE_STATUS_TOPIC = "instance/#"

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc
new file mode 100644
index 0000000..0b31e3a
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..e599ef8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -0,0 +1,94 @@
+from Crypto.Cipher import AES
+import base64
+import logging
+import os
+import time
+import socket
+
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+
+unpad = lambda s : s[0:-ord(s[-1])]
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+cartridge_agent_config = CartridgeAgentConfiguration()
+
+current_milli_time = lambda: int(round(time.time() * 1000))
+
+
+def decrypt_password(pass_str, secret):
+    if pass_str is None:
+        return pass_str
+
+    dec_pass = ""
+
+    try:
+        log.debug("Decrypting password")
+        bdecoded_pass = base64.b64decode(pass_str)
+        #secret length should be 16
+        cipher = AES.new(secret, AES.MODE_ECB)
+        dec_pass = unpad(cipher.decrypt(bdecoded_pass))
+    except:
+        log.exception("Exception occurred while decrypting password")
+
+    log.debug("Decrypted PWD: [%r]" % dec_pass)
+    return dec_pass
+
+
+def create_dir(path):
+    """
+    mkdir the provided path
+    :param path: The path to the directory to be made
+    :return: True if mkdir was successful, False if dir already exists
+    """
+    try:
+        os.mkdir(path)
+        log.info("Successfully created directory [%r]" % path)
+        return True
+    except OSError:
+        log.exception("Directory creating failed in [%r]. Directory already exists. " % path)
+
+    return False
+
+
+def wait_until_ports_active(ip_address, ports):
+    ports_check_timeout = cartridge_agent_config.read_property("port.check.timeout")
+    if ports_check_timeout is None:
+        ports_check_timeout = 1000 * 60 * 10
+
+    log.debug("Port check timeout: %r" % ports_check_timeout)
+
+    active = False
+    start_time = current_milli_time()
+    while not active:
+        log.info("Waiting for ports to be active: [ip] %r [ports] %r" % (ip_address, ports))
+        active = check_ports_active(ip_address, ports)
+        end_time = current_milli_time()
+        duration  = end_time - start_time
+        if duration > ports_check_timeout:
+            return
+
+        try:
+            time.sleep(5)
+        except:
+            pass
+
+    log.info("Ports activated: [ip] %r [ports] %r" % (ip_address, ports))
+
+
+def check_ports_active(ip_address, ports):
+    if len(ports) < 1:
+        raise RuntimeError("No ports found")
+
+    for port in ports:
+        s = socket.socket()
+        s.settimeout(5)
+        try:
+            s.connect(ip_address, port)
+            log.debug("Port %r is active" % port)
+            s.close()
+        except socket.error:
+            log.debug("Print %r is not active" % port)
+            return False
+
+    return True
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc
new file mode 100644
index 0000000..729c54b
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..c2ecc52
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -0,0 +1,40 @@
+import logging
+
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+
+def execute_copy_artifact_extension(source, destination):
+    raise NotImplementedError
+
+
+def execute_instance_started_extention(env_params):
+    raise NotImplementedError
+
+
+def execute_instance_activated_extension():
+    raise NotImplementedError
+
+
+def execute_artifacts_updated_extension(env_params):
+    raise NotImplementedError
+
+
+def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
+    raise NotImplementedError
+
+
+def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, domain_name):
+    raise NotImplementedError
+
+
+def wait_for_complete_topology():
+    raise NotImplementedError
+
+
+def check_topology_consistency(service_name, cluster_id, member_id):
+    raise NotImplementedError
+
+
+def execute_volume_mount_extension(persistance_mappings_payload):
+    raise NotImplementedError
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
deleted file mode 100644
index 923c1de..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['cartridgeagentpublisher']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
deleted file mode 100644
index a47c1be..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import logging
-from ..event.instance.status.events import *
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import cartridgeagentconstants
-import paho.mqtt.publish as publish
-
-
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-started = False
-activated = False
-ready_to_shutdown = False
-maintenance = False
-
-cartridge_agent_config = CartridgeAgentConfiguration()
-
-publishers = {}
-
-
-def publish_instance_started_event():
-    global started, log, cartridge_agent_config
-    if not started:
-        log.info("Publishing instance started event")
-        service_name = cartridge_agent_config.get_service_name()
-        cluster_id = cartridge_agent_config.get_cluster_id()
-        network_partition_id = cartridge_agent_config.get_network_partition_id()
-        parition_id = cartridge_agent_config.get_partition_id()
-        member_id = cartridge_agent_config.get_member_id()
-
-        instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
-                                                      member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
-        publisher.publish(instance_started_event)
-        started = True
-        log.info("Instance started event published")
-    else:
-        log.warn("Instance already started")
-
-
-def publish_instance_activated_event():
-    global activated, log, cartridge_agent_config
-    if not activated:
-        log.info("Publishing instance activated event")
-        service_name = cartridge_agent_config.get_service_name()
-        cluster_id = cartridge_agent_config.get_cluster_id()
-        network_partition_id = cartridge_agent_config.get_network_partition_id()
-        parition_id = cartridge_agent_config.get_partition_id()
-        member_id = cartridge_agent_config.get_member_id()
-
-        instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
-                                                          member_id)
-        publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
-        publisher.publish(instance_activated_event)
-
-        log.info("Instance activated event published")
-        log.info("Starting health statistics notifier")
-
-        # TODO: health stat publisher start()
-        activated = True
-        log.info("Health statistics notifier started")
-    else:
-        log.warn("Instance already activated")
-
-
-def get_publisher(topic):
-    if topic not in publishers:
-        publishers[topic] = EventPublisher(topic)
-
-    return publishers[topic]
-
-
-class EventPublisher:
-    def __init__(self, topic):
-        self.__topic = topic
-        self.cartridge_agent_config = CartridgeAgentConfiguration()
-
-    """
-    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 = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
-        mb_port = self.cartridge_agent_config.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/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/readme.txt
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/readme.txt b/tools/python-cartridge-agent/cartridge-agent/readme.txt
deleted file mode 100644
index 65c3e8c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-sudo apt-get install python-setuptools
-easy_install http://stomppy.googlecode.com/files/stomp.py-3.0.2a.tar.gz

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/script.sh
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/script.sh b/tools/python-cartridge-agent/cartridge-agent/script.sh
deleted file mode 100755
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py b/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
deleted file mode 100644
index 27483e8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['eventsubscriber']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
deleted file mode 100644
index c71fb71..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import logging
-import threading
-import paho.mqtt.client as mqtt
-
-from ..util import cartridgeagentconstants
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-
-
-class EventSubscriber(threading.Thread):
-
-    def __init__(self, topic):
-        threading.Thread.__init__(self)
-
-        self.cartridge_agent_config = CartridgeAgentConfiguration()
-        #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
-        self.__event_handlers = {}
-
-        logging.basicConfig(level=logging.DEBUG)
-        self.log = logging.getLogger(__name__)
-
-        self.__mb_client = None
-
-        self.__topic = topic
-
-        self.__subscribed = False
-
-    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 = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
-        mb_port = self.cartridge_agent_config.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.__subscribed = True
-        self.__mb_client.loop_forever()
-
-    def register_handler(self, event, handler):
-        self.__event_handlers[event] = handler
-        self.log.debug("Registered handler for event %r" % event)
-
-    def on_connect(self, client, userdata, flags, rc):
-        self.log.debug("Connected to message broker.")
-        self.__mb_client.subscribe(self.__topic)
-        self.log.debug("Subscribed to %r" % self.__topic)
-
-    def on_message(self, client, userdata, msg):
-        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)
-
-    def is_subscribed(self):
-        return self.__subscribed

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/__init__.py b/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
deleted file mode 100644
index 7051a3c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['cartridgeagentconstants', 'cartridgeagentutils', 'extensionutils']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
deleted file mode 100644
index a2efe80..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
+++ /dev/null
@@ -1,88 +0,0 @@
-JNDI_PROPERTIES_DIR = "jndi.properties.dir"
-PARAM_FILE_PATH = "param.file.path"
-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"
-SERVICE_NAME = "SERVICE_NAME"
-CLUSTER_ID = "CLUSTER_ID"
-LB_CLUSTER_ID = "LB_CLUSTER_ID"
-NETWORK_PARTITION_ID = "NETWORK_PARTITION_ID"
-PARTITION_ID = "PARTITION_ID"
-MEMBER_ID = "MEMBER_ID"
-TENANT_ID= "TENANT_ID"
-REPO_URL = "REPO_URL"
-PORTS = "PORTS"
-DEPLOYMENT = "DEPLOYMENT"
-MANAGER_SERVICE_TYPE = "MANAGER_SERVICE_TYPE"
-WORKER_SERVICE_TYPE = "WORKER_SERVICE_TYPE"
-
-# stratos.sh environment variables keys
-LOG_FILE_PATHS = "LOG_FILE_PATHS"
-MEMORY_CONSUMPTION = "memory_consumption"
-LOAD_AVERAGE = "load_average"
-PORTS_NOT_OPEN = "ports_not_open"
-MULTITENANT = "MULTITENANT"
-CLUSTERING = "CLUSTERING"
-MIN_INSTANCE_COUNT = "MIN_COUNT"
-ENABLE_ARTIFACT_UPDATE = "enable.artifact.update"
-ARTIFACT_UPDATE_INTERVAL = "artifact.update.interval"
-COMMIT_ENABLED = "COMMIT_ENABLED"
-AUTO_COMMIT = "auto.commit"
-AUTO_CHECKOUT = "auto.checkout"
-LISTEN_ADDRESS = "listen.address"
-PROVIDER = "PROVIDER"
-INTERNAL = "internal"
-LB_PRIVATE_IP = "lb.private.ip"
-LB_PUBLIC_IP = "lb.public.ip"
-
-# stratos.sh extension points shell scripts names keys
-INSTANCE_STARTED_SCRIPT = "extension.instance.started"
-START_SERVERS_SCRIPT = "extension.start.servers"
-INSTANCE_ACTIVATED_SCRIPT = "extension.instance.activated"
-ARTIFACTS_UPDATED_SCRIPT = "extension.artifacts.updated"
-CLEAN_UP_SCRIPT = "extension.clean"
-MOUNT_VOLUMES_SCRIPT = "extension.mount.volumes"
-MEMBER_ACTIVATED_SCRIPT = "extension.member.activated"
-MEMBER_TERMINATED_SCRIPT = "extension.member.terminated"
-MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
-MEMBER_STARTED_SCRIPT = "extension.member.started"
-COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
-COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
-SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added"
-SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed"
-ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
-TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
-TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"
-
-SERVICE_GROUP_TOPOLOGY_KEY = "payload_parameter.SERIVCE_GROUP"
-CLUSTERING_TOPOLOGY_KEY = "payload_parameter.CLUSTERING"
-CLUSTERING_PRIMARY_KEY = "PRIMARY"
-
-SUPERTENANT_TEMP_PATH = "/tmp/-1234/"
-
-DEPLOYMENT_MANAGER = "manager"
-DEPLOYMENT_WORKER = "worker"
-DEPLOYMENT_DEFAULT = "default"
-SUPER_TENANT_REPO_PATH = "super.tenant.repository.path"
-TENANT_REPO_PATH = "tenant.repository.path"
-
-# topic names to subscribe
-INSTANCE_NOTIFIER_TOPIC = "instance/#"
-HEALTH_STAT_TOPIC = "health/#"
-TOPOLOGY_TOPIC = "topology/#"
-TENANT_TOPIC = "tenant/#"
-INSTANCE_STATUS_TOPIC = "instance/#"

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
deleted file mode 100644
index c8d70a3..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
+++ /dev/null
@@ -1,94 +0,0 @@
-from Crypto.Cipher import AES
-import base64
-import logging
-import os
-import time
-import socket
-
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-
-unpad = lambda s : s[0:-ord(s[-1])]
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-cartridge_agent_config = CartridgeAgentConfiguration()
-
-current_milli_time = lambda: int(round(time.time() * 1000))
-
-
-def decrypt_password(pass_str, secret):
-    if pass_str is None:
-        return pass_str
-
-    dec_pass = ""
-
-    try:
-        log.debug("Decrypting password")
-        bdecoded_pass = base64.b64decode(pass_str)
-        #secret length should be 16
-        cipher = AES.new(secret, AES.MODE_ECB)
-        dec_pass = unpad(cipher.decrypt(bdecoded_pass))
-    except:
-        log.exception("Exception occurred while decrypting password")
-
-    log.debug("Decrypted PWD: [%r]" % dec_pass)
-    return dec_pass
-
-
-def create_dir(path):
-    """
-    mkdir the provided path
-    :param path: The path to the directory to be made
-    :return: True if mkdir was successful, False if dir already exists
-    """
-    try:
-        os.mkdir(path)
-        log.info("Successfully created directory [%r]" % path)
-        return True
-    except OSError:
-        log.exception("Directory creating failed in [%r]. Directory already exists. " % path)
-
-    return False
-
-
-def wait_until_ports_active(ip_address, ports):
-    ports_check_timeout = cartridge_agent_config.read_property("port.check.timeout")
-    if ports_check_timeout is None:
-        ports_check_timeout = 1000 * 60 * 10
-
-    log.debug("Port check timeout: %r" % ports_check_timeout)
-
-    active = False
-    start_time = current_milli_time()
-    while not active:
-        log.info("Waiting for ports to be active: [ip] %r [ports] %r" % (ip_address, ports))
-        active = check_ports_active(ip_address, ports)
-        end_time = current_milli_time()
-        duration  = end_time - start_time
-        if duration > ports_check_timeout:
-            return
-
-        try:
-            time.sleep(5)
-        except:
-            pass
-
-    log.info("Ports activated: [ip] %r [ports] %r" % (ip_address, ports))
-
-
-def check_ports_active(ip_address, ports):
-    if len(ports) < 1:
-        raise RuntimeError("No ports found")
-
-    for port in ports:
-        s = socket.socket()
-        s.settimeout(5)
-        try:
-            s.connect(ip_address, port)
-            log.debug("Port %r is active" % port)
-            s.close()
-        except socket.error:
-            log.debug("Print %r is not active" % port)
-            return False
-
-    return True
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
deleted file mode 100644
index c2ecc52..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import logging
-
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-
-def execute_copy_artifact_extension(source, destination):
-    raise NotImplementedError
-
-
-def execute_instance_started_extention(env_params):
-    raise NotImplementedError
-
-
-def execute_instance_activated_extension():
-    raise NotImplementedError
-
-
-def execute_artifacts_updated_extension(env_params):
-    raise NotImplementedError
-
-
-def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
-    raise NotImplementedError
-
-
-def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, domain_name):
-    raise NotImplementedError
-
-
-def wait_for_complete_topology():
-    raise NotImplementedError
-
-
-def check_topology_consistency(service_name, cluster_id, member_id):
-    raise NotImplementedError
-
-
-def execute_volume_mount_extension(persistance_mappings_payload):
-    raise NotImplementedError
\ No newline at end of file


[38/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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/16b17eda/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):


[43/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/15939879
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/15939879
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/15939879

Branch: refs/heads/master
Commit: 159398795d0f6e98b2086f3b9f2c9034ffd55c1a
Parents: 16b17ed
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 03:42:24 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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/15939879/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()


[35/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/038cf1b2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/038cf1b2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/038cf1b2

Branch: refs/heads/master
Commit: 038cf1b2bc80a66b2247fd2e69a95d2f4cc75601
Parents: 87b2ba9
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Wed Oct 1 16:42:31 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/038cf1b2/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/038cf1b2/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/038cf1b2/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/038cf1b2/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/038cf1b2/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/038cf1b2/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/038cf1b2/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


[25/50] [abbrv] git commit: Provided documentation comments with reStructured text, with additional type hinting

Posted by ni...@apache.org.
Provided documentation comments with reStructured text, with additional type hinting


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

Branch: refs/heads/master
Commit: 59c14888ea61acefdbb0ca58f1c88b82e88c732c
Parents: 71f827d
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sun Sep 28 14:05:00 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/agent.py                    |  15 +-
 .../modules/artifactmgt/git/agentgithandler.py  |   3 +
 .../modules/artifactmgt/git/gitrepository.py    |  14 ++
 .../artifactmgt/repositoryinformation.py        |   9 +-
 .../config/cartridgeagentconfiguration.py       |  48 ++++-
 .../modules/event/instance/notifier/events.py   |   9 +
 .../modules/event/instance/status/events.py     |  20 ++
 .../modules/event/tenant/events.py              |  17 ++
 .../modules/event/topology/events.py            |  32 ++++
 .../exception/parameternotfoundexception.py     |   9 +
 .../extensions/defaultextensionhandler.py       |   3 +
 .../publisher/cartridgeagentpublisher.py        |   4 +
 .../modules/subscriber/eventsubscriber.py       |  16 ++
 .../modules/tenant/tenantcontext.py             |  80 ++++++++
 .../modules/topology/topologycontext.py         | 182 ++++++++++++++++++-
 .../modules/util/asyncscheduledtask.py          |  11 ++
 .../modules/util/cartridgeagentutils.py         |  36 ++++
 .../modules/util/extensionutils.py              |  24 ++-
 18 files changed, 512 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 8ac6803..ad063c8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -22,6 +22,7 @@ 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)
@@ -34,30 +35,38 @@ class CartridgeAgent(threading.Thread):
     def run(self):
         self.log.info("Starting Cartridge Agent...")
 
+        #Check if required prpoerties are set
         self.validate_required_properties()
 
+        #Start instance notifier listener thread
         self.subscribe_to_topics_and_register_listeners()
 
+        #Start topology event receiver thread
         self.register_topology_event_listeners()
 
+        #Start tenant event receiver thread
         self.register_tenant_event_listeners()
 
+        #Execute instance started shell script
         self.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()
         except:
             self.log.exception("Error processing start servers event")
 
+        #Wait for all ports to be active
         cartridgeagentutils.wait_until_ports_active(
             CartridgeAgentConfiguration.listen_address,
             CartridgeAgentConfiguration.ports
         )
 
+        # check if artifact management is required before publishing instance activated event
         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()
@@ -73,6 +82,10 @@ class CartridgeAgent(threading.Thread):
             #TODO: wait until terminated is true
 
     def validate_required_properties(self):
+        """
+        Checks if required properties are set
+        :return: True if
+        """
         # JNDI_PROPERTIES_DIR
         try:
             CartridgeAgentConfiguration.read_property(cartridgeagentconstants.JNDI_PROPERTIES_DIR)

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 6671c48..fb8100b 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
@@ -61,8 +61,11 @@ class AgentGitHandler:
     @staticmethod
     def add_remote(repo_context):
         try:
+            #add origin remote
             repo_context.repo.create_remote("origin", repo_context.repo_url)
+            #fetch branch details from origin
             repo_context.repo.git.fetch()
+            #checkout master branch from origin/master as tracking
             repo_context.repo.git.branch("-f", "--track", "master", "origin/master")
             return True
         except:

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 92929b5..ba9d3d7 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,17 +1,31 @@
 from ...util.asyncscheduledtask import AsyncScheduledTask
 
+
 class GitRepository:
+    """
+    Represents a git repository inside a particular instance
+    """
 
     def __init__(self):
         self.repo_url = None
+        """ :type : str  """
         self.local_repo_path = None
+        """ :type : str  """
         self.cloned = False
+        """ :type : bool  """
         self.repo = None
+        """ :type : str  """
         self.tenant_id = None
+        """ :type : int  """
         self.key_based_auth = False
+        """ :type : bool  """
         self.repo_username = None
+        """ :type : str  """
         self.repo_password = None
+        """ :type : str  """
         self.is_multitenant = False
+        """ :type : bool  """
         self.commit_enabled = False
+        """ :type : bool  """
         self.scheduled_update_task = None
         """:type : AsyncScheduledTask """
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 d30c319..2d6ae0b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
@@ -5,9 +5,16 @@ class RepositoryInformation:
 
     def __init__(self, repo_url, repo_username, repo_password, repo_path, tenant_id, is_multitenant, commit_enabled):
         self.repo_url = repo_url
+        """ :type : str  """
         self.repo_username = repo_username
+        """ :type : str  """
         self.repo_password = repo_password
+        """ :type : str  """
         self.repo_path = repo_path
+        """ :type : str  """
         self.tenant_id = tenant_id
+        """ :type : int  """
         self.is_multitenant = is_multitenant
-        self.commit_enabled = commit_enabled
\ No newline at end of file
+        """ :type : bool  """
+        self.commit_enabled = commit_enabled
+        """ :type : bool  """
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 c87f0c4..bb26569 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -7,6 +7,9 @@ from ..exception.parameternotfoundexception import ParameterNotFoundException
 
 
 class CartridgeAgentConfiguration:
+    """
+    Handles the configuration information of the particular Cartridge Agent
+    """
     # set log level
     logging.basicConfig(level=logging.DEBUG)
     log = logging.getLogger(__name__)
@@ -15,37 +18,71 @@ class CartridgeAgentConfiguration:
     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()
@@ -218,7 +255,7 @@ class CartridgeAgentConfiguration:
     def __read_conf_file():
         """
         Reads and stores the agent's configuration file
-        :return:
+        :return: void
         """
 
         base_working_dir = os.path.abspath(os.path.dirname(__file__)).replace("modules/config", "")
@@ -231,7 +268,7 @@ class CartridgeAgentConfiguration:
     def __read_parameter_file():
         """
         Reads the payload file of the cartridge and stores the values in a dictionary
-        :return:
+        :return: void
         """
 
         param_file = CartridgeAgentConfiguration.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
@@ -251,6 +288,13 @@ class CartridgeAgentConfiguration:
 
     @staticmethod
     def read_property(property_key):
+        """
+        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)

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 5ab3e6c..91e0367 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
@@ -4,12 +4,19 @@ import json
 class ArtifactUpdatedEvent:
     def __init__(self):
         self.cluster_id = None
+        """ :type : str  """
         self.status = None
+        """ :type : str  """
         self.repo_username = None
+        """ :type : str  """
         self.repo_password = None
+        """ :type : str  """
         self.repo_url = None
+        """ :type : str  """
         self.tenant_id = None
+        """ :type : int  """
         self.commit_enabled = None
+        """ :type : bool  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -29,6 +36,7 @@ class ArtifactUpdatedEvent:
 class InstanceCleanupClusterEvent:
     def __init__(self, cluster_id):
         self.cluster_id = cluster_id
+        """ :type : str  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -41,6 +49,7 @@ class InstanceCleanupClusterEvent:
 class InstanceCleanupMemberEvent:
     def __init__(self, member_id):
         self.member_id = member_id
+        """ :type : str  """
 
     @staticmethod
     def create_from_json(json_str):

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 2f14477..774b111 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
@@ -4,10 +4,15 @@ import json
 class InstanceActivatedEvent:
     def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
         self.serviceName = service_name
+        """ :type : str  """
         self.clusterId = cluster_id
+        """ :type : str  """
         self.networkPartitionId = network_partition_id
+        """ :type : str  """
         self.partitionId = parition_id
+        """ :type : str  """
         self.memberId = member_id
+        """ :type : str  """
 
     def to_json(self):
         return to_json(self)
@@ -16,10 +21,15 @@ class InstanceActivatedEvent:
 class InstanceStartedEvent:
     def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
         self.serviceName = service_name
+        """ :type : str  """
         self.clusterId = cluster_id
+        """ :type : str  """
         self.networkPartitionId = network_partition_id
+        """ :type : str  """
         self.partitionId = parition_id
+        """ :type : str  """
         self.memberId = member_id
+        """ :type : str  """
 
     def to_json(self):
         return to_json(self)
@@ -29,10 +39,15 @@ class InstanceMaintenanceModeEvent:
 
     def __init__(self, service_name, cluster_id, network_partition_id, partition_id, member_id):
         self.serviceName = service_name
+        """ :type : str  """
         self.clusterId = cluster_id
+        """ :type : str  """
         self.networkPartitionId = network_partition_id
+        """ :type : str  """
         self.partitionId = partition_id
+        """ :type : str  """
         self.memberId = member_id
+        """ :type : str  """
 
     def to_json(self):
         return to_json(self)
@@ -42,10 +57,15 @@ class InstanceReadyToShutdownEvent:
 
     def __init__(self, service_name, cluster_id, network_partition_id, partition_id, member_id):
         self.serviceName = service_name
+        """ :type : str  """
         self.clusterId = cluster_id
+        """ :type : str  """
         self.networkPartitionId = network_partition_id
+        """ :type : str  """
         self.partitionId = partition_id
+        """ :type : str  """
         self.memberId = member_id
+        """ :type : str  """
 
     def to_json(self):
         return to_json(self)

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 ce27f66..5cb838d 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
@@ -6,10 +6,15 @@ class SubscriptionDomainAddedEvent():
 
     def __init__(self):
         self.tenant_id = None
+        """ :type : int  """
         self.service_name = None
+        """ :type : str  """
         self.cluster_ids = None
+        """ :type : list[str]  """
         self.domain_name = None
+        """ :type : str  """
         self.application_context = None
+        """ :type : str  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -29,9 +34,13 @@ class SubscriptionDomainRemovedEvent:
 
     def __init__(self, tenant_id, service_name, cluster_ids, domain_name):
         self.tenant_id = tenant_id
+        """ :type : int  """
         self.service_name = service_name
+        """ :type : str  """
         self.cluster_ids = cluster_ids
+        """ :type : list[str]  """
         self.domain_name = domain_name
+        """ :type : str  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -50,7 +59,9 @@ class CompleteTenantEvent:
 
     def __init__(self):
         self.tenants = []
+        """ :type : list[Tenant]  """
         self.tenant_list_json = None
+        """ :type : str  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -79,8 +90,11 @@ class TenantSubscribedEvent:
 
     def __init__(self):
         self.tenant_id = None
+        """ :type : int  """
         self.service_name = None
+        """ :type : str  """
         self.cluster_ids = None
+        """ :type : list[str]  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -98,8 +112,11 @@ class TenantUnsubscribedEvent:
 
     def __init__(self):
         self.tenant_id = None
+        """ :type : int  """
         self.service_name = None
+        """ :type : str  """
         self.cluster_ids = None
+        """ :type : list[str]  """
 
     @staticmethod
     def create_from_json(json_str):

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 da07f68..5f37784 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
@@ -7,14 +7,27 @@ class MemberActivatedEvent:
 
     def __init__(self):
         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.port_map = {}
+        """ :type : dict[str, Port]  """
         self.member_ip = None
+        """ :type : str  """
 
     def get_port(self, proxy_port):
+        """
+        Returns the port object of the provided port id
+        :param str proxy_port:
+        :return: Port object, None if the port id is invalid
+        :rtype: topology.topologycontext.Port
+        """
         if proxy_port in self.port_map:
             return self.port_map[proxy_port]
 
@@ -43,11 +56,17 @@ class MemberTerminatedEvent:
 
     def __init__(self):
         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.properties = {}
+        """ :type : dict[str, str]  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -65,10 +84,15 @@ class MemberSuspendedEvent:
 
     def __init__(self):
         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  """
 
     @staticmethod
     def create_from_json(json_str):
@@ -86,6 +110,7 @@ class CompleteTopologyEvent:
 
     def __init__(self):
         self.topology = None
+        """ :type :  Topology """
 
     @staticmethod
     def create_from_json(json_str):
@@ -161,12 +186,19 @@ class MemberStartedEvent:
 
     def __init__(self):
         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.status = None
+        """ :type : str  """
         self.properties = {}
+        """ :type : dict[str, str]  """
 
     @staticmethod
     def create_from_json(json_str):

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 a9a776e..720f458 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
@@ -1,4 +1,8 @@
 class ParameterNotFoundException(Exception):
+    """
+    Exception raised when a property is not present in the configuration or the payload
+    of the cartridge agent
+    """
     __message = None
 
     def __init__(self, message):
@@ -6,4 +10,9 @@ class ParameterNotFoundException(Exception):
         self.__message = message
 
     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/59c14888/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 0b6e523..a93130f 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -12,6 +12,9 @@ from ..tenant.tenantcontext import *
 
 
 class DefaultExtensionHandler:
+    """
+    TODO : Provide abstraction
+    """
     log = None
 
     def __init__(self):

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 e239b0d..84ee43a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -16,6 +16,7 @@ ready_to_shutdown = False
 maintenance = False
 
 publishers = {}
+""" :type : dict[str, EventPublisher] """
 
 
 def publish_instance_started_event():
@@ -117,6 +118,9 @@ def get_publisher(topic):
 
 
 class EventPublisher:
+    """
+    TODO: provide abstraction
+    """
     def __init__(self, topic):
         self.__topic = topic
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 3138663..44ed8d8 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -7,6 +7,10 @@ from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 
 
 class EventSubscriber(threading.Thread):
+    """
+    Provides functionality to subscribe to a given topic on the stratos MB and
+    register event handlers for various events.
+    """
 
     def __init__(self, topic):
         threading.Thread.__init__(self)
@@ -37,6 +41,13 @@ class EventSubscriber(threading.Thread):
         self.__mb_client.loop_forever()
 
     def register_handler(self, event, handler):
+        """
+        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
+        :return: void
+        :rtype: void
+        """
         self.__event_handlers[event] = handler
         self.log.debug("Registered handler for event %r" % event)
 
@@ -58,4 +69,9 @@ class EventSubscriber(threading.Thread):
             self.log.exception("Error processing %r event" % event)
 
     def is_subscribed(self):
+        """
+        Checks if this event subscriber is successfully subscribed to the provided topic
+        :return: True if subscribed, False if otherwise
+        :rtype: bool
+        """
         return self.__subscribed

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 dd7bcc0..90c9f0b 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/tenant/tenantcontext.py
@@ -1,56 +1,124 @@
 class Tenant:
+    """
+    Object type representing the tenant details of a single tenant
+    """
 
     def __init__(self, tenant_id,  tenant_domain):
         self.tenant_id = tenant_id
+        """ :type : int """
         self.tenant_domain = tenant_domain
+        """ :type : str """
         self.service_name_subscription_map = {}
+        """ :type : dict[str, Subscription] """
 
     def get_subscription(self, service_name):
+        """
+        Returns the Subscription object related to the provided service name
+        :param str service_name: service name to be retrieved
+        :return: Subscription of the service or None if the service name doesn't exist
+        :rtype: Subscription
+        """
         if service_name in self.service_name_subscription_map:
             return self.service_name_subscription_map[service_name]
 
         return None
 
     def is_subscribed(self, service_name):
+        """
+        Checks if the given service name has a subscription from this tenant
+        :param str service_name: name of the service to check
+        :return: True if the tenant is subscribed to the given service name, False if not
+        :rtype: bool
+        """
         return service_name in self.service_name_subscription_map
 
     def add_subscription(self, subscription):
+        """
+        Adds a subscription information entry on the subscription list for this tenant
+        :param Subscription subscription: Subscription information to be added
+        :return: void
+        :rtype: void
+        """
         self.service_name_subscription_map[subscription.service_name] = subscription
 
     def remove_subscription(self, service_name):
+        """
+        Removes the specified subscription details from the subscription list
+        :param str service_name: The service name of the subscription to be removed
+        :return: void
+        :rtype: void
+        """
         if service_name in self.service_name_subscription_map:
             self.service_name_subscription_map.pop(service_name)
 
 
 class Subscription:
+    """
+    Subscription information of a particular subscription to a service
+    """
 
     def __init__(self, service_name, cluster_ids):
         self.service_name = service_name
+        """ :type : str """
         self.cluster_ids = cluster_ids
+        """ :type : list[str]  """
         self.subscription_domain_map = {}
+        """ :type : dict[str, SubscriptionDomain]  """
 
     def add_subscription_domain(self, domain_name, application_context):
+        """
+        Adds a subscription domain
+        :param str domain_name:
+        :param str application_context:
+        :return: void
+        :rtype: void
+        """
         self.subscription_domain_map[domain_name] = SubscriptionDomain(domain_name, application_context)
 
     def remove_subscription_domain(self, domain_name):
+        """
+        Removes the subscription domain of the specified domain name
+        :param str domain_name:
+        :return: void
+        :rtype: void
+        """
         if domain_name in self.subscription_domain_map:
             self.subscription_domain_map.pop(domain_name)
 
     def subscription_domain_exists(self, domain_name):
+        """
+        Returns the SubscriptionDomain information of the specified domain name
+        :param str domain_name:
+        :return: SubscriptionDomain
+        :rtype: SubscriptionDomain
+        """
         return domain_name in self.subscription_domain_map
 
     def get_subscription_domains(self):
+        """
+        Returns the list of subscription domains of this subscription
+        :return: List of SubscriptionDomain objects
+        :rtype: list[SubscriptionDomain]
+        """
         return self.subscription_domain_map.values()
 
 
 class SubscriptionDomain:
+    """
+    TODO
+    """
 
     def __init__(self, domain_name, application_context):
         self.domain_name = domain_name
+        """ :type : str  """
         self.application_context = application_context
+        """ :type : str  """
 
 
 class TenantContext:
+    """
+    Handles and maintains a model of all the information related to tenants within this instance
+    """
     tenants = {}
     initialized = False
     tenant_domains = {"carbon.super": Tenant(-1234, "carbon.super")}
@@ -74,6 +142,12 @@ class TenantContext:
 
     @staticmethod
     def get_tenant(tenant_id):
+        """
+        Gets the Tenant object of the provided tenant ID
+        :param int tenant_id:
+        :return: Tenant object of the provided tenant ID
+        :rtype: Tenant
+        """
         if tenant_id in TenantContext.tenants:
             return TenantContext.tenants[tenant_id]
 
@@ -81,6 +155,12 @@ class TenantContext:
 
     @staticmethod
     def get_tenant_by_domain(tenant_domain):
+        """
+        Gets the Tenant object of the provided tenant domain
+        :param str tenant_domain:
+        :return: Tenant object of the provided tenant domain
+        :rtype: str
+        """
         if tenant_domain in TenantContext.tenant_domains:
             return TenantContext.tenant_domains[tenant_domain]
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 dea8bed..564b959 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/topology/topologycontext.py
@@ -2,19 +2,31 @@ from ..util import cartridgeagentutils, cartridgeagentconstants
 
 
 class Topology:
+    """
+    Represents the topology provided by the Cloud Controller
+    """
+
     def __init__(self):
         self.service_map = {}
+        """ :type : dict[str, Service]  """
         self.initialized = False
+        """ :type : bool  """
         self.json_str = None
+        """ :type : str  """
 
     def get_services(self):
+        """
+        Provides the list of services on the topology
+        :return: The list of Service objects
+        :rtype: list[Service]
+        """
         return self.service_map.values()
 
     def get_service(self, service_name):
         """
-
+        Provides the service information for the given service name
         :param str service_name: service name to be retrieved
-        :return: Service object of the service
+        :return: Service object of the service, None if the provided service name is invalid
         :rtype: Service
         """
         if service_name in self.service_map:
@@ -23,38 +35,87 @@ class Topology:
         return None
 
     def add_service(self, service):
+        """
+        Adds a service to the list of services on the topology
+
+        :param Service service:
+        :return: void
+        """
         self.service_map[service.service_name] = service
 
     def add_services(self, services):
+        """
+
+        :param list[Service] services:
+        :return: void
+        """
         for service in services:
             self.add_service(service)
 
     def remove_service(self, service_name):
+        """
+        Removes the service of the provided service name
+        :param str service_name:
+        :return: void
+        """
         if service_name in self.service_map:
             self.service_map.pop(service_name)
 
     def service_exists(self, service_name):
+        """
+        Checks if the service of the provided service name exists
+        :param str service_name:
+        :return: True if the service exists, False if otherwise
+        :rtype: bool
+        """
         return service_name in self.service_map
 
     def clear(self):
+        """
+        Clears the service information list
+        :return: void
+        """
         self.service_map = {}
 
     def __str__(self):
+        """
+        to string override
+        :return:
+        """
         return "Topology [serviceMap= %r , initialized= %r ]" % (self.service_map, self.initialized)
 
 
 class Service:
+    """
+    Represents a service on the topology
+    """
+
     def __init__(self, service_name, service_type):
         self.service_name = service_name
+        """ :type : str  """
         self.service_type = service_type
+        """ :type : str  """
         self.cluster_id_cluster_map = {}
+        """ :type : dict[str, Cluster]  """
         self.port_map = {}
+        """ :type : dict[str, Port]  """
         self.properties = {}
+        """ :type : dict[str, str]  """
 
     def get_clusters(self):
+        """
+        Provides the list of clusters in the particular service
+        :return: The list of Cluster objects
+        :rtype: list[Cluster]
+        """
         return self.cluster_id_cluster_map.values()
 
     def add_cluster(self, cluster):
+        """
+        Adds a cluster to the service
+        :param Cluster cluster: the cluster to be added
+        :return: void
+        """
         self.cluster_id_cluster_map[cluster.cluster_id] = cluster
 
     def remove_cluster(self, cluster_id):
@@ -62,20 +123,43 @@ class Service:
             self.cluster_id_cluster_map.pop(cluster_id)
 
     def cluster_exists(self, cluster_id):
+        """
+        Checks if the cluster with the given cluster id exists for ther service
+        :param str cluster_id:
+        :return: True if the cluster for the given cluster id exists, False if otherwise
+        :rtype: bool
+        """
         return cluster_id in self.cluster_id_cluster_map
 
     def get_cluster(self, cluster_id):
+        """
+        Provides the Cluster information for the provided cluster id
+        :param str cluster_id: the cluster id to search for
+        :return: Cluster object for the given cluster id, None if the cluster id is invalid
+        :rtype: Cluster
+        """
         if cluster_id in self.cluster_id_cluster_map:
             return self.cluster_id_cluster_map[cluster_id]
 
         return None
 
     def get_ports(self):
+        """
+        Returns the list of ports in the particular service
+        :return: The list of Port object
+        :rtype: list[Port]
+        """
         return self.port_map.values()
 
-    def get_port(self, proxy):
-        if proxy in self.port_map:
-            return self.port_map[proxy]
+    def get_port(self, proxy_port):
+        """
+        Provides the port information for the provided proxy port
+        :param str proxy_port:
+        :return: Port object for the provided port, None if port is invalid
+        :rtype: Port
+        """
+        if proxy_port in self.port_map:
+            return self.port_map[proxy_port]
 
         return None
 
@@ -88,20 +172,36 @@ class Service:
 
 
 class Cluster:
+    """
+    Represents a cluster for a service
+    """
+
     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
+        """ :type : str  """
         self.deployment_policy_name = deployment_policy_name
+        """ :type : str  """
         self.autoscale_policy_name = autoscale_policy_name
+        """ :type : str  """
         self.hostnames = []
+        """ :type : list[str]  """
         self.member_map = {}
+        """ :type : dict[str, Member]  """
 
         self.tenant_range = None
+        """ :type : str  """
         self.is_lb_cluster = False
+        """ :type : bool  """
         self.status = None
+        """ :type : str  """
         self.load_balancer_algorithm_name = None
+        """ :type : str  """
         self.properties = {}
+        """ :type : dict[str, str]  """
         self.member_list_json = None
+        """ :type : str  """
 
     def add_hostname(self, hostname):
         self.hostnames.append(hostname)
@@ -111,6 +211,11 @@ class Cluster:
         self.tenant_range = tenant_range
 
     def get_members(self):
+        """
+        Provides the list of member information in the cluster
+        :return: The list of Member object
+        :rtype: list[Member]
+        """
         return self.member_map.values()
 
     def add_member(self, member):
@@ -122,9 +227,9 @@ class Cluster:
 
     def get_member(self, member_id):
         """
-
-        :param member_id:
-        :return:
+        Provides the member information for the provided member id
+        :param str member_id:
+        :return: Member object for the provided member id, None if member id is invalid
         :rtype: Member
         """
         if self.member_exists(member_id):
@@ -133,6 +238,12 @@ class Cluster:
         return None
 
     def member_exists(self, member_id):
+        """
+        Checks if the member for the provided member id exists in this cluster
+        :param str member_id: member id to be searched
+        :return: True if the member exists, False if otherwise
+        :rtype: bool
+        """
         return member_id in self.member_map
 
     def __str__(self):
@@ -140,6 +251,12 @@ class Cluster:
                (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)
 
     def tenant_id_in_range(self, tenant_id):
+        """
+        Check whether a given tenant id is in tenant range of the cluster.
+        :param str tenant_id: tenant id to be checked
+        :return: True if the tenant id is in tenant id range, False if otherwise
+        :rtype: bool
+        """
         if self.tenant_range is None:
             return False
 
@@ -160,29 +277,60 @@ class Cluster:
 
 
 class Member:
+    """
+    Represents a member on a particular cluster
+    """
 
     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
+        """ :type : str  """
         self.network_partition_id = network_partition_id
+        """ :type : str  """
         self.partition_id = parition_id
+        """ :type : str  """
         self.member_id = member_id
+        """ :type : str  """
         self.port_map = {}
+        """ :type : dict[str, Port]  """
 
         self.member_public_ip = None
+        """ :type : str  """
         self.status = None
+        """ :type : str  """
         self.member_ip = None
+        """ :type : str  """
         self.properties = {}
+        """ :type : dict[str, str]  """
         self.lb_cluster_id = None
+        """ :type : str  """
         self.json_str = None
+        """ :type : str  """
 
     def is_active(self):
+        """
+        Checks if the member is in active state
+        :return: True if active, False if otherwise
+        :rtype: bool
+        """
         return self.status == MemberStatus.Activated
 
     def get_ports(self):
+        """
+        Provides the list of the ports in the member
+        :return: List of Port objects
+        :rtype: list[Port]
+        """
         return self.port_map.values()
 
     def get_port(self, proxy):
+        """
+        Provides the port information for the given port id
+        :param str proxy: The port id
+        :return: Port object of the provided port id, None if otherwise
+        :rtype: Port
+        """
         if proxy in self.port_map:
             return self.port_map[proxy]
 
@@ -197,28 +345,43 @@ class Member:
 
 
 class Port:
+    """
+    Represents a port on a particular member
+    """
 
     def __init__(self, protocol, value, proxy):
         self.protocol = protocol
+        """ :type : str  """
         self.value = value
+        """ :type : str  """
         self.proxy = proxy
+        """ :type : str  """
 
     def __str__(self):
         return "Port [protocol=%r, value=%r proxy=%r]" % (self.protocol, self.value, self.proxy)
 
 
 class ServiceType:
+    """
+    ServiceType enum
+    """
     SingleTenant = 1
     MultiTenant = 2
 
 
 class ClusterStatus:
+    """
+    ClusterStatus enum
+    """
     Created = 1
     In_Maintenance = 2
     Removed = 3
 
 
 class MemberStatus:
+    """
+    MemberStatus enum
+    """
     Created = 1
     Starting = 2
     Activated = 3
@@ -230,6 +393,9 @@ class MemberStatus:
 
 
 class TopologyContext:
+    """
+    Handles and maintains a model of the topology provided by the Cloud Controller
+    """
     topology = None
     # TODO: read write locks, Lock() and RLock()
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 12ec849..85f8c3e 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/asyncscheduledtask.py
@@ -10,13 +10,24 @@ class AsyncScheduledTask(Thread):
     def __init__(self, delay, task):
         Thread.__init__(self)
         self.delay = delay
+        """ :type : int  """
         self.task = task
+        """ :type : Thread  """
         self.terminated = False
+        """ :type : bool  """
 
     def run(self):
+        """
+        Start the scheuled task with a sleep time of delay in between
+        :return:
+        """
         while not self.terminated:
             time.sleep(self.delay)
             self.task.start()
 
     def terminate(self):
+        """
+        Terminate the scheduled task. Allow a maximum of 'delay' seconds to be terminated.
+        :return: void
+        """
         self.terminated = True
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 444f9ac..89e7961 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -10,6 +10,7 @@ from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 import cartridgeagentconstants
 
 unpad = lambda s: s[0:-ord(s[-1])]
+
 logging.basicConfig(level=logging.DEBUG)
 log = logging.getLogger(__name__)
 
@@ -17,6 +18,15 @@ current_milli_time = lambda: int(round(time.time() * 1000))
 
 
 def decrypt_password(pass_str, secret):
+    """
+    Decrypts the given password using the given secret. The encryption is assumed to be done
+    without IV, in AES.
+    :param str pass_str: Encrypted password string in Base64 encoding
+    :param str secret: The secret string
+    :return: The decrypted password
+    :rtype: str
+    """
+
     if pass_str is None:
         return pass_str
 
@@ -40,6 +50,7 @@ def create_dir(path):
     mkdir the provided path
     :param path: The path to the directory to be made
     :return: True if mkdir was successful, False if dir already exists
+    :rtype: bool
     """
     try:
         os.mkdir(path)
@@ -52,6 +63,11 @@ def create_dir(path):
 
 
 def delete_folder_tree(path):
+    """
+    Completely deletes the provided folder
+    :param str path: Full path of the folder
+    :return: void
+    """
     try:
         shutil.rmtree(path)
         log.debug("Directory [%r] deleted." % path)
@@ -60,6 +76,12 @@ def delete_folder_tree(path):
 
 
 def wait_until_ports_active(ip_address, ports):
+    """
+    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
+    :return: void
+    """
     ports_check_timeout = CartridgeAgentConfiguration.read_property("port.check.timeout")
     if ports_check_timeout is None:
         ports_check_timeout = 1000 * 60 * 10
@@ -73,6 +95,7 @@ def wait_until_ports_active(ip_address, ports):
         active = check_ports_active(ip_address, ports)
         end_time = current_milli_time()
         duration = end_time - start_time
+
         if duration > ports_check_timeout:
             return
 
@@ -82,6 +105,13 @@ def wait_until_ports_active(ip_address, ports):
 
 
 def check_ports_active(ip_address, ports):
+    """
+    Checks the given list of port addresses for active state
+    :param str ip_address: Ip address of the member to be checked
+    :param list[str] ports: The list of ports to be checked
+    :return: True if the ports are active, False if at least one is not active
+    :rtype: bool
+    """
     if len(ports) < 1:
         raise RuntimeError("No ports found")
 
@@ -100,6 +130,12 @@ def check_ports_active(ip_address, ports):
 
 
 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

http://git-wip-us.apache.org/repos/asf/stratos/blob/59c14888/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 3ca4cc0..60a1558 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -335,7 +335,7 @@ def prepare_command(script_name):
 
 def clean_process_parameters(params):
     """
-
+    Removes any null valued parameters before passing them to the extension scripts
     :param dict params:
     :return: cleaned parameters
     :rtype: dict
@@ -348,6 +348,12 @@ def clean_process_parameters(params):
 
 
 def add_payload_parameters(env_params):
+    """
+    Adds the common parameters to be used by the extension scripts
+    :param dict[str, str] env_params: Dictionary to be added
+    :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)
     env_params["STRATOS_SERVICE_NAME"] = CartridgeAgentConfiguration.service_name
@@ -383,10 +389,11 @@ def add_payload_parameters(env_params):
 
 def add_properties(properties, params, prefix):
     """
-    :param dict properties: service properties
-    :param dict params:
+    Adds the given property list to the parameters list with given prefix in the parameter name
+    :param dict[str, str] properties: service properties
+    :param dict[str, str] params:
     :param str prefix:
-    :return:
+    :return: dict[str, str]
     """
     if properties is None or properties.items() is None:
         return
@@ -413,11 +420,12 @@ def get_lb_member_ip(lb_cluster_id):
 
 def execute_command(command, env_params=None):
     """
-
-    :param str command:
-    :param dict env_params:
-    :return: output and error tuple
+    Executes the given command string with given environment parameters
+    :param str command: Command with arguments to be executed
+    :param dict[str, str] env_params: Environment variables to be used
+    :return: output and error string tuple, RuntimeError if errors occur
     :rtype: tuple
+    :exception: RuntimeError
     """
     os_env = os.environ.copy()
     if env_params is not None:


[11/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/52e258b7
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/52e258b7
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/52e258b7

Branch: refs/heads/master
Commit: 52e258b71ef613a405786482c645c8d3d66588e3
Parents: 126fa52
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Sep 29 19:26:57 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/52e258b7/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/52e258b7/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/52e258b7/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/52e258b7/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/52e258b7/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/52e258b7/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/52e258b7/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/52e258b7/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


[44/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/599cbdc9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/599cbdc9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/599cbdc9

Branch: refs/heads/master
Commit: 599cbdc903db8c892555256dcfdd53aa01e4f60a
Parents: 1593987
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 3 04:22:56 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:30 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/599cbdc9/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/599cbdc9/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/599cbdc9/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/599cbdc9/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/599cbdc9/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/599cbdc9/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__)
 


[46/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/af49e72c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/af49e72c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/af49e72c

Branch: refs/heads/master
Commit: af49e72cb0f8110923517ec2b839d676ae784338
Parents: da2fb82
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Oct 9 16:24:52 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:31 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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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/af49e72c/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


[08/50] [abbrv] git commit: Restructured modules to suit relative imports

Posted by ni...@apache.org.
Restructured modules to suit relative imports


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

Branch: refs/heads/master
Commit: ed08e2d3feac5aad4eae676a1311acf6a5181625
Parents: 1e8ad22
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Sep 23 14:03:46 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../cartridge-agent/__init__.py                 |   1 -
 .../cartridge-agent/agent.py                    |  16 +-
 .../cartridge-agent/agent.sh                    |   8 -
 .../cartridge-agent/agent1.py                   |  15 -
 .../cartridge-agent/artifactmgt/__init__.py     |   1 -
 .../cartridge-agent/artifactmgt/git/__init__.py |   1 -
 .../artifactmgt/git/agentgithandler.py          | 147 ---------
 .../artifactmgt/git/gitrepository.py            |  12 -
 .../artifactmgt/repositoryinformation.py        |  13 -
 .../cartridge-agent/config/__init__.py          |   1 -
 .../config/cartridgeagentconfiguration.py       | 297 ------------------
 .../cartridge-agent/event/__init__.py           |   1 -
 .../cartridge-agent/event/instance/__init__.py  |   1 -
 .../event/instance/notifier/__init__.py         |   1 -
 .../event/instance/notifier/events.py           |  50 ----
 .../event/instance/status/__init__.py           |   1 -
 .../event/instance/status/events.py             |  25 --
 .../cartridge-agent/event/tenant/__init__.py    |   1 -
 .../cartridge-agent/event/tenant/events.py      |  98 ------
 .../cartridge-agent/exception/__init__.py       |   1 -
 .../exception/parameternotfoundexception.py     |   9 -
 .../cartridge-agent/extensionhandler.py         |  88 +++---
 .../cartridge-agent/extensions/__init__.py      |   1 -
 .../extensions/defaultextensionhandler.py       | 148 ---------
 .../cartridge-agent/modules/__init__.py         |   0
 .../cartridge-agent/modules/__init__.pyc        | Bin 0 -> 194 bytes
 .../modules/artifactmgt/__init__.py             |   1 +
 .../modules/artifactmgt/git/__init__.py         |   1 +
 .../modules/artifactmgt/git/agentgithandler.py  | 148 +++++++++
 .../modules/artifactmgt/git/gitrepository.py    |  12 +
 .../artifactmgt/repositoryinformation.py        |  13 +
 .../cartridge-agent/modules/config/__init__.py  |   1 +
 .../cartridge-agent/modules/config/__init__.pyc | Bin 0 -> 254 bytes
 .../config/cartridgeagentconfiguration.py       | 298 +++++++++++++++++++
 .../config/cartridgeagentconfiguration.pyc      | Bin 0 -> 17633 bytes
 .../cartridge-agent/modules/event/__init__.py   |   1 +
 .../modules/event/instance/__init__.py          |   1 +
 .../modules/event/instance/notifier/__init__.py |   1 +
 .../modules/event/instance/notifier/events.py   |  50 ++++
 .../modules/event/instance/status/__init__.py   |   1 +
 .../modules/event/instance/status/events.py     |  25 ++
 .../modules/event/tenant/__init__.py            |   1 +
 .../modules/event/tenant/events.py              |  98 ++++++
 .../modules/exception/__init__.py               |   1 +
 .../modules/exception/__init__.pyc              | Bin 0 -> 256 bytes
 .../exception/parameternotfoundexception.py     |   9 +
 .../exception/parameternotfoundexception.pyc    | Bin 0 -> 1133 bytes
 .../modules/extensions/__init__.py              |   1 +
 .../extensions/defaultextensionhandler.py       | 148 +++++++++
 .../modules/publisher/__init__.py               |   1 +
 .../publisher/cartridgeagentpublisher.py        |  90 ++++++
 .../modules/subscriber/__init__.py              |   1 +
 .../modules/subscriber/eventsubscriber.py       |  62 ++++
 .../cartridge-agent/modules/util/__init__.py    |   1 +
 .../cartridge-agent/modules/util/__init__.pyc   | Bin 0 -> 297 bytes
 .../modules/util/cartridgeagentconstants.py     |  88 ++++++
 .../modules/util/cartridgeagentconstants.pyc    | Bin 0 -> 3917 bytes
 .../modules/util/cartridgeagentutils.py         |  94 ++++++
 .../modules/util/cartridgeagentutils.pyc        | Bin 0 -> 3924 bytes
 .../modules/util/extensionutils.py              |  40 +++
 .../cartridge-agent/publisher/__init__.py       |   1 -
 .../publisher/cartridgeagentpublisher.py        |  88 ------
 .../cartridge-agent/readme.txt                  |   2 -
 .../cartridge-agent/script.sh                   |   0
 .../cartridge-agent/subscriber/__init__.py      |   1 -
 .../subscriber/eventsubscriber.py               |  62 ----
 .../cartridge-agent/util/__init__.py            |   1 -
 .../util/cartridgeagentconstants.py             |  88 ------
 .../cartridge-agent/util/cartridgeagentutils.py |  94 ------
 .../cartridge-agent/util/extensionutils.py      |  40 ---
 70 files changed, 1240 insertions(+), 1262 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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 7108801..0dfecb2 100644
--- a/tools/python-cartridge-agent/cartridge-agent/agent.py
+++ b/tools/python-cartridge-agent/cartridge-agent/agent.py
@@ -3,14 +3,14 @@ import logging
 import threading
 import time
 
-from config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from util import *
-from exception.parameternotfoundexception import ParameterNotFoundException
-from subscriber.eventsubscriber import EventSubscriber
-from extensions.defaultextensionhandler import DefaultExtensionHandler
-from publisher import cartridgeagentpublisher
-from event.instance.notifier.events import *
-from event.tenant.events import *
+from modules.config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from modules.util import *
+from modules.exception.parameternotfoundexception import ParameterNotFoundException
+from modules.subscriber.eventsubscriber import EventSubscriber
+from modules.extensions.defaultextensionhandler import DefaultExtensionHandler
+from modules.publisher import cartridgeagentpublisher
+from modules.event.instance.notifier.events import *
+from modules.event.tenant.events import *
 
 
 class CartridgeAgent(threading.Thread):

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/agent.sh
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent.sh b/tools/python-cartridge-agent/cartridge-agent/agent.sh
deleted file mode 100644
index 15b4759..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/agent.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-param_path="/home/gayan/Resources/Stratos/payload/launch-params"
-extension_path="/home/gayan/Resources/Stratos/extentions"
-
-python agent.py $param_path $extension_path
-
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/agent1.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/agent1.py b/tools/python-cartridge-agent/cartridge-agent/agent1.py
deleted file mode 100644
index cf9dda1..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/agent1.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-import stomp
-import time
-import logging
-import sys
-import random
-import os
-import threading
-import socket
-
-payloadPath="/home/gayan/Resources/Stratos/payload/launch-params";
-extensionsDir="/home/gayan/Resources/Stratos/extentions"
-mbip=""
-mbport=""
-

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/artifactmgt/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/__init__.py b/tools/python-cartridge-agent/cartridge-agent/artifactmgt/__init__.py
deleted file mode 100644
index b1e49e4..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['repositoryinformation']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/__init__.py b/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/__init__.py
deleted file mode 100644
index 372e725..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['agentgithandler', 'gitrepository']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/agentgithandler.py b/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/agentgithandler.py
deleted file mode 100644
index 9c27f68..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/agentgithandler.py
+++ /dev/null
@@ -1,147 +0,0 @@
-from git import *
-import gitrepository
-import logging
-
-from ...config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ...util import cartridgeagentutils
-
-
-class AgentGitHandler:
-    logging.basicConfig(level=logging.DEBUG)
-    log = logging.getLogger(__name__)
-
-    SUPER_TENANT_ID = -1234
-    SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
-    TENANT_REPO_PATH = "/repository/tenants/"
-
-    cartridge_agent_config = CartridgeAgentConfiguration()
-
-    __git_repositories = {}
-    # (tenant_id => gitrepository.GitRepository)
-
-    @staticmethod
-    def checkout(repo_info):
-        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
-            cloned = True
-            #TODO: handle conflicts and errors using repo.git.pull(), status(), checkout() outputs
-            AgentGitHandler.log.debug("Existing git repository detected for tenant %r, no clone required" % repo_info.tenant_id)
-            AgentGitHandler.pull(repo_context)
-        else:
-            #subscribing run.. need to clone
-            cloned = False
-            repo_context = AgentGitHandler.create_git_repo_context(repo_info)
-            AgentGitHandler.clone(repo_context)
-
-        return {"cloned": cloned, "repo_context": repo_context}
-
-    @staticmethod
-    def pull(repo_context):
-        #create repo object
-        repo = Repo(repo_context.local_repo_path)
-        repo.remotes.origin.pull()
-
-        # TODO: handle conflict errors
-
-
-    @staticmethod
-    def clone(repo_context):
-        try:
-            repo = Repo.clone_from(repo_context.repo_url, repo_context.local_repo_path)
-            repo_context.cloned = True
-            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.message:
-                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)
-
-    @staticmethod
-    def add_repo_context(repo_context):
-        AgentGitHandler.__git_repositories[repo_context.tenant_id] = repo_context
-
-    @staticmethod
-    def get_repo_context(tenant_id):
-        if tenant_id in AgentGitHandler.__git_repositories:
-            return AgentGitHandler.__git_repositories[tenant_id]
-
-        return None
-
-    @staticmethod
-    def remove_repo_context(tenant_id):
-        if tenant_id in AgentGitHandler.__git_repositories:
-            del AgentGitHandler.__git_repositories[tenant_id]
-
-    @staticmethod
-    def create_git_repo_context(repo_info):
-        repo_context = gitrepository.GitRepositoryContext()
-        repo_context.tenant_id = repo_info.tenant_id
-        repo_context.local_repo_path = AgentGitHandler.get_repo_path_for_tenant(
-            repo_info.tenant_id, repo_info.repo_path, repo_info.is_multitenant)
-        repo_context.repo_url = repo_info.repo_url
-        repo_context.repo_username = repo_info.repo_username
-        repo_context.repo_password = repo_info.repo_password
-
-        # 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
-
-        repo_context.cloned = False
-
-        return repo_context
-
-    # @staticmethod
-    # def is_key_based_auth(repo_url, tenant_id):
-
-
-    @staticmethod
-    def get_repo_path_for_tenant(tenant_id, git_local_repo_path, is_multitenant):
-        repo_path = ""
-
-        if is_multitenant:
-            if tenant_id == AgentGitHandler.SUPER_TENANT_ID:
-                #super tenant, /repository/deploy/server/
-                super_tenant_repo_path = AgentGitHandler.cartridge_agent_config.get_super_tenant_repo_path()
-                #"app_path"
-                repo_path += git_local_repo_path
-
-                if super_tenant_repo_path is not None  and super_tenant_repo_path != "":
-                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.startswith("/") else "/" + super_tenant_repo_path
-                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.endswith("/") else  super_tenant_repo_path + "/"
-                    #"app_path/repository/deploy/server/"
-                    repo_path += super_tenant_repo_path
-                else:
-                    #"app_path/repository/deploy/server/"
-                    repo_path += AgentGitHandler.SUPER_TENANT_REPO_PATH
-
-            else:
-                #normal tenant, /repository/tenants/tenant_id
-                tenant_repo_path = AgentGitHandler.cartridge_agent_config.get_tenant_repo_path()
-                #"app_path"
-                repo_path += git_local_repo_path
-
-                if tenant_repo_path is not None and tenant_repo_path != "":
-                    tenant_repo_path = tenant_repo_path if tenant_repo_path.startswith("/") else "/" + tenant_repo_path
-                    tenant_repo_path = tenant_repo_path if tenant_repo_path.endswith("/") else tenant_repo_path + "/"
-                    #"app_path/repository/tenants/244653444"
-                    repo_path += tenant_repo_path + tenant_id
-                else:
-                    #"app_path/repository/tenants/244653444"
-                    repo_path += AgentGitHandler.TENANT_REPO_PATH + tenant_id
-
-                #tenant_dir_path = git_local_repo_path + AgentGitHandler.TENANT_REPO_PATH + tenant_id
-                cartridgeagentutils.create_dir(repo_path)
-        else:
-            #not multi tenant, app_path
-            repo_path = git_local_repo_path
-
-        AgentGitHandler.log.debug("Repo path returned : %r" % repo_path)
-        return repo_path
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/gitrepository.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/gitrepository.py b/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/gitrepository.py
deleted file mode 100644
index 12ce591..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/git/gitrepository.py
+++ /dev/null
@@ -1,12 +0,0 @@
-class GitRepositoryContext:
-
-    def __init__(self):
-        self.repo_url = None
-        self.local_repo_path = None
-        self.cloned = False
-        self.repo = None
-        self.tenant_id = None
-        self.key_based_auth = False
-        self.repo_username = None
-        self.repo_password = None
-        #scheduled update service
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/artifactmgt/repositoryinformation.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/repositoryinformation.py b/tools/python-cartridge-agent/cartridge-agent/artifactmgt/repositoryinformation.py
deleted file mode 100644
index d30c319..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/artifactmgt/repositoryinformation.py
+++ /dev/null
@@ -1,13 +0,0 @@
-class RepositoryInformation:
-    """
-    Holds repository information to be used in artifact management
-    """
-
-    def __init__(self, repo_url, repo_username, repo_password, repo_path, tenant_id, is_multitenant, commit_enabled):
-        self.repo_url = repo_url
-        self.repo_username = repo_username
-        self.repo_password = repo_password
-        self.repo_path = repo_path
-        self.tenant_id = tenant_id
-        self.is_multitenant = is_multitenant
-        self.commit_enabled = commit_enabled
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/config/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/config/__init__.py b/tools/python-cartridge-agent/cartridge-agent/config/__init__.py
deleted file mode 100644
index 836c3ab..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/config/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['cartridgeagentconfiguration']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/config/cartridgeagentconfiguration.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/config/cartridgeagentconfiguration.py b/tools/python-cartridge-agent/cartridge-agent/config/cartridgeagentconfiguration.py
deleted file mode 100644
index a57c0ca..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/config/cartridgeagentconfiguration.py
+++ /dev/null
@@ -1,297 +0,0 @@
-import ConfigParser
-import logging
-
-from ..util import cartridgeagentconstants
-from ..exception.parameternotfoundexception import ParameterNotFoundException
-
-
-class CartridgeAgentConfiguration:
-    class __CartridgeAgentConfiguration:
-
-        def __init__(self):
-            # set log level
-            logging.basicConfig(level=logging.DEBUG)
-            self.log = logging.getLogger(__name__)
-
-            self.__read_conf_file()
-            self.__read_parameter_file()
-
-            try:
-                self.__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.__isClustered = True
-                else:
-                    self.__isClustered = 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.__partitionId = self.read_property(cartridgeagentconstants.PARTITION_ID)
-                self.__memberId = self.read_property(cartridgeagentconstants.MEMBER_ID)
-                self.__cartridgeKey = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
-                self.__appPath = self.read_property(cartridgeagentconstants.APP_PATH)
-                self.__repoUrl = self.read_property(cartridgeagentconstants.REPO_URL)
-                self.__ports = str(self.read_property(cartridgeagentconstants.PORTS)).split("|")
-
-                try:
-                    self.__logFilePaths = 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.__logFilePaths = None
-
-                is_multi_str = self.read_property(cartridgeagentconstants.CLUSTER_ID)
-                self.__isMultitenant = True if str(is_multi_str).lower().strip() == "true" else False
-
-                try:
-                    self.__persistenceMappings = self.read_property("PERSISTENCE_MAPPING")
-                except ParameterNotFoundException as ex:
-                    self.log.debug("Cannot read persistence mapping : %r" % ex.get_message())
-                    self.__persistenceMappings = None
-
-                try:
-                    is_commit_str = self.read_property(cartridgeagentconstants.COMMIT_ENABLED)
-                    self.__isCommitsEnabled = True if str(is_commit_str).lower().strip() == "true" else False
-                except ParameterNotFoundException:
-                    try:
-                        is_commit_str = self.read_property(cartridgeagentconstants.AUTO_COMMIT)
-                        self.__isCommitsEnabled = 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.__isCommitsEnabled = False
-
-                auto_checkout_str = self.read_property(cartridgeagentconstants.AUTO_CHECKOUT)
-                self.__isCheckoutEnabled = True if str(auto_checkout_str).lower().strip() == "true" else False
-
-                self.__listenAddress = self.read_property(cartridgeagentconstants.LISTEN_ADDRESS)
-
-                try:
-                    int_repo_str = self.read_property(cartridgeagentconstants.PROVIDER)
-                    self.__isInternalRepo = True if str(int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
-                except ParameterNotFoundException:
-                    self.log.info(" INTERNAL payload parameter is not found")
-                    self.__isInternalRepo = False
-
-                self.__tenantId = self.read_property(cartridgeagentconstants.TENANT_ID)
-                self.__lbClusterId = self.read_property(cartridgeagentconstants.LB_CLUSTER_ID)
-                self.__minCount = self.read_property(cartridgeagentconstants.MIN_INSTANCE_COUNT)
-                self.__lbPrivateIp = self.read_property(cartridgeagentconstants.LB_PRIVATE_IP)
-                self.__lbPublicIp = self.read_property(cartridgeagentconstants.LB_PUBLIC_IP)
-                self.__tenantRepositoryPath = self.read_property(cartridgeagentconstants.TENANT_REPO_PATH)
-                self.__superTenantRepositoryPath = self.read_property(cartridgeagentconstants.SUPER_TENANT_REPO_PATH)
-
-                try:
-                    self.__deployment = self.read_property(cartridgeagentconstants.DEPLOYMENT)
-                except ParameterNotFoundException:
-                    self.__deployment = None
-
-                # Setting worker-manager setup - manager service name
-                if self.__deployment is None:
-                    self.__managerServiceName = None
-
-                if str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
-                    self.__managerServiceName = self.__service_name
-
-                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
-                    self.__deployment = self.read_property(cartridgeagentconstants.MANAGER_SERVICE_TYPE)
-
-                elif str(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.__workerServiceName = None
-
-                if str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
-                    self.__managerServiceName = self.__service_name
-
-                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
-                    self.__deployment = self.read_property(cartridgeagentconstants.WORKER_SERVICE_TYPE)
-
-                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
-                    self.__deployment = None
-                else:
-                    self.__deployment = None
-
-                try:
-                    self.__isPrimary = self.read_property(cartridgeagentconstants.CLUSTERING_PRIMARY_KEY)
-                except ParameterNotFoundException:
-                    self.__isPrimary = 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.__partitionId)
-            self.log.debug("member-id: %r" % self.__memberId)
-            self.log.debug("cartridge-key: %r" % self.__cartridgeKey)
-            self.log.debug("app-path: %r" % self.__appPath)
-            self.log.debug("repo-url: %r" % self.__repoUrl)
-            self.log.debug("ports: %r" % str(self.__ports))
-            self.log.debug("lb-private-ip: %r" % self.__lbPrivateIp)
-            self.log.debug("lb-public-ip: %r" % self.__lbPublicIp)
-
-        def __read_conf_file(self):
-            """
-            Reads and stores the agent's configuration file
-            :return:
-            """
-
-            self.properties = ConfigParser.SafeConfigParser()
-            self.properties.read('agent.conf')
-
-        def __read_parameter_file(self):
-            """
-            Reads the payload file of the cartridge and stores the values in a dictionary
-            :return:
-            """
-
-            param_file = self.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
-
-            try:
-                if param_file is not None:
-                    metadata_file = open(param_file)
-                    metadata_payload_content = metadata_file.read()
-                    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.error("Could not read launch parameter file, hence trying to read from System properties.")
-
-        def read_property(self, property_key):
-
-            if self.properties.has_option("agent", property_key):
-                temp_str = self.properties.get("agent", property_key)
-                if temp_str != "" and temp_str is not None:
-                    return temp_str
-
-            if self.payload_params.has_key(property_key):
-                temp_str = self.payload_params[property_key]
-                if temp_str != "" and temp_str is not None:
-                    return temp_str
-
-            raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
-
-        def get_service_name(self):
-            return self.__service_name
-
-        def get_cluster_id(self):
-            return self.__cluster_id
-
-        def get_network_partition_id(self):
-            return self.__network_partition_id
-
-        def get_partition_id(self):
-            return self.__partitionId
-
-        def get_member_id(self):
-            return self.__memberId
-
-        def get_cartridge_key(self):
-            return self.__cartridgeKey
-
-        def get_app_path(self):
-            return self.__appPath
-
-        def get_repo_url(self):
-            return self.__repoUrl
-
-        def get_ports(self):
-            return self.__ports
-
-        def get_log_file_paths(self):
-            return self.__logFilePaths
-
-        def is_multitenant(self):
-            return self.__isMultitenant
-
-        def get_persistance_mappings(self):
-            return self.__persistenceMappings
-
-        def is_commits_enabled(self):
-            return self.__isCommitsEnabled
-
-        def get_listen_address(self):
-            return self.__listenAddress
-
-        def is_internal_repo(self):
-            return self.__isInternalRepo
-
-        def get_tenant_id(self):
-            return self.__tenantId
-
-        def get_lb_cluster_id(self):
-            return self.__lbClusterId
-
-        def get_service_group(self):
-            return self.__service_group
-
-        def is_clustered(self):
-            return self.__isClustered
-
-        def get_min_count(self):
-            return self.__minCount
-
-        def is_primary(self):
-            return self.__isPrimary
-
-        def get_lb_public_ip(self):
-            return self.__lbPublicIp
-
-        def set_lb_public_ip(self, ip):
-            self.__lbPublicIp = ip
-
-        def get_lb_private(self):
-            return self.__lbPrivateIp
-
-        def set_lb_privateip(self, ip):
-            self.__lbPrivateIp = ip
-
-        def get_deployment(self):
-            return self.__deployment
-
-        def set_deployment(self, dep):
-            self.__deployment = dep
-
-        def get_manager_service_name(self):
-            return self.__managerServiceName
-
-        def set_manager_service_name(self, mgr):
-            self.__managerServiceName = mgr
-
-        def get_worker_service_name(self):
-            return self.__workerServiceName
-
-        def set_worker_service_name(self, wrkr):
-            self.__workerServiceName = wrkr
-
-        def get_super_tenant_repo_path(self):
-            return self.__superTenantRepositoryPath
-
-        def get_tenant_repo_path(self):
-            return self.__tenantRepositoryPath
-
-        def is_checkout_enabled(self):
-            return self.__isCheckoutEnabled
-
-    instance = None
-
-    def __init__(self):
-        if not CartridgeAgentConfiguration.instance:
-            CartridgeAgentConfiguration.instance = CartridgeAgentConfiguration.__CartridgeAgentConfiguration()
-
-    def __getattr__(self, item):
-        return getattr(self.instance, item)
-
-

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

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/__init__.py b/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/__init__.py
deleted file mode 100644
index 3bcb310..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/events.py b/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/events.py
deleted file mode 100644
index 5ab3e6c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/instance/notifier/events.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import json
-
-
-class ArtifactUpdatedEvent:
-    def __init__(self):
-        self.cluster_id = None
-        self.status = None
-        self.repo_username = None
-        self.repo_password = None
-        self.repo_url = None
-        self.tenant_id = None
-        self.commit_enabled = None
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = ArtifactUpdatedEvent()
-
-        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
-        instance.status = json_obj["status"] if "status" in json_obj else None
-        instance.repo_username = json_obj["repoUserName"] if "repoUserName" in json_obj else None
-        instance.repo_password = json_obj["repoPassword"] if "repoPassword" in json_obj else None
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.commit_enabled = json_obj["commitEnabled"] if "commitEnabled" in json_obj else None
-
-        return instance
-
-
-class InstanceCleanupClusterEvent:
-    def __init__(self, cluster_id):
-        self.cluster_id = cluster_id
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        c_id = json_obj["clusterId"] if "clusterId" in json_obj else None
-
-        return InstanceCleanupClusterEvent(c_id)
-
-
-class InstanceCleanupMemberEvent:
-    def __init__(self, member_id):
-        self.member_id = member_id
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        m_id = json_obj["memberId"] if "memberId" in json_obj else None
-
-        return InstanceCleanupMemberEvent(m_id)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/instance/status/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/instance/status/__init__.py b/tools/python-cartridge-agent/cartridge-agent/event/instance/status/__init__.py
deleted file mode 100644
index cd8b9d2..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/instance/status/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/instance/status/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/instance/status/events.py b/tools/python-cartridge-agent/cartridge-agent/event/instance/status/events.py
deleted file mode 100644
index 878667c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/instance/status/events.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import json
-
-
-class InstanceActivatedEvent:
-    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
-        self.serviceName = service_name
-        self.clusterId = cluster_id
-        self.networkPartitionId = network_partition_id
-        self.partitionId = parition_id
-        self.memberId = member_id
-
-    def to_json(self):
-        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
-
-
-class InstanceStartedEvent:
-    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
-        self.serviceName = service_name
-        self.clusterId = cluster_id
-        self.networkPartitionId = network_partition_id
-        self.partitionId = parition_id
-        self.memberId = member_id
-
-    def to_json(self):
-        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/tenant/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/tenant/__init__.py b/tools/python-cartridge-agent/cartridge-agent/event/tenant/__init__.py
deleted file mode 100644
index cd8b9d2..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/tenant/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/event/tenant/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/event/tenant/events.py b/tools/python-cartridge-agent/cartridge-agent/event/tenant/events.py
deleted file mode 100644
index 7395f7e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/event/tenant/events.py
+++ /dev/null
@@ -1,98 +0,0 @@
-import json
-
-
-class SubscriptionDomainAddedEvent():
-
-    def __init__(self):
-        self.tenant_id = None
-        self.service_name = None
-        self.cluster_ids = None
-        self.domain_name = None
-        self.application_context = None
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = SubscriptionDomainAddedEvent()
-
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
-        instance.application_context = json_obj["applicationContext"] if "applicationContext" in json_obj else None
-
-        return instance
-
-
-class SubscriptionDomainRemovedEvent:
-
-    def __init__(self, tenant_id, service_name, cluster_ids, domain_name):
-        self.tenant_id = tenant_id
-        self.service_name = service_name
-        self.cluster_ids = cluster_ids
-        self.domain_name = domain_name
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = SubscriptionDomainRemovedEvent()
-
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
-
-        return instance
-
-
-class CompleteTenantEvent:
-
-    def __init__(self):
-        self.tenants = None
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = CompleteTenantEvent()
-
-        instance.tenants = json_obj["tenants"] if "tenants" in json_obj else None
-
-        return instance
-
-
-class TenantSubscribedEvent:
-
-    def __init__(self):
-        self.tenant_id = None
-        self.service_name = None
-        self.cluster_ids = None
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = TenantSubscribedEvent()
-
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-
-        return instance
-
-
-class TenantUnsubscribedEvent:
-
-    def __init__(self):
-        self.tenant_id = None
-        self.service_name = None
-        self.cluster_ids = None
-
-    @staticmethod
-    def create_from_json(json_str):
-        json_obj = json.loads(json_str)
-        instance = TenantUnsubscribedEvent()
-
-        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
-        instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
-
-        return instance
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/exception/__init__.py
deleted file mode 100644
index 7f59666..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/exception/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__ = ['parameternotfoundexception']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/exception/parameternotfoundexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/exception/parameternotfoundexception.py b/tools/python-cartridge-agent/cartridge-agent/exception/parameternotfoundexception.py
deleted file mode 100644
index a9a776e..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/exception/parameternotfoundexception.py
+++ /dev/null
@@ -1,9 +0,0 @@
-class ParameterNotFoundException(Exception):
-    __message = None
-
-    def __init__(self, message):
-        Exception.__init__(self, message)
-        self.__message = message
-
-    def get_message(self):
-        return self.__message

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
index 4a0d8f2..adf3dd6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/extensionhandler.py
@@ -1,44 +1,44 @@
-#!/usr/bin/env python
-import stomp
-import time
-import logging
-import sys
-import random
-import os
-import threading
-import socket
-import json
-from subprocess import Popen,PIPE
-
-
-def onArtifactUpdatedEvent(extenstionpath,scriptname):
-    Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-    print Process.communicate() #now you should see your output
-   # os.system()
-
-def onInstanceCleanupMemberEvent(extenstionpath,scriptname):
-    Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-    print Process.communicate()
-
-def onInstanceCleanupClusterEvent(extenstionpath,scriptname):
-    Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
-    print Process.communicate()
-
-def startServerExtension():
-    print('=================================startServerExtension')
-
-def onInstanceStartedEvent(extensionpath, scriptname, multitenant, copyartifactscriptname, apppath, envparams):
-    print('=================================onInstanceStartedEvent')
-    #if ismultitenant
-    #   execute copy artifact extension
-
-    if multitenant == "true":
-        Process = Popen([os.path.join(extensionpath, copyartifactscriptname), apppath + "/repository/deployment/server/", "/tmp/-1234/"], shell=True, stdin=PIPE, stderr=PIPE)
-        print Process.communicate()
-
-    #addPayloadParams()
-    Process = Popen([os.path.join(extensionpath, scriptname), envparams], shell=True, stdin=PIPE, stderr=PIPE)
-    print Process.communicate()
-
-    #execute instance started extension with empty map
-
+# #!/usr/bin/env python
+# import stomp
+# import time
+# import logging
+# import sys
+# import random
+# import os
+# import threading
+# import socket
+# import json
+# from subprocess import Popen,PIPE
+#
+#
+# def onArtifactUpdatedEvent(extenstionpath,scriptname):
+#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
+#     print Process.communicate() #now you should see your output
+#    # os.system()
+#
+# def onInstanceCleanupMemberEvent(extenstionpath,scriptname):
+#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
+#     print Process.communicate()
+#
+# def onInstanceCleanupClusterEvent(extenstionpath,scriptname):
+#     Process=Popen([os.path.join(extenstionpath,scriptname),str('php')],shell=True,stdin=PIPE,stderr=PIPE)
+#     print Process.communicate()
+#
+# def startServerExtension():
+#     print('=================================startServerExtension')
+#
+# def onInstanceStartedEvent(extensionpath, scriptname, multitenant, copyartifactscriptname, apppath, envparams):
+#     print('=================================onInstanceStartedEvent')
+#     #if ismultitenant
+#     #   execute copy artifact extension
+#
+#     if multitenant == "true":
+#         Process = Popen([os.path.join(extensionpath, copyartifactscriptname), apppath + "/repository/deployment/server/", "/tmp/-1234/"], shell=True, stdin=PIPE, stderr=PIPE)
+#         print Process.communicate()
+#
+#     #addPayloadParams()
+#     Process = Popen([os.path.join(extensionpath, scriptname), envparams], shell=True, stdin=PIPE, stderr=PIPE)
+#     print Process.communicate()
+#
+#     #execute instance started extension with empty map
+#

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/extensions/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/extensions/__init__.py b/tools/python-cartridge-agent/cartridge-agent/extensions/__init__.py
deleted file mode 100644
index 33da048..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/extensions/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['defaultextensionhandler']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/extensions/defaultextensionhandler.py
deleted file mode 100644
index 766dde0..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/extensions/defaultextensionhandler.py
+++ /dev/null
@@ -1,148 +0,0 @@
-import logging
-
-from ..artifactmgt.git.agentgithandler import AgentGitHandler
-from ..artifactmgt.repositoryinformation import RepositoryInformation
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import extensionutils, cartridgeagentconstants, cartridgeagentutils
-from ..publisher import cartridgeagentpublisher
-
-
-class DefaultExtensionHandler:
-    log = None
-    cartridge_agent_config = None
-
-    def __init__(self):
-        logging.basicConfig(level=logging.DEBUG)
-        self.log = logging.getLogger(__name__)
-
-        self.cartridge_agent_config = CartridgeAgentConfiguration()
-
-        pass
-
-    def on_instance_started_event(self):
-        try:
-            self.log.debug("Processing instance started event...")
-            if self.cartridge_agent_config.is_multitenant():
-                artifact_source = "%r/repository/deployment/server/" % self.cartridge_agent_config.get_app_path()
-                artifact_dest = cartridgeagentconstants.SUPERTENANT_TEMP_PATH
-                extensionutils.execute_copy_artifact_extension(artifact_source, artifact_dest)
-
-            env_params = {}
-            extensionutils.execute_instance_started_extention(env_params)
-
-        except Exception:
-            self.log.exception("Error processing instance started event")
-
-    def on_instance_activated_event(self):
-        extensionutils.execute_instance_activated_extension()
-
-    def on_artifact_updated_event(self, event):
-        self.log.info("Artifact update event received: [tenant] %r [cluster] %r [status] %r" %
-                      (event.tenant_id, event.cluster_id, event.status))
-
-        cluster_id_event = str(event.cluster_id).strip()
-        cluster_id_payload = self.cartridge_agent_config.get_cluster_id()
-        repo_url = str(event.repo_url).strip()
-
-        if (repo_url != "") and (cluster_id_payload is not None) and (cluster_id_payload == cluster_id_event):
-            local_repo_path = self.cartridge_agent_config.get_app_path()
-
-            secret = self.cartridge_agent_config.get_cartridge_key()
-            repo_password = cartridgeagentutils.decrypt_password(event.repo_password, secret)
-
-            repo_username = event.repo_username
-            tenant_id = event.tenant_id
-            is_multitenant = self.cartridge_agent_config.is_multitenant()
-            commit_enabled = event.commit_enabled
-
-            self.log.info("Executing git checkout")
-
-            # create repo object
-            repo_info = RepositoryInformation(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
-                                              is_multitenant, commit_enabled)
-
-            #checkout code
-            checkout_result = AgentGitHandler.checkout(repo_info)
-            #execute artifact updated extension
-            env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": event.cluster_id,
-                          "STRATOS_ARTIFACT_UPDATED_TENANT_ID": event.tenant_id,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_URL": event.repo_url,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_PASSWORD": event.repo_password,
-                          "STRATOS_ARTIFACT_UPDATED_REPO_USERNAME": event.repo_username,
-                          "STRATOS_ARTIFACT_UPDATED_STATUS": event.status}
-
-            extensionutils.execute_artifacts_updated_extension(env_params)
-
-            #if !cloneExists publish instanceActivatedEvent
-            if not checkout_result["cloned"]:
-                #publish instanceActivated
-                cartridgeagentpublisher.publish_instance_activated_event()
-
-            #TODO: set artifact update task
-
-    def on_artifact_update_scheduler_event(self, tenantId):
-        pass
-
-    def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
-        pass
-
-    def onInstanceCleanupMemberEvent(self, instanceCleanupMemberEvent):
-        pass
-
-    def onMemberActivatedEvent(self, memberActivatedEvent):
-        pass
-
-    def onCompleteTopologyEvent(self, completeTopologyEvent):
-        pass
-
-    def onCompleteTenantEvent(self, completeTenantEvent):
-        pass
-
-    def onMemberTerminatedEvent(self, memberTerminatedEvent):
-        pass
-
-    def onMemberSuspendedEvent(self, memberSuspendedEvent):
-        pass
-
-    def onMemberStartedEvent(self, memberStartedEvent):
-        pass
-
-    def start_server_extension(self):
-        raise NotImplementedError
-        # extensionutils.wait_for_complete_topology()
-        # self.log.info("[start server extension] complete topology event received")
-        #
-        # service_name_in_payload = self.cartridge_agent_config.get_service_name()
-        # cluster_id_in_payload = self.cartridge_agent_config.get_cluster_id()
-        # member_id_in_payload = self.cartridge_agent_config.get_member_id()
-        #
-        # try:
-        #     consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
-        #
-        #     if not consistant:
-        #         self.log.error("Topology is inconsistent...failed to execute start server event")
-        #         return
-        #
-        #
-        # except:
-        #     self.log.exception("Error processing start servers event")
-        # finally:
-        #     pass
-
-    def volume_mount_extension(self, persistence_mappings_payload):
-        extensionutils.execute_volume_mount_extension(persistence_mappings_payload)
-
-    def onSubscriptionDomainAddedEvent(self, subscriptionDomainAddedEvent):
-        pass
-
-    def onSubscriptionDomainRemovedEvent(self, subscriptionDomainRemovedEvent):
-        pass
-
-    def onCopyArtifactsExtension(self, src, des):
-        pass
-
-    def onTenantSubscribedEvent(self, tenantSubscribedEvent):
-        pass
-
-    def onTenantUnSubscribedEvent(self, tenantUnSubscribedEvent):
-        pass
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/__init__.pyc
new file mode 100644
index 0000000..c030e83
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..b1e49e4
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/__init__.py
@@ -0,0 +1 @@
+__all__=['repositoryinformation']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..372e725
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/__init__.py
@@ -0,0 +1 @@
+__all__=['agentgithandler', 'gitrepository']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..fff1ae8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/agentgithandler.py
@@ -0,0 +1,148 @@
+import logging
+
+from git import *
+
+from gitrepository import GitRepositoryContext
+from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from ... util import cartridgeagentutils
+
+
+class AgentGitHandler:
+    logging.basicConfig(level=logging.DEBUG)
+    log = logging.getLogger(__name__)
+
+    SUPER_TENANT_ID = -1234
+    SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
+    TENANT_REPO_PATH = "/repository/tenants/"
+
+    cartridge_agent_config = CartridgeAgentConfiguration()
+
+    __git_repositories = {}
+    # (tenant_id => gitrepository.GitRepository)
+
+    @staticmethod
+    def checkout(repo_info):
+        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
+            cloned = True
+            #TODO: handle conflicts and errors using repo.git.pull(), status(), checkout() outputs
+            AgentGitHandler.log.debug("Existing git repository detected for tenant %r, no clone required" % repo_info.tenant_id)
+            AgentGitHandler.pull(repo_context)
+        else:
+            #subscribing run.. need to clone
+            cloned = False
+            repo_context = AgentGitHandler.create_git_repo_context(repo_info)
+            AgentGitHandler.clone(repo_context)
+
+        return {"cloned": cloned, "repo_context": repo_context}
+
+    @staticmethod
+    def pull(repo_context):
+        #create repo object
+        repo = Repo(repo_context.local_repo_path)
+        repo.remotes.origin.pull()
+
+        # TODO: handle conflict errors
+
+
+    @staticmethod
+    def clone(repo_context):
+        try:
+            repo = Repo.clone_from(repo_context.repo_url, repo_context.local_repo_path)
+            repo_context.cloned = True
+            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.message:
+                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)
+
+    @staticmethod
+    def add_repo_context(repo_context):
+        AgentGitHandler.__git_repositories[repo_context.tenant_id] = repo_context
+
+    @staticmethod
+    def get_repo_context(tenant_id):
+        if tenant_id in AgentGitHandler.__git_repositories:
+            return AgentGitHandler.__git_repositories[tenant_id]
+
+        return None
+
+    @staticmethod
+    def remove_repo_context(tenant_id):
+        if tenant_id in AgentGitHandler.__git_repositories:
+            del AgentGitHandler.__git_repositories[tenant_id]
+
+    @staticmethod
+    def create_git_repo_context(repo_info):
+        repo_context = GitRepositoryContext()
+        repo_context.tenant_id = repo_info.tenant_id
+        repo_context.local_repo_path = AgentGitHandler.get_repo_path_for_tenant(
+            repo_info.tenant_id, repo_info.repo_path, repo_info.is_multitenant)
+        repo_context.repo_url = repo_info.repo_url
+        repo_context.repo_username = repo_info.repo_username
+        repo_context.repo_password = repo_info.repo_password
+
+        # 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
+
+        repo_context.cloned = False
+
+        return repo_context
+
+    # @staticmethod
+    # def is_key_based_auth(repo_url, tenant_id):
+
+
+    @staticmethod
+    def get_repo_path_for_tenant(tenant_id, git_local_repo_path, is_multitenant):
+        repo_path = ""
+
+        if is_multitenant:
+            if tenant_id == AgentGitHandler.SUPER_TENANT_ID:
+                #super tenant, /repository/deploy/server/
+                super_tenant_repo_path = AgentGitHandler.cartridge_agent_config.get_super_tenant_repo_path()
+                #"app_path"
+                repo_path += git_local_repo_path
+
+                if super_tenant_repo_path is not None  and super_tenant_repo_path != "":
+                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.startswith("/") else "/" + super_tenant_repo_path
+                    super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.endswith("/") else  super_tenant_repo_path + "/"
+                    #"app_path/repository/deploy/server/"
+                    repo_path += super_tenant_repo_path
+                else:
+                    #"app_path/repository/deploy/server/"
+                    repo_path += AgentGitHandler.SUPER_TENANT_REPO_PATH
+
+            else:
+                #normal tenant, /repository/tenants/tenant_id
+                tenant_repo_path = AgentGitHandler.cartridge_agent_config.get_tenant_repo_path()
+                #"app_path"
+                repo_path += git_local_repo_path
+
+                if tenant_repo_path is not None and tenant_repo_path != "":
+                    tenant_repo_path = tenant_repo_path if tenant_repo_path.startswith("/") else "/" + tenant_repo_path
+                    tenant_repo_path = tenant_repo_path if tenant_repo_path.endswith("/") else tenant_repo_path + "/"
+                    #"app_path/repository/tenants/244653444"
+                    repo_path += tenant_repo_path + tenant_id
+                else:
+                    #"app_path/repository/tenants/244653444"
+                    repo_path += AgentGitHandler.TENANT_REPO_PATH + tenant_id
+
+                #tenant_dir_path = git_local_repo_path + AgentGitHandler.TENANT_REPO_PATH + tenant_id
+                cartridgeagentutils.create_dir(repo_path)
+        else:
+            #not multi tenant, app_path
+            repo_path = git_local_repo_path
+
+        AgentGitHandler.log.debug("Repo path returned : %r" % repo_path)
+        return repo_path
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..12ce591
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/git/gitrepository.py
@@ -0,0 +1,12 @@
+class GitRepositoryContext:
+
+    def __init__(self):
+        self.repo_url = None
+        self.local_repo_path = None
+        self.cloned = False
+        self.repo = None
+        self.tenant_id = None
+        self.key_based_auth = False
+        self.repo_username = None
+        self.repo_password = None
+        #scheduled update service
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..d30c319
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/artifactmgt/repositoryinformation.py
@@ -0,0 +1,13 @@
+class RepositoryInformation:
+    """
+    Holds repository information to be used in artifact management
+    """
+
+    def __init__(self, repo_url, repo_username, repo_password, repo_path, tenant_id, is_multitenant, commit_enabled):
+        self.repo_url = repo_url
+        self.repo_username = repo_username
+        self.repo_password = repo_password
+        self.repo_path = repo_path
+        self.tenant_id = tenant_id
+        self.is_multitenant = is_multitenant
+        self.commit_enabled = commit_enabled
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..836c3ab
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.py
@@ -0,0 +1 @@
+__all__=['cartridgeagentconfiguration']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.pyc
new file mode 100644
index 0000000..7ca42b4
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/config/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..495d759
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.py
@@ -0,0 +1,298 @@
+import ConfigParser
+import logging
+
+from .. util import cartridgeagentconstants
+from .. exception.parameternotfoundexception import ParameterNotFoundException
+
+
+class CartridgeAgentConfiguration:
+    class __CartridgeAgentConfiguration:
+
+        def __init__(self):
+            # set log level
+            logging.basicConfig(level=logging.DEBUG)
+            self.log = logging.getLogger(__name__)
+
+            self.payload_params = {}
+            self.__read_conf_file()
+            self.__read_parameter_file()
+
+            try:
+                self.__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.__isClustered = True
+                else:
+                    self.__isClustered = 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.__partitionId = self.read_property(cartridgeagentconstants.PARTITION_ID)
+                self.__memberId = self.read_property(cartridgeagentconstants.MEMBER_ID)
+                self.__cartridgeKey = self.read_property(cartridgeagentconstants.CARTRIDGE_KEY)
+                self.__appPath = self.read_property(cartridgeagentconstants.APP_PATH)
+                self.__repoUrl = self.read_property(cartridgeagentconstants.REPO_URL)
+                self.__ports = str(self.read_property(cartridgeagentconstants.PORTS)).split("|")
+
+                try:
+                    self.__logFilePaths = 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.__logFilePaths = None
+
+                is_multi_str = self.read_property(cartridgeagentconstants.CLUSTER_ID)
+                self.__isMultitenant = True if str(is_multi_str).lower().strip() == "true" else False
+
+                try:
+                    self.__persistenceMappings = self.read_property("PERSISTENCE_MAPPING")
+                except ParameterNotFoundException as ex:
+                    self.log.debug("Cannot read persistence mapping : %r" % ex.get_message())
+                    self.__persistenceMappings = None
+
+                try:
+                    is_commit_str = self.read_property(cartridgeagentconstants.COMMIT_ENABLED)
+                    self.__isCommitsEnabled = True if str(is_commit_str).lower().strip() == "true" else False
+                except ParameterNotFoundException:
+                    try:
+                        is_commit_str = self.read_property(cartridgeagentconstants.AUTO_COMMIT)
+                        self.__isCommitsEnabled = 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.__isCommitsEnabled = False
+
+                auto_checkout_str = self.read_property(cartridgeagentconstants.AUTO_CHECKOUT)
+                self.__isCheckoutEnabled = True if str(auto_checkout_str).lower().strip() == "true" else False
+
+                self.__listenAddress = self.read_property(cartridgeagentconstants.LISTEN_ADDRESS)
+
+                try:
+                    int_repo_str = self.read_property(cartridgeagentconstants.PROVIDER)
+                    self.__isInternalRepo = True if str(int_repo_str).strip().lower() == cartridgeagentconstants.INTERNAL else False
+                except ParameterNotFoundException:
+                    self.log.info(" INTERNAL payload parameter is not found")
+                    self.__isInternalRepo = False
+
+                self.__tenantId = self.read_property(cartridgeagentconstants.TENANT_ID)
+                self.__lbClusterId = self.read_property(cartridgeagentconstants.LB_CLUSTER_ID)
+                self.__minCount = self.read_property(cartridgeagentconstants.MIN_INSTANCE_COUNT)
+                self.__lbPrivateIp = self.read_property(cartridgeagentconstants.LB_PRIVATE_IP)
+                self.__lbPublicIp = self.read_property(cartridgeagentconstants.LB_PUBLIC_IP)
+                self.__tenantRepositoryPath = self.read_property(cartridgeagentconstants.TENANT_REPO_PATH)
+                self.__superTenantRepositoryPath = self.read_property(cartridgeagentconstants.SUPER_TENANT_REPO_PATH)
+
+                try:
+                    self.__deployment = self.read_property(cartridgeagentconstants.DEPLOYMENT)
+                except ParameterNotFoundException:
+                    self.__deployment = None
+
+                # Setting worker-manager setup - manager service name
+                if self.__deployment is None:
+                    self.__managerServiceName = None
+
+                if str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                    self.__managerServiceName = self.__service_name
+
+                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                    self.__deployment = self.read_property(cartridgeagentconstants.MANAGER_SERVICE_TYPE)
+
+                elif str(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.__workerServiceName = None
+
+                if str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_WORKER.lower():
+                    self.__managerServiceName = self.__service_name
+
+                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_MANAGER.lower():
+                    self.__deployment = self.read_property(cartridgeagentconstants.WORKER_SERVICE_TYPE)
+
+                elif str(self.__deployment).lower() == cartridgeagentconstants.DEPLOYMENT_DEFAULT.lower():
+                    self.__deployment = None
+                else:
+                    self.__deployment = None
+
+                try:
+                    self.__isPrimary = self.read_property(cartridgeagentconstants.CLUSTERING_PRIMARY_KEY)
+                except ParameterNotFoundException:
+                    self.__isPrimary = 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.__partitionId)
+            self.log.debug("member-id: %r" % self.__memberId)
+            self.log.debug("cartridge-key: %r" % self.__cartridgeKey)
+            self.log.debug("app-path: %r" % self.__appPath)
+            self.log.debug("repo-url: %r" % self.__repoUrl)
+            self.log.debug("ports: %r" % str(self.__ports))
+            self.log.debug("lb-private-ip: %r" % self.__lbPrivateIp)
+            self.log.debug("lb-public-ip: %r" % self.__lbPublicIp)
+
+        def __read_conf_file(self):
+            """
+            Reads and stores the agent's configuration file
+            :return:
+            """
+
+            self.properties = ConfigParser.SafeConfigParser()
+            self.properties.read('agent.conf')
+
+        def __read_parameter_file(self):
+            """
+            Reads the payload file of the cartridge and stores the values in a dictionary
+            :return:
+            """
+
+            param_file = self.read_property(cartridgeagentconstants.PARAM_FILE_PATH)
+
+            try:
+                if param_file is not None:
+                    metadata_file = open(param_file)
+                    metadata_payload_content = metadata_file.read()
+                    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.error("Could not read launch parameter file, hence trying to read from System properties.")
+
+        def read_property(self, property_key):
+
+            if self.properties.has_option("agent", property_key):
+                temp_str = self.properties.get("agent", property_key)
+                if temp_str != "" and temp_str is not None:
+                    return temp_str
+
+            if self.payload_params.has_key(property_key):
+                temp_str = self.payload_params[property_key]
+                if temp_str != "" and temp_str is not None:
+                    return temp_str
+
+            raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
+
+        def get_service_name(self):
+            return self.__service_name
+
+        def get_cluster_id(self):
+            return self.__cluster_id
+
+        def get_network_partition_id(self):
+            return self.__network_partition_id
+
+        def get_partition_id(self):
+            return self.__partitionId
+
+        def get_member_id(self):
+            return self.__memberId
+
+        def get_cartridge_key(self):
+            return self.__cartridgeKey
+
+        def get_app_path(self):
+            return self.__appPath
+
+        def get_repo_url(self):
+            return self.__repoUrl
+
+        def get_ports(self):
+            return self.__ports
+
+        def get_log_file_paths(self):
+            return self.__logFilePaths
+
+        def is_multitenant(self):
+            return self.__isMultitenant
+
+        def get_persistance_mappings(self):
+            return self.__persistenceMappings
+
+        def is_commits_enabled(self):
+            return self.__isCommitsEnabled
+
+        def get_listen_address(self):
+            return self.__listenAddress
+
+        def is_internal_repo(self):
+            return self.__isInternalRepo
+
+        def get_tenant_id(self):
+            return self.__tenantId
+
+        def get_lb_cluster_id(self):
+            return self.__lbClusterId
+
+        def get_service_group(self):
+            return self.__service_group
+
+        def is_clustered(self):
+            return self.__isClustered
+
+        def get_min_count(self):
+            return self.__minCount
+
+        def is_primary(self):
+            return self.__isPrimary
+
+        def get_lb_public_ip(self):
+            return self.__lbPublicIp
+
+        def set_lb_public_ip(self, ip):
+            self.__lbPublicIp = ip
+
+        def get_lb_private(self):
+            return self.__lbPrivateIp
+
+        def set_lb_privateip(self, ip):
+            self.__lbPrivateIp = ip
+
+        def get_deployment(self):
+            return self.__deployment
+
+        def set_deployment(self, dep):
+            self.__deployment = dep
+
+        def get_manager_service_name(self):
+            return self.__managerServiceName
+
+        def set_manager_service_name(self, mgr):
+            self.__managerServiceName = mgr
+
+        def get_worker_service_name(self):
+            return self.__workerServiceName
+
+        def set_worker_service_name(self, wrkr):
+            self.__workerServiceName = wrkr
+
+        def get_super_tenant_repo_path(self):
+            return self.__superTenantRepositoryPath
+
+        def get_tenant_repo_path(self):
+            return self.__tenantRepositoryPath
+
+        def is_checkout_enabled(self):
+            return self.__isCheckoutEnabled
+
+    instance = None
+
+    def __init__(self):
+        if not CartridgeAgentConfiguration.instance:
+            CartridgeAgentConfiguration.instance = CartridgeAgentConfiguration.__CartridgeAgentConfiguration()
+
+    def __getattr__(self, item):
+        return getattr(self.instance, item)
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.pyc
new file mode 100644
index 0000000..180de3f
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/config/cartridgeagentconfiguration.pyc differ

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

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..0de6991
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/__init__.py
@@ -0,0 +1 @@
+__author__ = 'chamilad'

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..3bcb310
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/__init__.py
@@ -0,0 +1 @@
+__all__ = ['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..5ab3e6c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/notifier/events.py
@@ -0,0 +1,50 @@
+import json
+
+
+class ArtifactUpdatedEvent:
+    def __init__(self):
+        self.cluster_id = None
+        self.status = None
+        self.repo_username = None
+        self.repo_password = None
+        self.repo_url = None
+        self.tenant_id = None
+        self.commit_enabled = None
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        instance = ArtifactUpdatedEvent()
+
+        instance.cluster_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+        instance.status = json_obj["status"] if "status" in json_obj else None
+        instance.repo_username = json_obj["repoUserName"] if "repoUserName" in json_obj else None
+        instance.repo_password = json_obj["repoPassword"] if "repoPassword" in json_obj else None
+        instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+        instance.commit_enabled = json_obj["commitEnabled"] if "commitEnabled" in json_obj else None
+
+        return instance
+
+
+class InstanceCleanupClusterEvent:
+    def __init__(self, cluster_id):
+        self.cluster_id = cluster_id
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        c_id = json_obj["clusterId"] if "clusterId" in json_obj else None
+
+        return InstanceCleanupClusterEvent(c_id)
+
+
+class InstanceCleanupMemberEvent:
+    def __init__(self, member_id):
+        self.member_id = member_id
+
+    @staticmethod
+    def create_from_json(json_str):
+        json_obj = json.loads(json_str)
+        m_id = json_obj["memberId"] if "memberId" in json_obj else None
+
+        return InstanceCleanupMemberEvent(m_id)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..cd8b9d2
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/__init__.py
@@ -0,0 +1 @@
+__all__=['events']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..878667c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/instance/status/events.py
@@ -0,0 +1,25 @@
+import json
+
+
+class InstanceActivatedEvent:
+    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
+        self.serviceName = service_name
+        self.clusterId = cluster_id
+        self.networkPartitionId = network_partition_id
+        self.partitionId = parition_id
+        self.memberId = member_id
+
+    def to_json(self):
+        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
+
+
+class InstanceStartedEvent:
+    def __init__(self, service_name, cluster_id, network_partition_id, parition_id, member_id):
+        self.serviceName = service_name
+        self.clusterId = cluster_id
+        self.networkPartitionId = network_partition_id
+        self.partitionId = parition_id
+        self.memberId = member_id
+
+    def to_json(self):
+        return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..cd8b9d2
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/__init__.py
@@ -0,0 +1 @@
+__all__=['events']
\ No newline at end of file


[15/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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)


[26/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/126fa522
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/126fa522
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/126fa522

Branch: refs/heads/master
Commit: 126fa522679d3b62fa331650654123d4a16700bf
Parents: 116d8f6
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Mon Sep 29 15:13:49 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/126fa522/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/126fa522/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/126fa522/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/126fa522/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/126fa522/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/126fa522/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/126fa522/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/126fa522/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/126fa522/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__)
 
 


[31/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/c2fad133
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c2fad133
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c2fad133

Branch: refs/heads/master
Commit: c2fad133695f23f6a97e7b40bdeb4e0666d59916
Parents: 52e258b
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Tue Sep 30 15:30:41 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:29 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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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
+
+


[47/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/fd0f922a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fd0f922a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fd0f922a

Branch: refs/heads/master
Commit: fd0f922a0f9bdfdce2c579862a19daef0755c577
Parents: b3500df
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Fri Oct 10 20:13:08 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:31 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/fd0f922a/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/fd0f922a/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/fd0f922a/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)


[18/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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/15d864ab/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()


[02/50] [abbrv] git commit: Completed git pull, clone and merge scenarios in artifact updated event

Posted by ni...@apache.org.
Completed git pull, clone and merge scenarios in artifact updated event


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

Branch: refs/heads/master
Commit: 4d93c9713bb953906f07e5b2dd143c1f91cc2c84
Parents: 93ad2aa
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Thu Sep 25 05:07:04 2014 +0530
Committer: Nirmal Fernando <ni...@gmail.com>
Committed: Sat Oct 11 14:38:28 2014 +0530

----------------------------------------------------------------------
 .../modules/artifactmgt/git/agentgithandler.py  | 75 +++++++++++++++++---
 .../modules/artifactmgt/git/gitrepository.py    |  4 +-
 .../modules/util/cartridgeagentutils.py         |  8 +++
 3 files changed, 78 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4d93c971/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 f9de8b4..a59e83c 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,11 +1,13 @@
 import logging
+from threading import current_thread
 
 from git import *
 
 from gitrepository import GitRepository
 from ... config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 from ... util import cartridgeagentutils
-
+from ... artifactmgt.repositoryinformation import RepositoryInformation
+from ... extensions.defaultextensionhandler import DefaultExtensionHandler
 
 class AgentGitHandler:
     logging.basicConfig(level=logging.DEBUG)
@@ -16,6 +18,7 @@ class AgentGitHandler:
     TENANT_REPO_PATH = "/repository/tenants/"
 
     cartridge_agent_config = CartridgeAgentConfiguration()
+    extension_handler = DefaultExtensionHandler()
 
     __git_repositories = {}
     # (tenant_id => gitrepository.GitRepository)
@@ -39,9 +42,6 @@ class AgentGitHandler:
                         AgentGitHandler.pull(repo_context)
                     else:
                         repo_context = None
-
-            #TODO: handle conflicts and errors using repo.git.pull(), status(), checkout() outputs
-
         else:
             #subscribing run.. need to clone
             subscribe_run = True
@@ -93,25 +93,82 @@ class AgentGitHandler:
 
     @staticmethod
     def pull(repo_context):
-        #create repo object
         repo = Repo(repo_context.local_repo_path)
-        repo.remotes.origin.pull()
+        try:
+            repo.git.checkout("master")
+            pull_output = repo.git.pull()
+            if "Already up-to-date." not in pull_output:
+                AgentGitHandler.log.debug("Artifacts were updated as a result of the pull operation, thread: %r - %r" % (current_thread().getName(), current_thread().ident))
 
-        # TODO: handle conflict errors
+            AgentGitHandler.extension_handler.on_artifact_update_scheduler_event(repo_context.tenant_id)
+        except GitCommandError as ex:
+            if "fatal: Could not read from remote repository." in ex:
+                #invalid configuration, need to delete and reclone
+                AgentGitHandler.log.warn("Git pull unsuccessful for tenant %r, invalid configuration. %r" % (repo_context.tenant_id, ex))
+                cartridgeagentutils.delete_folder_tree(repo_context.local_repo_path)
+                AgentGitHandler.clone(RepositoryInformation(
+                    repo_context.repo_url,
+                    repo_context.repo_username,
+                    repo_context.repo_password,
+                    repo_context.local_repo_path,
+                    repo_context.tenant_id,
+                    repo_context.is_multitenant,
+                    repo_context.commit_enabled
+                ))
+                AgentGitHandler.extension_handler.on_artifact_update_scheduler_event(repo_context.tenant_id)
+            elif "error: Your local changes to the following files would be overwritten by merge:" in ex:
+                #conflict error
+                AgentGitHandler.log.warn("Git pull unsuccessful for tenant %r, conflicts detected." % repo_context.tenant_id)
+                #raise ex
+
+                """
+                0:'git pull' returned exit status 1: error: Your local changes to the following files would be overwritten by merge:
+                1:    README.md
+                2:    index.php
+                3:Please, commit your changes or stash them before you can merge.
+                4:Aborting
+                """
+                conflict_list = []
+                files_arr = str(ex).split("\n")
+                for file_index in range (1, len(files_arr)-2):
+                    file_name = files_arr[file_index].strip()
+                    conflict_list.append(file_name)
+                    AgentGitHandler.log.debug("Added the file path %r to checkout from the remote repository" % file_name)
+
+                AgentGitHandler.checkout_individually(conflict_list, repo)
+            elif "fatal: unable to access " in ex:
+                #transport error
+                AgentGitHandler.log.exception("Accessing remote git repository %r failed for tenant %r" % (repo_context.repo_url, repo_context.tenant_id))
+            else:
+                AgentGitHandler.log.exception("Git pull operation for tenant %r failed" % repo_context.tenant_id)
 
+    @staticmethod
+    def checkout_individually(conflict_list, repo):
+        try:
+            for conflicted_file in conflict_list:
+                repo.git.checkout(conflicted_file)
+                AgentGitHandler.log.info("Checked out the conflicting files from the remote repository successfully")
+        except:
+            AgentGitHandler.log.exception("Checking out artifacts from index failed")
 
     @staticmethod
     def clone(repo_info):
+        #TODO: credential management
         repo_context = None
         try:
             repo_context = AgentGitHandler.create_git_repo_context(repo_info)
+            #create the directory if it doesn't exist
+            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)
+
             repo_context.cloned = True
             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.message:
+            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)
@@ -145,6 +202,8 @@ class AgentGitHandler:
         repo_context.repo_url = repo_info.repo_url
         repo_context.repo_username = repo_info.repo_username
         repo_context.repo_password = repo_info.repo_password
+        repo_context.is_multitenant = repo_info.is_multitenant
+        repo_context.commit_enabled = repo_info.commit_enabled
 
         # TODO: push
         # push not implemented

http://git-wip-us.apache.org/repos/asf/stratos/blob/4d93c971/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 26950ae..568c275 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
@@ -9,4 +9,6 @@ class GitRepository:
         self.key_based_auth = False
         self.repo_username = None
         self.repo_password = None
-        #scheduled update service
\ No newline at end of file
+        self.is_multitenant = False
+        self.commit_enabled = False
+        #scheduled update servicef
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/4d93c971/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 25d3b8a..f58ea1a 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -4,6 +4,7 @@ import logging
 import os
 import time
 import socket
+import shutil
 
 from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
 import cartridgeagentconstants
@@ -52,6 +53,13 @@ def create_dir(path):
     return False
 
 
+def delete_folder_tree(path):
+    try:
+        shutil.rmtree(path)
+        log.debug("Directory [%r] deleted." % path)
+    except OSError:
+        log.exception("Deletion of folder path %r failed." % path)
+
 def wait_until_ports_active(ip_address, ports):
     ports_check_timeout = cartridge_agent_config.read_property("port.check.timeout")
     if ports_check_timeout is None:


[28/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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/c2fad133/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']