From bb62ba0be4f07628f7bccf320f1f4d035e463cef Mon Sep 17 00:00:00 2001 From: gayan Date: Tue, 11 Nov 2014 12:47:21 +0530 Subject: [PATCH 1/3] Refactor code with reformatting --- .../registry/CarbonRegistry.java | 311 +++++++++--------- .../metadataservice/registry/DataStore.java | 15 +- .../registry/GRegRegistry.java | 161 +++++---- .../services/MetaDataAdmin.java | 297 +++++++++-------- .../metadataservice/util/ConfUtil.java | 13 +- 5 files changed, 425 insertions(+), 372 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java index 89250b33b4..cd76b9e2d3 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java @@ -31,162 +31,171 @@ import javax.ws.rs.core.Context; import java.util.*; - /** * Carbon registry implementation */ public class CarbonRegistry extends AbstractAdmin implements DataStore { - private static Log log = LogFactory.getLog(CarbonRegistry.class); - @Context - HttpServletRequest httpServletRequest; - - private static final String mainResource = "/stratos/"; - - - public CarbonRegistry() { - - } - - - /** - * Get Properties of clustor - * @param applicationName - * @param clusterId - * @return - * @throws RegistryException - */ - public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationName + "/" + clusterId; - if (!tempRegistry.resourceExists(resourcePath)) { - return null; - //throw new RegistryException("Cluster does not exist at " + resourcePath); - } - Resource regResource = tempRegistry.get(resourcePath); - - ArrayList newProperties = new ArrayList(); - - Properties props = regResource.getProperties(); - Enumeration x = props.propertyNames(); - while (x.hasMoreElements()) { - String key = (String) x.nextElement(); - List values = regResource.getPropertyValues(key); - NewProperty property = new NewProperty(); - property.setKey(key); - String[] valueArr = new String[values.size()]; - property.setValues(values.toArray(valueArr)); - - newProperties.add(property); - } - - return newProperties; - } - - /** - * Add property to cluster - * @param applicationId - * @param clusterId - * @param property - * @throws RegistryException - */ - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationId + "/" + clusterId; - Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); - - regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); - tempRegistry.put(resourcePath, regResource); - log.info(String.format("Property %s is added to cluster %s of application %s", property.getKey(), clusterId, applicationId)); - - } - - /** - * Delete the resource identified by the applicationId, if exist. - * @param applicationId ID of the application. - * @return True if resource exist and able to delete, else false. - * @throws RegistryException - */ - public boolean deleteApplication(String applicationId) throws RegistryException { - if(StringUtils.isEmpty(applicationId)){ - throw new IllegalArgumentException("Application ID can not be null"); - } - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationId; - - if(tempRegistry.resourceExists(resourcePath)){ - tempRegistry.delete(resourcePath); - log.info(String.format("Application removed from registry %s", applicationId)); - return true; - } - - return false; - } - - /** - * Add properties to cluster - * @param applicationName - * @param clusterId - * @param properties - * @throws RegistryException - */ - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationName + "/" + clusterId; - Resource regResource; - regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); - - for (NewProperty property : properties) { - regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); - - } - tempRegistry.put(resourcePath, regResource); - log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName)); - } - - /** - * Create or get resource for application - * @param tempRegistry - * @param resourcePath - * @return - * @throws RegistryException - */ - private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException { - Resource regResource; - if (tempRegistry.resourceExists(resourcePath)) { - regResource = tempRegistry.get(resourcePath); - } else { - regResource = tempRegistry.newCollection(); - if (log.isDebugEnabled()) { - log.debug("Registry resource is create at path " + regResource.getPath() + " for application"); - } - } - return regResource; - } - - /** - * Create and get resources for Clustor - * @param tempRegistry - * @param resourcePath - * @return - * @throws RegistryException - */ - private Resource createOrGetResourceforCluster(Registry tempRegistry, String resourcePath) throws RegistryException { - - int index = resourcePath.lastIndexOf('/'); - String applicationResourcePath = resourcePath.substring(0, index); - createOrGetResourceforApplication(tempRegistry, applicationResourcePath); - Resource regResource; - if (tempRegistry.resourceExists(resourcePath)) { - regResource = tempRegistry.get(resourcePath); - } else { - regResource = tempRegistry.newResource(); - if (log.isDebugEnabled()) { - log.debug("Registry resource is create at path for cluster" + regResource.getPath() + " for cluster"); - } - } - return regResource; - } + private static Log log = LogFactory.getLog(CarbonRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static final String mainResource = "/stratos/"; + + public CarbonRegistry() { + + } + + /** + * Get Properties of clustor + * + * @param applicationName ID of the application. + * @param clusterId Cluster ID + * @return + * @throws RegistryException + */ + public List getPropertiesOfCluster(String applicationName, + String clusterId) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + if (!tempRegistry.resourceExists(resourcePath)) { + return null; + //throw new RegistryException("Cluster does not exist at " + resourcePath); + } + Resource regResource = tempRegistry.get(resourcePath); + + ArrayList newProperties = new ArrayList(); + + Properties props = regResource.getProperties(); + Enumeration x = props.propertyNames(); + while (x.hasMoreElements()) { + String key = (String) x.nextElement(); + List values = regResource.getPropertyValues(key); + NewProperty property = new NewProperty(); + property.setKey(key); + String[] valueArr = new String[values.size()]; + property.setValues(values.toArray(valueArr)); + + newProperties.add(property); + } + + return newProperties; + } + + /** + * Add property to cluster + * + * @param applicationId ID of the application. + * @param clusterId Cluster ID + * @param property Propertys + * @throws RegistryException + */ + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId + "/" + clusterId; + Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + + regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); + tempRegistry.put(resourcePath, regResource); + log.info(String.format("Property %s is added to cluster %s of application %s", property.getKey(), clusterId, + applicationId)); + + } + + /** + * Delete the resource identified by the applicationId, if exist. + * + * @param applicationId ID of the application. + * @return True if resource exist and able to delete, else false. + * @throws RegistryException + */ + public boolean deleteApplication(String applicationId) throws RegistryException { + if (StringUtils.isEmpty(applicationId)) { + throw new IllegalArgumentException("Application ID can not be null"); + } + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + + if (tempRegistry.resourceExists(resourcePath)) { + tempRegistry.delete(resourcePath); + log.info(String.format("Application removed from registry %s", applicationId)); + return true; + } + + return false; + } + + /** + * Add properties to cluster + * + * @param applicationName Name of the application + * @param clusterId Cluster id of the application + * @param properties Properties of the application + * @throws RegistryException + */ + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + Resource regResource; + regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + + for (NewProperty property : properties) { + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + + } + tempRegistry.put(resourcePath, regResource); + log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName)); + } + + /** + * Create or get resource for application + * + * @param tempRegistry Temp registry + * @param resourcePath Resource path + * @return Resource + * @throws RegistryException + */ + private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) + throws RegistryException { + Resource regResource; + if (tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + } else { + regResource = tempRegistry.newCollection(); + if (log.isDebugEnabled()) { + log.debug("Registry resource is create at path " + regResource.getPath() + " for application"); + } + } + return regResource; + } + + /** + * Create and get resources for Clustor + * + * @param tempRegistry Temp registry + * @param resourcePath Resource path + * @return + * @throws RegistryException + */ + private Resource createOrGetResourceforCluster(Registry tempRegistry, String resourcePath) + throws RegistryException { + + int index = resourcePath.lastIndexOf('/'); + String applicationResourcePath = resourcePath.substring(0, index); + createOrGetResourceforApplication(tempRegistry, applicationResourcePath); + Resource regResource; + if (tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + } else { + regResource = tempRegistry.newResource(); + if (log.isDebugEnabled()) { + log.debug("Registry resource is create at path for cluster" + regResource.getPath() + " for cluster"); + } + } + return regResource; + } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index 33f322956b..eb4a53ec6e 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.metadataservice.registry; - import org.apache.stratos.metadataservice.definition.NewProperty; import org.wso2.carbon.registry.api.RegistryException; @@ -29,12 +28,14 @@ */ public interface DataStore { - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) - throws RegistryException; - public List getPropertiesOfCluster(String applicationName, String clusterId) - throws RegistryException; + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + throws RegistryException; + + public List getPropertiesOfCluster(String applicationName, String clusterId) + throws RegistryException; - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + throws RegistryException; - public boolean deleteApplication(String applicationId) throws RegistryException; + public boolean deleteApplication(String applicationId) throws RegistryException; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index c2ba22e241..8e14f30c2c 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -39,71 +39,100 @@ */ public class GRegRegistry implements DataStore { - - private static Log log = LogFactory.getLog(GRegRegistry.class); - @Context - HttpServletRequest httpServletRequest; - - private static ConfigurationContext configContext; - - static { - configContext = null; - } - - private static final String defaultUsername = "admin@org.com"; - private static final String defaultPassword = "admin123"; - private static final String serverURL = "https://localhost:9445/services/"; - private static final String mainResource = "/startos/"; - private static final int defaultRank = 3; - - /* - * Registry initiation - */ - private static WSRegistryServiceClient setRegistry() throws Exception { - - XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); - - String gregUsername = conf.getString("metadataservice.username", defaultUsername); - String gregPassword = conf.getString("metadataservice.password", defaultPassword); - String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); - String defaultAxis2Repo = "repository/deployment/client"; - String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); - String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; - String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); - String defaultTrustStore = - "repository" + File.separator + "resources" + File.separator + - "security" + File.separator + "wso2carbon.jks"; - String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); - String trustStorePassword = - conf.getString("metadataservice.trustStorePassword", - "wso2carbon"); - String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); - - System.setProperty("javax.net.ssl.trustStore", trustStorePath); - System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" - System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" - System.setProperty("carbon.repo.write.mode", "true"); - configContext = - ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, - axis2Conf); - return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); - } - - - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { - - } - - public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { - return null; - } - - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { - - } - - public boolean deleteApplication(String applicationId) { - return false; - } + private static Log log = LogFactory.getLog(GRegRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext; + + static { + configContext = null; + } + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; + + /* + * Registry initiation + */ + private static WSRegistryServiceClient setRegistry() throws Exception { + + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + + String gregUsername = conf.getString("metadataservice.username", defaultUsername); + String gregPassword = conf.getString("metadataservice.password", defaultPassword); + String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); + String defaultAxis2Repo = "repository/deployment/client"; + String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); + String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); + String defaultTrustStore = + "repository" + File.separator + "resources" + File.separator + + "security" + File.separator + "wso2carbon.jks"; + String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); + String trustStorePassword = + conf.getString("metadataservice.trustStorePassword", + "wso2carbon"); + String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); + + System.setProperty("javax.net.ssl.trustStore", trustStorePath); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" + System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" + System.setProperty("carbon.repo.write.mode", "true"); + configContext = + ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, + axis2Conf); + return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); + } + + /** + * + * @param applicationName Name of the application + * @param clusterId Cluster ID + * @param properties Properties + * @throws RegistryException + */ + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + throws RegistryException { + //TODO : Implemenattion related to the GREG + } + + /** + * + * @param applicationName Name of the application + * @param clusterId Cluster ID + * @return List of properties + * @throws RegistryException + */ + public List getPropertiesOfCluster(String applicationName, + String clusterId) throws RegistryException { + //TODO : Implemenattion related to the GREG + return null; + } + + /** + * + * @param applicationId ID of the application + * @param clusterId ID of the clustor + * @param property property + * @throws RegistryException + */ + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + throws RegistryException { + //TODO : Implemenattion related to the GREG + } + + /** + * + * @param applicationId ID of the application + * @return + */ + public boolean deleteApplication(String applicationId) { + //TODO : Implemenattion related to the GREG + return false; + } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index e88bc2acdd..7d6c1ca2e6 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -39,150 +39,157 @@ @Path("/") public class MetaDataAdmin { - @Context - UriInfo uriInfo; - - private static Log log = LogFactory.getLog(MetaDataAdmin.class); - @Context - HttpServletRequest httpServletRequest; - - - private DataStore registry; - - /** - * Meta data admin configuration loading - */ - public MetaDataAdmin(){ - XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); - String DEFAULT_REG_TYPE = "carbon"; - String registryType = conf.getString("metadataservice.govenanceregistrytype", DEFAULT_REG_TYPE); - registry = DataRegistryFactory.getDataRegistryFactory(registryType); - } - - @GET - @Path("/application/{application_id}/cluster/{cluster_id}/properties") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ - - List properties; - NewProperty[] propertiesArr = null; - try { - properties = registry - .getPropertiesOfCluster(applicationId, clusterId); - if (properties != null) { - propertiesArr = new NewProperty[properties.size()]; - propertiesArr = properties.toArray(propertiesArr); - } - } catch (Exception e) { - log.error("Error occurred while getting properties ", e); - } - - Response.ResponseBuilder rb; - if (propertiesArr == null) { - rb = Response.status(Response.Status.NOT_FOUND); - } else { - rb = Response.ok().entity(propertiesArr); - } - return rb.build(); - } - - @GET - @Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - - public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName){ - List properties; - - - NewProperty property = null; - - try { - properties = registry - .getPropertiesOfCluster(applicationId, clusterId); - if (properties == null) { - return Response.status(Response.Status.NOT_FOUND).build(); - } - for (NewProperty p : properties) { - if (propertyName.equals(p.getKey())) { - property = p; - break; - } - } - } catch (Exception e) { - log.error("Error occurred while getting property ", e); - } - - Response.ResponseBuilder rb; - if (property == null) { - rb = Response.status(Response.Status.NOT_FOUND); - } else { - rb = Response.ok().entity(property); - } - return rb.build(); - } - - @POST - @Path("application/{application_id}/cluster/{cluster_id}/property") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addPropertyToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) - throws RestAPIException { - - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); - - try { - registry.addPropertyToCluster(applicationId, clusterId, property); - } catch (RegistryException e) { - log.error("Error occurred while adding property", e); - } - - return Response.created(url).build(); - } - - @POST - @Path("application/{application_id}/cluster/{cluster_id}/properties") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty[] properties) - throws RestAPIException { - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); - - try { - registry.addPropertiesToCluster(applicationId, clusterId, properties); - } catch (Exception e) { - log.error("Error occurred while adding properties ", e); - } - - return Response.created(url).build(); - } - - @DELETE - @Path("application/{application_id}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response deleteApplicationProperties(@PathParam("application_id") String applicationId) - throws RestAPIException { - - try { - boolean deleted = registry.deleteApplication(applicationId); - if(!deleted){ - log.warn(String.format("Either no metadata is associated with given appId %s Or resources could not be deleted", applicationId)); - } - } catch (RegistryException e) { - String msg= "Resource attached with appId could not be deleted"; - log.error(msg, e); - throw new RestAPIException(" ", e); - } - - return Response.ok().build(); - } - + @Context + UriInfo uriInfo; + + private static Log log = LogFactory.getLog(MetaDataAdmin.class); + @Context + HttpServletRequest httpServletRequest; + + private DataStore registry; + + /** + * Meta data admin configuration loading + */ + public MetaDataAdmin() { + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + String KEY = "metadataservice.govenanceregistrytype"; + String DEFAULT_REG_TYPE = "carbon"; + String registryType = conf.getString(KEY, DEFAULT_REG_TYPE); + registry = DataRegistryFactory.getDataRegistryFactory(registryType); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperties(@PathParam("application_id") String applicationId, + @PathParam("cluster_id") String clusterId) { + + List properties; + NewProperty[] propertiesArr = null; + try { + properties = registry.getPropertiesOfCluster(applicationId, clusterId); + if (properties != null) { + propertiesArr = new NewProperty[properties.size()]; + propertiesArr = properties.toArray(propertiesArr); + } + } catch (Exception e) { + log.error("Error occurred while getting properties ", e); + } + + Response.ResponseBuilder rb; + if (propertiesArr == null) { + rb = Response.status(Response.Status.NOT_FOUND); + } else { + rb = Response.ok().entity(propertiesArr); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + + public Response getClusterProperty(@PathParam("application_id") String applicationId, + @PathParam("cluster_id") String clusterId, + @PathParam("property_name") String propertyName) { + + List properties; + NewProperty property = null; + + try { + properties = registry.getPropertiesOfCluster(applicationId, clusterId); + if (properties == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + for (NewProperty p : properties) { + if (propertyName.equals(p.getKey())) { + property = p; + break; + } + } + } catch (Exception e) { + log.error("Error occurred while getting property ", e); + } + + Response.ResponseBuilder rb; + if (property == null) { + rb = Response.status(Response.Status.NOT_FOUND); + } else { + rb = Response.ok().entity(property); + } + return rb.build(); + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/property") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertyToACluster(@PathParam("application_id") String applicationId, + @PathParam("cluster_id") String clusterId, + NewProperty property) + throws RestAPIException { + + URI url = uriInfo.getAbsolutePathBuilder() + .path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); + + try { + registry.addPropertyToCluster(applicationId, clusterId, property); + } catch (RegistryException e) { + log.error("Error occurred while adding property", e); + } + + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, + @PathParam("cluster_id") String clusterId, + NewProperty[] properties) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); + + try { + registry.addPropertiesToCluster(applicationId, clusterId, properties); + } catch (Exception e) { + log.error("Error occurred while adding properties ", e); + } + + return Response.created(url).build(); + } + + @DELETE + @Path("application/{application_id}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response deleteApplicationProperties(@PathParam("application_id") String applicationId) + throws RestAPIException { + + try { + boolean deleted = registry.deleteApplication(applicationId); + if (!deleted) { + log.warn(String.format( + "Either no metadata is associated with given appId %s Or resources could " + + "not be deleted", + applicationId)); + } + } catch (RegistryException e) { + String msg = "Resource attached with appId could not be deleted"; + log.error(msg, e); + throw new RestAPIException(" ", e); + } + + return Response.ok().build(); + } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java index b6d4ce059a..4904fe734d 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -41,7 +41,7 @@ public class ConfUtil { private static ConfUtil instance = null; private ConfUtil(String configFilePath) { - log.debug("Loading configuration....."); + log.debug("Loading configuration....."); try { @@ -51,8 +51,8 @@ private ConfUtil(String configFilePath) { } else { confFile = - new File(CarbonUtils.getCarbonConfigDirPath(), - Constants.METADATASERVICE_CONFIG_FILE_NAME); + new File(CarbonUtils.getCarbonConfigDirPath(), + Constants.METADATASERVICE_CONFIG_FILE_NAME); } config = new XMLConfiguration(confFile); @@ -62,6 +62,10 @@ private ConfUtil(String configFilePath) { } } + /** + * @param configFilePath Config File Path + * @return + */ public static ConfUtil getInstance(String configFilePath) { if (instance == null) { instance = new ConfUtil(configFilePath); @@ -69,6 +73,9 @@ public static ConfUtil getInstance(String configFilePath) { return instance; } + /** + * @return XML configurations + */ public XMLConfiguration getConfiguration() { return config; } From 10efa0534abeed00e2b0c20a98dd03c2beb14c97 Mon Sep 17 00:00:00 2001 From: gayan Date: Thu, 13 Nov 2014 12:40:11 +0530 Subject: [PATCH 2/3] Refactor NewProperty class to MetaDataProperty --- .../definition/ClusterBean.java | 12 ++++++------ ...{NewProperty.java => MetaDataProperty.java} | 8 +++----- .../registry/CarbonRegistry.java | 14 +++++++------- .../metadataservice/registry/DataStore.java | 8 ++++---- .../metadataservice/registry/GRegRegistry.java | 8 ++++---- .../services/MetaDataAdmin.java | 18 +++++++++--------- 6 files changed, 33 insertions(+), 35 deletions(-) rename components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/{NewProperty.java => MetaDataProperty.java} (88%) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java index 5c5187af81..424658170b 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java @@ -26,15 +26,15 @@ public class ClusterBean { private String clusterId; - private List properties; + private List properties; public ClusterBean(){ - this.setProperties(new ArrayList()); + this.setProperties(new ArrayList()); } public ClusterBean(String id){ this.setClusterId(id); - this.setProperties(new ArrayList()); + this.setProperties(new ArrayList()); } public String getClusterId() { @@ -45,15 +45,15 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } - public List getProperties() { + public List getProperties() { return properties; } - public void setProperties(List properties) { + public void setProperties(List properties) { this.properties = properties; } - public void addProperty(NewProperty property){ + public void addProperty(MetaDataProperty property){ this.properties.add(property); } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/MetaDataProperty.java similarity index 88% rename from components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java rename to components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/MetaDataProperty.java index 552d29f791..fef453d234 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/MetaDataProperty.java @@ -19,8 +19,6 @@ package org.apache.stratos.metadataservice.definition; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.ArrayList; @@ -28,13 +26,13 @@ import java.util.List; @XmlRootElement(name="properties") -public class NewProperty implements Serializable{ +public class MetaDataProperty implements Serializable{ private String key; private List values = new ArrayList(); - public NewProperty(){} - public NewProperty(String key, String value){ + public MetaDataProperty(){} + public MetaDataProperty(String key, String value){ this.key=key; this.values.add(value); } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java index cd76b9e2d3..f6d9459332 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java @@ -21,7 +21,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.NewProperty; +import org.apache.stratos.metadataservice.definition.MetaDataProperty; import org.wso2.carbon.core.AbstractAdmin; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; @@ -55,7 +55,7 @@ public CarbonRegistry() { * @return * @throws RegistryException */ - public List getPropertiesOfCluster(String applicationName, + public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; @@ -65,14 +65,14 @@ public List getPropertiesOfCluster(String applicationName, } Resource regResource = tempRegistry.get(resourcePath); - ArrayList newProperties = new ArrayList(); + ArrayList newProperties = new ArrayList(); Properties props = regResource.getProperties(); Enumeration x = props.propertyNames(); while (x.hasMoreElements()) { String key = (String) x.nextElement(); List values = regResource.getPropertyValues(key); - NewProperty property = new NewProperty(); + MetaDataProperty property = new MetaDataProperty(); property.setKey(key); String[] valueArr = new String[values.size()]; property.setValues(values.toArray(valueArr)); @@ -91,7 +91,7 @@ public List getPropertiesOfCluster(String applicationName, * @param property Propertys * @throws RegistryException */ - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + public void addPropertyToCluster(String applicationId, String clusterId, MetaDataProperty property) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationId + "/" + clusterId; @@ -135,14 +135,14 @@ public boolean deleteApplication(String applicationId) throws RegistryException * @param properties Properties of the application * @throws RegistryException */ - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + public void addPropertiesToCluster(String applicationName, String clusterId, MetaDataProperty[] properties) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; Resource regResource; regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); - for (NewProperty property : properties) { + for (MetaDataProperty property : properties) { regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index eb4a53ec6e..e43ab4b1b3 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.metadataservice.registry; -import org.apache.stratos.metadataservice.definition.NewProperty; +import org.apache.stratos.metadataservice.definition.MetaDataProperty; import org.wso2.carbon.registry.api.RegistryException; import java.util.List; @@ -28,13 +28,13 @@ */ public interface DataStore { - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + public void addPropertiesToCluster(String applicationName, String clusterId, MetaDataProperty[] properties) throws RegistryException; - public List getPropertiesOfCluster(String applicationName, String clusterId) + public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException; - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + public void addPropertyToCluster(String applicationId, String clusterId, MetaDataProperty property) throws RegistryException; public boolean deleteApplication(String applicationId) throws RegistryException; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 8e14f30c2c..ebaed9b703 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.NewProperty; +import org.apache.stratos.metadataservice.definition.MetaDataProperty; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; @@ -95,7 +95,7 @@ private static WSRegistryServiceClient setRegistry() throws Exception { * @param properties Properties * @throws RegistryException */ - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + public void addPropertiesToCluster(String applicationName, String clusterId, MetaDataProperty[] properties) throws RegistryException { //TODO : Implemenattion related to the GREG } @@ -107,7 +107,7 @@ public void addPropertiesToCluster(String applicationName, String clusterId, New * @return List of properties * @throws RegistryException */ - public List getPropertiesOfCluster(String applicationName, + public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { //TODO : Implemenattion related to the GREG return null; @@ -120,7 +120,7 @@ public List getPropertiesOfCluster(String applicationName, * @param property property * @throws RegistryException */ - public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) + public void addPropertyToCluster(String applicationId, String clusterId, MetaDataProperty property) throws RegistryException { //TODO : Implemenattion related to the GREG } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index 7d6c1ca2e6..74bf0fcac4 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; -import org.apache.stratos.metadataservice.definition.NewProperty; +import org.apache.stratos.metadataservice.definition.MetaDataProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; import org.apache.stratos.metadataservice.registry.DataStore; @@ -67,12 +67,12 @@ public MetaDataAdmin() { public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId) { - List properties; - NewProperty[] propertiesArr = null; + List properties; + MetaDataProperty[] propertiesArr = null; try { properties = registry.getPropertiesOfCluster(applicationId, clusterId); if (properties != null) { - propertiesArr = new NewProperty[properties.size()]; + propertiesArr = new MetaDataProperty[properties.size()]; propertiesArr = properties.toArray(propertiesArr); } } catch (Exception e) { @@ -98,15 +98,15 @@ public Response getClusterProperty(@PathParam("application_id") String applicati @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName) { - List properties; - NewProperty property = null; + List properties; + MetaDataProperty property = null; try { properties = registry.getPropertiesOfCluster(applicationId, clusterId); if (properties == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - for (NewProperty p : properties) { + for (MetaDataProperty p : properties) { if (propertyName.equals(p.getKey())) { property = p; break; @@ -132,7 +132,7 @@ public Response getClusterProperty(@PathParam("application_id") String applicati @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response addPropertyToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, - NewProperty property) + MetaDataProperty property) throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder() @@ -154,7 +154,7 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, - NewProperty[] properties) + MetaDataProperty[] properties) throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); From 0b86e155a35614aec726ea4634b7b0afd3dfef31 Mon Sep 17 00:00:00 2001 From: gayan Date: Tue, 18 Nov 2014 19:43:03 +0530 Subject: [PATCH 3/3] updates --- .../domain/message/TopicTextMessage.java | 52 +++++++++++++++++++ .../tenant/TenantEventMessageListener.java | 41 ++++++++------- .../TopologyEventMessageListener.java | 4 +- .../listener/TopologyAgent.java | 8 +-- .../metadataservice/util/ConfUtil.java | 2 +- 5 files changed, 80 insertions(+), 27 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/message/TopicTextMessage.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/message/TopicTextMessage.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/message/TopicTextMessage.java new file mode 100644 index 0000000000..251fa55a54 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/message/TopicTextMessage.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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.messaging.domain.message; + +import java.util.HashMap; + +/** + * Custom text message for internal queue + */ +public class TopicTextMessage { + + private String textMessage; + + private HashMap header; + + public TopicTextMessage(){ + header=new HashMap(); + } + + public String getText() { + return textMessage; + } + + public void setText(String textMessage) { + this.textMessage = textMessage; + } + + public String getStringProperty(String key) { + return header.get(key); + } + + public void setStringProperty(String key,String value) { + header.put(key,value); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/tenant/TenantEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/tenant/TenantEventMessageListener.java index 4e446ce8c8..4d013def63 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/tenant/TenantEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/tenant/TenantEventMessageListener.java @@ -47,37 +47,38 @@ public TenantEventMessageListener(TenantEventMessageQueue messageQueue) { } @Override - public void connectionLost(Throwable arg0) { - log.warn("MQTT Connection is lost", arg0); + public void connectionLost(Throwable err) { + log.warn("MQTT Connection is lost", err); } @Override - public void deliveryComplete(IMqttDeliveryToken arg0) { - // TODO Auto-generated method stub + public void deliveryComplete(IMqttDeliveryToken deliveryToken) { + if (log.isDebugEnabled()) { + log.debug(String.format("Message delivery is complete: %s", + ((deliveryToken != null) ? deliveryToken.toString() : ""))); + } } @Override public void messageArrived(String topicName, MqttMessage message) throws Exception { - if (message instanceof MqttMessage) { - - TextMessage receivedMessage = new ActiveMQTextMessage(); - - receivedMessage.setText(new String(message.getPayload())); - receivedMessage.setStringProperty(Constants.EVENT_CLASS_NAME, - Util.getEventNameForTopic(topicName)); + TextMessage receivedMessage = new ActiveMQTextMessage(); - try { - if (log.isDebugEnabled()) { - log.debug(String.format("Tanent message received: %s", - ((TextMessage) message).getText())); - } - // Add received message to the queue - messageQueue.add(receivedMessage); + receivedMessage.setText(new String(message.getPayload())); + receivedMessage.setStringProperty(Constants.EVENT_CLASS_NAME, + Util.getEventNameForTopic(topicName)); - } catch (JMSException e) { - log.error(e.getMessage(), e); + try { + if (log.isDebugEnabled()) { + log.debug(String.format("Tanent message received: %s", + ((TextMessage) message).getText())); } + // Add received message to the queue + messageQueue.add(receivedMessage); + + } catch (JMSException e) { + log.error(e.getMessage(), e); } + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java index 020ba08f2e..3c6d249865 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageListener.java @@ -44,8 +44,8 @@ public TopologyEventMessageListener(TopologyEventMessageQueue messageQueue) { } @Override - public void connectionLost(Throwable throwable) { - log.warn("MQTT Connection is lost", throwable); + public void connectionLost(Throwable err) { + log.warn("MQTT Connection is lost", err); } @Override diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java index f39594aeae..e644c10dc8 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -43,8 +43,8 @@ public class TopologyAgent implements Runnable { @Override public void run() { - if (log.isInfoEnabled()) { - log.info("Topology agent started"); + if (log.isDebugEnabled()) { + log.debug("Topology agent started"); } // Start topology event receiver thread @@ -59,7 +59,7 @@ private void registerTopologyEventListeners() { final String defaultRegType = "carbon"; XMLConfiguration conf; - log.info("==================Starting topology event message receiver thread================="); + log.info("==Starting topology event message receiver thread=="); if (log.isDebugEnabled()) { log.debug("Starting topology event message receiver thread"); } @@ -123,7 +123,7 @@ protected void onEvent(Event event) { Thread thread = new Thread(topologyEventReceiver); thread.start(); if (log.isDebugEnabled()) { - log.info("Cartridge Agent topology receiver thread started"); + log.debug("Cartridge Agent topology receiver thread started"); } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java index 4904fe734d..77846e5a2d 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -57,7 +57,7 @@ private ConfUtil(String configFilePath) { config = new XMLConfiguration(confFile); } catch (ConfigurationException e) { - log.error("Unable to load autoscaler configuration file", e); + log.error("Unable to load configuration file", e); config = new XMLConfiguration(); // continue with default values } }