You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2014/10/15 10:32:12 UTC

[1/5] git commit: add mysql-python puppet changes

Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 961e58483 -> fde396a03


add mysql-python puppet changes


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

Branch: refs/heads/4.0.0-grouping
Commit: 82701ff975c47a4339315d6170859e2facb0557f
Parents: a456b4e
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Oct 13 09:03:07 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Oct 13 09:03:07 2014 +0530

----------------------------------------------------------------------
 tools/puppet3/modules/mysql/manifests/init.pp   | 10 +++
 .../mysql/templates/instance-activated.sh.erb   | 28 ++++++
 .../mysql/templates/instance-started.sh.erb     | 43 +++++++++
 .../templates/mysql_root_password_setter.sh.erb | 16 ++++
 .../mysql/templates/publish-metadata.py.erb     | 95 ++++++++++++++++++++
 5 files changed, 192 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/82701ff9/tools/puppet3/modules/mysql/manifests/init.pp
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/manifests/init.pp b/tools/puppet3/modules/mysql/manifests/init.pp
index 070862b..be6c77f 100644
--- a/tools/puppet3/modules/mysql/manifests/init.pp
+++ b/tools/puppet3/modules/mysql/manifests/init.pp
@@ -17,6 +17,14 @@
 
 class mysql{
 
+  require java
+
+  $custom_agent_templates = ['extensions/instance-started.sh','extensions/instance-activated.sh', 'extensions/publish-metadata.py', 'extensions/mysql_root_password_setter.sh']
+  class {'agent':
+    custom_templates => $custom_agent_templates,
+    module=>'mysql'
+  }
+
   if $stratos_mysql_password {
     $root_password = $stratos_mysql_password
   }
@@ -96,4 +104,6 @@ class mysql{
     require => File['/etc/apache2/sites-enabled/000-default'];
   }
 
+  # install stratos_base before java before mysql before agent
+  Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['mysql'] 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/82701ff9/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb b/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb
new file mode 100755
index 0000000..7bd6ef6
--- /dev/null
+++ b/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb
@@ -0,0 +1,28 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the instance is started.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance Activated Event: " | tee -a $log
+python publish-metadata.py

http://git-wip-us.apache.org/repos/asf/stratos/blob/82701ff9/tools/puppet3/modules/mysql/templates/instance-started.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/templates/instance-started.sh.erb b/tools/puppet3/modules/mysql/templates/instance-started.sh.erb
new file mode 100755
index 0000000..1babac5
--- /dev/null
+++ b/tools/puppet3/modules/mysql/templates/instance-started.sh.erb
@@ -0,0 +1,43 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the instance is started.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo `date`": Instance Started Event: " | tee -a $log
+
+export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin'
+
+PASSWD=`facter -p stratos_mysql_password`
+
+/etc/init.d/mysql start
+
+# Set mysql password
+mysqladmin -uroot password "$PASSWD"
+
+# Remove other users
+mysql -uroot -p"$PASSWD" -Bse "DELETE from mysql.user WHERE password=''"
+
+# Set root user with remote access
+mysql -uroot -p"$PASSWD" -Bse "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWD}'"
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/82701ff9/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb b/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb
new file mode 100755
index 0000000..427e31e
--- /dev/null
+++ b/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin'
+
+PASSWD=$1
+
+service mysql start
+echo $PASSWD> /tmp/udara
+# Set mysql password
+mysqladmin -uroot password "$PASSWD"
+
+# Remove other users
+mysql -uroot -p"$PASSWD" -Bse "DELETE from mysql.user WHERE password=''"
+
+# Set root user with remote access
+mysql -uroot -p"$PASSWD" -Bse "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWD}'"

http://git-wip-us.apache.org/repos/asf/stratos/blob/82701ff9/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb
----------------------------------------------------------------------
diff --git a/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb b/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb
new file mode 100755
index 0000000..2a4f734
--- /dev/null
+++ b/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb
@@ -0,0 +1,95 @@
+__author__ = 'udara'
+
+import urllib2
+from urllib2 import URLError, HTTPError
+import json
+import base64
+import logging
+import os,subprocess
+from subprocess import Popen, PIPE
+import random,string
+
+logging.basicConfig(filename='publish_metadata.log',level=logging.DEBUG,format='%(asctime)s: [%(levelname)s] %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
+
+def get_launch_param_file_location():
+    launch_params_file = os.path.abspath(os.path.dirname(__file__)).split("extensions")[0] + "payload/launch-params"
+    logging.debug("Launch param file location " + launch_params_file)
+    return launch_params_file
+
+def get_paylod_property(name):
+    logging.debug("[property  " + name + " = " + properties[name] + "]")
+    return properties[name]
+
+
+def get_metadataserviceurl():
+    return properties['METADATASERVICE_URL']
+
+def do_post(url, data):
+    req = urllib2.Request(url)
+    base64string = base64.encodestring('%s:%s' % ("admin", "admin")).replace('\n', '')
+    req.add_header("Authorization", "Basic %s" % base64string)
+    req.add_header('Content-Type', 'application/json')
+
+    try:
+        logging.info('sending to ' + url)
+        logging.info('sent data ' + json.dumps(data))
+        response = urllib2.urlopen(req, json.dumps(data))
+    except HTTPError as e:
+        logging.error('The server couldn\'t fulfill the request.')
+        logging.error('Error code .' + e.code)
+    except URLError as e:
+        print 'We failed to reach a server.'
+        logging.error('We failed to reach a server.')
+        logging.error('Reason: ' + e.reason)
+
+def generate_mysql_password(size=6, chars=string.ascii_uppercase + string.digits):
+    return ''.join(random.choice(chars) for _ in range(size))
+
+def set_mysql_password(password):
+    command = "./mysql_root_password_setter.sh " + password
+    logging.debug(" Setting mysql password [" + command + "]")
+    p = subprocess.Popen(command , stdout=PIPE, stderr=PIPE, shell=True)
+    stdout_data, stderr_data = p.communicate()
+    if p.returncode != 0:
+        logging.error(" failed, status code %s stdout %r stderr %r" % ( p.returncode, stdout_data, stderr_data))
+        raise RuntimeError(" failed, status code %s stdout %r stderr %r" % ( p.returncode, stdout_data, stderr_data))
+    print(stdout_data)
+
+param_file = get_launch_param_file_location()
+print param_file
+try:
+    metadata_file = open(param_file, "r")
+except IOError:
+    logging.error( 'Cannot open' + param_file)
+    raise RuntimeError("Could not open payload params, halting....")
+
+metadata_payload_content = metadata_file.read()
+logging.debug("Payload : " + metadata_payload_content)
+properties = {}
+for param in metadata_payload_content.split(","):
+    if param.strip() != "":
+        param_value = param.strip().split("=")
+        properties[param_value[0]] = param_value[1]
+
+logging.debug("Payload properties : ")
+logging.debug(properties)
+
+my_alias = get_paylod_property('CARTRIDGE_ALIAS')
+
+my_ip = urllib2.urlopen('http://ip.42.pl/raw').read()
+my_username = "root"
+my_password = generate_mysql_password()
+set_mysql_password(my_password)
+app_id= get_paylod_property('APP_ID')
+
+resource_url = get_metadataserviceurl()+ "/stratosmetadataservice/application/" + app_id + "/cluster/" + my_alias + "/property"
+data = {"key":"MYSQL_IP","values":my_ip}
+do_post(resource_url, data)
+data = {"key":"MYSQL_PASS","values":my_password}
+do_post(resource_url, data)
+
+data = {"key":"MYSQL_UNAME","values":my_username}
+do_post(resource_url, data)
+
+logging.info("************************")
+


[4/5] git commit: making transactionmanager singleton

Posted by ud...@apache.org.
making transactionmanager singleton


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

Branch: refs/heads/4.0.0-grouping
Commit: f5ae1b93df20ef78687a26aecd846117ae97f392
Parents: 7002c68
Author: Udara Liyanage <ud...@wso2.com>
Authored: Wed Oct 15 13:47:31 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Wed Oct 15 13:47:31 2014 +0530

----------------------------------------------------------------------
 .../client/DefaultMetaDataServiceClient.java    |  8 +++-
 .../metadata/client/rest/DefaultRestClient.java | 31 +++++--------
 .../client/rest/HTTPConnectionManager.java      | 47 ++++++++++++++++++++
 .../metadata/client/rest/RestClient.java        | 20 ++++++++-
 4 files changed, 83 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f5ae1b93/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
index 6c43915..d509533 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
@@ -22,6 +22,7 @@ package org.apache.stratos.metadata.client;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.metadata.client.beans.PropertyBean;
+import org.apache.stratos.metadata.client.config.MetaDataClientConfig;
 import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption;
 import org.apache.stratos.metadata.client.exception.RestClientException;
 import org.apache.stratos.metadata.client.rest.DefaultRestClient;
@@ -39,8 +40,11 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient {
     private final String baseUrl;
 
     public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException {
-        this.baseUrl = baseUrl;
-        this.restClient = new DefaultRestClient();
+        MetaDataClientConfig metaDataClientConfig = MetaDataClientConfig.getInstance();
+        this.baseUrl = metaDataClientConfig.getMetaDataServiceBaseUrl();
+        String username = metaDataClientConfig.getUsername();
+        String password = metaDataClientConfig.getPassword();
+        this.restClient = new DefaultRestClient(username, password);
     }
 
     public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient) throws RestClientException {

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5ae1b93/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
index 29f5415..b671219 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
@@ -29,14 +29,13 @@ import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.conn.ssl.SSLContextBuilder;
 import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.stratos.metadata.client.config.MetaDataClientConfig;
 import org.apache.stratos.metadata.client.exception.RestClientException;
 
@@ -48,16 +47,19 @@ import java.security.NoSuchAlgorithmException;
 
 public class DefaultRestClient implements RestClient {
 
-    private static final int MAX_TOTAL_CONNECTIONS = 100;
-    private static final int DEFAULT_MAX_PER_ROUTE = 20;
     private static final String APPLICATION_JSON = "application/json";
     private static final Log log = LogFactory.getLog(DefaultRestClient.class);
 
+    private final String username;
+    private final String password;
+
     private HttpClient httpClient;
 
-    public DefaultRestClient() throws RestClientException {
-        SSLContextBuilder builder = new SSLContextBuilder();
+    public DefaultRestClient(String username, String password) throws RestClientException {
+        this.username  =username;
+        this.password=password;
 
+        SSLContextBuilder builder = new SSLContextBuilder();
         SSLConnectionSocketFactory sslConnectionFactory;
         try {
             builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
@@ -69,20 +71,11 @@ public class DefaultRestClient implements RestClient {
         } catch (KeyStoreException e) {
             throw new RestClientException(e);
         }
-        CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory).setConnectionManager(getHttpConnectionManager()).build();
+        CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory)
+                .setConnectionManager(HTTPConnectionManager.getInstance().getHttpConnectionManager()).build();
         this.httpClient = closableHttpClient;
     }
 
-    private HttpClientConnectionManager getHttpConnectionManager() {
-        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
-        // TODO: Introduce configurable variable for Max total and max per router variables.
-        cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
-        cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
-        //HttpHost localhost = new HttpHost("locahost", 80);
-        //cm.setMaxPerRoute(new HttpRoute(localhost), 50);
-        return cm;
-    }
-
     public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException {
 
         HttpPost post = new HttpPost(resourcePath);
@@ -100,9 +93,7 @@ public class DefaultRestClient implements RestClient {
         }
     }
 
-    private void setAuthHeader(HttpPost post) {
-        String username = getUsername();
-        String password = getPassword();
+    private void setAuthHeader(HttpRequestBase post) {
         String identity = username + ":" + password;
         String encoding = new String(Base64.encodeBase64(identity.getBytes()));
         post.setHeader("Authorization", "Basic " + encoding);

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5ae1b93/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java
new file mode 100644
index 0000000..aadfa49
--- /dev/null
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT 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.metadata.client.rest;
+
+import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+
+public class HTTPConnectionManager {
+
+    private static final int MAX_TOTAL_CONNECTIONS = 100;
+    private static final int DEFAULT_MAX_PER_ROUTE = 20;
+
+    private static class InstanceHolder {
+        public static HTTPConnectionManager instance = new HTTPConnectionManager();
+    }
+
+    public static HTTPConnectionManager getInstance() {
+        return InstanceHolder.instance;
+    }
+
+    public HttpClientConnectionManager getHttpConnectionManager(){
+        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
+        // TODO: Introduce configurable variable for Max total and max per router variables.
+        cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
+        cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
+        //HttpHost localhost = new HttpHost("locahost", 80);
+        //cm.setMaxPerRoute(new HttpRoute(localhost), 50);
+        return cm;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5ae1b93/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
index 4c8fb6e..3189218 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
@@ -23,10 +23,28 @@ import org.apache.http.HttpResponse;
 import org.apache.stratos.metadata.client.exception.RestClientException;
 
 public interface RestClient {
-
+    /**
+     * Perform a HTTP POST request to @resourcePath with request body containing @payload converted to JSON.
+     * @param resourcePath Resource path to where is request is sent.
+     * @param payload request message body.
+     * @return Response of the request.
+     * @throws RestClientException
+     */
     public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException;
 
+    /**
+     * Perform a HTTP GET request to @resourcePath.
+     * @param resourcePath
+     * @return Response of the request.
+     * @throws RestClientException
+     */
     public HttpResponse doGet(String resourcePath) throws RestClientException;
 
+    /**
+     * Perform a HTTP DELETE request to @resourcePath.
+     * @param resourcePath
+     * @return Response of the request.
+     * @throws RestClientException
+     */
     public HttpResponse doDelete(String resourcePath) throws RestClientException;
 }


[2/5] git commit: Merge branch '4.0.0-grouping' of https://git-wip-us.apache.org/repos/asf/stratos into 4.0.0-grouping

Posted by ud...@apache.org.
Merge branch '4.0.0-grouping' of https://git-wip-us.apache.org/repos/asf/stratos into 4.0.0-grouping


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

Branch: refs/heads/4.0.0-grouping
Commit: 9075e87169ed7c3156acbc4bd25aeea57faae19c
Parents: 82701ff 67b281e
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Oct 13 11:53:39 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Oct 13 11:53:39 2014 +0530

----------------------------------------------------------------------
 .../grouping/dependency/DependencyBuilder.java  |  18 +-
 .../monitor/application/ApplicationMonitor.java |   6 +-
 .../autoscaler/monitor/group/GroupMonitor.java  |   6 +-
 .../status/checker/StatusChecker.java           |  62 +++++-
 .../application/parser/ParserUtils.java         |   4 +-
 .../CompositeApplicationParseTest.java          | 209 +++++++++++++++++++
 .../topology/GroupActivatedProcessor.java       |   4 +-
 7 files changed, 278 insertions(+), 31 deletions(-)
----------------------------------------------------------------------



[5/5] git commit: Merge branch '4.0.0-grouping' of https://git-wip-us.apache.org/repos/asf/stratos into 4.0.0-grouping

Posted by ud...@apache.org.
Merge branch '4.0.0-grouping' of https://git-wip-us.apache.org/repos/asf/stratos into 4.0.0-grouping


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

Branch: refs/heads/4.0.0-grouping
Commit: fde396a0327c7b75a59a528026bf76b2d90fef01
Parents: f5ae1b9 961e584
Author: Udara Liyanage <ud...@wso2.com>
Authored: Wed Oct 15 13:48:04 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Wed Oct 15 13:48:04 2014 +0530

----------------------------------------------------------------------
 .../status/checker/StatusChecker.java           | 61 ++++++-------
 .../CompositeApplicationParseTest.java          | 52 +++++++++++
 .../deployment_script.sh                        | 36 ++++++++
 .../m1-samples/ec2/autoscale-policy.json        | 14 +++
 .../m1-samples/ec2/deployment-policy.json       | 14 +++
 .../ec2/m1_single_subsciption_app.json          | 19 ++++
 .../m1-samples/ec2/p1.json                      | 10 +++
 .../m1-samples/ec2/php-cart.json                | 38 ++++++++
 .../m1-samples/os/autoscale-policy.json         | 14 +++
 .../m1-samples/os/deployment-policy.json        | 14 +++
 .../os/m1_single_subsciption_app.json           | 19 ++++
 .../m1-samples/os/p1.json                       | 10 +++
 .../m1-samples/os/php-cart.json                 | 46 ++++++++++
 .../samples/ec2/autoscale-policy 2.json         | 17 ++++
 .../samples/ec2/autoscale-policy.json           | 14 +++
 .../samples/ec2/deployment-policy 2.json        | 14 +++
 .../samples/ec2/deployment-policy.json          | 14 +++
 .../samples/ec2/group1.json                     |  9 ++
 .../samples/ec2/group2.json                     | 15 ++++
 .../samples/ec2/m1_single_subsciption_app.json  | 19 ++++
 .../samples/ec2/m2_single_subsciption_app.json  | 95 ++++++++++++++++++++
 .../samples/ec2/mysql.json                      | 33 +++++++
 .../samples/ec2/mytest.json                     | 33 +++++++
 .../samples/ec2/p1.json                         | 10 +++
 .../samples/ec2/php-cart.json                   | 38 ++++++++
 .../samples/ec2/tomcat.json                     | 33 +++++++
 .../samples/os/autoscale-policy.json            | 14 +++
 .../samples/os/deployment-policy.json           | 14 +++
 .../samples/os/m1_single_subsciption_app.json   | 19 ++++
 .../samples/os/p1.json                          | 10 +++
 .../samples/os/php-cart.json                    | 46 ++++++++++
 tools/test.json                                 |  0
 32 files changed, 764 insertions(+), 30 deletions(-)
----------------------------------------------------------------------



[3/5] git commit: refactor metadata client

Posted by ud...@apache.org.
refactor metadata client


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

Branch: refs/heads/4.0.0-grouping
Commit: 7002c68d52c078d4c384616080a8a2c7c1fbd4d5
Parents: 9075e87
Author: Udara Liyanage <ud...@wso2.com>
Authored: Wed Oct 15 08:25:48 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Wed Oct 15 08:25:48 2014 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.metadata.client/pom.xml  | 51 ++++++-----
 .../client/DefaultMetaDataServiceClient.java    | 35 ++------
 .../metadata/client/MetaDataServiceClient.java  | 25 +++---
 .../metadata/client/beans/PropertyBean.java     | 23 ++---
 .../client/config/MetaDataClientConfig.java     | 74 +++++-----------
 .../data/extractor/MetaDataExtractor.java       | 36 --------
 .../exception/MetaDataExtractorException.java   | 47 ----------
 .../factory/MetaDataExtractorFactory.java       | 51 -----------
 .../metadata/client/pojo/DataContext.java       | 88 -------------------
 .../metadata/client/rest/DefaultRestClient.java | 40 +++++----
 .../metadata/client/rest/RestClient.java        |  6 +-
 .../client/sample/DefaultMetaDataExtractor.java | 45 ----------
 .../sample/MetaDataServiceClientSample.java     | 92 --------------------
 .../client/util/MetaDataClientConstants.java    |  2 -
 14 files changed, 107 insertions(+), 508 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml
index fcafdaa..4f92ca7 100644
--- a/components/org.apache.stratos.metadata.client/pom.xml
+++ b/components/org.apache.stratos.metadata.client/pom.xml
@@ -1,5 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <parent>
         <groupId>org.apache.stratos</groupId>
@@ -7,32 +7,31 @@
         <version>4.1.0-SNAPSHOT</version>
     </parent>
 
-  <groupId>org.apache.stratos</groupId>
-  <artifactId>org.apache.stratos.metadata.client</artifactId>
-  <packaging>bundle</packaging>
-  <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.metadata.client</artifactId>
+    <packaging>bundle</packaging>
+    <modelVersion>4.0.0</modelVersion>
 
-  <name>Apache Stratos - Metadata Client</name>
+    <name>Apache Stratos - Metadata Client</name>
 
-  <dependencies>
-      <dependency>
-          <groupId>org.apache.httpcomponents</groupId>
-          <artifactId>httpclient</artifactId>
-          <version>4.3.5</version>
-          <scope>provided</scope>
-      </dependency>
-      <dependency>
-          <groupId>commons-configuration</groupId>
-          <artifactId>commons-configuration</artifactId>
-          <version>1.9</version>
-          <scope>provided</scope>
-      </dependency>
-      <dependency>
-          <groupId>com.google.code.gson</groupId>
-          <artifactId>gson</artifactId>
-          <version>2.2.4</version>
-      </dependency>
-  </dependencies>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.3.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+            <version>1.9</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.2.4</version>
+        </dependency>
+    </dependencies>
 
     <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
index d60dfb2..6c43915 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java
@@ -21,7 +21,6 @@ package org.apache.stratos.metadata.client;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
 import org.apache.stratos.metadata.client.beans.PropertyBean;
 import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption;
 import org.apache.stratos.metadata.client.exception.RestClientException;
@@ -34,14 +33,19 @@ import java.util.Set;
 
 public class DefaultMetaDataServiceClient implements MetaDataServiceClient {
 
-    private static Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class);
+    private static final Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class);
 
     private RestClient restClient;
-    private String baseUrl;
+    private final String baseUrl;
 
-    public DefaultMetaDataServiceClient (String baseUrl) throws RestClientException {
+    public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException {
         this.baseUrl = baseUrl;
-        restClient = new DefaultRestClient();
+        this.restClient = new DefaultRestClient();
+    }
+
+    public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient) throws RestClientException {
+        this.baseUrl = baseUrl;
+        this.restClient = restClient;
     }
 
     public void initialize() {
@@ -59,32 +63,11 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient {
         }
     }
 
-    public void addPropertyToApplication(String appId, String propertyKey, String propertyValue)
-            throws MetaDataServiceClientExeption {
-        String applicationPath = baseUrl.concat("application/").concat(appId).concat("/property");
-        PropertyBean property = new PropertyBean(propertyKey, propertyValue);
-        HttpResponse x;
-        try {
-            x = restClient.doPost(applicationPath, property);
-        } catch (RestClientException e) {
-            log.error(String.format("Error occurred while adding property %s", propertyKey));
-        }
-    }
-
-//    public void addPropertyToCluster(String appId, String propertyKey, String propertyValue)
-//            throws MetaDataServiceClientExeption {
-//        //To change body of implemented methods use File | Settings | File Templates.
-//    }
-
     public Map<String, Set<String>> getProperties(String appId, String clusterId)
             throws MetaDataServiceClientExeption {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-//    public Map<String, Set<String>> getProperties(String appId) throws MetaDataServiceClientExeption {
-//        return null;  //To change body of implemented methods use File | Settings | File Templates.
-//    }
-
     public Set<String> getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java
index fa89f96..01ea3e3 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java
@@ -28,22 +28,23 @@ public interface MetaDataServiceClient {
 
     /**
      * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient.
+     *
      * @throws MetaDataServiceClientExeption
      */
-    public void initialize ();
+    public void initialize();
 
     /**
      * Adds a property key value pair for the relevant cluster of the specified app
      *
-     * @param appId Application id
-     * @param clusterId Cluster id
-     * @param propertyKey Key of the Property
+     * @param appId         Application id
+     * @param clusterId     Cluster id
+     * @param propertyKey   Key of the Property
      * @param propertyValue Value of the Property
      * @throws MetaDataServiceClientExeption
      */
     public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption;
 
-//    /**
+    //    /**
 //     * Adds a property key value pair for the specified app
 //     *
 //     * @param appId Application id
@@ -61,9 +62,9 @@ public interface MetaDataServiceClient {
 //     * @return Map of Keys and Values for the specified cluster in the relevant app. Each key can have multiple Values.
 //     * @throws MetaDataServiceClientExeption
 //     */
-    public Map<String, Set<String>> getProperties (String appId, String clusterId) throws MetaDataServiceClientExeption;
+    public Map<String, Set<String>> getProperties(String appId, String clusterId) throws MetaDataServiceClientExeption;
 
-//    /**
+    //    /**
 //     * Retrieves the property key value pairs of the specified app
 //     *
 //     * @param appId Application id
@@ -80,23 +81,23 @@ public interface MetaDataServiceClient {
 //     * @return Set of Values for specified Key of the relevant app.
 //     * @throws MetaDataServiceClientExeption
 //     */
-    public Set<String> getProperty (String appId, String propertyKey) throws MetaDataServiceClientExeption;
+    public Set<String> getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption;
 
     /**
      * Retrieves the property values for the specified key of the relevant cluster and app
      *
-     * @param appId Application id
-     * @param clusterId Cluster id
+     * @param appId       Application id
+     * @param clusterId   Cluster id
      * @param propertyKey Key of the Property
      * @return Set of Values for specified Key of the relevant cluster in the relevant app.
      * @throws MetaDataServiceClientExeption
      */
-    public Set<String> getProperty (String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption;
+    public Set<String> getProperty(String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption;
 
     /**
      * Shutdown the MetaDataServiceClient. Should be called once after using the client.
      *
      * @throws MetaDataServiceClientExeption
      */
-    public void terminate () throws MetaDataServiceClientExeption;
+    public void terminate() throws MetaDataServiceClientExeption;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java
index dd2d777..7fae6a6 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java
@@ -24,14 +24,16 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-@XmlRootElement(name="properties")
+@XmlRootElement(name = "properties")
 public class PropertyBean {
     private String key;
     private List<String> values = new ArrayList<String>();
 
-    public PropertyBean(){}
-    public PropertyBean(String key, String value){
-        this.key=key;
+    public PropertyBean() {
+    }
+
+    public PropertyBean(String key, String value) {
+        this.key = key;
         this.values.add(value);
     }
 
@@ -43,22 +45,21 @@ public class PropertyBean {
         this.key = key;
     }
 
-    public String[] getValues(){
+    public String[] getValues() {
         String[] values = new String[this.values.size()];
         values = this.values.toArray(values);
         return values;
     }
 
-    public void setValues(String[] values) {
-        this.values.addAll(Arrays.asList(values));
-    }
-
-
     public void setValues(String value) {
         this.values.add(value);
     }
 
-    public void addValue(String value){
+    public void setValues(String[] values) {
+        this.values.addAll(Arrays.asList(values));
+    }
+
+    public void addValue(String value) {
         this.values.add(value);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
index 2596ca9..4324e5d 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java
@@ -21,35 +21,40 @@ package org.apache.stratos.metadata.client.config;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadata.client.sample.MetaDataServiceClientSample;
 import org.apache.stratos.metadata.client.util.MetaDataClientConstants;
 
-
 import java.io.File;
 
 public class MetaDataClientConfig {
 
-    private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class);
-
+    private static final Log log = LogFactory.getLog(MetaDataClientConfig.class);
+    private static volatile MetaDataClientConfig metaDataClientConfig;
     private String metaDataServiceBaseUrl;
-
-    private String dataExtractorClass;
-
     private String username;
-
     private String password;
-
     private XMLConfiguration config;
 
-    private static volatile MetaDataClientConfig metaDataClientConfig;
-
-    private MetaDataClientConfig () {
+    private MetaDataClientConfig() {
         readConfig();
     }
 
-    private void readConfig () throws RuntimeException{
+    public static MetaDataClientConfig getInstance() {
+
+        if (metaDataClientConfig == null) {
+            synchronized (MetaDataClientConfig.class) {
+                if (metaDataClientConfig == null) {
+                    metaDataClientConfig = new MetaDataClientConfig();
+                }
+            }
+        }
+
+        return metaDataClientConfig;
+    }
+
+    private void readConfig() throws RuntimeException {
 
         // the config file path is found from a system property
         String configFilePath = System.getProperty(MetaDataClientConstants.METADATA_CLIENT_CONFIG_FILE);
@@ -62,7 +67,7 @@ public class MetaDataClientConfig {
         metaDataServiceBaseUrl = config.getString(MetaDataClientConstants.METADATA_SERVICE_BASE_URL);
         if (metaDataServiceBaseUrl == null) {
             throw new RuntimeException("Unable to find metadata service base URL [ " +
-                    MetaDataClientConstants.METADATA_SERVICE_BASE_URL  + " ] in the config file");
+                    MetaDataClientConstants.METADATA_SERVICE_BASE_URL + " ] in the config file");
         }
 
         username = config.getString(MetaDataClientConstants.METADATA_SERVICE_USERNAME);
@@ -74,56 +79,25 @@ public class MetaDataClientConfig {
         if (password == null) {
             throw new RuntimeException("Meta data service password not defined in the configuration");
         }
-
-        dataExtractorClass = config.getString(MetaDataClientConstants.METADATA_CLIENT_DATA_EXTRACTOR_CLASS);
-        if (dataExtractorClass == null) {
-            if(log.isDebugEnabled()) {
-                log.debug("No custom Data Extractor class detected in the configuration");
-            }
-        }
     }
 
-    private void  loadConfig (String configFilePath) {
+    private void loadConfig(String configFilePath) {
 
+        if(StringUtils.isEmpty(configFilePath)){
+            throw new IllegalArgumentException("Confguration file path can not be null or empaty");
+        }
         try {
-
-            File confFile;
-            if (configFilePath != null && !configFilePath.isEmpty()) {
-                confFile = new File(configFilePath);
-
-            } else {
-                confFile = new File(configFilePath);
-            }
-
-            config = new XMLConfiguration(confFile);
-
+            config = new XMLConfiguration(new File(configFilePath));
         } catch (ConfigurationException e) {
             String errorMsg = "Unable to load configuration file at " + configFilePath;
             throw new RuntimeException(errorMsg);
         }
     }
 
-    public static MetaDataClientConfig getInstance () {
-
-        if (metaDataClientConfig == null) {
-            synchronized (MetaDataClientConfig.class) {
-                if (metaDataClientConfig == null) {
-                    metaDataClientConfig = new MetaDataClientConfig();
-                }
-            }
-        }
-
-        return metaDataClientConfig;
-    }
-
     public String getMetaDataServiceBaseUrl() {
         return metaDataServiceBaseUrl;
     }
 
-    public String getDataExtractorClass() {
-        return dataExtractorClass;
-    }
-
     public String getUsername() {
         return username;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java
deleted file mode 100644
index 13bc725..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java
+++ /dev/null
@@ -1,36 +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.metadata.client.data.extractor;
-
-import org.apache.stratos.metadata.client.exception.MetaDataExtractorException;
-import org.apache.stratos.metadata.client.pojo.DataContext;
-
-import java.util.Collection;
-
-public interface MetaDataExtractor {
-
-    public void initialize ();
-
-    public Collection<DataContext> getAllData (Object object) throws MetaDataExtractorException;
-
-    public DataContext getData (Object object) throws MetaDataExtractorException;
-
-    public void terminate () throws MetaDataExtractorException;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java
deleted file mode 100644
index c1273f5..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java
+++ /dev/null
@@ -1,47 +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.metadata.client.exception;
-
-public class MetaDataExtractorException extends Exception {
-
-    private String message;
-
-    public MetaDataExtractorException() {
-        super();
-    }
-
-    public MetaDataExtractorException(String message, Throwable cause) {
-        super(message, cause);
-        this.message = message;
-    }
-
-    public MetaDataExtractorException(String message) {
-        super(message);
-        this.message = message;
-    }
-
-    public MetaDataExtractorException(Throwable cause) {
-        super(cause);
-    }
-
-    public String getMessage() {
-        return message;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java
deleted file mode 100644
index 90d39d1..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java
+++ /dev/null
@@ -1,51 +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.metadata.client.factory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor;
-
-public class MetaDataExtractorFactory {
-
-    private static final Log log = LogFactory.getLog(MetaDataExtractorFactory.class);
-
-    public static MetaDataExtractor getMetaDataServiceClient (String clazzName) throws RuntimeException {
-
-        try {
-            return (MetaDataExtractor) MetaDataExtractor.class.getClassLoader().loadClass(clazzName).newInstance();
-
-        } catch (InstantiationException e) {
-            String errorMsg = "Unable to instatiate class " + clazzName;
-            log.error(errorMsg, e);
-            throw new RuntimeException(errorMsg, e);
-
-        } catch (IllegalAccessException e) {
-            String errorMsg = "Unable to instatiate class " + clazzName;
-            log.error(errorMsg, e);
-            throw new RuntimeException(errorMsg, e);
-
-        } catch (ClassNotFoundException e) {
-            String errorMsg = "Unable to instatiate class " + clazzName;
-            log.error(errorMsg, e);
-            throw new RuntimeException(errorMsg, e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java
deleted file mode 100644
index f5194c8..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java
+++ /dev/null
@@ -1,88 +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.metadata.client.pojo;
-
-import java.util.Set;
-
-public class DataContext {
-
-    private String appId;
-
-    private String clusterId;
-
-    private String propertyKey;
-
-    private Set<String> propertyValues;
-
-    private String propertyValue;
-
-
-    public DataContext (String appId, String propertyKey, Set<String> propertyValues) {
-
-        this.appId = appId;
-        this.propertyKey = propertyKey;
-        this.propertyValues = propertyValues;
-
-    }
-
-    public DataContext (String appId, String clusterId, String propertyKey, Set<String> propertyValues) {
-
-        this.appId = appId;
-        this.clusterId = clusterId;
-        this.propertyKey = propertyKey;
-        this.propertyValues = propertyValues;
-    }
-
-    public DataContext (String appId, String propertyKey, String propertyValue) {
-
-        this.appId = appId;
-        this.propertyKey = propertyKey;
-        this.propertyValue = propertyValue;
-    }
-
-    public DataContext (String appId, String clusterId, String propertyKey, String propertyValue) {
-
-        this.appId = appId;
-        this.clusterId = clusterId;
-        this.propertyKey = propertyKey;
-        this.propertyValue = propertyValue;
-    }
-
-    public String getAppId() {
-        return appId;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getPropertyKey() {
-        return propertyKey;
-    }
-
-    public Set<String> getPropertyValues() {
-        return propertyValues;
-    }
-
-    public String getPropertyValue() {
-        return propertyValue;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
index a6f0fb4..29f5415 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
@@ -48,34 +48,32 @@ import java.security.NoSuchAlgorithmException;
 
 public class DefaultRestClient implements RestClient {
 
+    private static final int MAX_TOTAL_CONNECTIONS = 100;
+    private static final int DEFAULT_MAX_PER_ROUTE = 20;
     private static final String APPLICATION_JSON = "application/json";
-    public static final int MAX_TOTAL_CONNECTIONS = 100;
-    public static final int DEFAULT_MAX_PER_ROUTE = 20;
-
-    private static Log log = LogFactory.getLog(DefaultRestClient.class);
+    private static final Log log = LogFactory.getLog(DefaultRestClient.class);
 
     private HttpClient httpClient;
 
-    public DefaultRestClient() throws  RestClientException{
+    public DefaultRestClient() throws RestClientException {
         SSLContextBuilder builder = new SSLContextBuilder();
 
-        SSLConnectionSocketFactory sslsf = null;
+        SSLConnectionSocketFactory sslConnectionFactory;
         try {
             builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
-            sslsf = new SSLConnectionSocketFactory(
-                    builder.build());
+            sslConnectionFactory = new SSLConnectionSocketFactory(builder.build());
         } catch (NoSuchAlgorithmException e) {
-            throw  new RestClientException(e);
+            throw new RestClientException(e);
         } catch (KeyManagementException e) {
-            throw  new RestClientException(e);
+            throw new RestClientException(e);
         } catch (KeyStoreException e) {
-            throw  new RestClientException(e);
+            throw new RestClientException(e);
         }
-        CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslsf).setConnectionManager(getHttpConnectionManager()).build();
+        CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory).setConnectionManager(getHttpConnectionManager()).build();
         this.httpClient = closableHttpClient;
     }
 
-    private HttpClientConnectionManager getHttpConnectionManager(){
+    private HttpClientConnectionManager getHttpConnectionManager() {
         PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
         // TODO: Introduce configurable variable for Max total and max per router variables.
         cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
@@ -97,7 +95,7 @@ public class DefaultRestClient implements RestClient {
             String errorMsg = "Error while executing POST statement";
             log.error(errorMsg, e);
             throw new RestClientException(errorMsg, e);
-        }finally {
+        } finally {
             post.releaseConnection();
         }
     }
@@ -105,7 +103,7 @@ public class DefaultRestClient implements RestClient {
     private void setAuthHeader(HttpPost post) {
         String username = getUsername();
         String password = getPassword();
-        String identity = username+":"+password;
+        String identity = username + ":" + password;
         String encoding = new String(Base64.encodeBase64(identity.getBytes()));
         post.setHeader("Authorization", "Basic " + encoding);
     }
@@ -122,7 +120,7 @@ public class DefaultRestClient implements RestClient {
         GsonBuilder gsonBuilder = new GsonBuilder();
         Gson gson = gsonBuilder.create();
 
-        String payloadText =  gson.toJson(payload, payload.getClass());
+        String payloadText = gson.toJson(payload, payload.getClass());
         addStringPayload(post, payloadText);
     }
 
@@ -137,7 +135,7 @@ public class DefaultRestClient implements RestClient {
             String errorMsg = "Error while executing GET statement";
             log.error(errorMsg, e);
             throw new RestClientException(errorMsg, e);
-        }finally {
+        } finally {
             get.releaseConnection();
         }
     }
@@ -153,20 +151,24 @@ public class DefaultRestClient implements RestClient {
             String errorMsg = "Error while executing DELETE statement";
             log.error(errorMsg, e);
             throw new RestClientException(errorMsg, e);
-        }finally {
+        } finally {
             delete.releaseConnection();
         }
     }
 
 
     private void addStringPayload(HttpPost post, String payloadText) {
+        if(org.apache.commons.lang.StringUtils.isEmpty(payloadText)){
+            throw new IllegalArgumentException("Payload text can not be null or empty");
+        }
         StringEntity stringEntity = null;
         try {
             stringEntity = new StringEntity(payloadText);
+            stringEntity.setContentType(APPLICATION_JSON);
         } catch (UnsupportedEncodingException e) {
             e.printStackTrace();
         }
-        stringEntity.setContentType(APPLICATION_JSON);
+
         post.setEntity(stringEntity);
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
index 5027735..4c8fb6e 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java
@@ -24,9 +24,9 @@ import org.apache.stratos.metadata.client.exception.RestClientException;
 
 public interface RestClient {
 
-    public HttpResponse doPost (String resourcePath, Object payload) throws RestClientException;
+    public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException;
 
-    public HttpResponse doGet (String resourcePath) throws RestClientException;
+    public HttpResponse doGet(String resourcePath) throws RestClientException;
 
-    public HttpResponse doDelete (String resourcePath) throws RestClientException;
+    public HttpResponse doDelete(String resourcePath) throws RestClientException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java
deleted file mode 100644
index 1594601..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java
+++ /dev/null
@@ -1,45 +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.metadata.client.sample;
-
-import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor;
-import org.apache.stratos.metadata.client.exception.MetaDataExtractorException;
-import org.apache.stratos.metadata.client.pojo.DataContext;
-
-import java.util.Collection;
-
-public class DefaultMetaDataExtractor implements MetaDataExtractor {
-
-    public void initialize() {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public Collection<DataContext> getAllData(Object object) throws MetaDataExtractorException {
-        return null;  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public DataContext getData(Object object) throws MetaDataExtractorException {
-        return null;  //To change body of implemented methods use File | Settings | File Templates.
-    }
-
-    public void terminate() throws MetaDataExtractorException {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java
deleted file mode 100644
index 6c0215d..0000000
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java
+++ /dev/null
@@ -1,92 +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.metadata.client.sample;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient;
-import org.apache.stratos.metadata.client.MetaDataServiceClient;
-import org.apache.stratos.metadata.client.config.MetaDataClientConfig;
-import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor;
-import org.apache.stratos.metadata.client.exception.MetaDataExtractorException;
-import org.apache.stratos.metadata.client.exception.RestClientException;
-import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory;
-import org.apache.stratos.metadata.client.pojo.DataContext;
-
-import java.util.Collection;
-
-public class MetaDataServiceClientSample {
-
-    private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class);
-
-    private MetaDataServiceClient metaDataServiceClient;
-
-    private MetaDataExtractor metaDataExtractor;
-
-    private MetaDataClientConfig metaDataClientConfig;
-
-
-    public MetaDataServiceClientSample() throws RestClientException {
-        //initialize();
-    }
-
-    private void initialize() throws RestClientException {
-
-        metaDataClientConfig = MetaDataClientConfig.getInstance();
-        metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig.
-                getMetaDataServiceBaseUrl());
-        metaDataServiceClient.initialize();
-
-        if (MetaDataClientConfig.getInstance().getDataExtractorClass() != null) {
-            metaDataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig.
-                getDataExtractorClass());
-            metaDataExtractor.initialize();
-        }
-    }
-
-    public Collection<DataContext> getAllData (Object someObj) {
-
-        Collection<DataContext> dataContexts = null;
-
-        try {
-            dataContexts = metaDataExtractor.getAllData(someObj);
-
-        } catch (MetaDataExtractorException e) {
-            log.error("Unable to get extracted data", e);
-        }
-
-        return dataContexts;
-    }
-
-    public DataContext getData (Object someObj) {
-
-        DataContext dataContext = null;
-
-        try {
-            dataContext = metaDataExtractor.getData(someObj);
-
-        } catch (MetaDataExtractorException e) {
-            log.error("Unable to get extracted data", e);
-        }
-
-        return dataContext;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/7002c68d/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java
index c027bed..5cd29fb 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java
@@ -29,6 +29,4 @@ public class MetaDataClientConstants {
 
     public static final String METADATA_SERVICE_PASSWORD = "metadataService.password";
 
-    public static final String METADATA_CLIENT_DATA_EXTRACTOR_CLASS = "metadataClient.dataExtractorClass";
-
 }