You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2015/12/21 13:00:37 UTC
[1/2] stratos git commit: PCA - Cleanup
Repository: stratos
Updated Branches:
refs/heads/master 932c3286e -> a760c0694
PCA - Cleanup
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/97706437
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/97706437
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/97706437
Branch: refs/heads/master
Commit: 9770643773f6b5f0fdfe9a3f376af450f1a3b26a
Parents: 932c328
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 17:15:07 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 17:15:07 2015 +0530
----------------------------------------------------------------------
.../pom.xml | 38 --
.../cartridge.agent/subscriber.py | 1 -
.../python/cartridge.agent/tests/__init__.py | 16 -
.../tests/conf/complete_topology_event.json | 1 -
.../tests/conf/git/auth_repo.json | 10 -
.../tests/conf/git/auth_repo2.json | 10 -
.../tests/conf/git/simple_repo.json | 10 -
.../python/cartridge.agent/tests/test_events.py | 125 -----
.../python/cartridge.agent/tests/test_git.py | 79 ---
.../python/cartridge.agent/tests/test_util.py | 127 -----
.../test/PythonCartridgeAgentTest.java | 529 -------------------
11 files changed, 946 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/pom.xml b/components/org.apache.stratos.python.cartridge.agent/pom.xml
index 1ea6aa7..95cd071 100644
--- a/components/org.apache.stratos.python.cartridge.agent/pom.xml
+++ b/components/org.apache.stratos.python.cartridge.agent/pom.xml
@@ -30,44 +30,6 @@
<packaging>pom</packaging>
<name>Apache Stratos - Python Cartridge Agent</name>
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/*/PythonCartridgeAgentTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*/PythonCartridgeAgentTest.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<dependencies>
<dependency>
<groupId>org.wso2.carbon</groupId>
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
index 165cd5b..87dceeb 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
@@ -209,4 +209,3 @@ class EventExecutor(threading.Thread):
def terminate(self):
self.terminate()
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/__init__.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/__init__.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/__init__.py
deleted file mode 100644
index 13a8339..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/__init__.py
+++ /dev/null
@@ -1,16 +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.
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/complete_topology_event.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/complete_topology_event.json b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/complete_topology_event.json
deleted file mode 100644
index 14d6d8b..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/complete_topology_event.json
+++ /dev/null
@@ -1 +0,0 @@
-{"topology":{"serviceMap":{"tomcat":{"serviceName":"tomcat","serviceType":"SingleTenant","clusterIdClusterMap":{"php1.tomcat.domain":{"serviceName":"tomcat","clusterId":"php1.tomcat.domain","autoscalePolicyName":"autoscale_policy_1","hostNames":["php1.isuruh.lk"],"tenantRange":"*","isLbCluster":false,"isKubernetesCluster":false,"memberMap":{"php1.tomcat.domain6d4d09ee-2ec8-4c00-962d-3449305a4dfa":{"serviceName":"tomcat","clusterId":"php1.tomcat.domain","memberId":"php1.tomcat.domain6d4d09ee-2ec8-4c00-962d-3449305a4dfa","clusterInstanceId":"single-cartridge-app-1","networkPartitionId":"openstack_R1","partitionId":"P1","initTime":1422699519228,"portMap":{"8280":{"protocol":"http","value":22,"proxy":8280}},"memberPublicIPs":["192.168.17.200"],"defaultPublicIP":"192.168.17.200","memberPrivateIPs":["10.0.0.59"],"defaultPrivateIP":"10.0.0.59","properties":{"PRIMARY":"false","MIN_COUNT":"1"},"memberStateManager":{"stateStack":["Created","Initialized"],"identifier":"php1.tomcat.domain6d4d09
ee-2ec8-4c00-962d-3449305a4dfa"}}},"appId":"single-cartridge-app","properties":{},"instanceIdToInstanceContextMap":{"single-cartridge-app-1":{"instanceId":"single-cartridge-app-1","instanceProperties":{},"lifeCycleStateManager":{"stateStack":["Created"],"identifier":"php1.tomcat.domain_single-cartridge-app-1"},"networkPartitionId":"openstack_R1"}}}},"portMap":{"8280":{"protocol":"http","value":22,"proxy":8280}},"properties":{}}},"initialized":false}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo.json b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo.json
deleted file mode 100644
index b6143a0..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "repoURL": "https://testapache2211@bitbucket.org/testapache2211/testrepo.git",
- "repoUsername" : "testapache2211",
- "repoPassword" : "iXSLhimFulqe",
- "repoPath" : "/tmp/apachestratos/testauth_repo",
- "tenantId" : "0002",
- "multitenant" : "False",
- "commitEnabled" : "False",
- "fallbackHash" : "a71503a2fed5e2c00b050ac69c912a33483949a8"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo2.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo2.json b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo2.json
deleted file mode 100644
index fa91094..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/auth_repo2.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "repoURL": "https://bitbucket.org/testapache2211/testrepo.git",
- "repoUsername" : "testapache2211",
- "repoPassword" : "iXSLhimFulqe",
- "repoPath" : "/tmp/apachestratos/testauth_repo2",
- "tenantId" : "0003",
- "multitenant" : "False",
- "commitEnabled" : "False",
- "fallbackHash" : "a71503a2fed5e2c00b050ac69c912a33483949a8"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/simple_repo.json
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/simple_repo.json b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/simple_repo.json
deleted file mode 100644
index c88b1aa..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/conf/git/simple_repo.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "repoURL": "https://bitbucket.org/testapache2211/opentestrepo1.git",
- "repoUsername" : "testapache2211",
- "repoPassword" : "iXSLhimFulqe",
- "repoPath" : "/tmp/apachestratos/opentest_repo",
- "tenantId" : "0001",
- "multitenant" : "False",
- "commitEnabled" : "False",
- "fallbackHash" : "a1ae3d7d00bf4d5a63b21bcdc82d075e1def4121"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_events.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_events.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_events.py
deleted file mode 100644
index ae4021c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_events.py
+++ /dev/null
@@ -1,125 +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 .. cartridgeagent.modules.event.topology.events import CompleteTopologyEvent
-import pytest
-
-
-def test_complete_topology_event():
- with open("conf/complete_topology_event.json", "r") as f:
- event_json = f.read()
-
- event_object = CompleteTopologyEvent.create_from_json(event_json)
- topology = event_object.get_topology()
-
- assert not topology.initialized and \
- len(topology.service_map.keys()) == 1 and \
- topology.service_map.keys()[0] == "tomcat", \
- "Topology object not serialized properly"
-
- service = topology.get_service("tomcat")
-
- assert service.service_name == "tomcat", \
- "Service object not serialized properly. [serviceName] %s" % service.service_name
- assert service.service_type == "SingleTenant", \
- "Service object not serialized properly. [srviceType] %s" % service.service_type
- assert len(service.cluster_id_cluster_map.keys()) == 1, \
- "Service object not serialized properly. Count[clusterIdClusterMap] %s" % \
- len(service.cluster_id_cluster_map.keys())
- assert service.cluster_id_cluster_map.keys()[0] == "php1.tomcat.domain", \
- "Service object not serialized properly. [clusterIdClusterMap] %s" % service.cluster_id_cluster_map.keys()[0]
- assert len(service.port_map.keys()) == 1, \
- "Service object not serialized properly. Count[portMap] %s" % len(service.port_map.keys())
- assert service.port_map.keys()[0] == "8280", \
- "Service object not serialized properly. [portMap] %s" % service.port_map.keys()[0]
- assert len(service.properties.keys()) == 0, \
- "Service object not serialized properly. Count[properties] %s" % len(service.properties.keys())
-
- cluster = service.get_cluster("php1.tomcat.domain")
-
- assert cluster.service_name == "tomcat", \
- "Cluster object not serialized properly. [serviceName] %s" % cluster.service_name
- assert cluster.cluster_id == "php1.tomcat.domain", \
- "Cluster object not serialized properly. [clusterId] %s" % cluster.cluster_id
- assert cluster.deployment_policy_name is None, \
- "Cluster object not serialized properly. [deploymentPolicyName] %s" % cluster.deployment_policy_name
- assert cluster.autoscale_policy_name == "autoscale_policy_1", \
- "Cluster object not serialized properly. [autoscalePolicyName] %s" % cluster.autoscale_policy_name
- assert len(cluster.hostnames) == 1, \
- "Cluster object not serialized properly. Count[hostNames] %s" % len(cluster.hostnames)
- assert cluster.tenant_range == "*", \
- "Cluster object not serialized properly. [tenantRange] %s" % cluster.tenant_range
- assert not cluster.is_lb_cluster, \
- "Cluster object not serialized properly. [isLbCluster] %s" % cluster.is_lb_cluster
- assert not cluster.is_kubernetes_cluster, \
- "Cluster object not serialized properly. [isKubernetesCluster] %s" % cluster.is_kubernetes_cluster
- assert cluster.load_balancer_algorithm_name is None, \
- "Cluster object not serialized properly. [loadBalancerAlogrithmName] %s" % cluster.load_balancer_algorithm_name
- assert cluster.app_id == "single-cartridge-app", \
- "Cluster object not serialized properly. [appId] %s" % cluster.app_id
- assert len(cluster.properties.keys()) == 0, \
- "Cluster object not serialized properly. Count[properties] %s" % len(cluster.properties.keys())
- assert len(cluster.member_map.keys()) == 1, \
- "Cluster object not serialized properly. Count[memberMap] %s" % len(cluster.member_map.keys())
- assert cluster.member_exists("php1.tomcat.domain6d4d09ee-2ec8-4c00-962d-3449305a4dfa"), \
- "Cluster object not serialized properly. Targeted member not found."
-
- # assert cluster.tenant_id_in_range("222"), "Checking tenant id in range"
-
- try:
- cluster.validate_tenant_range("*")
- except RuntimeError:
- pytest.fail("Validating tenant range logic failed. [input] *")
-
- try:
- cluster.validate_tenant_range("22-45")
- except RuntimeError:
- pytest.fail("Validating tenant range logic failed. [input] 22-45")
-
- with pytest.raises(RuntimeError):
- cluster.validate_tenant_range("rf-56")
-
- member = cluster.get_member("php1.tomcat.domain6d4d09ee-2ec8-4c00-962d-3449305a4dfa")
-
- assert member.service_name == "tomcat",\
- "Member object not serialized properly. [serviceName] %s " % member.service_name
- assert member.cluster_id == "php1.tomcat.domain",\
- "Member object not serialized properly. [clusterId] %s " % member.cluster_id
- assert member.member_id == "php1.tomcat.domain6d4d09ee-2ec8-4c00-962d-3449305a4dfa",\
- "Member object not serialized properly. [memberId] %s " % member.member_id
- assert member.cluster_instance_id == "single-cartridge-app-1",\
- "Member object not serialized properly. [clusterInstanceId] %s " % member.cluster_instance_id
- assert member.network_partition_id == "openstack_R1",\
- "Member object not serialized properly. [networkPartitionId] %s " % member.network_partition_id
- assert member.partition_id == "P1",\
- "Member object not serialized properly. [partitionId] %s " % member.partition_id
- assert member.init_time == 1422699519228,\
- "Member object not serialized properly. [initTime] %s " % member.init_time
- assert member.member_public_ips[0] == "192.168.17.200",\
- "Member object not serialized properly. [memberPublicIps] %s " % member.member_public_ips[0]
- assert member.member_default_public_ip == member.member_public_ips[0],\
- "Member object not serialized properly. [defaultPublicIp] %s " % member.member_default_public_ip
- assert member.member_private_ips[0] == "10.0.0.59",\
- "Member object not serialized properly. [memberPrivateIps] %s " % member.member_private_ips[0]
- assert member.member_default_private_ip == member.member_private_ips[0],\
- "Member object not serialized properly. [defaultPrivateIp] %s " % member.member_default_private_ip
- assert member.properties["MIN_COUNT"] == "1",\
- "Member object not serialized properly. [properties] %s " % member.properties["MIN_COUNT"]
- assert member.status == "Initialized",\
- "Member object not serialized properly. [status] %s " % member.status
- assert member.lb_cluster_id is None,\
- "Member object not serialized properly. [lbClusterId] %s " % member.lb_cluster_id
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_git.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_git.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_git.py
deleted file mode 100644
index c1074aa..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_git.py
+++ /dev/null
@@ -1,79 +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 pytest
-import json
-import shutil
-import os
-from .. cartridgeagent.modules.artifactmgt.repository import Repository
-from .. cartridgeagent.modules.artifactmgt.git.agentgithandler import *
-
-
-@pytest.mark.parametrize("input, expected", [
- ("simple_repo.json", True),
- ("auth_repo.json", True),
- ("auth_repo2.json", True),
-])
-def test_clone(input, expected):
- with open("conf/git/" + input, "r") as f:
- repo_string = f.read()
-
- repo_info = json.loads(repo_string, object_hook=repo_object_decoder)
- sub_run, repo_context = AgentGitHandler.run_checkout_job(repo_info)
-
- assert sub_run, "Not detected as subscription run"
-
- result, msg = verify_git_repo(repo_info)
- assert result == expected, msg
-
-
-def setup_module(module):
- # clear the temp folder path to clone new folders
- try:
- shutil.rmtree("/tmp/apachestratos")
- except:
- pass
-
- try:
- os.makedirs("/tmp/apachestratos")
- except:
- pass
-
-
-def verify_git_repo(repo_info):
- """
- Assert the status of the git repository
- :param repo_info:
- :return:
- """
- if not os.path.isdir(repo_info.repo_path):
- return False, "Local repository directory not created."
-
- output, errors = AgentGitHandler.execute_git_command(["status"], repo_info.repo_path)
- if not (len(errors) == 0 and "nothing to commit, working directory clean" in output):
- return False, "Git clone failed. "
-
- return True, None
-
-
-def repo_object_decoder(obj):
- """ Repository object decoder from JSON
- :param obj: json object
- :return:
- """
- return Repository(str(obj["repoURL"]), str(obj["repoUsername"]), str(obj["repoPassword"]), str(obj["repoPath"]),
- str(obj["tenantId"]), str(obj["multitenant"]), str(obj["commitEnabled"]))
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_util.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_util.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_util.py
deleted file mode 100644
index ff6a6fe..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/tests/test_util.py
+++ /dev/null
@@ -1,127 +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 ..cartridgeagent.modules.util.asyncscheduledtask import *
-from ..cartridgeagent.modules.util import cartridgeagentutils
-import time
-import socket
-from threading import Thread
-
-# ASYNC_WRITE_FILE = "asynctest.txt"
-
-
-# def test_async_task():
-# with open(ASYNC_WRITE_FILE, "r") as f:
-# init_context = f.read()
-#
-# test_task = TestTask()
-# astask = ScheduledExecutor(1, test_task)
-# start_time = time.time() * 1000
-# astask.start()
-# contents_changed = False
-# timeout = 10 #seconds
-#
-# # wait till file content is written
-# while not contents_changed and (time.time() * 1000 - start_time) < (10 * 1000):
-# time.sleep(2)
-# with open(ASYNC_WRITE_FILE, "r") as f:
-# now_content = f.read()
-#
-# if init_context != now_content:
-# contents_changed = True
-#
-# astask.terminate()
-# f = open(ASYNC_WRITE_FILE, "r")
-# end_time = float(f.read())
-# assert (end_time - start_time) >= 1 * 1000, "Task was executed before specified delay"
-#
-#
-# class TestTask(AbstractAsyncScheduledTask):
-#
-# def execute_task(self):
-# with open(ASYNC_WRITE_FILE, "w") as f:
-# f.seek(0)
-# f.truncate()
-# f.write("%1.4f" % (time.time()*1000))
-
-
-def test_decrypt_password_success():
- plain_password = "plaintext"
- secret_key = "tvnw63ufg9gh5111"
- encrypted_password= "jP1lZ5xMlpLzu8MbY2Porg=="
-
- decrypted_password = cartridgeagentutils.decrypt_password(encrypted_password, secret_key)
- #print decrypted_password
-
- assert decrypted_password == plain_password, "Password decryption failed"
-
-
-def test_decrypt_password_failure():
- plain_password = "plaintext"
- secret_key = "notsecretkeyhere"
- encrypted_password= "jP1lZ5xMlpLzu8MbY2Porg=="
- assert cartridgeagentutils.decrypt_password(encrypted_password, secret_key) != plain_password, "Password decrypted for wrong key"
-#
-#
-# def test_create_dir_normal():
-# assert True
-#
-#
-# def test_create_dir_system_path():
-# assert True
-#
-#
-# def test_create_dir_existing_dir():
-# assert True
-
-
-def test_wait_for_ports_activity_normal():
- portnumber = 12345
- listener = PortListener(portnumber)
- listener.start()
-
- assert cartridgeagentutils.check_ports_active(socket.gethostbyname(socket.gethostname()), [str(portnumber)])
-
-
-def test_wait_for_ports_activity_non_existent():
- assert cartridgeagentutils.check_ports_active(socket.gethostbyname(socket.gethostname()), [str(34565)]) == False
-
-
-class PortListener(Thread):
-
- def __init__(self, portnumber):
- Thread.__init__(self)
- self.portnumber = portnumber
- self.terminated = False
-
- def run(self):
- s = socket.socket()
- host = socket.gethostname()
-
- s.bind((host, self.portnumber))
- s.listen(5)
-
- # while not self.terminated:
- c, addr = s.accept() # Establish connection with client.
- # print 'Got connection from', addr
- c.send('Thank you for connecting')
- c.close()
-
- s.close()
-
- def terminate(self):
- self.terminated = True
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/97706437/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java b/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
deleted file mode 100644
index 620e11b..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
+++ /dev/null
@@ -1,529 +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.
- */
-
-package org.apache.stratos.python.cartridge.agent.test;
-
-import org.apache.activemq.broker.BrokerService;
-import org.apache.commons.exec.*;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.domain.LoadBalancingIPType;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
-import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
-import org.apache.stratos.messaging.event.topology.MemberInitializedEvent;
-import org.apache.stratos.messaging.listener.instance.status.InstanceActivatedEventListener;
-import org.apache.stratos.messaging.listener.instance.status.InstanceStartedEventListener;
-import org.apache.stratos.messaging.message.receiver.instance.status.InstanceStatusEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
-import org.apache.stratos.messaging.util.MessagingUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.*;
-import java.util.concurrent.ExecutorService;
-
-import static junit.framework.Assert.assertTrue;
-
-@RunWith(Parameterized.class)
-public class PythonCartridgeAgentTest {
-
- private static final Log log = LogFactory.getLog(PythonCartridgeAgentTest.class);
-
- private static final String NEW_LINE = System.getProperty("line.separator");
- // private static final long TIMEOUT = 1440000;
- private static final long TIMEOUT = 120000;
- private static final String CLUSTER_ID = "php.php.domain";
- private static final String DEPLOYMENT_POLICY_NAME = "deployment-policy-1";
- private static final String AUTOSCALING_POLICY_NAME = "autoscaling-policy-1";
- private static final String APP_ID = "application-1";
- private static final String MEMBER_ID = "php.member-1";
- private static final String CLUSTER_INSTANCE_ID = "cluster-1-instance-1";
- private static final String NETWORK_PARTITION_ID = "network-partition-1";
- private static final String PARTITION_ID = "partition-1";
- private static final String TENANT_ID = "-1234";
- private static final String SERVICE_NAME = "php";
- public static final String SOURCE_PATH = "/tmp/stratos-pca-test-app-path/";
-
- private static List<ServerSocket> serverSocketList;
- private static Map<String, Executor> executorList;
- private final ArtifactUpdatedEvent artifactUpdatedEvent;
- private final Boolean expectedResult;
- private boolean instanceStarted;
- private boolean instanceActivated;
- private ByteArrayOutputStreamLocal outputStream;
- private boolean eventReceiverInitiated = false;
- private TopologyEventReceiver topologyEventReceiver;
- private InstanceStatusEventReceiver instanceStatusEventReceiver;
- private int cepPort = 7712;
- private BrokerService broker = new BrokerService();
- private static final String ACTIVEMQ_AMQP_BIND_ADDRESS = "tcp://localhost:61617";
- private static final String ACTIVEMQ_MQTT_BIND_ADDRESS = "mqtt://localhost:1884";
- private static final UUID PYTHON_AGENT_DIR_NAME = UUID.randomUUID();
-
- public PythonCartridgeAgentTest(ArtifactUpdatedEvent artifactUpdatedEvent, Boolean expectedResult) {
- this.artifactUpdatedEvent = artifactUpdatedEvent;
- this.expectedResult = expectedResult;
- }
-
- /**
- * Setup method for test class
- */
- @BeforeClass
- public static void oneTimeSetUp() {
- // Set jndi.properties.dir system property for initializing event publishers and receivers
- System.setProperty("jndi.properties.dir", getResourcesFolderPath());
- }
-
- /**
- * Setup method for test method testPythonCartridgeAgent
- */
- @Before
- public void setup() {
- serverSocketList = new ArrayList<ServerSocket>();
- executorList = new HashMap<String, Executor>();
- try {
- broker.addConnector(ACTIVEMQ_AMQP_BIND_ADDRESS);
- broker.addConnector(ACTIVEMQ_MQTT_BIND_ADDRESS);
- broker.setBrokerName("testBroker");
- broker.setDataDirectory(PythonCartridgeAgentTest.class.getResource("/").getPath() +
- File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME + File.separator + "activemq-data");
- broker.start();
- log.info("Broker service started!");
- }
- catch (Exception e) {
- log.error("Error while setting up broker service", e);
- }
- if (!this.eventReceiverInitiated) {
- ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL", 15);
- topologyEventReceiver = new TopologyEventReceiver();
- topologyEventReceiver.setExecutorService(executorService);
- topologyEventReceiver.execute();
-
- instanceStatusEventReceiver = new InstanceStatusEventReceiver();
- instanceStatusEventReceiver.setExecutorService(executorService);
- instanceStatusEventReceiver.execute();
-
- this.instanceStarted = false;
- instanceStatusEventReceiver.addEventListener(new InstanceStartedEventListener() {
- @Override
- protected void onEvent(Event event) {
- log.info("Instance started event received");
- instanceStarted = true;
- }
- });
-
- this.instanceActivated = false;
- instanceStatusEventReceiver.addEventListener(new InstanceActivatedEventListener() {
- @Override
- protected void onEvent(Event event) {
- log.info("Instance activated event received");
- instanceActivated = true;
- }
- });
-
- this.eventReceiverInitiated = true;
- }
- // Simulate CEP server socket
- startServerSocket(cepPort);
- String agentPath = setupPythonAgent();
- log.info("Python agent working directory name: " + PYTHON_AGENT_DIR_NAME);
- log.info("Starting python cartridge agent...");
- this.outputStream = executeCommand(
- "python " + agentPath + "/agent.py > " + getResourcesFolderPath() + File.separator + ".." +
- File.separator + PYTHON_AGENT_DIR_NAME + File.separator + "cartridge-agent.log");
- }
-
- /**
- * TearDown method for test method testPythonCartridgeAgent
- */
- @After
- public void tearDown() {
- for (Map.Entry<String, Executor> entry : executorList.entrySet()) {
- try {
- String commandText = entry.getKey();
- Executor executor = entry.getValue();
- ExecuteWatchdog watchdog = executor.getWatchdog();
- if (watchdog != null) {
- log.info("Terminating process: " + commandText);
- watchdog.destroyProcess();
- }
- }
- catch (Exception ignore) {
- }
- }
- for (ServerSocket serverSocket : serverSocketList) {
- try {
- log.info("Stopping socket server: " + serverSocket.getLocalSocketAddress());
- serverSocket.close();
- }
- catch (IOException ignore) {
- }
- }
-
- try {
- log.info("Deleting source checkout folder...");
- FileUtils.deleteDirectory(new File(SOURCE_PATH));
- }
- catch (Exception ignore) {
-
- }
-
- this.instanceStatusEventReceiver.terminate();
- this.topologyEventReceiver.terminate();
-
- this.instanceActivated = false;
- this.instanceStarted = false;
- try {
- broker.stop();
- }
- catch (Exception e) {
- log.error("Error while stopping the broker service", e);
- }
- }
-
-
- /**
- * This method returns a collection of {@link org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent}
- * objects as parameters to the test
- *
- * @return
- */
- @Parameterized.Parameters
- public static Collection getArtifactUpdatedEventsAsParams() {
- ArtifactUpdatedEvent publicRepoEvent = createTestArtifactUpdatedEvent();
-
- ArtifactUpdatedEvent privateRepoEvent = createTestArtifactUpdatedEvent();
- privateRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/testrepo.git");
- privateRepoEvent.setRepoUserName("testapache2211");
- privateRepoEvent.setRepoPassword("RExPDGa4GkPJj4kJDzSROQ==");
-
- ArtifactUpdatedEvent privateRepoEvent2 = createTestArtifactUpdatedEvent();
- privateRepoEvent2.setRepoURL("https://testapache2211@bitbucket.org/testapache2211/testrepo.git");
- privateRepoEvent2.setRepoUserName("testapache2211");
- privateRepoEvent2.setRepoPassword("iF7qT+BKKPE3PGV1TeDsJA==");
-
- return Arrays.asList(new Object[][]{
- {publicRepoEvent, true},
- {privateRepoEvent, true},
- {privateRepoEvent2, true}
- });
-
-// return Arrays.asList(new Object[][]{
-// {publicRepoEvent, true}
-// });
-
- }
-
- /**
- * Creates an {@link org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent} object with a public
- * repository URL
- *
- * @return
- */
- private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() {
- ArtifactUpdatedEvent publicRepoEvent = new ArtifactUpdatedEvent();
- publicRepoEvent.setClusterId(CLUSTER_ID);
- publicRepoEvent.setTenantId(TENANT_ID);
- publicRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/opentestrepo1.git");
- return publicRepoEvent;
- }
-
- @Test(timeout = TIMEOUT)
- public void testPythonCartridgeAgent() {
- Thread communicatorThread = new Thread(new Runnable() {
- @Override
- public void run() {
- List<String> outputLines = new ArrayList<String>();
- while (!outputStream.isClosed()) {
- List<String> newLines = getNewLines(outputLines, outputStream.toString());
- if (newLines.size() > 0) {
- for (String line : newLines) {
- if (line.contains("Subscribed to 'topology/#'")) {
- sleep(1000);
- // Send complete topology event
- log.info("Publishing complete topology event...");
- Topology topology = createTestTopology();
- CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology);
- publishEvent(completeTopologyEvent);
- log.info("Complete topology event published");
-
- sleep(3000);
- // Publish member initialized event
- log.info("Publishing member initialized event...");
- MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent(
- SERVICE_NAME, CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID,
- PARTITION_ID
- );
- publishEvent(memberInitializedEvent);
- log.info("Member initialized event published");
-
- // Simulate server socket
- startServerSocket(8080);
- }
- if (line.contains("Artifact repository found")) {
- // Send artifact updated event
- publishEvent(artifactUpdatedEvent);
- }
-
- if (line.contains("Exception in thread") || line.contains("ERROR")) {
- //throw new RuntimeException(line);
- }
- log.info(line);
- }
- }
- sleep(100);
- }
- }
- });
-
- communicatorThread.start();
-
- while (!instanceActivated) {
- // wait until the instance activated event is received.
- sleep(2000);
- }
-
- assertTrue("Instance started event was not received", instanceStarted);
- assertTrue("Instance activated event was not received", instanceActivated == this.expectedResult);
- }
-
- /**
- * Publish messaging event
- *
- * @param event
- */
- private void publishEvent(Event event) {
- String topicName = MessagingUtil.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topicName);
- eventPublisher.publish(event);
- }
-
- /**
- * Start server socket
- *
- * @param port
- */
- private void startServerSocket(final int port) {
- Thread socketThread = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- ServerSocket serverSocket = new ServerSocket(port);
- serverSocketList.add(serverSocket);
- log.info("Server socket started on port: " + port);
- serverSocket.accept();
- }
- catch (IOException e) {
- String message = "Could not start server socket: [port] " + port;
- log.error(message, e);
- throw new RuntimeException(message, e);
- }
- }
- });
- socketThread.start();
- }
-
- /**
- * Create test topology
- *
- * @return
- */
- private Topology createTestTopology() {
- Topology topology = new Topology();
- Service service = new Service(SERVICE_NAME, ServiceType.SingleTenant);
- topology.addService(service);
-
- Cluster cluster = new Cluster(service.getServiceName(), CLUSTER_ID, DEPLOYMENT_POLICY_NAME,
- AUTOSCALING_POLICY_NAME, APP_ID);
- service.addCluster(cluster);
-
- Member member = new Member(service.getServiceName(), cluster.getClusterId(), MEMBER_ID,
- CLUSTER_INSTANCE_ID, NETWORK_PARTITION_ID, PARTITION_ID, LoadBalancingIPType.Private,
- System.currentTimeMillis());
-
- member.setDefaultPrivateIP("10.0.0.1");
- member.setDefaultPublicIP("20.0.0.1");
- Properties properties = new Properties();
- properties.setProperty("prop1", "value1");
- member.setProperties(properties);
- member.setStatus(MemberStatus.Created);
- cluster.addMember(member);
-
- return topology;
- }
-
- /**
- * Return new lines found in the output
- *
- * @param currentOutputLines current output lines
- * @param output output
- * @return
- */
- private List<String> getNewLines(List<String> currentOutputLines, String output) {
- List<String> newLines = new ArrayList<String>();
-
- if (StringUtils.isNotBlank(output)) {
- String[] lines = output.split(NEW_LINE);
- if (lines != null) {
- for (String line : lines) {
- if (!currentOutputLines.contains(line)) {
- currentOutputLines.add(line);
- newLines.add(line);
- }
- }
- }
- }
- return newLines;
- }
-
- /**
- * Sleep current thread
- *
- * @param time
- */
- private void sleep(long time) {
- try {
- Thread.sleep(time);
- }
- catch (InterruptedException ignore) {
- }
- }
-
- /**
- * Copy python agent distribution to a new folder, extract it and copy sample configuration files
- *
- * @return
- */
- private String setupPythonAgent() {
- try {
- log.info("Setting up python cartridge agent...");
- String srcAgentPath = getResourcesFolderPath() + "/../../src/main/python/cartridge.agent/cartridge.agent";
- String destAgentPath =
- getResourcesFolderPath() + File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME +
- "/cartridge.agent";
- FileUtils.copyDirectory(new File(srcAgentPath), new File(destAgentPath));
-
- String srcAgentConfPath = getResourcesFolderPath() + "/agent.conf";
- String destAgentConfPath = destAgentPath + "/agent.conf";
- FileUtils.copyFile(new File(srcAgentConfPath), new File(destAgentConfPath));
-
- String srcLoggingIniPath = getResourcesFolderPath() + "/logging.ini";
- String destLoggingIniPath = destAgentPath + "/logging.ini";
- FileUtils.copyFile(new File(srcLoggingIniPath), new File(destLoggingIniPath));
-
- String srcPayloadPath = getResourcesFolderPath() + "/payload";
- String destPayloadPath = destAgentPath + "/payload";
- FileUtils.copyDirectory(new File(srcPayloadPath), new File(destPayloadPath));
-
- log.info("Changing extension scripts permissions");
- File extensionsPath = new File(destAgentPath + "/extensions/bash");
- File[] extensions = extensionsPath.listFiles();
- for (File extension : extensions) {
- extension.setExecutable(true);
- }
-
- log.info("Python cartridge agent setup completed");
-
- return destAgentPath;
- }
- catch (Exception e) {
- String message = "Could not copy cartridge agent distribution";
- log.error(message, e);
- throw new RuntimeException(message, e);
- }
- }
-
- /**
- * Execute shell command
- *
- * @param commandText
- */
- private ByteArrayOutputStreamLocal executeCommand(final String commandText) {
- final ByteArrayOutputStreamLocal outputStream = new ByteArrayOutputStreamLocal();
- try {
- CommandLine commandline = CommandLine.parse(commandText);
- DefaultExecutor exec = new DefaultExecutor();
- PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
- exec.setWorkingDirectory(new File(
- getResourcesFolderPath() + File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME));
- exec.setStreamHandler(streamHandler);
- ExecuteWatchdog watchdog = new ExecuteWatchdog(TIMEOUT);
- exec.setWatchdog(watchdog);
- exec.execute(commandline, new ExecuteResultHandler() {
- @Override
- public void onProcessComplete(int i) {
- log.info(commandText + " process completed");
- }
-
- @Override
- public void onProcessFailed(ExecuteException e) {
- log.error(commandText + " process failed", e);
- }
- });
- executorList.put(commandText, exec);
- return outputStream;
- }
- catch (Exception e) {
- log.error(outputStream.toString(), e);
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Get resources folder path
- *
- * @return
- */
- private static String getResourcesFolderPath() {
- String path = PythonCartridgeAgentTest.class.getResource(File.separator).getPath();
- return StringUtils.removeEnd(path, File.separator);
- }
-
- /**
- * Implements ByteArrayOutputStream.isClosed() method
- */
- private class ByteArrayOutputStreamLocal extends ByteArrayOutputStream {
- private boolean closed;
-
- @Override
- public void close() throws IOException {
- super.close();
- closed = true;
- }
-
- public boolean isClosed() {
- return closed;
- }
- }
-}
[2/2] stratos git commit: Messaging - Move initialized flag to
TopologyManager from Topology
Posted by ch...@apache.org.
Messaging - Move initialized flag to TopologyManager from Topology
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/a760c069
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/a760c069
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/a760c069
Branch: refs/heads/master
Commit: a760c0694ff23a9de65bd86e35628c7674c98f2d
Parents: 9770643
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 17:28:51 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 17:28:51 2015 +0530
----------------------------------------------------------------------
.../cartridge/agent/util/ExtensionUtils.java | 4 ++--
.../messaging/domain/topology/Topology.java | 19 +++----------------
...plicationClustersCreatedMessageProcessor.java | 3 ++-
...plicationClustersRemovedMessageProcessor.java | 3 ++-
.../topology/ClusterCreatedMessageProcessor.java | 3 ++-
.../ClusterInstanceActivatedProcessor.java | 3 ++-
.../ClusterInstanceCreatedMessageProcessor.java | 3 ++-
.../ClusterInstanceInactivateProcessor.java | 3 ++-
.../ClusterInstanceTerminatedProcessor.java | 3 ++-
.../ClusterInstanceTerminatingProcessor.java | 3 ++-
.../topology/ClusterRemovedMessageProcessor.java | 3 ++-
.../topology/ClusterResetMessageProcessor.java | 3 ++-
.../CompleteTopologyMessageProcessor.java | 5 +++--
.../MemberActivatedMessageProcessor.java | 3 ++-
.../topology/MemberCreatedMessageProcessor.java | 3 ++-
.../MemberInitializedMessageProcessor.java | 3 ++-
.../topology/MemberMaintenanceModeProcessor.java | 3 ++-
.../MemberReadyToShutdownMessageProcessor.java | 3 ++-
.../topology/MemberStartedMessageProcessor.java | 3 ++-
.../MemberSuspendedMessageProcessor.java | 3 ++-
.../MemberTerminatedMessageProcessor.java | 3 ++-
.../topology/ServiceCreatedMessageProcessor.java | 3 ++-
.../topology/ServiceRemovedMessageProcessor.java | 3 ++-
.../receiver/topology/TopologyManager.java | 10 ++++++++++
.../extension/FaultHandlingWindowProcessor.java | 2 +-
.../extension/FaultHandlingWindowProcessor.java | 2 +-
.../integration/common/TopologyHandler.java | 6 +++---
27 files changed, 63 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
index 66612e8..58c79e9 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
@@ -94,7 +94,7 @@ public class ExtensionUtils {
envParameters.put("STRATOS_LB_PUBLIC_IP", lbPublicIp);
Topology topology = TopologyManager.getTopology();
- if (topology.isInitialized()) {
+ if (TopologyManager.isInitialized()) {
Service service = topology.getService(CartridgeAgentConfiguration.getInstance().getServiceName());
Cluster cluster = service.getCluster(CartridgeAgentConfiguration.getInstance().getClusterId());
String memberIdInPayload = CartridgeAgentConfiguration.getInstance().getMemberId();
@@ -473,7 +473,7 @@ public class ExtensionUtils {
public static boolean isTopologyInitialized() {
TopologyManager.acquireReadLock();
- boolean active = TopologyManager.getTopology().isInitialized();
+ boolean active = TopologyManager.isInitialized();
TopologyManager.releaseReadLock();
return active;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index 9f641ec..94f9d83 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -19,8 +19,6 @@
package org.apache.stratos.messaging.domain.topology;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
import java.io.Serializable;
@@ -37,12 +35,9 @@ public class Topology implements Serializable {
// Key: Service.serviceName
private Map<String, Service> serviceMap;
- private boolean initialized;
- private static Log log = LogFactory.getLog(Topology.class);
-
public Topology() {
- this.serviceMap = new HashMap<String, Service>();
- this.clusterMap = new HashMap<String, Cluster>();
+ this.serviceMap = new HashMap<>();
+ this.clusterMap = new HashMap<>();
}
public Collection<Service> getServices() {
@@ -92,16 +87,8 @@ public class Topology implements Serializable {
this.clusterMap.clear();
}
- public void setInitialized(boolean initialized) {
- this.initialized = initialized;
- }
-
- public boolean isInitialized() {
- return initialized;
- }
-
@Override
public String toString() {
- return "Topology [serviceMap=" + serviceMap + ", initialized=" + initialized + "]";
+ return "Topology [serviceMap=" + serviceMap + "]";
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
index dcae73e..dc0e7ad 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java
@@ -29,6 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
import java.util.List;
@@ -50,7 +51,7 @@ public class ApplicationClustersCreatedMessageProcessor extends MessageProcessor
Topology topology = (Topology) object;
if (ApplicationClustersCreatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersRemovedMessageProcessor.java
index 6c7f45a..07e8134 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersRemovedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersRemovedMessageProcessor.java
@@ -27,6 +27,7 @@ import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ApplicationClustersRemovedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
import java.util.Set;
@@ -47,7 +48,7 @@ public class ApplicationClustersRemovedMessageProcessor extends MessageProcessor
Topology topology = (Topology) object;
if (ApplicationClustersRemovedEvent.class.getName().equals(type)) {
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
index 0e14bcd..2e5475f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java
@@ -29,6 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ClusterCreatedMessageProcessor extends MessageProcessor {
@@ -47,7 +48,7 @@ public class ClusterCreatedMessageProcessor extends MessageProcessor {
Topology topology = (Topology) object;
if (ClusterCreatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceActivatedProcessor.java
index a1448cb..0969f7c 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceActivatedProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
/**
@@ -52,7 +53,7 @@ public class ClusterInstanceActivatedProcessor extends MessageProcessor {
if (ClusterInstanceActivatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceCreatedMessageProcessor.java
index ae84a67..d8129e2 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceCreatedMessageProcessor.java
@@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ClusterInstanceCreatedMessageProcessor extends MessageProcessor {
@@ -48,7 +49,7 @@ public class ClusterInstanceCreatedMessageProcessor extends MessageProcessor {
Topology topology = (Topology) object;
if (ClusterInstanceCreatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
index c86efe3..42f1959 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceInactivateProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
/**
@@ -52,7 +53,7 @@ public class ClusterInstanceInactivateProcessor extends MessageProcessor {
if (ClusterInstanceInactivateEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatedProcessor.java
index e307bd8..f581705 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatedProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
/**
@@ -52,7 +53,7 @@ public class ClusterInstanceTerminatedProcessor extends MessageProcessor {
if (ClusterInstanceTerminatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatingProcessor.java
index 158d10f..bb3f921 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInstanceTerminatingProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
/**
@@ -52,7 +53,7 @@ public class ClusterInstanceTerminatingProcessor extends MessageProcessor {
if (ClusterInstanceTerminatingEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java
index f84cece..5099418 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java
@@ -29,6 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ClusterRemovedMessageProcessor extends MessageProcessor {
@@ -47,7 +48,7 @@ public class ClusterRemovedMessageProcessor extends MessageProcessor {
if (ClusterRemovedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
index dc94a2a..123bc1f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ClusterResetMessageProcessor extends MessageProcessor {
@@ -49,7 +50,7 @@ public class ClusterResetMessageProcessor extends MessageProcessor {
Topology topology = (Topology) object;
if (ClusterResetEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
index 6172654..c3d778a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
import java.util.ArrayList;
@@ -54,7 +55,7 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
// Parse complete message and build event
CompleteTopologyEvent event = (CompleteTopologyEvent) MessagingUtil.jsonToObject(message, CompleteTopologyEvent.class);
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
TopologyUpdater.acquireWriteLock();
try {
@@ -141,6 +142,6 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
}
// Set topology initialized
- topology.setInitialized(true);
+ TopologyManager.setInitialized(true);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java
index 6e1d9d8..d618575 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberActivatedMessageProcessor extends MessageProcessor {
@@ -46,7 +47,7 @@ public class MemberActivatedMessageProcessor extends MessageProcessor {
if (MemberActivatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberCreatedMessageProcessor.java
index d6bfd4d..4d52bc1 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberCreatedMessageProcessor.java
@@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilte
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberCreatedMessageProcessor extends MessageProcessor {
@@ -48,7 +49,7 @@ public class MemberCreatedMessageProcessor extends MessageProcessor {
if (MemberCreatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberInitializedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberInitializedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberInitializedMessageProcessor.java
index 82b0caa..e138341 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberInitializedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberInitializedMessageProcessor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberInitializedMessageProcessor extends MessageProcessor {
@@ -46,7 +47,7 @@ public class MemberInitializedMessageProcessor extends MessageProcessor {
if (MemberInitializedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java
index f0b53ff..f57806f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java
@@ -29,6 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberMaintenanceModeProcessor extends MessageProcessor {
@@ -46,7 +47,7 @@ public class MemberMaintenanceModeProcessor extends MessageProcessor {
if (MemberMaintenanceModeEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java
index 628123f..48525fa 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberReadyToShutdownMessageProcessor extends MessageProcessor {
@@ -45,7 +46,7 @@ public class MemberReadyToShutdownMessageProcessor extends MessageProcessor {
if (MemberReadyToShutdownEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java
index 990d337..6ea9b16 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberStartedMessageProcessor extends MessageProcessor {
@@ -46,7 +47,7 @@ public class MemberStartedMessageProcessor extends MessageProcessor {
if (MemberStartedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java
index a8b3ac9..5911876 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java
@@ -28,6 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberSuspendedMessageProcessor extends MessageProcessor {
@@ -46,7 +47,7 @@ public class MemberSuspendedMessageProcessor extends MessageProcessor {
if (MemberSuspendedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java
index ee33269..286fbcd 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java
@@ -31,6 +31,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class MemberTerminatedMessageProcessor extends MessageProcessor {
@@ -49,7 +50,7 @@ public class MemberTerminatedMessageProcessor extends MessageProcessor {
if (MemberTerminatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java
index 9460ea6..32a8858 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java
@@ -26,6 +26,7 @@ import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ServiceCreatedMessageProcessor extends MessageProcessor {
@@ -44,7 +45,7 @@ public class ServiceCreatedMessageProcessor extends MessageProcessor {
if (ServiceCreatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized()) {
+ if (!TopologyManager.isInitialized()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java
index 8fc3376..eea4e6d 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java
@@ -26,6 +26,7 @@ import org.apache.stratos.messaging.event.topology.ServiceRemovedEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.MessagingUtil;
public class ServiceRemovedMessageProcessor extends MessageProcessor {
@@ -44,7 +45,7 @@ public class ServiceRemovedMessageProcessor extends MessageProcessor {
if (ServiceRemovedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
- if (!topology.isInitialized())
+ if (!TopologyManager.isInitialized())
return false;
// Parse complete message and build event
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
index 7d38620..d7a3368 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
@@ -65,6 +65,8 @@ public class TopologyManager {
private static volatile TopologyLockHierarchy topologyLockHierarchy =
TopologyLockHierarchy.getInstance();
+ private static boolean initialized = false;
+
/**
* Acquires read lock for the Complete Topology
*/
@@ -221,4 +223,12 @@ public class TopologyManager {
}
return topology;
}
+
+ public static void setInitialized(boolean initialized){
+ TopologyManager.initialized = initialized;
+ }
+
+ public static boolean isInitialized(){
+ return TopologyManager.initialized;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/extensions/cep/modules/stratos-cep-extension/wso2cep-3.0.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
----------------------------------------------------------------------
diff --git a/extensions/cep/modules/stratos-cep-extension/wso2cep-3.0.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java b/extensions/cep/modules/stratos-cep-extension/wso2cep-3.0.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
index 0526f6a..8d16b33 100644
--- a/extensions/cep/modules/stratos-cep-extension/wso2cep-3.0.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
+++ b/extensions/cep/modules/stratos-cep-extension/wso2cep-3.0.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
@@ -176,7 +176,7 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
if (StringUtils.isEmpty(memberId)) {
return null;
}
- if (TopologyManager.getTopology().isInitialized()) {
+ if (TopologyManager.isInitialized()) {
try {
TopologyManager.acquireReadLock();
if (TopologyManager.getTopology().getServices() == null) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/extensions/cep/modules/stratos-cep-extension/wso2cep-3.1.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
----------------------------------------------------------------------
diff --git a/extensions/cep/modules/stratos-cep-extension/wso2cep-3.1.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java b/extensions/cep/modules/stratos-cep-extension/wso2cep-3.1.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
index 2fdce19..eb07dd9 100644
--- a/extensions/cep/modules/stratos-cep-extension/wso2cep-3.1.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
+++ b/extensions/cep/modules/stratos-cep-extension/wso2cep-3.1.0/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
@@ -170,7 +170,7 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
if (StringUtils.isEmpty(memberId)) {
return null;
}
- if (TopologyManager.getTopology().isInitialized()) {
+ if (TopologyManager.isInitialized()) {
try {
TopologyManager.acquireReadLock();
if (TopologyManager.getTopology().getServices() == null) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/a760c069/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
index a0cc928..3af9866 100644
--- a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/TopologyHandler.java
@@ -237,18 +237,18 @@ public class TopologyHandler {
private void assertTopologyInitialized() {
log.info(String.format("Asserting topology initialization within %d ms", TOPOLOGY_INIT_TIMEOUT));
long startTime = System.currentTimeMillis();
- while (!TopologyManager.getTopology().isInitialized()) {
+ while (!TopologyManager.isInitialized()) {
log.info("Waiting for topology to be initialized...");
sleep(1000);
if ((System.currentTimeMillis() - startTime) > TOPOLOGY_INIT_TIMEOUT) {
break;
}
}
- if (TopologyManager.getTopology().isInitialized()) {
+ if (TopologyManager.isInitialized()) {
log.info(String.format("Topology initialized under %d ms", (System.currentTimeMillis() - startTime)));
}
assertTrue(String.format("Topology didn't get initialized within %d ms", TOPOLOGY_INIT_TIMEOUT),
- TopologyManager.getTopology().isInitialized());
+ TopologyManager.isInitialized());
}
private void assertTenantInitialized() {