Repository: stratos Updated Branches: refs/heads/4.0.0-grouping d4a9a3b88 -> 24d47c29b
formating changes Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/24d47c29 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/24d47c29 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/24d47c29 Branch: refs/heads/4.0.0-grouping Commit: 24d47c29b54159fbb2b6ef6e5d86c660d2dd9a27 Parents: d4a9a3b Author: Udara Liyanage <[email protected]> Authored: Wed Oct 15 16:08:14 2014 +0530 Committer: Udara Liyanage <[email protected]> Committed: Wed Oct 15 16:08:14 2014 +0530 ---------------------------------------------------------------------- .../client/DefaultMetaDataServiceClient.java | 88 -------------- .../metadata/client/MetaDataServiceClient.java | 103 ---------------- .../client/config/MetaDataClientConfig.java | 4 +- .../defaults/DefaultMetaDataServiceClient.java | 120 +++++++++++++++++++ .../client/defaults/MetaDataServiceClient.java | 67 +++++++++++ .../MetaDataServiceClientException.java | 48 ++++++++ .../MetaDataServiceClientExeption.java | 48 -------- .../metadata/client/rest/DefaultRestClient.java | 6 +- .../client/rest/HTTPConnectionManager.java | 11 +- .../metadata/client/rest/RestClient.java | 9 +- 10 files changed, 253 insertions(+), 251 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 deleted file mode 100644 index d509533..0000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.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; - -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; -import org.apache.stratos.metadata.client.rest.RestClient; - -import java.util.Map; -import java.util.Set; - - -public class DefaultMetaDataServiceClient implements MetaDataServiceClient { - - private static final Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); - - private RestClient restClient; - private final String baseUrl; - - public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException { - 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 { - this.baseUrl = baseUrl; - this.restClient = restClient; - } - - public void initialize() { - // initialization, if any - } - - public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) - throws MetaDataServiceClientExeption { - String applicationPath = baseUrl.concat("application/").concat(appId).concat("/cluster/").concat(clusterId).concat("/property"); - PropertyBean property = new PropertyBean(propertyKey, propertyValue); - try { - restClient.doPost(applicationPath, property); - } catch (RestClientException e) { - log.error(String.format("Error occurred while adding property %s", propertyKey)); - } - } - - 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 Set<String> getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Set<String> getProperty(String appId, String clusterId, String propertyKey) - throws MetaDataServiceClientExeption { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - - public void terminate() throws MetaDataServiceClientExeption { - restClient = null; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 deleted file mode 100644 index 01ea3e3..0000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java +++ /dev/null @@ -1,103 +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; - -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; - -import java.util.Map; -import java.util.Set; - -public interface MetaDataServiceClient { - - /** - * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. - * - * @throws MetaDataServiceClientExeption - */ - 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 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 -// * @param propertyKey Key of the Property -// * @param propertyValue Value of the Property -// * @throws MetaDataServiceClientExeption -// */ -// public void addPropertyToCluster (String appId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; -// -// /** -// * Retrieves the property key value pairs for the relevant cluster of the specified app -// * -// * @param appId Application id -// * @param clusterId Cluster id -// * @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; - - // /** -// * Retrieves the property key value pairs of the specified app -// * -// * @param appId Application id -// * @return Map of Keys and Values for the specified app. Each key can have multiple Values. -// * @throws MetaDataServiceClientExeption -// */ -// public Map<String, Set<String>> getProperties (String appId) throws MetaDataServiceClientExeption; -// -// /** -// * Retrieves the property values for the specified key of the relevant app -// * -// * @param appId Application id -// * @param propertyKey Key of the Property -// * @return Set of Values for specified Key of the relevant app. -// * @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 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; - - /** - * Shutdown the MetaDataServiceClient. Should be called once after using the client. - * - * @throws MetaDataServiceClientExeption - */ - public void terminate() throws MetaDataServiceClientExeption; -} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 4324e5d..7b53147 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 @@ -83,8 +83,8 @@ public class MetaDataClientConfig { private void loadConfig(String configFilePath) { - if(StringUtils.isEmpty(configFilePath)){ - throw new IllegalArgumentException("Confguration file path can not be null or empaty"); + if (StringUtils.isEmpty(configFilePath)) { + throw new IllegalArgumentException("Configuration file path can not be null or empty"); } try { config = new XMLConfiguration(new File(configFilePath)); http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java new file mode 100644 index 0000000..a231789 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.defaults; + +import com.google.gson.Gson; +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.config.MetaDataClientConfig; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientException; +import org.apache.stratos.metadata.client.exception.RestClientException; +import org.apache.stratos.metadata.client.rest.DefaultRestClient; +import org.apache.stratos.metadata.client.rest.RestClient; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.List; + + +public class DefaultMetaDataServiceClient implements MetaDataServiceClient { + + private static final Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); + private final String baseUrl; + private RestClient restClient; + + public DefaultMetaDataServiceClient() throws RestClientException { + 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 { + this.baseUrl = baseUrl; + this.restClient = restClient; + } + + public void initialize() { + // initialization, if any + } + + public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) + throws MetaDataServiceClientException { + + StringBuilder applicationPath = new StringBuilder(baseUrl).append("application/").append(appId).append("/cluster/").append(clusterId).append("/property"); + + PropertyBean property = new PropertyBean(propertyKey, propertyValue); + try { + restClient.doPost(applicationPath.toString(), property); + } catch (RestClientException e) { + String message = "Error occurred while adding property " + property.getKey(); + log.error(message); + throw new MetaDataServiceClientException(message, e); + } + } + + public PropertyBean getProperty(String appId, String clusterId, String propertyName) throws MetaDataServiceClientException { + StringBuilder applicationPath = new StringBuilder(baseUrl). + append("application/").append(appId).append("/cluster/"). + append(clusterId).append("/property/").append(propertyName); + HttpResponse response; + try { + response = restClient.doGet(applicationPath.toString()); + } catch (RestClientException e) { + String message = "Error occurred while fetching property " + propertyName; + throw new MetaDataServiceClientException(message, e); + } + + String responseContent; + try { + responseContent = readResponseContent(response); + } catch (IOException e) { + throw new MetaDataServiceClientException("Error occurred while reading the response from metadata service", e); + } + Gson gson = new Gson(); + return gson.fromJson(responseContent, PropertyBean.class); + } + + private String readResponseContent(HttpResponse response) throws IOException { + + BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); + StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line).append("\n"); + } + + return builder.toString(); + } + + public List<PropertyBean> getProperties(String appId, String clusterId) + throws MetaDataServiceClientException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void terminate() { + log.info("Terminating the metadata client"); + restClient = null; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java new file mode 100644 index 0000000..d1a9e25 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.defaults; + +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientException; + +public interface MetaDataServiceClient { + + /** + * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. + */ + 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 propertyValue Value of the Property + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientException; + + /** + * Get all properties from metadata service. + * + * @param appId Application id + * @param clusterId Cluster id + * @return List of properties + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public java.util.List<org.apache.stratos.metadata.client.beans.PropertyBean> getProperties(String appId, String clusterId) throws MetaDataServiceClientException; + + /** + * Fetch a given property from metadata service. + * + * @param appId Application id + * @param clusterID Cluster Id + * @param propertyKey Name of the property + * @return property + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public org.apache.stratos.metadata.client.beans.PropertyBean getProperty(String appId, String clusterID, String propertyKey) throws MetaDataServiceClientException; + + /** + * Shutdown the MetaDataServiceClient. Should be called once after using the client. + */ + public void terminate(); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java new file mode 100644 index 0000000..b0f7599 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 MetaDataServiceClientException extends Exception { + + private String message; + + public MetaDataServiceClientException() { + super(); + } + + public MetaDataServiceClientException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public MetaDataServiceClientException(String message) { + super(message); + this.message = message; + } + + public MetaDataServiceClientException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java deleted file mode 100644 index 8ef5e37..0000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java +++ /dev/null @@ -1,48 +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 MetaDataServiceClientExeption extends Exception { - - private String message; - - public MetaDataServiceClientExeption() { - super(); - } - - public MetaDataServiceClientExeption(String message, Throwable cause) { - super(message, cause); - this.message = message; - } - - public MetaDataServiceClientExeption(String message) { - super(message); - this.message = message; - } - - public MetaDataServiceClientExeption(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 b671219..e6279d7 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 @@ -56,8 +56,8 @@ public class DefaultRestClient implements RestClient { private HttpClient httpClient; public DefaultRestClient(String username, String password) throws RestClientException { - this.username =username; - this.password=password; + this.username = username; + this.password = password; SSLContextBuilder builder = new SSLContextBuilder(); SSLConnectionSocketFactory sslConnectionFactory; @@ -149,7 +149,7 @@ public class DefaultRestClient implements RestClient { private void addStringPayload(HttpPost post, String payloadText) { - if(org.apache.commons.lang.StringUtils.isEmpty(payloadText)){ + if (org.apache.commons.lang.StringUtils.isEmpty(payloadText)) { throw new IllegalArgumentException("Payload text can not be null or empty"); } StringEntity stringEntity = null; http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 index aadfa49..f6f0093 100644 --- 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 @@ -26,22 +26,25 @@ 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(); + private HTTPConnectionManager() { } public static HTTPConnectionManager getInstance() { return InstanceHolder.instance; } - public HttpClientConnectionManager getHttpConnectionManager(){ + 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); + //HttpHost localhost = new HttpHost("localhost", 80); //cm.setMaxPerRoute(new HttpRoute(localhost), 50); return cm; } + private static class InstanceHolder { + public static HTTPConnectionManager instance = new HTTPConnectionManager(); + } + } http://git-wip-us.apache.org/repos/asf/stratos/blob/24d47c29/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 3189218..e6b01c2 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 @@ -25,8 +25,9 @@ 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. + * @param payload request message body. * @return Response of the request. * @throws RestClientException */ @@ -34,7 +35,8 @@ public interface RestClient { /** * Perform a HTTP GET request to @resourcePath. - * @param resourcePath + * + * @param resourcePath Resource path to where is request is sent. * @return Response of the request. * @throws RestClientException */ @@ -42,7 +44,8 @@ public interface RestClient { /** * Perform a HTTP DELETE request to @resourcePath. - * @param resourcePath + * + * @param resourcePath Resource path to where is request is sent. * @return Response of the request. * @throws RestClientException */
