You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/11 07:17:52 UTC

[01/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Updated Branches:
  refs/heads/master 99508a500 -> df3475cc5


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
deleted file mode 100644
index cc30312..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.local.LocalTransportReceiver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.usage" immediate="true"
- * @scr.reference name="registry.service"
- * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
- * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
- * @scr.reference name="user.realmservice.default" 
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" 
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service" 
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" 
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageServiceComponent {
-    private static Log log = LogFactory.getLog(UsageServiceComponent.class);
-
-
-    protected void activate(ComponentContext context) {
-        try {
-            Util.registerRetrieverServices(context.getBundleContext());
-            log.debug("******* Usage bundle is activated ******* ");    
-        } catch (Exception e) {
-            log.error("******* Error in activating Usage bundle ******* ");
-        }
-    }
-
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Usage is deactivated ******* ");
-    }
-
-    protected void setRegistryService(RegistryService registryService) {
-        Util.setRegistryService(registryService);
-    }
-
-    protected void unsetRegistryService(RegistryService registryService) {
-        Util.setRegistryService(null);
-    }
-
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-    
-    protected void setConfigurationContextService(ConfigurationContextService ccService) {
-        //commented to work with the local transport
-	/*ConfigurationContext serverCtx = ccService.getServerConfigContext();
-        AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
-        LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
-        LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
-        LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
-	*/
-        Util.setConfigurationContextService(ccService);
-    }
-
-    protected void unsetConfigurationContextService(ConfigurationContextService ccService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(dataSourceService);
-    }
-    
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/services/UsageService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/services/UsageService.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/services/UsageService.java
deleted file mode 100644
index 2348b2b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/services/UsageService.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.services;
-
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.usage.beans.InstanceUsageStatics;
-import org.wso2.carbon.usage.beans.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.beans.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.beans.TenantUsage;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class UsageService extends AbstractAdmin {
-    /**
-     * Return the usage of the current logged in tenant
-     *
-     * @param yearMonth year month
-     * @return the current usage of the tenant
-     * @throws Exception
-     */
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
-        int tenantId = registry.getTenantId();
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    /**
-     * Return the all the tenant usages, requires super admin permissions
-     *
-     * @param yearMonth
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                        tenant.getId(), yearMonth);
-                tenantUsages.add(tenantUsage);
-            }
-        }
-        return tenantUsages.toArray(new TenantUsage[tenantUsages.size()]);
-    }
-
-    /**
-     * Return the all the tenant usages paginated, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param pageNumber
-     * @param entriesPerPage
-     * @return PaginatedTenantUsageInfo
-     * @throws Exception
-     */
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-
-        int i = 0;
-        int numberOfPages = 0;
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                if (i % entriesPerPage == 0) {
-                    numberOfPages++;
-                }
-                if (numberOfPages == pageNumber) {
-                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                            tenant.getId(), yearMonth);
-                    tenantUsages.add(tenantUsage);
-                }
-                i++;
-            }
-        }
-        PaginatedTenantUsageInfo paginatedTenantInfo = new PaginatedTenantUsageInfo();
-        paginatedTenantInfo.setTenantUsages(
-                tenantUsages.toArray(new TenantUsage[tenantUsages.size()]));
-        paginatedTenantInfo.setNumberOfPages(numberOfPages);
-        paginatedTenantInfo.setPageNumber(pageNumber);
-        return paginatedTenantInfo;
-    }
-
-    /**
-     * Returns usage of a particular tenant, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param tenantId
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception {
-        return Util.getTenantUsageRetriever().getInstanceUsages();
-    }
-
-    /**
-     * @param yearMonth      year and month that used to retrieve data
-     * @param pageNumber
-     * @param entriesPerPage number of entries per page
-     * @return PaginatedInstanceUsage object that hold instance data and other parameters
-     * @throws Exception when retrieving Paginated Instance Usage error occurs
-     */
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
-                                                                 int entriesPerPage) throws Exception {
-        InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
-        List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
-        PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
-        int i = 0;
-        int numberOfPages = 0;
-        if (instanceUsages != null && instanceUsages.length > 0) {
-            for (InstanceUsageStatics usage : instanceUsages) {
-                InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
-                if (instance != null) {
-                    if (i % entriesPerPage == 0) {
-                        numberOfPages++;
-                    }
-                }
-            }
-
-            paginatedInstanceUsages.setInstanceUsages(
-                instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
-        } else {
-            paginatedInstanceUsages.setInstanceUsages(null);
-        }
-
-        paginatedInstanceUsages.setNumberOfPages(numberOfPages);
-        paginatedInstanceUsages.setPageNumber(pageNumber);
-        return paginatedInstanceUsages;
-    }
-
-    /**
-     * @param usage     is Instance usage Statics object that holds data
-     * @param yearMonth year and month that need to check with instance usage data
-     * @return instance static if instance usage data match with given year and month, else null
-     */
-    public InstanceUsageStatics getValidUsageEntry(InstanceUsageStatics usage, String yearMonth) {
-        Date date = Calendar.getInstance().getTime();
-        if (yearMonth != null) {
-            try {
-                date = CommonUtil.getDateFromMonthString(yearMonth);
-            } catch (ParseException e) {
-
-            }
-        }
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-        if (usage.getStartTime().compareTo(startDate) <= 0 && usage.getStopTime().compareTo(endDate) >= 0) {
-            usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                    startDate.getTimeInMillis()) / 1000);
-            return usage;
-        }
-        if (usage.getStartTime().compareTo(startDate) > 0 && usage.getStartTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(endDate) < 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            } else if (usage.getStopTime().compareTo(endDate) > 0) {
-                usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            }
-        }
-        if (usage.getStartTime().compareTo(startDate) < 0 && usage.getStopTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(startDate) > 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        startDate.getTimeInMillis()) / 1000);
-                return usage;
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
deleted file mode 100644
index 386a212..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
+++ /dev/null
@@ -1,624 +0,0 @@
-package org.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.beans.*;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class DataAccessObject {
-
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-    private DataSource dataSource;
-
-
-    public DataAccessObject(){
-        if(Util.getDataSourceService()!=null){
-            try{
-                this.dataSource = (DataSource)Util.getDataSourceService().
-                        getDataSource(Util.BILLING_DATA_SOURCE_NAME).getDSObject();
-            }catch(Exception e){
-                log.error("Error occurred while obtaining " + Util.BILLING_DATA_SOURCE_NAME +
-                        " datasource from data source service.", e);
-                dataSource=null;
-            }
-        }else{
-            log.error("Cannot obtain data source " + Util.BILLING_DATA_SOURCE_NAME + ". Datasource service is null");
-            dataSource=null;
-        }
-    }
-
-
-    public List<BandwidthStatistics> getHourlyBandwidthStats(int tenantId, Calendar startDate,
-                                                             Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getDailyBandwidthStats(int tenantId, Calendar startDate,
-                                                            Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Stats of this month will be retrieved
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getMonthlyBandwidthStats(int tenantId,
-                                                              Calendar month) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_DATA");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getHourlyRequestStats(int tenantId, Calendar startDate,
-                                                         Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getDailyRequestStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Month - Stats of this month will be retrieved
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getMonthlyRequestStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    public TenantDataCapacity getTenantDataCapacity(int tenantId) throws Exception{
-        Connection connection = null;
-        TenantDataCapacity tenantDataCapacity = null;
-
-        try{
-            connection = dataSource.getConnection();
-            String id = ""  + tenantId + "Final";
-            String sql = "SELECT * FROM REGISTRY_USAGE_HOURLY_ANALYTICS WHERE ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, id);
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                long currentCapacity = resultSet.getLong("CURRENT_USAGE");
-                long historyCapacity = resultSet.getLong("HISTORY_USAGE");
-
-                tenantDataCapacity = new TenantDataCapacity(currentCapacity, historyCapacity);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving registry data usage from . ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return tenantDataCapacity;
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of CartridgeStatistics objects
-     * @throws Exception
-     */
-    public List<CartridgeStatistics> getHourlyCartridgeStats(int tenantId, Calendar startDate,
-                                                         Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-
-            String sql = "SELECT * FROM CARTRIDGE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, String.valueOf(tenantId));
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                CartridgeStatistics cs = new CartridgeStatistics();
-                cs.setInstanceId(resultSet.getString("IMAGE_ID"));
-                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
-                cs.setKey(resultSet.getString("CARTRIDGE_TYPE") + " - " + resultSet.getString("NODE_ID"));
-
-                csList.add(cs);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly cartridge stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return csList;
-
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<CartridgeStatistics> getDailyCartridgeStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            //TODO: Implement the SQL logic
-            String sql = "SELECT * FROM CARTRIDGE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, String.valueOf(tenantId));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                CartridgeStatistics cs = new CartridgeStatistics();
-                cs.setInstanceId(resultSet.getString("IMAGE_ID"));
-                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
-                cs.setKey(resultSet.getString("CARTRIDGE_TYPE") + " - " + resultSet.getString("NODE_ID"));
-
-                csList.add(cs);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily cartridge stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return csList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Month - Stats of this month will be retrieved
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<CartridgeStatistics> getMonthlyCartridgeStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            //TODO: Implement SQL logic
-            String sql = "SELECT * FROM CARTRIDGE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, String.valueOf(tenantId));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                CartridgeStatistics cs = new CartridgeStatistics();
-                cs.setInstanceId(resultSet.getString("NODE_ID"));
-                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
-                cs.setKey(resultSet.getString("IMAGE_ID"));
-
-                csList.add(cs);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly cartridge stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return csList;
-
-    }
-
-    /**
-     * @param tenantId  Tenant Id of associated tenant
-     * @param startDate Start Date start time stamp of hour
-     * @param endDate   End date end time stamp of hour
-     * @return APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getHourlyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                    Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     * @param tenantId  Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate   End date - Stats of this date will be included
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getDailyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                   Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if ("API-Call".equals(key)) {
-                    stats.setRequestCount(resultSet.getLong("PAYLOAD_VALUE"));
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-        return bwsList;
-    }
-
-    /**
-     * @param tenantId Tenant ID
-     * @param month    Stats of this month will be retrieved
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getMonthlyAPIManagerUsageStats(int tenantId,
-                                                                     Calendar month) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_DATA");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/Util.java
deleted file mode 100644
index 6c9ebae..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/util/Util.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-
-import javax.sql.DataSource;
-
-/**
- * Util methods for usage.
- */
-public class Util {
-
-    private static final Log log = LogFactory.getLog(Util.class);
-
-    private static RegistryService registryService;
-    private static RealmService realmService;
-    private static TenantUsageRetriever tenantUsageRetriever;
-    private static ConfigurationContextService configurationContextService;
-    private static DataSourceService dataSourceService;
-    public static String BILLING_DATA_SOURCE_NAME="WSO2BillingDS";
-
-    public static synchronized void setRegistryService(RegistryService service) {
-        if (registryService == null) {
-            registryService = service;
-        }
-    }
-    
-    public static void setConfigurationContextService(
-            ConfigurationContextService configurationContextService) {
-        Util.configurationContextService = configurationContextService;
-    }
-    
-    public static ConfigurationContextService getConfigurationContextService(){
-        return configurationContextService;
-    }
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static RegistryService getRegistryService() {
-        return registryService;
-    }
-
-    public static TenantUsageRetriever getTenantUsageRetriever() {
-        return tenantUsageRetriever;
-    }
-
-    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
-        return registryService.getUserRealm(tenantId);
-    }
-
-    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
-        return registryService.getGovernanceSystemRegistry();
-    }
-
-    public static void registerRetrieverServices(BundleContext bundleContext) throws Exception {
-        ConfigurationContextService confCtxSvc = Util.getConfigurationContextService();
-
-        // creating and registering tenant and user usage retrievers
-        tenantUsageRetriever = new TenantUsageRetriever(
-                registryService, confCtxSvc.getServerConfigContext());
-        bundleContext.registerService(
-                TenantUsageRetriever.class.getName(), tenantUsageRetriever, null);
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        Util.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 2d2f81e..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <!--<ManagementPermission>
-            <DisplayName>User-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/userUsage</ResourceId>
-        </ManagementPermission> -->
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Protected</DisplayName>
-            <ResourceId>/permission/protected</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/protected/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Any-Tenant-Usage</DisplayName>
-            <ResourceId>/permission/protected/monitor/anytenantUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 8e82415..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-    <service name="UsageService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.services.UsageService
-        </parameter>
-
-        <operation name="retrieveCurrentTenantUsage">
-            <parameter name="AuthorizationAction" locked="true">/permission/admin/monitor/tenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrievePaginatedTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsage">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-    </service>
-    <parameter name="adminService" locked="true">true</parameter>
-
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/all_tenant_usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/all_tenant_usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/all_tenant_usage_report.jrxml
deleted file mode 100644
index b9483aa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/all_tenant_usage_report.jrxml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="all_tenant_usage_report"  pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="yearMonth" class="java.lang.String"/>
-	<field name="tenantName" class="java.lang.String"/>
-	<field name="numberOfUsers" class="java.lang.String"/>
-	<field name="currentDataStorage" class="java.lang.String"/>
-	<field name="regBandwidth" class="java.lang.String"/>
-	<field name="svcBandwidth" class="java.lang.String"/>
-	<field name="svcTotalRequest" class="java.lang.String"/>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="79" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="35" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Transparent" x="0" y="0" width="279" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<text><![CDATA[Tenant Usage Report for the month]]></text>
-			</staticText>
-			<textField>
-				<reportElement mode="Transparent" x="279" y="0" width="276" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{yearMonth}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band height="61" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Opaque" x="0" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Domain]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="100" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Number of users]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="200" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Storage Usage]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="300" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Registry Bandwidth]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="400" y="29" width="73" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Service Bandwidht]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="473" y="29" width="82" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Service Requests]]></text>
-			</staticText>
-		</band>
-	</columnHeader>
-	<detail>
-		<band height="103" splitType="Stretch">
-			<textField>
-				<reportElement x="0" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantName}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="100" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{numberOfUsers}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="200" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{currentDataStorage}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="300" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{regBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="400" y="21" width="73" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="473" y="21" width="82" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcTotalRequest}]]></textFieldExpression>
-			</textField>
-		</band>
-	</detail>
-	<columnFooter>
-		<band height="45" splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="54" splitType="Stretch">
-			<textField>
-				<reportElement x="455" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
-			</textField>
-			<textField pattern="MMMMM dd, yyyy">
-				<reportElement x="0" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageFooter>
-	<summary>
-		<band height="42" splitType="Stretch"/>
-	</summary>
-</jasperReport>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/usage_report.jrxml
deleted file mode 100644
index 5b43c2f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/resources/reports/usage_report.jrxml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="task" class="java.lang.String"/>
-	<field name="usagecol1" class="java.lang.String"/>
-	<field name="usagecol2" class="java.lang.String"/>
-	<field name="usagecol3" class="java.lang.String"/>
-	<field name="usagecol4" class="java.lang.String"/>
-	<field name="usagecol1Value" class="java.lang.String"/>
-	<field name="usagecol2Value" class="java.lang.String"/>
-	<field name="usagecol3Value" class="java.lang.String"/>
-	<field name="usagecol4Value" class="java.lang.String"/>
-	<field name="tenantDomain" class="java.lang.String"/>
-	<group name="usagedatagroup">
-		<groupExpression><![CDATA[$F{task}]]></groupExpression>
-		<groupHeader>
-			<band height="72" splitType="Stretch">
-				<rectangle>
-					<reportElement x="0" y="21" width="555" height="16" backcolor="#D0F5E8"/>
-				</rectangle>
-				<textField>
-					<reportElement x="0" y="22" width="555" height="16"/>
-					<textElement>
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{task}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="38" width="555" height="16" backcolor="#E6F1B6"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="39" width="132" height="17"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="39" width="132" height="15"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="288" y="39" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="38" width="132" height="16"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="55" width="555" height="15" backcolor="#DBE596"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="57" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="55" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="287" y="55" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="56" width="132" height="15"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4Value}]]></textFieldExpression>
-				</textField>
-			</band>
-		</groupHeader>
-		<groupFooter>
-			<band splitType="Stretch"/>
-		</groupFooter>
-	</group>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="17" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="19" splitType="Stretch">
-			<textField pattern="dd/MM/yyyy h.mm a">
-				<reportElement x="403" y="0" width="132" height="16"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-			<staticText>
-				<reportElement x="0" y="1" width="169" height="15"/>
-				<textElement textAlignment="Right">
-					<font size="12" isUnderline="true"/>
-				</textElement>
-				<text><![CDATA[Usage Report For : ]]></text>
-			</staticText>
-			<textField>
-				<reportElement x="169" y="0" width="234" height="16"/>
-				<textElement verticalAlignment="Middle">
-					<font size="12"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantDomain}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band splitType="Stretch"/>
-	</columnHeader>
-	<detail>
-		<band height="5" splitType="Stretch"/>
-	</detail>
-	<columnFooter>
-		<band splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="8" splitType="Stretch"/>
-	</pageFooter>
-	<summary>
-		<band height="7" splitType="Stretch"/>
-	</summary>
-</jasperReport>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/pom.xml b/components/stratos/usage/pom.xml
deleted file mode 100644
index 57c4096..0000000
--- a/components/stratos/usage/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (c) 2009-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ Licensed 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.
--->
-
-<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/maven-v4_0_0.xsd">
-
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>stratos-components</artifactId>
-        <version>2.1.0</version>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>usage-parent</artifactId>
-    <packaging>pom</packaging>
-    <name>WSO2 Stratos - Usage Parent Module</name>
-    <description>WSO2 Stratos Usage Parent Module</description>
-    <url>http://wso2.org</url>
-
-    <modules>
-        <module>org.wso2.carbon.usage/2.1.0</module>
-        <module>org.wso2.carbon.usage.agent/2.1.0</module>
-        <module>org.wso2.carbon.usage.ui/2.1.0</module>
-        <module>org.wso2.carbon.usage.summary.helper/2.1.0</module>
-    </modules>
-
-</project>
-


[24/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/clients/UsageServiceClient.java b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/clients/UsageServiceClient.java
new file mode 100644
index 0000000..350fb82
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/clients/UsageServiceClient.java
@@ -0,0 +1,116 @@
+/*
+ *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.usage.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
+import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
+import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
+import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
+import org.wso2.carbon.usage.stub.services.UsageServiceStub;
+import org.wso2.carbon.utils.ServerConstants;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+
+public class UsageServiceClient {
+    private static final Log log = LogFactory.getLog(UsageServiceClient.class);
+
+    private UsageServiceStub stub;
+    private String epr;
+
+    public UsageServiceClient(
+            String cookie, String backendServerURL, ConfigurationContext configContext)
+            throws RegistryException {
+
+        epr = backendServerURL + "UsageService";
+
+        try {
+            stub = new UsageServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public UsageServiceClient(ServletConfig config, HttpSession session)
+            throws RegistryException {
+
+        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+        ConfigurationContext configContext = (ConfigurationContext) config.
+                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+        epr = backendServerURL + "UsageService";
+
+        try {
+            stub = new UsageServiceStub(configContext, epr);
+
+            ServiceClient client = stub._getServiceClient();
+            Options option = client.getOptions();
+            option.setManageSession(true);
+            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+        } catch (AxisFault axisFault) {
+            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
+            log.error(msg, axisFault);
+            throw new RegistryException(msg, axisFault);
+        }
+    }
+
+    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
+        return stub.retrieveCurrentTenantUsage(yearMonth);
+    }
+
+    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
+        return stub.retrieveTenantUsages(yearMonth);
+    }
+
+    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
+                                                                  int entriesPerPage) throws Exception {
+        return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
+    }
+
+    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
+        return stub.retrieveTenantUsage(yearMonth, tenantId);
+    }
+
+    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
+            return stub.retrieveInstanceUsage();
+    }
+
+    public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
+            String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
+            return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageData.java b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageData.java
new file mode 100755
index 0000000..c959dca
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageData.java
@@ -0,0 +1,96 @@
+/*
+ *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.usage.ui.report;
+
+public class AllTenantUsageData {
+
+	public AllTenantUsageData() {
+	}
+
+	String yearMonth;
+	
+	String tenantName;
+	
+	String numberOfUsers;
+	
+	String currentDataStorage;
+	
+	String regBandwidth;
+	
+	String svcBandwidth;
+	
+	String svcTotalRequest;
+
+	public String getYearMonth() {
+		return yearMonth;
+	}
+
+	public void setYearMonth(String yearMonth) {
+		this.yearMonth = yearMonth;
+	}
+
+	public String getTenantName() {
+		return tenantName;
+	}
+
+	public void setTenantName(String tenantName) {
+		this.tenantName = tenantName;
+	}
+
+	public String getNumberOfUsers() {
+		return numberOfUsers;
+	}
+
+	public void setNumberOfUsers(String numberOfUsers) {
+		this.numberOfUsers = numberOfUsers;
+	}
+
+	public String getCurrentDataStorage() {
+		return currentDataStorage;
+	}
+
+	public void setCurrentDataStorage(String currentDataStorage) {
+		this.currentDataStorage = currentDataStorage;
+	}
+
+	public String getRegBandwidth() {
+		return regBandwidth;
+	}
+
+	public void setRegBandwidth(String regBandwidth) {
+		this.regBandwidth = regBandwidth;
+	}
+
+	public String getSvcBandwidth() {
+		return svcBandwidth;
+	}
+
+	public void setSvcBandwidth(String svcBandwidth) {
+		this.svcBandwidth = svcBandwidth;
+	}
+
+	public String getSvcTotalRequest() {
+		return svcTotalRequest;
+	}
+
+	public void setSvcTotalRequest(String svcTotalRequest) {
+		this.svcTotalRequest = svcTotalRequest;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageReport.java b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageReport.java
new file mode 100644
index 0000000..fb5b0a4
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/AllTenantUsageReport.java
@@ -0,0 +1,110 @@
+/*
+ *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.usage.ui.report;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
+import org.apache.stratos.usage.ui.utils.UsageUtil;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * this class is used to generate reports of all tenant usages
+ */
+public class AllTenantUsageReport {
+
+    private TenantUsage[] tenantUsages;
+    private String yearMonth;
+
+    /**
+     * @param config
+     * @param session
+     * @param request
+     * @throws Exception
+     */
+    private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
+
+    public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
+            throws Exception {
+    	tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
+     
+ 
+        yearMonth = (String) request.getSession().getAttribute("year-month");
+    }
+
+    public List<AllTenantUsageData> getUsageReportData() {
+
+        List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>();   // all the strings need to be passed to
+        //  generate the report are added to this list
+
+        if (yearMonth == null) {
+            //  get the current year month
+            yearMonth = UsageUtil.getCurrentYearMonth();
+        }
+        String currentYearMonth = UsageUtil.getCurrentYearMonth();
+
+        //  add all the usage data to the list
+        try {
+            for (TenantUsage usage : tenantUsages) {
+                AllTenantUsageData usageData = new AllTenantUsageData();
+                usageData.setYearMonth(yearMonth);
+                String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
+                String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
+                String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
+                long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
+                int numberOfUsers = usage.getNumberOfUsers();
+
+                //  String username = (String) request.getSession().getAttribute("logged-user");
+                String tenantName = usage.getDomain();
+                int tenantId = usage.getTenantId();
+                String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
+
+                usageData.setTenantName(tenantName);
+                if (yearMonth.equals(currentYearMonth)) {
+                    usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
+                    usageData.setCurrentDataStorage(currentDataStorage);
+                }
+                // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
+                else {
+                    usageData.setNumberOfUsers("-");
+                    usageData.setCurrentDataStorage("-");
+                }
+                usageData.setRegBandwidth(regBandwidth);
+                usageData.setSvcBandwidth(svcBandwidth);
+                usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
+                reportData.add(usageData);
+            }
+        }
+        catch (Exception e) {
+            String msg = "Error while retrieving tenant usages for month : " + yearMonth;
+            log.error(msg, e);
+        }
+        return reportData;         // return as an array
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/UsageReport.java b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/UsageReport.java
new file mode 100644
index 0000000..264266d
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/report/UsageReport.java
@@ -0,0 +1,195 @@
+/*
+ *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.usage.ui.report;
+
+import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
+import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
+import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
+import org.apache.stratos.usage.ui.utils.UsageUtil;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class is used to generate tenant usage report
+ */
+public class UsageReport {
+    private TenantUsage usage;
+    private String yearMonth;
+
+    public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
+            throws Exception {
+        usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
+        yearMonth = (String) request.getSession().getAttribute("year-month");
+
+    }
+
+
+    public List<String> getUsageReportData() {
+
+        int numberOfUsers = usage.getNumberOfUsers();
+        if (yearMonth == null) {
+
+            yearMonth = UsageUtil.getCurrentYearMonth();
+        }
+
+        String tenantName = usage.getDomain();
+        String currentYearMonth = UsageUtil.getCurrentYearMonth();
+        List<String> reportData = new ArrayList<String>();
+        reportData.add("Basic Tenant Details");
+        reportData.add("");
+        reportData.add("Duration");
+        reportData.add("Tenant Name");
+        reportData.add("Number of users");
+        reportData.add("Basic Tenant Details");
+        reportData.add("");
+        reportData.add(yearMonth);
+        reportData.add(tenantName);
+        reportData.add(String.valueOf(numberOfUsers));
+
+
+        if (currentYearMonth.equals(yearMonth)) {
+            reportData.add("Storage Usage");
+            reportData.add("Data Storage");
+            reportData.add("Current Data Storage");
+            reportData.add("Historical Data Storage");
+            reportData.add("Total Data Storage");
+            String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
+            String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
+            String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
+            reportData.add("Storage Usage");
+            reportData.add("Registry Content");
+            reportData.add(totalDataStorage);
+            reportData.add(currentDataStorage);
+            reportData.add(historyDataStorage);
+        }
+
+        String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
+        String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
+        String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
+        reportData.add("Registry Bandwidth Usage");
+        reportData.add("Server Name");
+        reportData.add("Incoming Bandwidth");
+        reportData.add("Outgoing Bandwidth");
+        reportData.add("Total Bandwidth");
+        BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
+        if (regBWStats != null) {
+            for (BandwidthStatistics stat : regBWStats) {
+                String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+                String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+                String regBandwidth = UsageUtil.getTotalBandwidth(stat);
+                reportData.add("Server Name****");
+                reportData.add(regInBandwidth);
+                reportData.add(regOutBandwidth);
+                reportData.add(regBandwidth);
+
+            }
+        }
+        reportData.add("Registry Bandwidth Usage");
+        reportData.add("All Server Total");
+        reportData.add(totRegInBandwidth);
+        reportData.add(totRegOutBandwidth);
+        reportData.add(totRegBandwidth);
+
+        String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
+        String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
+        String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
+        reportData.add("Service Bandwidth Usage");
+        reportData.add("Server Name");
+        reportData.add("Incoming Bandwidth");
+        reportData.add("Outgoing Bandwidth");
+        reportData.add("Total Bandwidth");
+        BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
+        if (svcBWStats != null) {
+            for (BandwidthStatistics stat : svcBWStats) {
+                String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+                String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+                String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
+                reportData.add("Server Name****");
+                reportData.add(svcInBandwidth);
+                reportData.add(svcOutBandwidth);
+                reportData.add(svcBandwidth);
+
+            }
+        }
+        reportData.add("Service Bandwidth Usage");
+        reportData.add("All Server Total");
+        reportData.add(totSvcInBandwidth);
+        reportData.add(totSvcOutBandwidth);
+        reportData.add(totSvcBandwidth);
+
+        String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
+        String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
+        String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
+        BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
+        reportData.add("Webapp Bandwidth Usage");
+        reportData.add("Server Name");
+        reportData.add("Incoming Bandwidth");
+        reportData.add("Outgoing Bandwidth");
+        reportData.add("Total Bandwidth");
+        if (webappBWStats != null) {
+            for (BandwidthStatistics stat : webappBWStats) {
+                String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+                String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+                String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
+                reportData.add("Server Name****");
+                reportData.add(webappInBandwidth);
+                reportData.add(webappOutBandwidth);
+                reportData.add(webappBandwidth);
+            }
+        }
+        reportData.add("Webapp Bandwidth Usage");
+        reportData.add("All Server Total");
+        reportData.add(totWebappInBandwidth);
+        reportData.add(totWebappOutBandwidth);
+        reportData.add(totWebappBandwidth);
+
+
+        long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
+        long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
+        long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
+        RequestStatistics[] svcStats = usage.getRequestStatistics();
+        reportData.add("Service Usage Statistic");
+        reportData.add("Server Name");
+        reportData.add("Request Count");
+        reportData.add("Response Count");
+        reportData.add("Fault Count");
+        if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
+            for (RequestStatistics stat : svcStats) {
+                long svcReqCount = stat.getRequestCount();
+                long svcResCount = stat.getResponseCount();
+                long svcFaultCount = stat.getFaultCount();
+                reportData.add("Server Name****");
+                reportData.add(String.valueOf(svcReqCount));
+                reportData.add(String.valueOf(svcResCount));
+                reportData.add(String.valueOf(svcFaultCount));
+            }
+        }
+        reportData.add("Service Usage Statistic");
+        reportData.add("All Server Total");
+        reportData.add(String.valueOf(totSvcReqCount));
+        reportData.add(String.valueOf(totSvcRespCount));
+        reportData.add(String.valueOf(totSvcFaultCount));
+
+        return reportData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/utils/UsageUtil.java b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/utils/UsageUtil.java
new file mode 100644
index 0000000..0b7089f
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/java/org/apache/stratos/usage/ui/utils/UsageUtil.java
@@ -0,0 +1,251 @@
+/*
+ *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.usage.ui.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.util.CommonUtil;
+import org.wso2.carbon.registry.common.ui.UIException;
+import org.wso2.carbon.usage.stub.beans.xsd.*;
+import org.apache.stratos.usage.ui.clients.UsageServiceClient;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+public class UsageUtil {
+    private static final Log log = LogFactory.getLog(UsageUtil.class);
+
+    private static long KB_LIMIT = 1024;
+    private static long MB_LIMIT = 1024 * 1024;
+    private static long GB_LIMIT = 1024 * 1024 * 1024;
+    private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
+
+    public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
+                                                         ServletConfig config, HttpSession session) throws Exception {
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            String yearMonth = request.getParameter("year-month");
+            if (yearMonth == null) {
+                // get the current year month
+                yearMonth = getCurrentYearMonth();
+            }
+            return serviceClient.retrieveCurrentTenantUsage(yearMonth);
+        } catch (Exception e) {
+            String msg = "Failed to get current tenant usage.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
+                                                     ServletConfig config, HttpSession session) throws Exception {
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            String yearMonth = request.getParameter("year-month");
+            if (yearMonth == null) {
+                // get the current year month
+                yearMonth = getCurrentYearMonth();
+            }
+            return serviceClient.retrieveTenantUsages(yearMonth);
+        } catch (Exception e) {
+            String msg = "Failed to get all tenants usages.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
+                                                                         ServletConfig config, HttpSession session) throws Exception {
+        String requestedPage = request.getParameter("requestedPage");
+        int pageNumber = 1;
+        int numberOfPages = 1;
+        int entriesPerPage = 15;
+        if (requestedPage != null && requestedPage.length() > 0) {
+            pageNumber = new Integer(requestedPage);
+        }
+
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            String yearMonth = request.getParameter("year-month");
+            if (yearMonth == null) {
+                // get the current year month
+                yearMonth = getCurrentYearMonth();
+            }
+            return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
+        } catch (Exception e) {
+            String msg = "Failed to get all tenants usages.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static TenantUsage retrieveTenantUsage(ServletRequest request,
+                                                  ServletConfig config, HttpSession session) throws Exception {
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            String yearMonth = request.getParameter("year-month");
+            if (yearMonth == null) {
+                // get the current year month
+                yearMonth = getCurrentYearMonth();
+            }
+            String tenantIdStr = request.getParameter("tenant-id");
+            if (tenantIdStr == null) {
+                tenantIdStr = "0";
+            }
+            return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
+        } catch (Exception e) {
+            String msg = "Failed to get tenant usages.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+
+    public static String convertBytesToString(long storage) {
+        if (storage < KB_LIMIT) {
+            return storage + " Byte(s)";
+        } else if (storage < MB_LIMIT) {
+            return storage / KB_LIMIT + " KByte(s)";
+        } else if (storage < GB_LIMIT) {
+            return storage / MB_LIMIT + " MByte(s)";
+        } else if (storage < TB_LIMIT) {
+            return storage / GB_LIMIT + " GByte(s)";
+        } else {
+            return storage / TB_LIMIT + " TByte(s)";
+        }
+    }
+
+    public static String getCurrentYearMonth() {
+        Calendar calendar = Calendar.getInstance();
+        return CommonUtil.getMonthString(calendar);
+    }
+
+    public static String[] getYearMonths() {
+        // we will list 100 months for now
+        List<String> yearMonths = new ArrayList<String>();
+        for (int i = 0; i > -100; i--) {
+            String yearMonth = CommonUtil.getMonthString(i);
+            yearMonths.add(yearMonth);
+        }
+        return yearMonths.toArray(new String[yearMonths.size()]);
+    }
+
+    public static String getCurrentDataStorage(TenantUsage usage) {
+        TenantDataCapacity regData = usage.getRegistryCapacity();
+        long currentData = 0;
+        if (regData != null) {
+            currentData = regData.getRegistryContentCapacity();
+        }
+        return convertBytesToString(currentData);
+    }
+
+    public static String getHistoryDataStorage(TenantUsage usage) {
+        TenantDataCapacity historyData = usage.getRegistryCapacity();
+        long currentData = 0;
+        if (historyData != null) {
+            currentData = historyData.getRegistryContentHistoryCapacity();
+        }
+        return convertBytesToString(currentData);
+    }
+
+    public static String getTotalDataStorage(TenantUsage usage) {
+        TenantDataCapacity regData = usage.getRegistryCapacity();
+        long totalDataStorage = 0;
+        if (regData != null) {
+            totalDataStorage =
+                    regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
+        }
+        return convertBytesToString(totalDataStorage);
+    }
+
+    public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
+        long totalBW = 0;
+        if (bandwidth != null) {
+            totalBW = bandwidth.getIncomingBandwidth();
+        }
+        return convertBytesToString(totalBW);
+    }
+
+    public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
+        long totalBW = 0;
+        if (bandwidth != null) {
+            totalBW = bandwidth.getOutgoingBandwidth();
+        }
+        return convertBytesToString(totalBW);
+    }
+
+    public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
+        long totalBW = 0;
+        if (bandwidth != null) {
+            totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
+        }
+        return convertBytesToString(totalBW);
+    }
+
+    public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
+                                                               ServletConfig config, HttpSession session)
+            throws Exception {
+
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
+            return returnInstanceUsage;
+        } catch (Exception e) {
+            String msg = "Failed to get current instance usage.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+
+    public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
+                                                                         ServletConfig config, HttpSession session) throws Exception {
+        String requestedPage = request.getParameter("requestedPage");
+        int pageNumber = 1;
+        int numberOfPages = 1;
+        int entriesPerPage = 15;
+        if (requestedPage != null && requestedPage.length() > 0) {
+            pageNumber = new Integer(requestedPage);
+        }
+        try {
+            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
+            String yearMonth = request.getParameter("year-month");
+            if (yearMonth == null) {
+                // get the current year month
+                yearMonth = getCurrentYearMonth();
+            }
+            return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
+        } catch (Exception e) {
+            String msg = "Failed to get paginated instance usages.";
+            log.error(msg, e);
+            throw new UIException(msg, e);
+        }
+    }
+    public static String getAPIUsage(TenantUsage usage) {
+        long count = 0;
+
+        if (usage.getApiManagerUsageStats() != null) {
+            count =usage.getApiManagerUsageStats()[0].getRequestCount();
+        }
+        return Long.toString(count);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.usage.ui/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..d4ba371
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/META-INF/component.xml
@@ -0,0 +1,74 @@
+<!--
+  ~  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.
+  -->
+<component xmlns="http://products.wso2.org/carbon">
+    <!-- sample menu configuration -->
+    <menus>
+        <menu>
+            <id>usage_monitoring_menu</id>
+            <i18n-key>usage.monitoring</i18n-key>
+            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
+            <parent-menu></parent-menu>
+            <link>#</link>
+            <region>region4</region>
+            <style-class>home</style-class>
+            <order>22</order>
+            <icon>../services/images/services.gif</icon>
+        </menu>
+        <menu>
+            <id>tenant_usage_menu</id>
+            <i18n-key>tenant.usage.report</i18n-key>
+            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>monitor_menu</parent-menu>
+            <link>../tenant-usage/tenant_usage.jsp</link>
+            <region>region4</region>
+            <order>51</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-usage/images/user-usage-report.gif</icon>
+            <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
+            <require-not-super-tenant>true</require-not-super-tenant>
+        </menu>
+        <!--menu>
+            <id>all_tenant_instance_usage_menu</id>
+            <i18n-key>instance.usage.report</i18n-key>
+            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>monitor_menu</parent-menu>
+            <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
+            <region>region4</region>
+            <order>50</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-usage/images/instance-usage-report.gif</icon>
+            <require-permission>/permission/protected/monitor/userUsage</require-permission>
+            <require-super-tenant>true</require-super-tenant>
+        </menu-->
+        <menu>
+            <id>all_tenant_usage_menu</id>
+            <i18n-key>all.tenant.usage.report</i18n-key>
+            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
+            <parent-menu>monitor_menu</parent-menu>
+            <link>../tenant-usage/all_tenant_usage.jsp</link>
+            <region>region4</region>
+            <order>50</order>
+            <style-class>manage</style-class>
+            <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
+            <require-permission>/permission/protected/monitor/userUsage</require-permission>
+            <require-super-tenant>true</require-super-tenant>
+        </menu>
+    </menus>
+
+</component>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/UsageService.wsdl
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/UsageService.wsdl b/components/org.apache.stratos.usage.ui/src/main/resources/UsageService.wsdl
new file mode 100644
index 0000000..b14c186
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/UsageService.wsdl
@@ -0,0 +1,605 @@
+<!--
+  ~  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.
+  -->
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:ns1="http://org.apache.axis2/xsd"
+                  xmlns:ns="http://services.usage.carbon.wso2.org"
+                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+                  xmlns:ax2249="http://beans.usage.carbon.wso2.org/xsd"
+                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+                  targetNamespace="http://services.usage.carbon.wso2.org">
+    <wsdl:documentation>UsageService</wsdl:documentation>
+    <wsdl:types>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
+                   targetNamespace="http://beans.usage.carbon.wso2.org/xsd">
+            <xs:complexType name="TenantUsage">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="domain" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="numberOfUsers" type="xs:int"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0"
+                                name="registryBandwidthStatistics" nillable="true"
+                                type="ax2249:BandwidthStatistics"/>
+
+                    <xs:element minOccurs="0" name="registryCapacity" nillable="true"
+                                type="ax2249:TenantDataCapacity"/>
+                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
+                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="requestStatistics"
+                                nillable="true" type="ax2249:RequestStatistics"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0"
+                                name="serviceBandwidthStatistics" nillable="true"
+                                type="ax2249:BandwidthStatistics"/>
+                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
+                    <xs:element minOccurs="0" name="totalIncomingBandwidth" type="xs:long"/>
+                    <xs:element minOccurs="0" name="totalOutgoingBandwidth" type="xs:long"/>
+                    <xs:element minOccurs="0" name="totalRegistryBandwidth" nillable="true"
+                                type="ax2249:BandwidthStatistics"/>
+
+                    <xs:element minOccurs="0" name="totalRequestStatistics" nillable="true"
+                                type="ax2249:RequestStatistics"/>
+                    <xs:element minOccurs="0" name="totalServiceBandwidth" nillable="true"
+                                type="ax2249:BandwidthStatistics"/>
+                    <xs:element minOccurs="0" name="totalWebappBandwidth" nillable="true"
+                                type="ax2249:BandwidthStatistics"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="usageEntries"
+                                nillable="true" type="ax2249:UsageEntry"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="webappBandwidthStatistics"
+                                nillable="true" type="ax2249:BandwidthStatistics"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="BandwidthStatistics">
+                <xs:sequence>
+
+                    <xs:element minOccurs="0" name="incomingBandwidth" type="xs:long"/>
+                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="outgoingBandwidth" type="xs:long"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="TenantDataCapacity">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
+                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
+
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="RequestStatistics">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="faultCount" type="xs:long"/>
+                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="requestCount" type="xs:long"/>
+                    <xs:element minOccurs="0" name="responseCount" type="xs:long"/>
+                </xs:sequence>
+
+            </xs:complexType>
+            <xs:complexType name="UsageEntry">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="PaginatedTenantUsageInfo">
+                <xs:sequence>
+
+                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
+                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="tenantUsages"
+                                nillable="true" type="ax2249:TenantUsage"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="PaginatedInstanceUsage">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceUsages"
+                                nillable="true" type="ax2249:InstanceUsageStatics"/>
+                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
+
+                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:complexType name="InstanceUsageStatics">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="instanceID" nillable="true" type="xs:int"/>
+                    <xs:element minOccurs="0" name="instanceURL" nillable="true" type="xs:string"/>
+                    <xs:element minOccurs="0" name="running" type="xs:boolean"/>
+                    <xs:element minOccurs="0" name="startTime" nillable="true" type="xs:dateTime"/>
+
+                    <xs:element minOccurs="0" name="stopTime" nillable="true" type="xs:dateTime"/>
+                    <xs:element minOccurs="0" name="usedTimeInSeconds" type="xs:long"/>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+        <xs:schema xmlns:ax2250="http://beans.usage.carbon.wso2.org/xsd"
+                   attributeFormDefault="qualified" elementFormDefault="qualified"
+                   targetNamespace="http://services.usage.carbon.wso2.org">
+            <xs:import namespace="http://beans.usage.carbon.wso2.org/xsd"/>
+            <xs:element name="Exception">
+                <xs:complexType>
+
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="Exception" nillable="true"
+                                    type="ns:Exception"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:complexType name="Exception">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
+                </xs:sequence>
+
+            </xs:complexType>
+            <xs:element name="retrieveTenantUsages">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
+                                    type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveTenantUsagesResponse">
+
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
+                                    nillable="true" type="ax2250:TenantUsage"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveTenantUsage">
+                <xs:complexType>
+                    <xs:sequence>
+
+                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
+                                    type="xs:string"/>
+                        <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveTenantUsageResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true"
+                                    type="ax2250:TenantUsage"/>
+
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrievePaginatedTenantUsages">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
+                                    type="xs:string"/>
+                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
+                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
+
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrievePaginatedTenantUsagesResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true"
+                                    type="ax2250:PaginatedTenantUsageInfo"/>
+                    </xs:sequence>
+                </xs:complexType>
+
+            </xs:element>
+            <xs:element name="retrievePaginatedInstanceUsage">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
+                                    type="xs:string"/>
+                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
+                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
+                    </xs:sequence>
+                </xs:complexType>
+
+            </xs:element>
+            <xs:element name="retrievePaginatedInstanceUsageResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true"
+                                    type="ax2250:PaginatedInstanceUsage"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveInstanceUsageResponse">
+
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
+                                    nillable="true" type="ax2250:InstanceUsageStatics"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveCurrentTenantUsage">
+                <xs:complexType>
+                    <xs:sequence>
+
+                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
+                                    type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="retrieveCurrentTenantUsageResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true"
+                                    type="ax2250:TenantUsage"/>
+                    </xs:sequence>
+
+                </xs:complexType>
+            </xs:element>
+        </xs:schema>
+    </wsdl:types>
+    <wsdl:message name="retrievePaginatedTenantUsagesRequest">
+        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsages"/>
+    </wsdl:message>
+    <wsdl:message name="retrievePaginatedTenantUsagesResponse">
+        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsagesResponse"/>
+
+    </wsdl:message>
+    <wsdl:message name="Exception">
+        <wsdl:part name="parameters" element="ns:Exception"/>
+    </wsdl:message>
+    <wsdl:message name="retrieveCurrentTenantUsageRequest">
+        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsage"/>
+    </wsdl:message>
+    <wsdl:message name="retrieveCurrentTenantUsageResponse">
+        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsageResponse"/>
+
+    </wsdl:message>
+    <wsdl:message name="retrieveTenantUsagesRequest">
+        <wsdl:part name="parameters" element="ns:retrieveTenantUsages"/>
+    </wsdl:message>
+    <wsdl:message name="retrieveTenantUsagesResponse">
+        <wsdl:part name="parameters" element="ns:retrieveTenantUsagesResponse"/>
+    </wsdl:message>
+    <wsdl:message name="retrieveTenantUsageRequest">
+        <wsdl:part name="parameters" element="ns:retrieveTenantUsage"/>
+
+    </wsdl:message>
+    <wsdl:message name="retrieveTenantUsageResponse">
+        <wsdl:part name="parameters" element="ns:retrieveTenantUsageResponse"/>
+    </wsdl:message>
+    <wsdl:message name="retrieveInstanceUsageRequest"/>
+    <wsdl:message name="retrieveInstanceUsageResponse">
+        <wsdl:part name="parameters" element="ns:retrieveInstanceUsageResponse"/>
+    </wsdl:message>
+    <wsdl:message name="retrievePaginatedInstanceUsageRequest">
+
+        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsage"/>
+    </wsdl:message>
+    <wsdl:message name="retrievePaginatedInstanceUsageResponse">
+        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsageResponse"/>
+    </wsdl:message>
+    <wsdl:portType name="UsageServicePortType">
+        <wsdl:operation name="retrievePaginatedTenantUsages">
+            <wsdl:input message="ns:retrievePaginatedTenantUsagesRequest"
+                        wsaw:Action="urn:retrievePaginatedTenantUsages"/>
+            <wsdl:output message="ns:retrievePaginatedTenantUsagesResponse"
+                         wsaw:Action="urn:retrievePaginatedTenantUsagesResponse"/>
+
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrievePaginatedTenantUsagesException"/>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveCurrentTenantUsage">
+            <wsdl:input message="ns:retrieveCurrentTenantUsageRequest"
+                        wsaw:Action="urn:retrieveCurrentTenantUsage"/>
+            <wsdl:output message="ns:retrieveCurrentTenantUsageResponse"
+                         wsaw:Action="urn:retrieveCurrentTenantUsageResponse"/>
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrieveCurrentTenantUsageException"/>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveTenantUsages">
+            <wsdl:input message="ns:retrieveTenantUsagesRequest"
+                        wsaw:Action="urn:retrieveTenantUsages"/>
+
+            <wsdl:output message="ns:retrieveTenantUsagesResponse"
+                         wsaw:Action="urn:retrieveTenantUsagesResponse"/>
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrieveTenantUsagesException"/>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveTenantUsage">
+            <wsdl:input message="ns:retrieveTenantUsageRequest"
+                        wsaw:Action="urn:retrieveTenantUsage"/>
+            <wsdl:output message="ns:retrieveTenantUsageResponse"
+                         wsaw:Action="urn:retrieveTenantUsageResponse"/>
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrieveTenantUsageException"/>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveInstanceUsage">
+
+            <wsdl:input message="ns:retrieveInstanceUsageRequest"
+                        wsaw:Action="urn:retrieveInstanceUsage"/>
+            <wsdl:output message="ns:retrieveInstanceUsageResponse"
+                         wsaw:Action="urn:retrieveInstanceUsageResponse"/>
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrieveInstanceUsageException"/>
+        </wsdl:operation>
+        <wsdl:operation name="retrievePaginatedInstanceUsage">
+            <wsdl:input message="ns:retrievePaginatedInstanceUsageRequest"
+                        wsaw:Action="urn:retrievePaginatedInstanceUsage"/>
+            <wsdl:output message="ns:retrievePaginatedInstanceUsageResponse"
+                         wsaw:Action="urn:retrievePaginatedInstanceUsageResponse"/>
+            <wsdl:fault message="ns:Exception" name="Exception"
+                        wsaw:Action="urn:retrievePaginatedInstanceUsageException"/>
+        </wsdl:operation>
+
+    </wsdl:portType>
+    <wsdl:binding name="UsageServiceSoap11Binding" type="ns:UsageServicePortType">
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <wsdl:operation name="retrievePaginatedTenantUsages">
+            <soap:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveCurrentTenantUsage">
+            <soap:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
+            <wsdl:input>
+
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveTenantUsages">
+            <soap:operation soapAction="urn:retrieveTenantUsages" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveTenantUsage">
+            <soap:operation soapAction="urn:retrieveTenantUsage" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveInstanceUsage">
+            <soap:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
+            <wsdl:input>
+
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrievePaginatedInstanceUsage">
+            <soap:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+
+                <soap:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="UsageServiceSoap12Binding" type="ns:UsageServicePortType">
+        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <wsdl:operation name="retrievePaginatedTenantUsages">
+            <soap12:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
+            <wsdl:input>
+
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveCurrentTenantUsage">
+            <soap12:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveTenantUsages">
+            <soap12:operation soapAction="urn:retrieveTenantUsages" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveTenantUsage">
+            <soap12:operation soapAction="urn:retrieveTenantUsage" style="document"/>
+            <wsdl:input>
+
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveInstanceUsage">
+            <soap12:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        <wsdl:operation name="retrievePaginatedInstanceUsage">
+            <soap12:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+
+                <soap12:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="Exception">
+                <soap12:fault use="literal" name="Exception"/>
+            </wsdl:fault>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="UsageServiceHttpBinding" type="ns:UsageServicePortType">
+        <http:binding verb="POST"/>
+
+        <wsdl:operation name="retrievePaginatedTenantUsages">
+            <http:operation location="retrievePaginatedTenantUsages"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveCurrentTenantUsage">
+            <http:operation location="retrieveCurrentTenantUsage"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveTenantUsages">
+            <http:operation location="retrieveTenantUsages"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveTenantUsage">
+            <http:operation location="retrieveTenantUsage"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrieveInstanceUsage">
+            <http:operation location="retrieveInstanceUsage"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="retrievePaginatedInstanceUsage">
+            <http:operation location="retrievePaginatedInstanceUsage"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="parameters"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+    </wsdl:binding>
+    <wsdl:service name="UsageService">
+        <wsdl:port name="UsageServiceHttpsSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
+            <soap:address
+                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap11Endpoint/"/>
+        </wsdl:port>
+        <wsdl:port name="UsageServiceHttpSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
+            <soap:address
+                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap11Endpoint/"/>
+        </wsdl:port>
+        <wsdl:port name="UsageServiceHttpSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
+
+            <soap12:address
+                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap12Endpoint/"/>
+        </wsdl:port>
+        <wsdl:port name="UsageServiceHttpsSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
+            <soap12:address
+                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap12Endpoint/"/>
+        </wsdl:port>
+        <wsdl:port name="UsageServiceHttpEndpoint" binding="ns:UsageServiceHttpBinding">
+            <http:address
+                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpEndpoint/"/>
+        </wsdl:port>
+        <wsdl:port name="UsageServiceHttpsEndpoint" binding="ns:UsageServiceHttpBinding">
+
+            <http:address
+                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsEndpoint/"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/JSResources.properties b/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/JSResources.properties
new file mode 100644
index 0000000..e7490b0
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/JSResources.properties
@@ -0,0 +1,2 @@
+empty=To make sure the js properties file is not empty
+session.timed.out=Session timed out. Please login again
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/Resources.properties b/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/Resources.properties
new file mode 100644
index 0000000..d7eda93
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/org/apache/carbon/usage/ui/i18n/Resources.properties
@@ -0,0 +1,57 @@
+usage.menu=User Usage
+user.usage.report=User Usage Report
+tenant.menu=Tenant Usage
+tenants.usage.report=Tenant Usage Report
+tenant.usage.report=Usage Report
+data.storage.name=Data Storage
+current.data.storage=Current Data Storage
+history.data.storage=Historical Data Storage
+total.data.storage=Total Data Storage
+registry.content.storage.name=Registry Content
+registry.bandwidth.usage=Registry Bandwidth Usage
+service.bandwidth.usage=Service Bandwidth Usage
+webapp.bandwidth.usage=Webapp Bandwidth Usage
+server.name=Server Name
+all.server.name=All Server Total
+incoming.bandwidth=Incoming Bandwidth
+outgoing.bandwidth=Outgoing Bandwidth
+total.bandwidth=Total Bandwidth
+storage.usage=Storage Usage
+number.of.users=Number of Users
+users=Users
+usage.monitoring=Usage Monitoring
+all.tenant.usage.report=All Tenant Usage
+tenant.domain=Domain
+tenant.id=Id
+full.report=Full Report
+report.duration=Report Duration
+year.month=Year-Month
+back=Back
+page.x.to.y=Page {0}
+prev=Prev
+next=Next
+service.usage.stat=Service Usage Statistics
+service.usage.request=Request Count
+service.usage.response=Response Count
+service.usage.fault=Fault Count
+service.total.request=Service Requests
+registry.total.bandwidth=Total Registry Bandwidth
+service.total.bandwidth=Total Service Bandwidth
+instance.usage.report=Instance Usage Report
+instance.server.url=Instance Server URL
+instance.id=Instance ID
+start.time=Start Time
+stop.time=Stop Time
+used.time.in.hours=Used Time In Hours
+instances.data=Instances Data
+failed.to.get.instance.data=Failed To Get Instance Data
+empty.instance.data=Instance Data Not Found
+usage.data.not.available=Usage Data not available
+empty.usage.data=Usage Data Not Found
+webapp.total.bandwidth=Total WebApp Bandwidth
+number.of.api.calls= Number of API Calls
+api.usage=API Usage
+cartridge.stat=Cartridge Usage
+cartridge.type=Cartridge Type
+image.id=Image ID
+cartridge.hours=Hours
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
new file mode 100644
index 0000000..32e03ba
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
@@ -0,0 +1,217 @@
+<!--
+  ~  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.
+  -->
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage" %>
+<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+
+<carbon:jsi18n
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
+        request="<%=request%>"/>
+
+
+<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
+    <carbon:breadcrumb
+            label="tenants.usage.report"
+            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+            topPage="true"
+            request="<%=request%>"/>
+    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
+    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
+    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
+    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
+
+
+    <%
+        String yearMonth = request.getParameter("year-month");
+        session.setAttribute("year-month", yearMonth);
+        int pageNumber=0;
+        int rowCount = 5;
+        int numberOfPages=0;
+        InstanceUsageStatics[] instanceUsages=null;
+        if (yearMonth == null) {
+            // get the current year month
+            yearMonth = UsageUtil.getCurrentYearMonth();
+        }
+        try{
+        PaginatedInstanceUsage instanceInfo =
+                UsageUtil.retrievePaginatedInstanceUsages(request, config, session);
+        instanceUsages = instanceInfo.getInstanceUsages();
+        pageNumber = instanceInfo.getPageNumber();
+        numberOfPages = instanceInfo.getNumberOfPages();
+
+        String currentYearMonth = UsageUtil.getCurrentYearMonth();
+
+        if (yearMonth.equals(currentYearMonth)) {
+            rowCount = 7;
+        }
+        }
+        catch (Exception e){
+        //No need to handle here it here.Error will show in next try block
+        //To avoid dead page
+        }
+    %>
+
+    <div id="middle">
+
+        <h2><fmt:message key="instance.usage.report"/> for the Month - <%=yearMonth%> (With All
+            Running Instances)</h2>
+
+        <div id="report_ui">
+            <carbon:reportNew
+                    component="org.wso2.carbon.usage"
+                    template="all_tenant_usage_report"
+                    pdfReport="true"
+                    htmlReport="true"
+                    excelReport="true"
+                    reportDataSession="all_tenant_usage_data"
+                    jsFunction="getUsageReportData()"/>
+        </div>
+
+        <div id="workArea">
+
+            <form id="usageForm" action="all_tenant_instance_usage.jsp" method="post">
+
+
+                <table class="styledLeft">
+                    <thead>
+                    <tr>
+                        <th>
+                            <fmt:message key="report.duration"/>
+                        </th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr>
+                        <td class="nopadding">
+                            <table class="normal-nopadding" cellspacing="0">
+                                <tbody>
+                                <tr>
+                                    <td><fmt:message key="year.month"/></td>
+                                    <td colspan="2">
+                                        <select onchange="this.form.submit()" name="year-month"
+                                                id="year-month" style="width:400px">
+                                            <%
+                                                for (String ym : UsageUtil.getYearMonths()) {
+                                                    String selectedStr = "";
+                                                    if (ym.equals(yearMonth)) {
+                                                        selectedStr = "selected=\"true\" ";
+                                                    }
+                                            %>
+                                            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
+                                            </option>
+                                            <%
+                                                }
+                                            %>
+                                        </select>
+                                        <input type="hidden" name="requestedPage" id="requestedPage"
+                                               value="<%=pageNumber%>"/>
+                                    </td>
+                                </tr>
+
+                                <tr>
+                                    <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
+                                            key="instances.data"/></td>
+                                </tr>
+                                <tr>
+                                    <th><fmt:message key="instance.id"/></th>
+                                    <th><fmt:message key="server.name"/></th>
+                                    <th><fmt:message key="start.time"/></th>
+                                    <th><fmt:message key="stop.time"/></th>
+                                    <th><fmt:message key="used.time.in.hours"/></th>
+                                </tr>
+                                <%                
+                                    try{
+                                    InstanceUsageStatics[] iu = UsageUtil.retrieveInstanceUsage(request, config, session);
+                                    java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz");
+                                    if (!iu.equals(null)) {
+                                        for (InstanceUsageStatics usage : instanceUsages) {
+                                            String endDate;
+                                            if (usage.getRunning() == true) {
+                                                endDate="Instance Still Running";
+                                            }
+                                            else{
+                                                endDate=dateFormatter.format(usage.getStopTime().getTime());
+                                            }
+                                            String startDate=dateFormatter.format(usage.getStartTime().getTime());
+                                            long usedHours;
+                                            long usedTimeInSeconds=usage.getUsedTimeInSeconds();
+                                            if(usedTimeInSeconds%3600==0){
+                                                usedHours=usedTimeInSeconds/3600;
+                                            }
+                                            else{
+                                                usedHours=(usedTimeInSeconds/3600)+1;
+                                            }
+                                %>
+                                <tr>
+                                    <td>
+                                        <%=usage.getInstanceID()%>
+                                    </td>
+                                    <td>
+                                        <%=usage.getInstanceURL().toString()%>
+                                    </td>
+                                    <td>
+                                        <%=startDate%>
+                                    </td>
+                                    <td>
+                                        <%=endDate%>
+                                    </td>
+                                    <td>
+
+                                        <%=usedHours%>
+                                    </td>
+                                </tr>
+                                <%
+
+                                        }
+                                    }
+                                    else{
+                                      %>
+                                     <td><fmt:message key="empty.instance.data"/></td>
+                                <%
+                                 }
+                                    }
+                                    catch (Exception e){ %>
+                                      <td><fmt:message key="failed.to.get.instance.data"/></td>
+                                   <% }
+                                %>
+                                <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
+                                                          numberOfPages="<%=numberOfPages%>"
+                                                          resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+                                                          nextKey="next" prevKey="prev"
+                                                          tdColSpan="6"
+                                                          paginationFunction="submitAllTenantPaginatedUsage({0})"/>
+                                </tbody>
+                            </table>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </form>
+            <br/>
+        </div>
+    </div>
+</fmt:bundle>
+
+


[15/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
deleted file mode 100644
index b3561b8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.util;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.Agent;
-import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.conf.AgentConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
-import org.wso2.carbon.databridge.commons.Event;
-import org.wso2.carbon.databridge.commons.exception.AuthenticationException;
-import org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException;
-import org.wso2.carbon.databridge.commons.exception.TransportException;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.user.api.Tenant;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.NetworkUtils;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-import org.wso2.carbon.usage.agent.beans.APIManagerRequestStats;
-
-import java.math.BigInteger;
-import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * this class provide utility methods to publish usage statistics
- */
-public class PublisherUtils {
-    private static Log log = LogFactory.getLog(PublisherUtils.class);
-    private static final String TRANSPORT = "https";
-    private static ConfigurationContextService configurationContextService;
-    private static Agent agent;
-    private static DataPublisher dataPublisher;
-    private static AsyncDataPublisher asyncDataPublisher;
-    private static String streamId;
-    private static final String usageEventStream = "org.wso2.carbon.usage.agent";
-    private static final String usageEventStreamVersion = "1.0.0";
-    
-    private static final String reqStatEventStream="org.wso2.carbon.service.request.stats";
-    private static final String reqStatEventStreamVersion="1.0.0";
-    private static String reqStatEventStreamId;
-    
-    private static Map<Integer, String> serverUrlMap = new HashMap<Integer, String>();
-
-
-    /**
-     * method to update server name
-     * @param tenantId tenant id
-     * @return server name
-     * @throws UsageException
-     */
-
-    public static String updateServerName(int tenantId) throws UsageException {
-
-        String serverName;
-        String hostName;
-
-        try {
-            hostName = NetworkUtils.getLocalHostname();
-        } catch (SocketException e) {
-            throw new UsageException("Error getting host name for the registry usage event payload",
-                    e);
-        }
-
-        ConfigurationContextService configurationContextService = PublisherUtils.
-                getConfigurationContextService();
-        ConfigurationContext configurationContext;
-        if (configurationContextService != null) {
-            configurationContext = configurationContextService.getServerConfigContext();
-        } else {
-            throw new UsageException("ConfigurationContext is null");
-        }
-//        int port = CarbonUtils.getTransportPort(configurationContext, "https");
-
-        String carbonHttpsPort = System.getProperty("carbon." + TRANSPORT + ".port");
-        if (carbonHttpsPort == null) {
-            carbonHttpsPort = Integer.toString(
-                    CarbonUtils.getTransportPort(configurationContext, TRANSPORT));
-        }
-        String baseServerUrl = TRANSPORT + "://" + hostName + ":" + carbonHttpsPort;
-        String context = configurationContext.getContextRoot();
-
-        String tenantDomain = null;
-        try {
-            Tenant tenant = Util.getRealmService().getTenantManager().getTenant(tenantId);
-            if(tenant!=null){
-                tenantDomain = tenant.getDomain();
-            }
-        } catch (org.wso2.carbon.user.api.UserStoreException e) {
-            throw new UsageException("Failed to get tenant domain", e);
-        }
-
-        if ((tenantDomain != null) &&
-                !(tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) {
-            serverName = baseServerUrl + context + "t/" + tenantDomain;
-
-        } else if (context.equals("/")) {
-
-            serverName = baseServerUrl + "";
-        } else {
-            serverName = baseServerUrl + context;
-
-        }
-
-        return serverName;
-    }
-    
-    public static String getServerUrl(int tenantId){
-
-        String serverUrl = serverUrlMap.get(tenantId);
-        if(serverUrl!=null){
-            return serverUrl;
-        }
-
-        if(serverUrl==null){
-            try{
-                serverUrl = updateServerName(tenantId);
-            }catch (UsageException e) {
-                log.error("Could not create the server url for tenant id: " + tenantId, e);
-            }
-        }
-
-        if(serverUrl!=null && !"".equals(serverUrl)){
-            serverUrlMap.put(tenantId, serverUrl);
-        }
-        return serverUrl;
-    }
-
-    public static void defineUsageEventStream() throws Exception {
-
-        createDataPublisher();
-
-        if(dataPublisher == null){
-            return;
-        }
-
-        try {
-
-            streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            log.info("Event stream with stream ID: " + streamId + " found.");
-
-        } catch (NoStreamDefinitionExistException e) {
-
-            log.info("Defining the event stream because it was not found in BAM");
-            try {
-                defineStream();    
-            } catch (Exception ex) {
-                String msg = "An error occurred while defining the even stream for Usage agent. " + e.getMessage();
-                log.warn(msg);
-            }
-
-        }
-
-    }
-    
-    private static void defineStream() throws Exception {
-        streamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + usageEventStream +"'," +
-                        "  'version':'" + usageEventStreamVersion +"'," +
-                        "  'nickName': 'usage.agent'," +
-                        "  'description': 'Tenant usage data'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'Type','type':'STRING'}," +
-                        "          {'name':'Value','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-        
-    }
-    
-    private static void defineRequestStatEventStream() throws Exception{
-        reqStatEventStreamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + reqStatEventStream +"'," +
-                        "  'version':'" + reqStatEventStreamVersion +"'," +
-                        "  'nickName': 'service.request.stats'," +
-                        "  'description': 'Tenants service request statistics'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'RequestCount','type':'INT'}," +
-                        "          {'name':'ResponseCount','type':'INT'}," +
-                        "          {'name':'FaultCount','type':'INT'}," +
-                        "          {'name':'ResponseTime','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-    }
-
-    public static void createDataPublisher(){
-
-        ServerConfiguration serverConfig =  CarbonUtils.getServerConfiguration();
-        String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
-        String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
-        String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
-        String adminUsername = CommonUtil.getStratosConfig().getAdminUserName();
-        String adminPassword = CommonUtil.getStratosConfig().getAdminPassword();
-
-        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
-        System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
-
-        try {
-            dataPublisher = new DataPublisher(bamServerUrl, adminUsername, adminPassword);
-        } catch (Exception e) {
-            log.warn("Unable to create a data publisher to " + bamServerUrl +
-                    ". Usage Agent will not function properly. " + e.getMessage());
-        }
-
-    }
-
-    /**
-     * Creates an async data publisher using the existing data publisher object
-     */
-    public static void createAsynDataPublisher(){
-        if(dataPublisher==null){
-            createDataPublisher();
-        }
-
-        if(dataPublisher==null){
-            log.warn("Cannot create the async data publisher because the data publisher is null");
-            return;
-        }
-
-        try {
-            asyncDataPublisher = new AsyncDataPublisher(dataPublisher);
-        } catch (Exception e) {
-            log.error("Could not create an async data publisher using the data publisher", e);
-        }
-    }
-
-
-    /**
-     * this method get the event payload, construct the SOAP envelop and call the publish method in
-     * EventBrokerService.
-     *
-     * @param usage BandwidthUsage
-     * @throws UsageException
-     */
-    public static void publish(BandwidthUsage usage) throws UsageException {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for usage data publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(streamId == null){
-            try{
-                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                                        new Object[]{getServerUrl(usage.getTenantId()),
-                                                    Integer.toString(usage.getTenantId()),
-                                                    usage.getMeasurement(),
-                                                    usage.getValue()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-    
-    public static void publish(SystemStatistics statistics, int tenantId) throws Exception {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for service-stats publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(reqStatEventStreamId == null){
-            try{
-                reqStatEventStreamId = dataPublisher.findStream(reqStatEventStream, reqStatEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineRequestStatEventStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(reqStatEventStreamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                    new Object[]{getServerUrl(tenantId),
-                            Integer.toString(tenantId),
-                            statistics.getCurrentInvocationRequestCount(),
-                            statistics.getCurrentInvocationResponseCount(),
-                            statistics.getCurrentInvocationFaultCount(),
-                            statistics.getCurrentInvocationResponseTime()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-
-    /**
-     * @param statistics APIManagerRequestStats which contains usage data
-     * @param tenantId   Tenant id of tenant associated with usage stat
-     * @throws Exception UsageException when error in usage stat publishing
-     */
-    public static void publish(APIManagerRequestStats statistics, int tenantId) throws Exception {
-
-        if (dataPublisher == null) {
-            log.info("Creating data publisher for usage data publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if (dataPublisher == null) {
-                return;
-            }
-        }
-
-        if (streamId == null) {
-            try {
-                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            } catch (NoStreamDefinitionExistException e) {
-                log.info("Defining the event stream because it was not found in BAM");
-                try {
-                    defineStream();
-                } catch (Exception ex) {
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            } catch (Exception exc) {
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-            //Get data from API manager request stat object and create event
-            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                    new Object[]{getServerUrl(statistics.getTenantId()),
-                            Integer.toString(statistics.getTenantId()),
-                            statistics.getMeasurement(),
-                            statistics.getValue()});
-            //publish usage to bam
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-
-    /**
-     * method to get configurationContextService
-     * @return configurationContextService
-     */
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return configurationContextService;
-    }
-
-    /**
-     * method to setConfigurationContextService
-     * @param configurationContextService
-     */
-    public static void setConfigurationContextService(ConfigurationContextService configurationContextService) {
-        PublisherUtils.configurationContextService = configurationContextService;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
deleted file mode 100644
index 8bbd800..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-/**
- * this class define constants for UsageAgent component
- */
-public class UsageAgentConstants {
-    public static final String ELEMENT_NAME_DATA = "Data";
-    public static final String ELEMENT_NAME_KEY = "Key";
-    public static final String ELEMENT_NAME_VALUE = "Value";
-
-    public static final String STATISTICS_DATA_NS_URI = "http://wso2.org/ns/2009/09/bam/server/user-defined/data";
-    public static final String STATISTICS_DATA_NS_PREFIX = "svrusrdata";
-
-    // OM element names
-    public static final String STATISTICS_DATA_ELEMENT_NAME_EVENT = "Event";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVICE_STATISTICS_DATA = "ServerUserDefinedData";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_TENANT_ID = "TenantID";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVER_NAME = "ServerName";
-
-    public static final String BAM_SERVER_URL = "BamServerURL";
-    public static final String BAM_SERVER_STAT_SERVICE = "BAMServerUserDefinedDataSubscriberService";
-    public static final String BAM_SERVER_STAT_FILTER = "carbon/bam/data/publishers/bandwidth-stat";
-
-    public static final String TOPIC_SEPARATOR = "/";
-    public static final String EVENT_NAME = "UsageMeteringEvent";
-
-    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER;
-//    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER + TOPIC_SEPARATOR + EVENT_NAME;
-
-
-    public static final String BANDWIDTH_USAGE_SERVICES_CONTEXT = "services";
-    public static final String BANDWIDTH_USAGE_WEBAPPS_CONTEXT = "webapps";
-    public static final String BANDWIDTH_CARBON = "carbon";
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
deleted file mode 100644
index f29b261..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.event.core.exception.EventBrokerException;
-import org.wso2.carbon.event.core.subscription.Subscription;
-import org.wso2.carbon.event.core.util.EventBrokerConstants;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.listeners.RegistryUsageListener;
-import org.wso2.carbon.usage.agent.persist.UsageDataPersistenceManager;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.File;
-
-
-/**
- * this class provide utility methods to set and get RealmService, initializing listeners,
- * initializing PersistenceManager etc
- * Further it provide methods to create statistics event subscription
- */
-
-public class Util {
-    private static final Log log = LogFactory.getLog(Util.class);
-    private static final String USAGE_THROTTLING_AGENT_CONFIG_FILE = "usage-throttling-agent-config.xml";
-    private static RealmService realmService;
-    private static ConfigurationContextService contextService;
-    private static UsageDataPersistenceManager persistenceManager;
-    //private static EventBrokerService eventBrokerService;
-    private static EventBroker eventBrokerService;
-    private static ServerConfigurationService serverConfiguration;
-
-    private static SystemStatisticsUtil systemStatisticsUtil;
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static void initializeAllListeners() throws Exception {
-        RegistryUsageListener.registerRegistryUsagePersistingListener(
-                RegistryContext.getBaseInstance());
-    }
-
-    public static void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.contextService = contextService;
-    }
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return Util.contextService;
-    }
-
-    /**
-     * this method create a PersistenceManager instance and start a thread for persisting statistics
-     */
-
-    public static void initializePersistenceManager() {
-        File usageAgentConfigFile  = new File(CarbonUtils.getCarbonConfigDirPath() + File.separator +
-                StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + Util.USAGE_THROTTLING_AGENT_CONFIG_FILE);
-        persistenceManager = new UsageDataPersistenceManager(new UsageAgentConfiguration(usageAgentConfigFile));
-        //start a thread for persisting bandwidth Usage statistics
-        if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            persistenceManager.scheduleBandwidthUsageDataRetrievalTask();
-            persistenceManager.scheduleUsageDataPersistenceTask();
-        }
-    }
-
-    public static void addToPersistingControllerQueue(BandwidthUsage usage) {
-        persistenceManager.addToQueue(usage);
-    }
-
-    public static EventBroker getEventBrokerService() {
-        return eventBrokerService;
-    }
-
-    public static void setEventBrokerService(EventBroker eventBrokerService) {
-        Util.eventBrokerService = eventBrokerService;
-    }
-
-    public static ServerConfigurationService getServerConfiguration() {
-        return serverConfiguration;
-    }
-
-    public static void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.serverConfiguration = serverConfiguration;
-    }
-
-    public static SystemStatisticsUtil getSystemStatisticsUtil() {
-        return systemStatisticsUtil;
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil) {
-        Util.systemStatisticsUtil = systemStatisticsUtil;
-    }
-
-    /**
-     * method to create static subscription to BAM
-     *
-     * @throws EventBrokerException, if creating the static subscription to BAM failed.
-     */
-    public static void createStaticEventSubscription() throws EventBrokerException {
-
-        //Get BAM URL from carbon.xml
-        ServerConfigurationService serverConfiguration = getServerConfiguration();
-        if (serverConfiguration == null) {
-            throw new IllegalArgumentException("Invalid server configuration");
-        }
-        String serverURL = serverConfiguration.getFirstProperty(UsageAgentConstants.BAM_SERVER_URL);
-
-        if(log.isDebugEnabled()){
-            log.debug("Bam url = " + serverURL);
-        }
-
-        //Add static subscription only if bam url is set
-        if (serverURL != null) {
-            String serviceURL = serverURL + UsageAgentConstants.BAM_SERVER_STAT_SERVICE;
-
-            EventBroker eventBrokerService = getEventBrokerService();
-            Subscription subscription = new Subscription();
-            // set the subscription end point to the service url
-            subscription.setEventSinkURL(serviceURL);
-            subscription.setTopicName(UsageAgentConstants.BAM_SERVER_STAT_FILTER);
-            subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);
-
-            try {
-                eventBrokerService.subscribe(subscription);
-            } catch (EventBrokerException e) {
-                String msg = "Cannot subscribe to the event broker ";
-                log.error(msg);
-                throw e;
-            }
-        }
-    }
-    
-    public static int getTenantId(String toAddress) throws Exception {
-        int index = toAddress.indexOf("/t/");
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        if(index >= 0){
-            String tenantDomain = toAddress.substring(index+2, toAddress.indexOf("/", index+3));
-            tenantId = getRealmService().getTenantManager().getTenantId(tenantDomain);
-        }
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 564f65f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage/customUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/module.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/module.xml
deleted file mode 100644
index 23f6025..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<module name="metering" class="org.wso2.carbon.usage.agent.listeners.axis2.RequestMeteringModule">
-   <InFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFlow>
-
-   <InFaultFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFaultFlow>
-
-    <OutFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-    </OutFlow>
-
-    <OutFaultFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-
-    </OutFaultFlow>
-   <parameter name="adminModule" locked="true">true</parameter>
-</module>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 720bdb9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-  <service name="CustomMeteringService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.agent.services.CustomMeteringService
-        </parameter>
-    </service>   
-    <parameter name="adminService" locked="true">true</parameter>
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/usage-throttling-agent-config.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/usage-throttling-agent-config.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/usage-throttling-agent-config.xml
deleted file mode 100644
index 6a222d7..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/resources/META-INF/usage-throttling-agent-config.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<UsageAndThrottlingAgentConfiguration xmlns="http://wso2.com/carbon/multitenancy/usage-throttling-agent/config">
-    <UsageAgent>
-        <UsageDataPersistenceTask>
-            <StartupDelayInMilliSeconds>60000</StartupDelayInMilliSeconds>
-            <NumberOfRecordsPerExecution>100</NumberOfRecordsPerExecution>
-            <ExecutionIntervalInMilliSeconds>100</ExecutionIntervalInMilliSeconds>
-        </UsageDataPersistenceTask>
-    </UsageAgent>
-    <ThrottlingAgent>
-        <ThrottlingInfoCacheUpdaterTask>
-            <StartupDelayInSeconds></StartupDelayInSeconds>
-            <ExecutionIntervalInSeconds></ExecutionIntervalInSeconds>
-        </ThrottlingInfoCacheUpdaterTask>
-    </ThrottlingAgent>
-</UsageAndThrottlingAgentConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/pom.xml
deleted file mode 100644
index 6d93478..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/pom.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.wso2.carbon</groupId>
-    <version>1.0.0</version>
-    <artifactId>org.wso2.carbon.usage.usage.summary.helper</artifactId>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos Usage Summary Generation Helper</name>
-
-    <build>
-
-        <plugins>
-	    <plugin>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>maven-scr-plugin</artifactId>
-                    <version>1.7.2</version>
-                    <executions>
-                        <execution>
-                            <id>generate-scr-scrdescriptor</id>
-                            <goals>
-                                <goal>scr</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-                </plugin>
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.summary.*,
-                        </Export-Package>
-                        <Import-Package>
-                            *;resolution:=optional
-                        </Import-Package>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-		<dependency>
-    	    <groupId>org.apache.hive.wso2</groupId>
-		    <artifactId>hive</artifactId>
-    	    <version>0.8.1.wso2v3</version>
-			<exclusions>
-        		<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-exec</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-shims</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-builtins</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-service</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-serde</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-metastore</artifactId>
-       	 		</exclusion>	
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-cassandra</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-jdbc</artifactId>
-       	 		</exclusion>
-				<exclusion>
-					<groupId>org.wso2.carbon</groupId>
-                    <artifactId>hive-jdbc-handler</artifactId>
-                </exclusion>
-			</exclusions> 
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.analytics.hive</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.hadoop</groupId>
-            <artifactId>hadoop-core</artifactId>
-            <version>0.20.2</version>
-        </dependency>
-    </dependencies>
-
-    <repositories>
-        <repository>
-            <id>wso2-nexus</id>
-            <name>WSO2 internal Repository</name>
-            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
-            <releases>
-                <enabled>true</enabled>
-                <updatePolicy>daily</updatePolicy>
-                <checksumPolicy>ignore</checksumPolicy>
-            </releases>
-        </repository>
-    </repositories>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
deleted file mode 100644
index d3152c1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the hour range for the next daily summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current daily summarization cycle
- * from the usage hourly tables.
- */
-public class DailyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats daily summarization.");
-        try {
-            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsDailyTimestamp();
-            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running daily service stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
-            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
-            setProperty("current_daily_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting date range for daily service stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
deleted file mode 100644
index a80670c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the hour range for the next daily summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current daily summarization cycle
- * from the usage hourly tables.
- */
-public class DailySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage daily summarization.");
-        try {
-            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageDailyTimestamp();
-            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running daily usage analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
-            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
-            setProperty("current_daily_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting date range for daily usage analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
deleted file mode 100644
index f1b44cc..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
- * This is needed to excluded the already summarized usage stats in the current summarization cycle.
- */
-public class HourlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlyServiceStatsSummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats hourly summarization.");
-        try {
-            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsHourlyTimestamp();
-            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-
-            log.info("Running hourly service stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting hour range for hourly service stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
deleted file mode 100644
index bafe96b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
- * This is needed to excluded the already summarized usage stats in the current summarization cycle.
- */
-public class HourlySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage hourly summarization.");
-        try {
-            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageHourlyTimestamp();
-            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-
-            log.info("Running hourly usage analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting hour range for hourly usage analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
deleted file mode 100644
index dec01ea..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the date range for the next monthly summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current monthly summarization cycle
- * from the usage hourly tables.
- */
-public class MonthlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats monthly summarization.");
-        try {
-            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageMonthlyTimestamp();
-            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
-            setProperty("current_monthly_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting month range for monthly service stats analytics. ", e);
-        }
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
deleted file mode 100644
index ce32eba..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the date range for the next monthly summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current monthly summarization cycle
- * from the usage hourly tables.
- */
-public class MonthlySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage monthly summarization.");
-        try {
-            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsMonthlyTimestamp();
-            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
-            setProperty("current_monthly_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting month range for monthly service stats analysis. ", e);
-        }
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
deleted file mode 100644
index 9f36639..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.internal;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.analytics.hive.service.HiveExecutorService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.usage.summary.helper.util.DataHolder;
-
-import javax.sql.DataSource;
-
-/**
- *
- * @scr.component name="org.wso2.carbon.usage.summary" immediate="true"
- * @scr.reference name="hive.executor.service"
- * interface="org.wso2.carbon.analytics.hive.service.HiveExecutorService" cardinality="1..1"
- * policy="dynamic" bind="setHiveExecutorService" unbind="unsetHiveExecutorService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageSummaryHelperServiceComponent {
-    
-    private static Log log = LogFactory.getLog(UsageSummaryHelperServiceComponent.class);
-
-    protected void activate(ComponentContext context){
-
-        log.info("Stratos usage summary helper bundle started");
-        /*try{
-
-        }catch (Throwable t){
-            log.error("Error occurred while activating the usage summary helper bundle..", t);
-        }*/
-    }
-
-    protected void deactivate(){
-        log.debug("Usage summary helper bundle was deactivated..");
-    }
-
-    protected void setHiveExecutorService(HiveExecutorService executorService){
-        //DataHolder.setExecutorService(executorService);
-    }
-
-    protected void unsetHiveExecutorService(HiveExecutorService executorService){
-        //DataHolder.setExecutorService(null);
-    }
-    
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        DataHolder.setDataSourceService(dataSourceService);
-        try {
-            DataHolder.setDataSource((DataSource)dataSourceService.getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject());
-            log.info("Data source set to data holder");
-        } catch (Exception e) {
-            log.error("Error occurred while retrieving the data source: " + DataHolder.BILLING_DATA_SOURCE_NAME, e); //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        DataHolder.setDataSourceService(null);
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
deleted file mode 100644
index c43f65a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to retrieve relevant timestamps from relational database tables.
- */
-public class DataAccessObject {
-
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-
-    private static DataSource dataSource = null;
-
-    private static DataAccessObject usageDataAccessObj = null;
-
-    private DataAccessObject() {
-    }
-
-    public static DataAccessObject getInstance() throws Exception {
-        if (usageDataAccessObj == null) {
-            usageDataAccessObj = new DataAccessObject();
-        }
-
-        if (usageDataAccessObj.dataSource == null) {
-            if (DataHolder.getDataSource() != null) {
-                try {
-                    dataSource = DataHolder.getDataSource();
-                    //dataSource = (DataSource) DataHolder.getDataSourceService().
-                    //       getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject();
-                } catch (Exception e) {
-                    log.error("Error occurred while obtaining " + DataHolder.BILLING_DATA_SOURCE_NAME +
-                              " datasource from data source service.", e);
-                    throw new Exception(e);
-                }
-            } else {
-                log.error("Cannot obtain data source " + DataHolder.BILLING_DATA_SOURCE_NAME +
-                          ". Datasource service is null");
-                throw new Exception("Datasource service not available");
-            }
-
-        }
-
-        return usageDataAccessObj;
-    }
-
-    public String getAndUpdateLastUsageHourlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_HOURLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastUsageDailyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_DAILY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastUsageMonthlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_MONTHLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsHourlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_HOURLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsDailyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_DAILY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsMonthlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_MONTHLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
deleted file mode 100644
index edc2064..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.0/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.util;
-
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-import javax.sql.DataSource;
-
-public class DataHolder {
-
-    private static DataSourceService dataSourceService;
-
-    private static DataSource dataSource;
-
-    public static final String BILLING_DATA_SOURCE_NAME = "WSO2BillingDS";
-    //public static final String BILLING_DATA_SOURCE_NAME = "WSO2USAGE_DS";
-
-
-    public static DataSource getDataSource() {
-        return dataSource;
-    }
-
-    public static void setDataSource(DataSource dataSource) {
-        DataHolder.dataSource = dataSource;
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        DataHolder.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/pom.xml
deleted file mode 100644
index 60f172c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/pom.xml
+++ /dev/null
@@ -1,136 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.wso2.carbon</groupId>
-    <version>2.1.3</version>
-    <artifactId>org.wso2.carbon.usage.summary.helper</artifactId>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos Usage Summary Generation Helper</name>
-
-    <build>
-
-        <plugins>
-	    <plugin>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>maven-scr-plugin</artifactId>
-                    <version>1.7.2</version>
-                    <executions>
-                        <execution>
-                            <id>generate-scr-scrdescriptor</id>
-                            <goals>
-                                <goal>scr</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-                </plugin>
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.summary.*,
-                        </Export-Package>
-                        <Import-Package>
-                            *;resolution:=optional
-                        </Import-Package>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-		<dependency>
-    	    <groupId>org.apache.hive.wso2</groupId>
-		    <artifactId>hive</artifactId>
-    	    <version>0.8.1.wso2v3</version>
-			<exclusions>
-        		<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-exec</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-shims</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-builtins</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-service</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-serde</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-metastore</artifactId>
-       	 		</exclusion>	
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-cassandra</artifactId>
-       	 		</exclusion>
-				<exclusion>
-          			<groupId>org.apache.hive</groupId>
-          			<artifactId>hive-jdbc</artifactId>
-       	 		</exclusion>
-				<exclusion>
-					<groupId>org.wso2.carbon</groupId>
-                    <artifactId>hive-jdbc-handler</artifactId>
-                </exclusion>
-			</exclusions> 
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.analytics.hive</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.hadoop</groupId>
-            <artifactId>hadoop-core</artifactId>
-            <version>0.20.2</version>
-        </dependency>
-    </dependencies>
-
-    <repositories>
-        <repository>
-            <id>wso2-nexus</id>
-            <name>WSO2 internal Repository</name>
-            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
-            <releases>
-                <enabled>true</enabled>
-                <updatePolicy>daily</updatePolicy>
-                <checksumPolicy>ignore</checksumPolicy>
-            </releases>
-        </repository>
-    </repositories>
-
-</project>


[10/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/tenant_usage.jsp
deleted file mode 100644
index bbf56e4..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/tenant_usage.jsp
+++ /dev/null
@@ -1,427 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="java.util.List" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.menu"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="true"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<script type="text/javascript" src="js/usage-report.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    session.setAttribute("year-month", yearMonth);
-
-
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-	List<String>  reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<%--<div id="report_ui">
-    <carbon:report
-            component="org.wso2.carbon.usage"
-            template="usage_report"
-            pdfReport="true"
-            htmlReport="true"
-            excelReport="true"
-            reportDataSession="usage_data"
-               />
-</div>--%>
-<div id="workArea">
-
-<form id="usageForm" action="tenant_usage.jsp" method="post">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-<%
-    }
-%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-<%--<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
---%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/usage_report.jsp
deleted file mode 100644
index cb6a28d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/usage_report.jsp
+++ /dev/null
@@ -1,28 +0,0 @@
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<carbon:jsi18n
-resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-request="<%=request%>" />
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/pom.xml
deleted file mode 100644
index 24adc75..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/pom.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage.ui</artifactId>
-    <version>2.1.2</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage - User Interface</name>
-
-    <build>
-
-        <plugins>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.ui.*,
-                        </Export-Package>
-                        <Import-Package>
-			    org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,                            
-                            org.apache.lucene.*,
-                            *;resolution:=optional
-                        </Import-Package>
-                        <Carbon-Component>UIBundle</Carbon-Component>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-	    <dependency>
-            <groupId>commons-codec.wso2</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.equinox</groupId>
-            <artifactId>javax.servlet</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
-            <artifactId>axiom</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-            <version>2.1.2</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.stub</artifactId>
-		<version>4.1.2</version>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
deleted file mode 100644
index 64ee922..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.stub.services.UsageServiceStub;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsageServiceClient {
-    private static final Log log = LogFactory.getLog(UsageServiceClient.class);
-
-    private UsageServiceStub stub;
-    private String epr;
-
-    public UsageServiceClient(
-            String cookie, String backendServerURL, ConfigurationContext configContext)
-            throws RegistryException {
-
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public UsageServiceClient(ServletConfig config, HttpSession session)
-            throws RegistryException {
-
-        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
-        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
-        ConfigurationContext configContext = (ConfigurationContext) config.
-                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        return stub.retrieveCurrentTenantUsage(yearMonth);
-    }
-
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        return stub.retrieveTenantUsages(yearMonth);
-    }
-
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-    }
-
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return stub.retrieveTenantUsage(yearMonth, tenantId);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
-            return stub.retrieveInstanceUsage();
-    }
-
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
-            String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
-            return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
deleted file mode 100755
index 38ff46b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.wso2.carbon.usage.ui.report;
-
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- * 
- * Licensed 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.
- */
-public class AllTenantUsageData {
-
-	public AllTenantUsageData() {
-	}
-
-	String yearMonth;
-	
-	String tenantName;
-	
-	String numberOfUsers;
-	
-	String currentDataStorage;
-	
-	String regBandwidth;
-	
-	String svcBandwidth;
-	
-	String svcTotalRequest;
-
-	public String getYearMonth() {
-		return yearMonth;
-	}
-
-	public void setYearMonth(String yearMonth) {
-		this.yearMonth = yearMonth;
-	}
-
-	public String getTenantName() {
-		return tenantName;
-	}
-
-	public void setTenantName(String tenantName) {
-		this.tenantName = tenantName;
-	}
-
-	public String getNumberOfUsers() {
-		return numberOfUsers;
-	}
-
-	public void setNumberOfUsers(String numberOfUsers) {
-		this.numberOfUsers = numberOfUsers;
-	}
-
-	public String getCurrentDataStorage() {
-		return currentDataStorage;
-	}
-
-	public void setCurrentDataStorage(String currentDataStorage) {
-		this.currentDataStorage = currentDataStorage;
-	}
-
-	public String getRegBandwidth() {
-		return regBandwidth;
-	}
-
-	public void setRegBandwidth(String regBandwidth) {
-		this.regBandwidth = regBandwidth;
-	}
-
-	public String getSvcBandwidth() {
-		return svcBandwidth;
-	}
-
-	public void setSvcBandwidth(String svcBandwidth) {
-		this.svcBandwidth = svcBandwidth;
-	}
-
-	public String getSvcTotalRequest() {
-		return svcTotalRequest;
-	}
-
-	public void setSvcTotalRequest(String svcTotalRequest) {
-		this.svcTotalRequest = svcTotalRequest;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
deleted file mode 100644
index 00d03b3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * this class is used to generate reports of all tenant usages
- */
-public class AllTenantUsageReport {
-
-    private TenantUsage[] tenantUsages;
-    private String yearMonth;
-
-    /**
-     * @param config
-     * @param session
-     * @param request
-     * @throws Exception
-     */
-    private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
-
-    public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-    	tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
-     
- 
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-    }
-
-    public List<AllTenantUsageData> getUsageReportData() {
-
-        List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>();   // all the strings need to be passed to
-        //  generate the report are added to this list
-
-        if (yearMonth == null) {
-            //  get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        //  add all the usage data to the list
-        try {
-            for (TenantUsage usage : tenantUsages) {
-                AllTenantUsageData usageData = new AllTenantUsageData();
-                usageData.setYearMonth(yearMonth);
-                String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                int numberOfUsers = usage.getNumberOfUsers();
-
-                //  String username = (String) request.getSession().getAttribute("logged-user");
-                String tenantName = usage.getDomain();
-                int tenantId = usage.getTenantId();
-                String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-
-                usageData.setTenantName(tenantName);
-                if (yearMonth.equals(currentYearMonth)) {
-                    usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
-                    usageData.setCurrentDataStorage(currentDataStorage);
-                }
-                // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
-                else {
-                    usageData.setNumberOfUsers("-");
-                    usageData.setCurrentDataStorage("-");
-                }
-                usageData.setRegBandwidth(regBandwidth);
-                usageData.setSvcBandwidth(svcBandwidth);
-                usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
-                reportData.add(usageData);
-            }
-        }
-        catch (Exception e) {
-            String msg = "Error while retrieving tenant usages for month : " + yearMonth;
-            log.error(msg, e);
-        }
-        return reportData;         // return as an array
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
deleted file mode 100644
index 6c0ad50..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to generate tenant usage report
- */
-public class UsageReport {
-    private TenantUsage usage;
-    private String yearMonth;
-
-    public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-        usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-
-    }
-
-
-    public List<String> getUsageReportData() {
-
-        int numberOfUsers = usage.getNumberOfUsers();
-        if (yearMonth == null) {
-
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-
-        String tenantName = usage.getDomain();
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        List<String> reportData = new ArrayList<String>();
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add("Duration");
-        reportData.add("Tenant Name");
-        reportData.add("Number of users");
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add(yearMonth);
-        reportData.add(tenantName);
-        reportData.add(String.valueOf(numberOfUsers));
-
-
-        if (currentYearMonth.equals(yearMonth)) {
-            reportData.add("Storage Usage");
-            reportData.add("Data Storage");
-            reportData.add("Current Data Storage");
-            reportData.add("Historical Data Storage");
-            reportData.add("Total Data Storage");
-            String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-            String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-            String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-            reportData.add("Storage Usage");
-            reportData.add("Registry Content");
-            reportData.add(totalDataStorage);
-            reportData.add(currentDataStorage);
-            reportData.add(historyDataStorage);
-        }
-
-        String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-        if (regBWStats != null) {
-            for (BandwidthStatistics stat : regBWStats) {
-                String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(regInBandwidth);
-                reportData.add(regOutBandwidth);
-                reportData.add(regBandwidth);
-
-            }
-        }
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totRegInBandwidth);
-        reportData.add(totRegOutBandwidth);
-        reportData.add(totRegBandwidth);
-
-        String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-        if (svcBWStats != null) {
-            for (BandwidthStatistics stat : svcBWStats) {
-                String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(svcInBandwidth);
-                reportData.add(svcOutBandwidth);
-                reportData.add(svcBandwidth);
-
-            }
-        }
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totSvcInBandwidth);
-        reportData.add(totSvcOutBandwidth);
-        reportData.add(totSvcBandwidth);
-
-        String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-        BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        if (webappBWStats != null) {
-            for (BandwidthStatistics stat : webappBWStats) {
-                String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(webappInBandwidth);
-                reportData.add(webappOutBandwidth);
-                reportData.add(webappBandwidth);
-            }
-        }
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totWebappInBandwidth);
-        reportData.add(totWebappOutBandwidth);
-        reportData.add(totWebappBandwidth);
-
-
-        long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-        long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-        long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-        RequestStatistics[] svcStats = usage.getRequestStatistics();
-        reportData.add("Service Usage Statistic");
-        reportData.add("Server Name");
-        reportData.add("Request Count");
-        reportData.add("Response Count");
-        reportData.add("Fault Count");
-        if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
-            for (RequestStatistics stat : svcStats) {
-                long svcReqCount = stat.getRequestCount();
-                long svcResCount = stat.getResponseCount();
-                long svcFaultCount = stat.getFaultCount();
-                reportData.add("Server Name****");
-                reportData.add(String.valueOf(svcReqCount));
-                reportData.add(String.valueOf(svcResCount));
-                reportData.add(String.valueOf(svcFaultCount));
-            }
-        }
-        reportData.add("Service Usage Statistic");
-        reportData.add("All Server Total");
-        reportData.add(String.valueOf(totSvcReqCount));
-        reportData.add(String.valueOf(totSvcRespCount));
-        reportData.add(String.valueOf(totSvcFaultCount));
-
-        return reportData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
deleted file mode 100644
index 401342d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.ui.utils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.common.ui.UIException;
-import org.wso2.carbon.usage.stub.beans.xsd.*;
-import org.wso2.carbon.usage.ui.clients.UsageServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class UsageUtil {
-    private static final Log log = LogFactory.getLog(UsageUtil.class);
-
-    private static long KB_LIMIT = 1024;
-    private static long MB_LIMIT = 1024 * 1024;
-    private static long GB_LIMIT = 1024 * 1024 * 1024;
-    private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
-
-    public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
-                                                         ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveCurrentTenantUsage(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get current tenant usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
-                                                     ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveTenantUsages(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage retrieveTenantUsage(ServletRequest request,
-                                                  ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            String tenantIdStr = request.getParameter("tenant-id");
-            if (tenantIdStr == null) {
-                tenantIdStr = "0";
-            }
-            return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
-        } catch (Exception e) {
-            String msg = "Failed to get tenant usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-
-    public static String convertBytesToString(long storage) {
-        if (storage < KB_LIMIT) {
-            return storage + " Byte(s)";
-        } else if (storage < MB_LIMIT) {
-            return storage / KB_LIMIT + " KByte(s)";
-        } else if (storage < GB_LIMIT) {
-            return storage / MB_LIMIT + " MByte(s)";
-        } else if (storage < TB_LIMIT) {
-            return storage / GB_LIMIT + " GByte(s)";
-        } else {
-            return storage / TB_LIMIT + " TByte(s)";
-        }
-    }
-
-    public static String getCurrentYearMonth() {
-        Calendar calendar = Calendar.getInstance();
-        return CommonUtil.getMonthString(calendar);
-    }
-
-    public static String[] getYearMonths() {
-        // we will list 100 months for now
-        List<String> yearMonths = new ArrayList<String>();
-        for (int i = 0; i > -100; i--) {
-            String yearMonth = CommonUtil.getMonthString(i);
-            yearMonths.add(yearMonth);
-        }
-        return yearMonths.toArray(new String[yearMonths.size()]);
-    }
-
-    public static String getCurrentDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (regData != null) {
-            currentData = regData.getRegistryContentCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getHistoryDataStorage(TenantUsage usage) {
-        TenantDataCapacity historyData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (historyData != null) {
-            currentData = historyData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getTotalDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long totalDataStorage = 0;
-        if (regData != null) {
-            totalDataStorage =
-                    regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(totalDataStorage);
-    }
-
-    public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
-                                                               ServletConfig config, HttpSession session)
-            throws Exception {
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
-            return returnInstanceUsage;
-        } catch (Exception e) {
-            String msg = "Failed to get current instance usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get paginated instance usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-    public static String getAPIUsage(TenantUsage usage) {
-        long count = 0;
-
-        if (usage.getApiManagerUsageStats() != null) {
-            count =usage.getApiManagerUsageStats()[0].getRequestCount();
-        }
-        return Long.toString(count);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 19b0510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<component xmlns="http://products.wso2.org/carbon">
-    <!-- sample menu configuration -->
-    <menus>
-        <menu>
-            <id>usage_monitoring_menu</id>
-            <i18n-key>usage.monitoring</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu></parent-menu>
-            <link>#</link>
-            <region>region4</region>
-            <style-class>home</style-class>
-            <order>22</order>
-            <icon>../services/images/services.gif</icon>
-        </menu>
-        <menu>
-            <id>tenant_usage_menu</id>
-            <i18n-key>tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>51</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/user-usage-report.gif</icon>
-            <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
-            <require-not-super-tenant>true</require-not-super-tenant>
-        </menu>
-        <!--menu>
-            <id>all_tenant_instance_usage_menu</id>
-            <i18n-key>instance.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/instance-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu-->
-        <menu>
-            <id>all_tenant_usage_menu</id>
-            <i18n-key>all.tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu>
-    </menus>
-
-</component>


[14/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
deleted file mode 100644
index 1daf872..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the hour range for the next daily summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current daily summarization cycle
- * from the usage hourly tables.
- */
-public class DailyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos cartridge stats daily summarization.");
-        try {
-            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsDailyTimestamp();
-            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running daily cartridge stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
-            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
-            setProperty("current_daily_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting date range for daily cartridge stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
deleted file mode 100644
index d3152c1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the hour range for the next daily summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current daily summarization cycle
- * from the usage hourly tables.
- */
-public class DailyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats daily summarization.");
-        try {
-            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsDailyTimestamp();
-            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running daily service stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
-            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
-            setProperty("current_daily_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting date range for daily service stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
deleted file mode 100644
index a80670c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/DailySummarizerHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the hour range for the next daily summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current daily summarization cycle
- * from the usage hourly tables.
- */
-public class DailySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage daily summarization.");
-        try {
-            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageDailyTimestamp();
-            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running daily usage analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
-            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
-            setProperty("current_daily_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting date range for daily usage analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
deleted file mode 100644
index f4da660..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
- * This is needed to excluded the already summarized usage stats in the current summarization cycle.
- */
-public class HourlyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlyCartridgeStatsSummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos cartridge stats hourly summarization.");
-        try {
-            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsHourlyTimestamp();
-            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-
-            log.info("Running hourly cartridge stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting hour range for hourly cartridge stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
deleted file mode 100644
index f1b44cc..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
- * This is needed to excluded the already summarized usage stats in the current summarization cycle.
- */
-public class HourlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlyServiceStatsSummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats hourly summarization.");
-        try {
-            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsHourlyTimestamp();
-            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-
-            log.info("Running hourly service stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting hour range for hourly service stats analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
deleted file mode 100644
index bafe96b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/HourlySummarizerHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
- * This is needed to excluded the already summarized usage stats in the current summarization cycle.
- */
-public class HourlySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage hourly summarization.");
-        try {
-            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageHourlyTimestamp();
-            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-
-            log.info("Running hourly usage analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting hour range for hourly usage analysis. ", e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
deleted file mode 100644
index 3619ad8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the date range for the next monthly summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current monthly summarization cycle
- * from the usage hourly tables.
- */
-public class MonthlyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos cartridge stats monthly summarization.");
-        try {
-            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsMonthlyTimestamp();
-            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running monthly cartridge stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
-            setProperty("current_monthly_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting month range for monthly cartridge stats analytics. ", e);
-        }
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
deleted file mode 100644
index dec01ea..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the date range for the next monthly summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current monthly summarization cycle
- * from the usage hourly tables.
- */
-public class MonthlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos service stats monthly summarization.");
-        try {
-            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageMonthlyTimestamp();
-            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
-            setProperty("current_monthly_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting month range for monthly service stats analytics. ", e);
-        }
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
deleted file mode 100644
index ce32eba..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/MonthlySummarizerHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
-import org.wso2.carbon.usage.summary.helper.util.DataAccessObject;
-
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to set the date range for the next monthly summarization cycle in the hive config.
- * This is important to select the data slice corresponding the current monthly summarization cycle
- * from the usage hourly tables.
- */
-public class MonthlySummarizerHelper extends AbstractHiveAnalyzer {
-
-    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
-
-    public void execute() {
-        log.info("Running custom analyzer for Stratos usage monthly summarization.");
-        try {
-            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsMonthlyTimestamp();
-            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            String currentTsStr = formatter.format(new Date().getTime());
-            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
-
-            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
-            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
-            setProperty("current_monthly_ts", currentTsSecs.toString());
-        } catch (Exception e) {
-            log.error("An error occurred while setting month range for monthly service stats analysis. ", e);
-        }
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
deleted file mode 100644
index 9f36639..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.internal;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.analytics.hive.service.HiveExecutorService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.usage.summary.helper.util.DataHolder;
-
-import javax.sql.DataSource;
-
-/**
- *
- * @scr.component name="org.wso2.carbon.usage.summary" immediate="true"
- * @scr.reference name="hive.executor.service"
- * interface="org.wso2.carbon.analytics.hive.service.HiveExecutorService" cardinality="1..1"
- * policy="dynamic" bind="setHiveExecutorService" unbind="unsetHiveExecutorService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageSummaryHelperServiceComponent {
-    
-    private static Log log = LogFactory.getLog(UsageSummaryHelperServiceComponent.class);
-
-    protected void activate(ComponentContext context){
-
-        log.info("Stratos usage summary helper bundle started");
-        /*try{
-
-        }catch (Throwable t){
-            log.error("Error occurred while activating the usage summary helper bundle..", t);
-        }*/
-    }
-
-    protected void deactivate(){
-        log.debug("Usage summary helper bundle was deactivated..");
-    }
-
-    protected void setHiveExecutorService(HiveExecutorService executorService){
-        //DataHolder.setExecutorService(executorService);
-    }
-
-    protected void unsetHiveExecutorService(HiveExecutorService executorService){
-        //DataHolder.setExecutorService(null);
-    }
-    
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        DataHolder.setDataSourceService(dataSourceService);
-        try {
-            DataHolder.setDataSource((DataSource)dataSourceService.getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject());
-            log.info("Data source set to data holder");
-        } catch (Exception e) {
-            log.error("Error occurred while retrieving the data source: " + DataHolder.BILLING_DATA_SOURCE_NAME, e); //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        DataHolder.setDataSourceService(null);
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
deleted file mode 100644
index 41a474c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataAccessObject.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Helper class to retrieve relevant timestamps from relational database tables.
- */
-public class DataAccessObject {
-
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-
-    private static DataSource dataSource = null;
-
-    private static DataAccessObject usageDataAccessObj = null;
-
-    private DataAccessObject() {
-    }
-
-    public static DataAccessObject getInstance() throws Exception {
-        if (usageDataAccessObj == null) {
-            usageDataAccessObj = new DataAccessObject();
-        }
-
-        if (usageDataAccessObj.dataSource == null) {
-            if (DataHolder.getDataSource() != null) {
-                try {
-                    dataSource = DataHolder.getDataSource();
-                    //dataSource = (DataSource) DataHolder.getDataSourceService().
-                    //       getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject();
-                } catch (Exception e) {
-                    log.error("Error occurred while obtaining " + DataHolder.BILLING_DATA_SOURCE_NAME +
-                              " datasource from data source service.", e);
-                    throw new Exception(e);
-                }
-            } else {
-                log.error("Cannot obtain data source " + DataHolder.BILLING_DATA_SOURCE_NAME +
-                          ". Datasource service is null");
-                throw new Exception("Datasource service not available");
-            }
-
-        }
-
-        return usageDataAccessObj;
-    }
-
-    public String getAndUpdateLastUsageHourlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_HOURLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastUsageDailyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_DAILY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastUsageMonthlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM USAGE_LAST_MONTHLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO USAGE_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsHourlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_HOURLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsDailyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_DAILY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastServiceStatsMonthlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_MONTHLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO SERVICE_STATS_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastCartridgeStatsHourlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_HOURLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last hourly timestamp for cartridge stats. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastCartridgeStatsDailyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_DAILY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last daily timestamp for cartridge stats. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-    public String getAndUpdateLastCartridgeStatsMonthlyTimestamp() throws SQLException {
-
-        Timestamp lastSummaryTs = null;
-        Connection connection = null;
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_MONTHLY_TS WHERE ID='LatestTS'";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ResultSet resultSet = ps.executeQuery();
-            if (resultSet.next()) {
-                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
-            } else {
-                lastSummaryTs = new Timestamp(0);
-            }
-
-            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
-            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
-
-            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
-            PreparedStatement ps1 = connection.prepareStatement(currentSql);
-            ps1.setTimestamp(1, currentTs);
-            ps1.setTimestamp(2, currentTs);
-            ps1.execute();
-
-        } catch (SQLException e) {
-            log.error("Error occurred while trying to get and update the last monthly timestamp for cartridge stats. ", e);
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return lastSummaryTs.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java b/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
deleted file mode 100644
index edc2064..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.summary.helper/2.1.3/src/main/java/org/wso2/carbon/usage/summary/helper/util/DataHolder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.summary.helper.util;
-
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-import javax.sql.DataSource;
-
-public class DataHolder {
-
-    private static DataSourceService dataSourceService;
-
-    private static DataSource dataSource;
-
-    public static final String BILLING_DATA_SOURCE_NAME = "WSO2BillingDS";
-    //public static final String BILLING_DATA_SOURCE_NAME = "WSO2USAGE_DS";
-
-
-    public static DataSource getDataSource() {
-        return dataSource;
-    }
-
-    public static void setDataSource(DataSource dataSource) {
-        DataHolder.dataSource = dataSource;
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        DataHolder.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/pom.xml
deleted file mode 100644
index e448fb1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage.ui</artifactId>
-    <version>2.1.0</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage - User Interface</name>
-
-    <build>
-
-        <plugins>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.ui.*,
-                        </Export-Package>
-                        <Import-Package>
-			    org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,                            
-                            org.apache.lucene.*,
-                            *;resolution:=optional
-                        </Import-Package>
-                        <Carbon-Component>UIBundle</Carbon-Component>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-	    <dependency>
-            <groupId>commons-codec.wso2</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.equinox</groupId>
-            <artifactId>javax.servlet</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
-            <artifactId>axiom</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.stub</artifactId>
-		<version>4.1.0</version>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
deleted file mode 100644
index 64ee922..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.stub.services.UsageServiceStub;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsageServiceClient {
-    private static final Log log = LogFactory.getLog(UsageServiceClient.class);
-
-    private UsageServiceStub stub;
-    private String epr;
-
-    public UsageServiceClient(
-            String cookie, String backendServerURL, ConfigurationContext configContext)
-            throws RegistryException {
-
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public UsageServiceClient(ServletConfig config, HttpSession session)
-            throws RegistryException {
-
-        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
-        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
-        ConfigurationContext configContext = (ConfigurationContext) config.
-                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        return stub.retrieveCurrentTenantUsage(yearMonth);
-    }
-
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        return stub.retrieveTenantUsages(yearMonth);
-    }
-
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-    }
-
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return stub.retrieveTenantUsage(yearMonth, tenantId);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
-            return stub.retrieveInstanceUsage();
-    }
-
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
-            String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
-            return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
deleted file mode 100755
index 38ff46b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.wso2.carbon.usage.ui.report;
-
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- * 
- * Licensed 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.
- */
-public class AllTenantUsageData {
-
-	public AllTenantUsageData() {
-	}
-
-	String yearMonth;
-	
-	String tenantName;
-	
-	String numberOfUsers;
-	
-	String currentDataStorage;
-	
-	String regBandwidth;
-	
-	String svcBandwidth;
-	
-	String svcTotalRequest;
-
-	public String getYearMonth() {
-		return yearMonth;
-	}
-
-	public void setYearMonth(String yearMonth) {
-		this.yearMonth = yearMonth;
-	}
-
-	public String getTenantName() {
-		return tenantName;
-	}
-
-	public void setTenantName(String tenantName) {
-		this.tenantName = tenantName;
-	}
-
-	public String getNumberOfUsers() {
-		return numberOfUsers;
-	}
-
-	public void setNumberOfUsers(String numberOfUsers) {
-		this.numberOfUsers = numberOfUsers;
-	}
-
-	public String getCurrentDataStorage() {
-		return currentDataStorage;
-	}
-
-	public void setCurrentDataStorage(String currentDataStorage) {
-		this.currentDataStorage = currentDataStorage;
-	}
-
-	public String getRegBandwidth() {
-		return regBandwidth;
-	}
-
-	public void setRegBandwidth(String regBandwidth) {
-		this.regBandwidth = regBandwidth;
-	}
-
-	public String getSvcBandwidth() {
-		return svcBandwidth;
-	}
-
-	public void setSvcBandwidth(String svcBandwidth) {
-		this.svcBandwidth = svcBandwidth;
-	}
-
-	public String getSvcTotalRequest() {
-		return svcTotalRequest;
-	}
-
-	public void setSvcTotalRequest(String svcTotalRequest) {
-		this.svcTotalRequest = svcTotalRequest;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
deleted file mode 100644
index 00d03b3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * this class is used to generate reports of all tenant usages
- */
-public class AllTenantUsageReport {
-
-    private TenantUsage[] tenantUsages;
-    private String yearMonth;
-
-    /**
-     * @param config
-     * @param session
-     * @param request
-     * @throws Exception
-     */
-    private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
-
-    public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-    	tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
-     
- 
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-    }
-
-    public List<AllTenantUsageData> getUsageReportData() {
-
-        List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>();   // all the strings need to be passed to
-        //  generate the report are added to this list
-
-        if (yearMonth == null) {
-            //  get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        //  add all the usage data to the list
-        try {
-            for (TenantUsage usage : tenantUsages) {
-                AllTenantUsageData usageData = new AllTenantUsageData();
-                usageData.setYearMonth(yearMonth);
-                String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                int numberOfUsers = usage.getNumberOfUsers();
-
-                //  String username = (String) request.getSession().getAttribute("logged-user");
-                String tenantName = usage.getDomain();
-                int tenantId = usage.getTenantId();
-                String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-
-                usageData.setTenantName(tenantName);
-                if (yearMonth.equals(currentYearMonth)) {
-                    usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
-                    usageData.setCurrentDataStorage(currentDataStorage);
-                }
-                // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
-                else {
-                    usageData.setNumberOfUsers("-");
-                    usageData.setCurrentDataStorage("-");
-                }
-                usageData.setRegBandwidth(regBandwidth);
-                usageData.setSvcBandwidth(svcBandwidth);
-                usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
-                reportData.add(usageData);
-            }
-        }
-        catch (Exception e) {
-            String msg = "Error while retrieving tenant usages for month : " + yearMonth;
-            log.error(msg, e);
-        }
-        return reportData;         // return as an array
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
deleted file mode 100644
index 6c0ad50..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to generate tenant usage report
- */
-public class UsageReport {
-    private TenantUsage usage;
-    private String yearMonth;
-
-    public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-        usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-
-    }
-
-
-    public List<String> getUsageReportData() {
-
-        int numberOfUsers = usage.getNumberOfUsers();
-        if (yearMonth == null) {
-
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-
-        String tenantName = usage.getDomain();
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        List<String> reportData = new ArrayList<String>();
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add("Duration");
-        reportData.add("Tenant Name");
-        reportData.add("Number of users");
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add(yearMonth);
-        reportData.add(tenantName);
-        reportData.add(String.valueOf(numberOfUsers));
-
-
-        if (currentYearMonth.equals(yearMonth)) {
-            reportData.add("Storage Usage");
-            reportData.add("Data Storage");
-            reportData.add("Current Data Storage");
-            reportData.add("Historical Data Storage");
-            reportData.add("Total Data Storage");
-            String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-            String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-            String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-            reportData.add("Storage Usage");
-            reportData.add("Registry Content");
-            reportData.add(totalDataStorage);
-            reportData.add(currentDataStorage);
-            reportData.add(historyDataStorage);
-        }
-
-        String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-        if (regBWStats != null) {
-            for (BandwidthStatistics stat : regBWStats) {
-                String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(regInBandwidth);
-                reportData.add(regOutBandwidth);
-                reportData.add(regBandwidth);
-
-            }
-        }
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totRegInBandwidth);
-        reportData.add(totRegOutBandwidth);
-        reportData.add(totRegBandwidth);
-
-        String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-        if (svcBWStats != null) {
-            for (BandwidthStatistics stat : svcBWStats) {
-                String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(svcInBandwidth);
-                reportData.add(svcOutBandwidth);
-                reportData.add(svcBandwidth);
-
-            }
-        }
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totSvcInBandwidth);
-        reportData.add(totSvcOutBandwidth);
-        reportData.add(totSvcBandwidth);
-
-        String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-        BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        if (webappBWStats != null) {
-            for (BandwidthStatistics stat : webappBWStats) {
-                String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(webappInBandwidth);
-                reportData.add(webappOutBandwidth);
-                reportData.add(webappBandwidth);
-            }
-        }
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totWebappInBandwidth);
-        reportData.add(totWebappOutBandwidth);
-        reportData.add(totWebappBandwidth);
-
-
-        long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-        long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-        long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-        RequestStatistics[] svcStats = usage.getRequestStatistics();
-        reportData.add("Service Usage Statistic");
-        reportData.add("Server Name");
-        reportData.add("Request Count");
-        reportData.add("Response Count");
-        reportData.add("Fault Count");
-        if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
-            for (RequestStatistics stat : svcStats) {
-                long svcReqCount = stat.getRequestCount();
-                long svcResCount = stat.getResponseCount();
-                long svcFaultCount = stat.getFaultCount();
-                reportData.add("Server Name****");
-                reportData.add(String.valueOf(svcReqCount));
-                reportData.add(String.valueOf(svcResCount));
-                reportData.add(String.valueOf(svcFaultCount));
-            }
-        }
-        reportData.add("Service Usage Statistic");
-        reportData.add("All Server Total");
-        reportData.add(String.valueOf(totSvcReqCount));
-        reportData.add(String.valueOf(totSvcRespCount));
-        reportData.add(String.valueOf(totSvcFaultCount));
-
-        return reportData;
-    }
-}


[02/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/Util.java
deleted file mode 100644
index 6c9ebae..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/Util.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-
-import javax.sql.DataSource;
-
-/**
- * Util methods for usage.
- */
-public class Util {
-
-    private static final Log log = LogFactory.getLog(Util.class);
-
-    private static RegistryService registryService;
-    private static RealmService realmService;
-    private static TenantUsageRetriever tenantUsageRetriever;
-    private static ConfigurationContextService configurationContextService;
-    private static DataSourceService dataSourceService;
-    public static String BILLING_DATA_SOURCE_NAME="WSO2BillingDS";
-
-    public static synchronized void setRegistryService(RegistryService service) {
-        if (registryService == null) {
-            registryService = service;
-        }
-    }
-    
-    public static void setConfigurationContextService(
-            ConfigurationContextService configurationContextService) {
-        Util.configurationContextService = configurationContextService;
-    }
-    
-    public static ConfigurationContextService getConfigurationContextService(){
-        return configurationContextService;
-    }
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static RegistryService getRegistryService() {
-        return registryService;
-    }
-
-    public static TenantUsageRetriever getTenantUsageRetriever() {
-        return tenantUsageRetriever;
-    }
-
-    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
-        return registryService.getUserRealm(tenantId);
-    }
-
-    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
-        return registryService.getGovernanceSystemRegistry();
-    }
-
-    public static void registerRetrieverServices(BundleContext bundleContext) throws Exception {
-        ConfigurationContextService confCtxSvc = Util.getConfigurationContextService();
-
-        // creating and registering tenant and user usage retrievers
-        tenantUsageRetriever = new TenantUsageRetriever(
-                registryService, confCtxSvc.getServerConfigContext());
-        bundleContext.registerService(
-                TenantUsageRetriever.class.getName(), tenantUsageRetriever, null);
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        Util.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 2d2f81e..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <!--<ManagementPermission>
-            <DisplayName>User-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/userUsage</ResourceId>
-        </ManagementPermission> -->
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Protected</DisplayName>
-            <ResourceId>/permission/protected</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/protected/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Any-Tenant-Usage</DisplayName>
-            <ResourceId>/permission/protected/monitor/anytenantUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 8e82415..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-    <service name="UsageService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.services.UsageService
-        </parameter>
-
-        <operation name="retrieveCurrentTenantUsage">
-            <parameter name="AuthorizationAction" locked="true">/permission/admin/monitor/tenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrievePaginatedTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsage">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-    </service>
-    <parameter name="adminService" locked="true">true</parameter>
-
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/all_tenant_usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/all_tenant_usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/all_tenant_usage_report.jrxml
deleted file mode 100644
index b9483aa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/all_tenant_usage_report.jrxml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="all_tenant_usage_report"  pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="yearMonth" class="java.lang.String"/>
-	<field name="tenantName" class="java.lang.String"/>
-	<field name="numberOfUsers" class="java.lang.String"/>
-	<field name="currentDataStorage" class="java.lang.String"/>
-	<field name="regBandwidth" class="java.lang.String"/>
-	<field name="svcBandwidth" class="java.lang.String"/>
-	<field name="svcTotalRequest" class="java.lang.String"/>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="79" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="35" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Transparent" x="0" y="0" width="279" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<text><![CDATA[Tenant Usage Report for the month]]></text>
-			</staticText>
-			<textField>
-				<reportElement mode="Transparent" x="279" y="0" width="276" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{yearMonth}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band height="61" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Opaque" x="0" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Domain]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="100" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Number of users]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="200" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Storage Usage]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="300" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Registry Bandwidth]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="400" y="29" width="73" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Service Bandwidht]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="473" y="29" width="82" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Service Requests]]></text>
-			</staticText>
-		</band>
-	</columnHeader>
-	<detail>
-		<band height="103" splitType="Stretch">
-			<textField>
-				<reportElement x="0" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantName}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="100" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{numberOfUsers}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="200" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{currentDataStorage}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="300" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{regBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="400" y="21" width="73" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="473" y="21" width="82" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcTotalRequest}]]></textFieldExpression>
-			</textField>
-		</band>
-	</detail>
-	<columnFooter>
-		<band height="45" splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="54" splitType="Stretch">
-			<textField>
-				<reportElement x="455" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
-			</textField>
-			<textField pattern="MMMMM dd, yyyy">
-				<reportElement x="0" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageFooter>
-	<summary>
-		<band height="42" splitType="Stretch"/>
-	</summary>
-</jasperReport>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/usage_report.jrxml
deleted file mode 100644
index 5b43c2f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/resources/reports/usage_report.jrxml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="task" class="java.lang.String"/>
-	<field name="usagecol1" class="java.lang.String"/>
-	<field name="usagecol2" class="java.lang.String"/>
-	<field name="usagecol3" class="java.lang.String"/>
-	<field name="usagecol4" class="java.lang.String"/>
-	<field name="usagecol1Value" class="java.lang.String"/>
-	<field name="usagecol2Value" class="java.lang.String"/>
-	<field name="usagecol3Value" class="java.lang.String"/>
-	<field name="usagecol4Value" class="java.lang.String"/>
-	<field name="tenantDomain" class="java.lang.String"/>
-	<group name="usagedatagroup">
-		<groupExpression><![CDATA[$F{task}]]></groupExpression>
-		<groupHeader>
-			<band height="72" splitType="Stretch">
-				<rectangle>
-					<reportElement x="0" y="21" width="555" height="16" backcolor="#D0F5E8"/>
-				</rectangle>
-				<textField>
-					<reportElement x="0" y="22" width="555" height="16"/>
-					<textElement>
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{task}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="38" width="555" height="16" backcolor="#E6F1B6"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="39" width="132" height="17"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="39" width="132" height="15"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="288" y="39" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="38" width="132" height="16"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="55" width="555" height="15" backcolor="#DBE596"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="57" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="55" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="287" y="55" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="56" width="132" height="15"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4Value}]]></textFieldExpression>
-				</textField>
-			</band>
-		</groupHeader>
-		<groupFooter>
-			<band splitType="Stretch"/>
-		</groupFooter>
-	</group>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="17" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="19" splitType="Stretch">
-			<textField pattern="dd/MM/yyyy h.mm a">
-				<reportElement x="403" y="0" width="132" height="16"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-			<staticText>
-				<reportElement x="0" y="1" width="169" height="15"/>
-				<textElement textAlignment="Right">
-					<font size="12" isUnderline="true"/>
-				</textElement>
-				<text><![CDATA[Usage Report For : ]]></text>
-			</staticText>
-			<textField>
-				<reportElement x="169" y="0" width="234" height="16"/>
-				<textElement verticalAlignment="Middle">
-					<font size="12"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantDomain}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band splitType="Stretch"/>
-	</columnHeader>
-	<detail>
-		<band height="5" splitType="Stretch"/>
-	</detail>
-	<columnFooter>
-		<band splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="8" splitType="Stretch"/>
-	</pageFooter>
-	<summary>
-		<band height="7" splitType="Stretch"/>
-	</summary>
-</jasperReport>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/pom.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/pom.xml
deleted file mode 100644
index 1c13d19..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/pom.xml
+++ /dev/null
@@ -1,143 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage</artifactId>
-    <version>2.1.3</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>add-source</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>target/generated-code/src</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <ListenerManager-RequiredServices>
-                            org.wso2.carbon.usage.api.TenantUsageRetriever
-                        </ListenerManager-RequiredServices>
-                        <Private-Package>
-                            org.wso2.carbon.usage.internal.*,
-                            org.wso2.carbon.usage.util.*,
-                            org.wso2.carbon.usage.services.*,
-                            org.wso2.carbon.usage.client.*
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.beans.*,
-                            org.wso2.carbon.usage.api.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.rule.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            org.wso2.carbon.stratos.common.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-            
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.mgt</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-            <version>2.1.2</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.agent</artifactId>
-        </dependency>
-         <!--<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId>
-        </dependency>-->
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ndatasource.core</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
deleted file mode 100644
index 922a4c3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.api;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.beans.*;
-import org.wso2.carbon.usage.util.DataAccessObject;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.util.*;
-
-public class TenantUsageRetriever {
-    private static final Log log = LogFactory.getLog(TenantUsageRetriever.class);
-    private static final String DEFAULT_SERVICE_NAME = "Stratos";
-    private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS";
-    private static final String TOTAL_LABEL = "Total";
-    public static final int REG_BANDWIDTH_INDEX = 0;
-    public static final int SVC_BANDWIDTH_INDEX = 1;
-    public static final int WEBAPP_BANDWIDTH_INDEX = 2;
-    public static final int API_CALL_STATS=3;
-
-    private RegistryService registryService;
-    private DataAccessObject dao;
-
-    public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext)
-            throws Exception {
-
-        // we are loading the essentials from the constructors in order to restrict the users
-        // to use the usage retrievers.
-        this.registryService = registryService;
-        this.dao = new DataAccessObject();
-    }
-
-
-    public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate,
-                                              boolean currentMonth) throws Exception {
-        TenantDataCapacity dataCapacity = null;
-
-        if(currentMonth){
-            dataCapacity = dao.getTenantDataCapacity(tenantId);
-        } else {
-            //we don't have a way to see the registry usage of last months yet
-        }
-
-        return dataCapacity;
-
-    }
-
-    /**
-     * This returns the number of users in a given tenant
-     * @param tenantId Tenant ID
-     * @return Number of users
-     * @throws RegistryException
-     */
-    public int getCurrentUserCount(int tenantId) throws RegistryException {
-        UserRealm userRealm = registryService.getUserRealm(tenantId);
-        int usersCount;
-        try {
-            String[] users = userRealm.getUserStoreManager().listUsers("*", -1);
-            usersCount = users.length;
-        } catch (UserStoreException e) {
-            String msg = "Error in getting the current users.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-        return usersCount;
-    }
-
-    public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        BandwidthStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-            bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour));
-            stats = convertBWListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>();
-
-        if (stats != null) {
-            for (BandwidthStatistics stat : stats) {
-                //Proceed only if incoming bandwidth or outgoing bandwidth is not zero
-                if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) {
-                    continue;
-                }
-
-                //TODO: fix the extractServiceUrl method properly
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String bandwidthName = stat.getKey();
-
-                HashMap<String, BandwidthStatistics> bwMap;
-                if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) {
-                    bwMap = regBwMap;
-                } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) {
-                    bwMap = svcBwMap;
-                } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) {
-                    bwMap = webappBwMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + bandwidthName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                BandwidthStatistics reqStat = bwMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new BandwidthStatistics(serverName);
-                    bwMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setIncomingBandwidth(
-                        reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth());
-                reqStat.setOutgoingBandwidth(
-                        reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth());
-            }
-        }
-
-        //Convert to array and return it
-        BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][];
-        Collection<BandwidthStatistics> values = regBwMap.values();
-        returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = svcBwMap.values();
-        returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = webappBwMap.values();
-        returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-
-        return returnValue;
-    }
-
-
-    public APIManagerUsageStats[] getAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        APIManagerUsageStats[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-            bwsList = dao.getDailyAPIManagerUsageStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyAPIManagerUsageStats(tenantId, startHour, endHour));
-            stats = convertAPIStatListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertAPIStatListToArray(dao.getMonthlyAPIManagerUsageStats(tenantId, monthCal));
-        }
-        HashMap<String, APIManagerUsageStats> statMap = new HashMap<String, APIManagerUsageStats>();
-        if (stats != null) {
-            for (APIManagerUsageStats stat : stats) {
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String statName = stat.getKey();
-
-                HashMap<String, APIManagerUsageStats> statsHashMap;
-                if (statName.equals("API-Call")) {
-                    statsHashMap = statMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + statName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                APIManagerUsageStats reqStat = statsHashMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new APIManagerUsageStats(serverName);
-                    statsHashMap.put(serverName, reqStat);
-                }
-                reqStat.setRequestCount(stat.getRequestCount());
-            }
-        }
-
-        //Convert to array and return it
-        APIManagerUsageStats[] returnValue = new APIManagerUsageStats[0];
-        Collection<APIManagerUsageStats> values = statMap.values();
-        returnValue = values.toArray(new APIManagerUsageStats[values.size()]);
-        return returnValue;
-    }
-
-
-    public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate,
-                                                    Calendar endDate, boolean currentMonth) throws Exception {
-        RequestStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-            rsList = dao.getDailyRequestStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour));
-
-            stats = convertRSListToArray(rsList);
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>();
-
-        if (stats != null) {
-            for (RequestStatistics stat : stats) {
-                //Proceed only if request count is not zero
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-
-                String serverName = extractServiceNameFromUrl(stat.getKey());
-
-                //find whether the map already has this key; If not, insert a new one
-                RequestStatistics reqStat = tempReqStatMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new RequestStatistics(serverName);
-                    tempReqStatMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount());
-                reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount());
-                reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount());
-            }
-        }
-
-        //Convert to array and return it
-        Collection<RequestStatistics> values = tempReqStatMap.values();
-        return values.toArray(new RequestStatistics[values.size()]);
-
-    }
-
-    public CartridgeStatistics[] getCartridgeStatistics(int tenantId, Calendar startDate,
-                                                    Calendar endDate, boolean currentMonth) throws Exception {
-        CartridgeStatistics[] stats;
-        /*if (currentMonth) {
-            //get from daily usage stats
-            List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
-            csList = dao.getDailyCartridgeStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            csList.addAll(dao.getHourlyCartridgeStats(tenantId, startHour, endHour));
-
-            stats = convertCSListToArray(csList);
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertCSListToArray(dao.getMonthlyCartridgeStats(tenantId, monthCal));
-        }*/
-        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
-        csList = dao.getHourlyCartridgeStats(tenantId, startDate, endDate);
-        stats = convertCSListToArray(csList);
-
-        //Add a comment explaining following logic later
-        HashMap<String, CartridgeStatistics> tempCartridgeStatMap = new HashMap<String, CartridgeStatistics>();
-
-        if (stats != null) {
-            for (CartridgeStatistics stat : stats) {
-                //Proceed only if request count is not zero
-                if (stat.getCartridgeHours() == 0) {
-                    continue;
-                }
-
-                
-                //find whether the map already has this key; If not, insert a new one
-                CartridgeStatistics cartridgeStat = tempCartridgeStatMap.get(stat.getKey());
-                if (cartridgeStat == null) {
-                    cartridgeStat = new CartridgeStatistics(stat.getKey());
-                    tempCartridgeStatMap.put(stat.getKey(), cartridgeStat);
-                }
-
-                // Update the service specific statistics
-                cartridgeStat.setCartridgeHours(cartridgeStat.getCartridgeHours() + stat.getCartridgeHours());
-                cartridgeStat.setInstanceId(stat.getInstanceId());
-            }
-        }
-
-        //Convert to array and return it
-        Collection<CartridgeStatistics> values = tempCartridgeStatMap.values();
-        return values.toArray(new CartridgeStatistics[values.size()]);
-
-    }
-
-    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
-        //get the domain name
-        TenantManager tenantManger = Util.getRealmService().getTenantManager();
-        String domain = tenantManger.getDomain(tenantId);
-        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);
-
-        //Get the startDate, endDate from yearMonth String
-        Date date = CommonUtil.getDateFromMonthString(yearMonth);
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-
-        //Calculate whether the yearMonth fits to current month; if the current date is less than
-        // endDate, then we treat it as current month
-        boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0);
-
-        //get the data capacity
-        TenantDataCapacity capacity;
-        try {
-            capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting data capacity from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryCapacity(capacity);
-
-        //get the service request statistics
-        RequestStatistics[] reqStats = null;
-        try {
-            reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting request statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRequestStatistics(reqStats);
-
-        //Calculate total Request statistics
-        RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL);
-        long totalReq = 0;
-        long totalRes = 0;
-        long totalFault = 0;
-        if(reqStats!=null){
-            for (RequestStatistics stat : reqStats) {
-                totalReq += stat.getRequestCount();
-                totalRes += stat.getResponseCount();
-                totalFault += stat.getFaultCount();
-            }
-            totalReqStat.setRequestCount(totalReq);
-            totalReqStat.setResponseCount(totalRes);
-            totalReqStat.setFaultCount(totalFault);
-        }
-        tenantUsage.setTotalRequestStatistics(totalReqStat);
-
-        //get Bandwidth statistics
-        BandwidthStatistics[][] bwStats = null;
-        try {
-            bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]);
-        tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]);
-        tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]);
-
-        //get the total bandwidths
-        int index = 0;
-        for (BandwidthStatistics[] bwArray : bwStats) {
-            long incomingBandwidth = 0;
-            long outgoingBandwidth = 0;
-            for (BandwidthStatistics bandwidth : bwArray) {
-                incomingBandwidth += bandwidth.getIncomingBandwidth();
-                outgoingBandwidth += bandwidth.getOutgoingBandwidth();
-            }
-            BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL);
-            total.setIncomingBandwidth(incomingBandwidth);
-            total.setOutgoingBandwidth(outgoingBandwidth);
-            switch (index) {
-                case REG_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalRegistryBandwidth(total);
-                    break;
-                case SVC_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalServiceBandwidth(total);
-                    break;
-                case WEBAPP_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalWebappBandwidth(total);
-                    break;
-            }
-            ++index;
-        }
-
-        // the users count will be calculated only if the yearMonth is the current yearMonth
-        if (isCurrentMonth) {
-            int usersCount = getCurrentUserCount(tenantId);
-            tenantUsage.setNumberOfUsers(usersCount);
-        }
-        // get the API invocation data
-        APIManagerUsageStats[] apiStats = null;
-        try {
-            apiStats = getAPIManagerUsageStats(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setApiManagerUsageStats(apiStats);
-
-        //retrieving cartridge hours
-        CartridgeStatistics[] cartridgeStatistics = getCartridgeStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        tenantUsage.setCartridgeStatistics(cartridgeStatistics);
-        long totalCartridgeHours = 0;
-        if(cartridgeStatistics!=null && cartridgeStatistics.length>0){
-            
-            for (CartridgeStatistics cs : cartridgeStatistics){
-                totalCartridgeHours += cs.getCartridgeHours();
-            }
-        }
-
-        CartridgeStatistics totalCS = new CartridgeStatistics();
-        totalCS.setCartridgeHours(totalCartridgeHours);
-
-        tenantUsage.setTotalCartridgeHours(totalCS);
-        return tenantUsage;
-    }
-
-    /**
-     * @param serviceURL
-     * @return service name
-     *         <p/>
-     *         Extract the stratos service part from URL; expecting the URL as
-     *         protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant
-     *         We are interested in "service" part only
-     */
-    private String extractServiceNameFromUrl(String serviceURL) {
-        if (serviceURL == null || serviceURL.equals("")) {
-            //No service URL is given, so return a default value
-            return DEFAULT_SERVICE_NAME;
-        }
-
-        int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part
-        if (startIndex != -1) {
-            // protocol://service.domain:port/tenant-domain/ case
-            startIndex += 3;
-        } else {
-            //service.domain:port/tenant case
-            startIndex = 0;
-        }
-
-        int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "."
-        if (endIndex == -1) {
-            // "." is not there; search for ":"
-            endIndex = serviceURL.indexOf(':', startIndex);
-
-            if (endIndex == -1) {
-                //Still could not find ":", then search for "/"
-                endIndex = serviceURL.indexOf('/', startIndex);
-
-                if (endIndex == -1) {
-                    //Noting is there, so take the whole service URL
-                    endIndex = serviceURL.length();
-                }
-            }
-
-        }
-        return serviceURL.substring(startIndex, endIndex);
-    }
-
-    /**
-     * @return Instance Usages Statics Array that contains data
-     * @throws Exception when back end error occurs
-     */
-    public InstanceUsageStatics[] getInstanceUsages() throws Exception {
-
-        //TODO: implement
-        return null;
-        /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats();
-        if (instanceData == null || instanceData.length == 0) {
-            return null;
-        }
-        InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length];
-        int elementID = 0;
-        for (InstanceUsageStat iu : instanceData) {
-            InstanceUsageStatics iu1 = new InstanceUsageStatics();
-            iu1.setInstanceID(iu.getInstanceId().intValue());
-            iu1.setInstanceURL(iu.getServerURL());
-            iu1.setStartTime(iu.getStartTimestamp());
-            iu1.setStopTime(iu.getStopTimestamp());
-            iu1.setRunning(iu.getIsRunning());
-            returnValue[elementID] = iu1;
-            elementID = elementID + 1;
-        }
-        return returnValue;
-        */
-    }
-
-
-    private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) {
-        BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private APIManagerUsageStats[] convertAPIStatListToArray(List<APIManagerUsageStats> bwsList) {
-        APIManagerUsageStats[] bwsArray = new APIManagerUsageStats[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) {
-        RequestStatistics[] rsArray = new RequestStatistics[rsList.size()];
-        rsArray = rsList.toArray(rsArray);
-        return rsArray;
-    }
-
-    private CartridgeStatistics[] convertCSListToArray(List<CartridgeStatistics> csList){
-        CartridgeStatistics[] csArray = new CartridgeStatistics[csList.size()];
-        csArray = csList.toArray(csArray);
-        return csArray;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
deleted file mode 100644
index 9321011..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-public class APIManagerUsageStats {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-    private long requestCount;
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-
-    public APIManagerUsageStats(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
deleted file mode 100644
index f236e0f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-/**
- * 
- */
-public class BandwidthStatistics {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-
-    public BandwidthStatistics(String key){
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/CartridgeStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/CartridgeStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/CartridgeStatistics.java
deleted file mode 100644
index 20308e6..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/CartridgeStatistics.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.wso2.carbon.usage.beans;
-
-
-public class CartridgeStatistics {
-    
-    private String key;
-    private String instanceId;
-    private long cartridgeHours;
-    
-    public CartridgeStatistics(){
-        //Default constructor
-    }
-
-    public CartridgeStatistics(String key){
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getCartridgeHours() {
-        return cartridgeHours;
-    }
-
-    public void setCartridgeHours(long cartridgeHours) {
-        this.cartridgeHours = cartridgeHours;
-    }
-
-    public String getInstanceId() {
-        return instanceId;
-    }
-
-    public void setInstanceId(String instanceId) {
-        this.instanceId = instanceId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
deleted file mode 100644
index 25cb759..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Calendar;
-
-public class InstanceUsageStatics {
-
-    private Calendar startTime;
-    private Calendar stopTime;
-    private String instanceURL;
-    private Integer instanceID;
-    private long usedTimeInSeconds;
-    private boolean running;
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    public void setRunning(boolean running) {
-        this.running = running;
-    }
-
-    public Calendar getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Calendar startTime) {
-        this.startTime = startTime;
-    }
-
-    public Calendar getStopTime() {
-        return stopTime;
-    }
-
-    public void setStopTime(Calendar stopTime) {
-        //Check weather stop time is Default value in database in that case
-        //server should still running so set isRunning as true
-        Calendar fixedDate = Calendar.getInstance();
-        fixedDate.set(2001, 1, 1, 00, 00, 00);
-        if (stopTime.compareTo(fixedDate) == 0) {
-            this.running = true;
-        }
-        this.stopTime = stopTime;
-    }
-
-    public String getInstanceURL() {
-        return instanceURL;
-    }
-
-    public void setInstanceURL(String instanceURL) {
-        this.instanceURL = instanceURL;
-    }
-
-    public Integer getInstanceID() {
-        return instanceID;
-    }
-
-    public void setInstanceID(Integer instanceID) {
-        this.instanceID = instanceID;
-    }
-
-    public long getUsedTimeInSeconds() {
-        long returnValue = (this.stopTime.getTimeInMillis() -
-                this.startTime.getTimeInMillis()) / 1000;
-        if (returnValue < 0) {
-            running = true;
-        }
-        return usedTimeInSeconds;
-    }
-    public void setUsedTimeInSeconds(long value){
-        this.usedTimeInSeconds=value;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
deleted file mode 100644
index b7407af..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedInstanceUsage {
-    private InstanceUsageStatics[] instanceUsages;
-    private int pageNumber;
-    private int numberOfPages;
-
-    public InstanceUsageStatics[] getInstanceUsages() {
-        if(instanceUsages != null) {
-        return Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-
-        return null;
-    }
-
-    public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) {
-        if(instanceUsages != null) {
-            this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-    }
-
-    public int getPageNumber() {
-        return pageNumber;
-    }
-
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
deleted file mode 100644
index 0a3bd1b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedTenantUsageInfo {
-    private TenantUsage[] tenantUsages;
-    private int pageNumber;
-    private int numberOfPages;
-    
-    public TenantUsage[] getTenantUsages() {
-        return Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public void setTenantUsages(TenantUsage[] tenantUsages) {
-        this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public int getPageNumber() {
-        return pageNumber;
-    }
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
deleted file mode 100644
index 085b91a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-public class RequestStatistics {
-    private String key;
-    private long requestCount;
-    private long responseCount;
-    private long faultCount;
-
-    public RequestStatistics(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public long getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(long responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public long getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(long faultCount) {
-        this.faultCount = faultCount;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
deleted file mode 100644
index 543126d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantDataCapacity {
-
-    private long registryContentCapacity;
-    private long registryContentHistoryCapacity;
-
-    public TenantDataCapacity() {
-    }
-    
-    /**
-     * @param registryContentCapacity
-     * @param registryContentHistoryCapacity
-     */
-    public TenantDataCapacity(
-            long registryContentCapacity, long registryContentHistoryCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-    public long getRegistryContentCapacity() {
-        return registryContentCapacity;
-    }
-
-    public void setRegistryContentCapacity(long registryContentCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-    }
-
-    public long getRegistryContentHistoryCapacity() {
-        return registryContentHistoryCapacity;
-    }
-
-    public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) {
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
deleted file mode 100644
index cde193c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantUsage {
-    private int tenantId;
-    private String domain;
-    private int numberOfUsers;
-    private UsageEntry[] usageEntries;
-    private BandwidthStatistics[] registryBandwidthStatistics;
-    private BandwidthStatistics[] serviceBandwidthStatistics;
-    private BandwidthStatistics[] webappBandwidthStatistics;
-    private CartridgeStatistics[] cartridgeStatistics;
-    private RequestStatistics[] requestStatistics;
-    private TenantDataCapacity registryCapacity;
-    private RequestStatistics totalRequestStatistics;
-    private BandwidthStatistics totalRegistryBandwidth;
-    private BandwidthStatistics totalServiceBandwidth;
-    private BandwidthStatistics totalWebappBandwidth;
-    private CartridgeStatistics totalCartridgeHours;
-    private APIManagerUsageStats[] apiManagerUsageStats;
-
-    public APIManagerUsageStats[] getApiManagerUsageStats() {
-        return apiManagerUsageStats;
-    }
-
-    public void setApiManagerUsageStats(APIManagerUsageStats[] apiManagerUsageStats) {
-        this.apiManagerUsageStats = apiManagerUsageStats;
-    }
-
-    public BandwidthStatistics[] getRegistryBandwidthStatistics() {
-        return registryBandwidthStatistics;
-    }
-
-    public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) {
-        this.registryBandwidthStatistics = registryBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getServiceBandwidthStatistics() {
-        return serviceBandwidthStatistics;
-    }
-
-    public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) {
-        this.serviceBandwidthStatistics = serviceBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getWebappBandwidthStatistics() {
-        return webappBandwidthStatistics;
-    }
-
-    public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) {
-        this.webappBandwidthStatistics = webappBandwidthStatistics;
-    }
-
-    public RequestStatistics getTotalRequestStatistics() {
-        return totalRequestStatistics;
-    }
-
-    public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) {
-        this.totalRequestStatistics = totalRequestStatistics;
-    }
-
-    public BandwidthStatistics getTotalRegistryBandwidth() {
-        return totalRegistryBandwidth;
-    }
-
-    public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) {
-        this.totalRegistryBandwidth = totalRegistryBandwidth;
-    }
-
-    public BandwidthStatistics getTotalServiceBandwidth() {
-        return totalServiceBandwidth;
-    }
-
-    public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) {
-        this.totalServiceBandwidth = totalServiceBandwidth;
-    }
-
-    public BandwidthStatistics getTotalWebappBandwidth() {
-        return totalWebappBandwidth;
-    }
-
-    public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) {
-        this.totalWebappBandwidth = totalWebappBandwidth;
-    }
-
-    public CartridgeStatistics[] getCartridgeStatistics() {
-        return cartridgeStatistics;
-    }
-
-    public void setCartridgeStatistics(CartridgeStatistics[] cartridgeStatistics) {
-        this.cartridgeStatistics = cartridgeStatistics;
-    }
-
-    public CartridgeStatistics getTotalCartridgeHours() {
-        return totalCartridgeHours;
-    }
-
-    public void setTotalCartridgeHours(CartridgeStatistics totalCartridgeHours) {
-        this.totalCartridgeHours = totalCartridgeHours;
-    }
-
-    public TenantUsage() {
-        // empty method required for used in web services
-    }
-
-    public TenantUsage(int tenantId, String domain) {
-        this.tenantId = tenantId;
-        this.domain = domain;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    public UsageEntry[] getUsageEntries() {
-        return usageEntries;
-    }
-
-    public void setUsageEntries(UsageEntry[] usageEntries) {
-        this.usageEntries = usageEntries;
-    }
-
-    public RequestStatistics[] getRequestStatistics() {
-        return requestStatistics;
-    }
-
-    public void setRequestStatistics(RequestStatistics[] requestStatistics) {
-        this.requestStatistics = requestStatistics;
-    }
-
-    public TenantDataCapacity getRegistryCapacity() {
-        return registryCapacity;
-    }
-
-    public void setRegistryCapacity(TenantDataCapacity registryCapacity) {
-        this.registryCapacity = registryCapacity;
-    }
-
-    public int getNumberOfUsers() {
-        return numberOfUsers;
-    }
-
-    public void setNumberOfUsers(int numberOfUsers) {
-        this.numberOfUsers = numberOfUsers;
-    }
-
-    public long getRegistryContentCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentCapacity();
-        }
-        return retValue;
-    }
-
-    public long getRegistryContentHistoryCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentHistoryCapacity();
-        }
-        return retValue;
-    }
-
-    public long getTotalIncomingBandwidth(){
-        long incomingBW =  0;
-        if(totalRegistryBandwidth != null){
-            incomingBW += totalRegistryBandwidth.getIncomingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            incomingBW += totalServiceBandwidth.getIncomingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            incomingBW += totalWebappBandwidth.getIncomingBandwidth();
-        }
-        return incomingBW;
-    }
-
-    public long getTotalOutgoingBandwidth(){
-        long outgoingBW =  0;
-        if(totalRegistryBandwidth != null){
-            outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            outgoingBW += totalServiceBandwidth.getOutgoingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            outgoingBW += totalWebappBandwidth.getOutgoingBandwidth();
-        }
-        return outgoingBW;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
deleted file mode 100644
index ff9c4be..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.3/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class UsageEntry {
-    private String key;
-    private String value;
-
-    public UsageEntry() {
-        // empty constructor to used in web services
-    }
-
-    public UsageEntry(String key, String value) {
-        this.key = key;
-        this.value = value;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-}


[08/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
deleted file mode 100644
index bbf56e4..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/tenant_usage.jsp
+++ /dev/null
@@ -1,427 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="java.util.List" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.menu"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="true"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<script type="text/javascript" src="js/usage-report.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    session.setAttribute("year-month", yearMonth);
-
-
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-	List<String>  reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<%--<div id="report_ui">
-    <carbon:report
-            component="org.wso2.carbon.usage"
-            template="usage_report"
-            pdfReport="true"
-            htmlReport="true"
-            excelReport="true"
-            reportDataSession="usage_data"
-               />
-</div>--%>
-<div id="workArea">
-
-<form id="usageForm" action="tenant_usage.jsp" method="post">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-<%
-    }
-%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-<%--<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
---%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
deleted file mode 100644
index cb6a28d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/usage_report.jsp
+++ /dev/null
@@ -1,28 +0,0 @@
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<carbon:jsi18n
-resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-request="<%=request%>" />
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
deleted file mode 100644
index 8522cfa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/pom.xml
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage.ui</artifactId>
-    <version>2.1.3</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage - User Interface</name>
-
-    <build>
-
-        <plugins>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.ui.*,
-                        </Export-Package>
-                        <Import-Package>
-			    org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,                            
-                            org.apache.lucene.*,
-                            *;resolution:=optional
-                        </Import-Package>
-                        <Carbon-Component>UIBundle</Carbon-Component>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-	    <dependency>
-            <groupId>commons-codec.wso2</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.equinox</groupId>
-            <artifactId>javax.servlet</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
-            <artifactId>axiom</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-            <version>2.1.2</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.stub</artifactId>
-		<version>4.1.3</version>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
deleted file mode 100644
index 64ee922..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.stub.services.UsageServiceStub;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsageServiceClient {
-    private static final Log log = LogFactory.getLog(UsageServiceClient.class);
-
-    private UsageServiceStub stub;
-    private String epr;
-
-    public UsageServiceClient(
-            String cookie, String backendServerURL, ConfigurationContext configContext)
-            throws RegistryException {
-
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public UsageServiceClient(ServletConfig config, HttpSession session)
-            throws RegistryException {
-
-        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
-        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
-        ConfigurationContext configContext = (ConfigurationContext) config.
-                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        return stub.retrieveCurrentTenantUsage(yearMonth);
-    }
-
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        return stub.retrieveTenantUsages(yearMonth);
-    }
-
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-    }
-
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return stub.retrieveTenantUsage(yearMonth, tenantId);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
-            return stub.retrieveInstanceUsage();
-    }
-
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
-            String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
-            return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
deleted file mode 100755
index 38ff46b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.wso2.carbon.usage.ui.report;
-
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- * 
- * Licensed 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.
- */
-public class AllTenantUsageData {
-
-	public AllTenantUsageData() {
-	}
-
-	String yearMonth;
-	
-	String tenantName;
-	
-	String numberOfUsers;
-	
-	String currentDataStorage;
-	
-	String regBandwidth;
-	
-	String svcBandwidth;
-	
-	String svcTotalRequest;
-
-	public String getYearMonth() {
-		return yearMonth;
-	}
-
-	public void setYearMonth(String yearMonth) {
-		this.yearMonth = yearMonth;
-	}
-
-	public String getTenantName() {
-		return tenantName;
-	}
-
-	public void setTenantName(String tenantName) {
-		this.tenantName = tenantName;
-	}
-
-	public String getNumberOfUsers() {
-		return numberOfUsers;
-	}
-
-	public void setNumberOfUsers(String numberOfUsers) {
-		this.numberOfUsers = numberOfUsers;
-	}
-
-	public String getCurrentDataStorage() {
-		return currentDataStorage;
-	}
-
-	public void setCurrentDataStorage(String currentDataStorage) {
-		this.currentDataStorage = currentDataStorage;
-	}
-
-	public String getRegBandwidth() {
-		return regBandwidth;
-	}
-
-	public void setRegBandwidth(String regBandwidth) {
-		this.regBandwidth = regBandwidth;
-	}
-
-	public String getSvcBandwidth() {
-		return svcBandwidth;
-	}
-
-	public void setSvcBandwidth(String svcBandwidth) {
-		this.svcBandwidth = svcBandwidth;
-	}
-
-	public String getSvcTotalRequest() {
-		return svcTotalRequest;
-	}
-
-	public void setSvcTotalRequest(String svcTotalRequest) {
-		this.svcTotalRequest = svcTotalRequest;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
deleted file mode 100644
index 00d03b3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * this class is used to generate reports of all tenant usages
- */
-public class AllTenantUsageReport {
-
-    private TenantUsage[] tenantUsages;
-    private String yearMonth;
-
-    /**
-     * @param config
-     * @param session
-     * @param request
-     * @throws Exception
-     */
-    private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
-
-    public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-    	tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
-     
- 
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-    }
-
-    public List<AllTenantUsageData> getUsageReportData() {
-
-        List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>();   // all the strings need to be passed to
-        //  generate the report are added to this list
-
-        if (yearMonth == null) {
-            //  get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        //  add all the usage data to the list
-        try {
-            for (TenantUsage usage : tenantUsages) {
-                AllTenantUsageData usageData = new AllTenantUsageData();
-                usageData.setYearMonth(yearMonth);
-                String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                int numberOfUsers = usage.getNumberOfUsers();
-
-                //  String username = (String) request.getSession().getAttribute("logged-user");
-                String tenantName = usage.getDomain();
-                int tenantId = usage.getTenantId();
-                String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-
-                usageData.setTenantName(tenantName);
-                if (yearMonth.equals(currentYearMonth)) {
-                    usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
-                    usageData.setCurrentDataStorage(currentDataStorage);
-                }
-                // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
-                else {
-                    usageData.setNumberOfUsers("-");
-                    usageData.setCurrentDataStorage("-");
-                }
-                usageData.setRegBandwidth(regBandwidth);
-                usageData.setSvcBandwidth(svcBandwidth);
-                usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
-                reportData.add(usageData);
-            }
-        }
-        catch (Exception e) {
-            String msg = "Error while retrieving tenant usages for month : " + yearMonth;
-            log.error(msg, e);
-        }
-        return reportData;         // return as an array
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
deleted file mode 100644
index 6c0ad50..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to generate tenant usage report
- */
-public class UsageReport {
-    private TenantUsage usage;
-    private String yearMonth;
-
-    public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-        usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-
-    }
-
-
-    public List<String> getUsageReportData() {
-
-        int numberOfUsers = usage.getNumberOfUsers();
-        if (yearMonth == null) {
-
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-
-        String tenantName = usage.getDomain();
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        List<String> reportData = new ArrayList<String>();
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add("Duration");
-        reportData.add("Tenant Name");
-        reportData.add("Number of users");
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add(yearMonth);
-        reportData.add(tenantName);
-        reportData.add(String.valueOf(numberOfUsers));
-
-
-        if (currentYearMonth.equals(yearMonth)) {
-            reportData.add("Storage Usage");
-            reportData.add("Data Storage");
-            reportData.add("Current Data Storage");
-            reportData.add("Historical Data Storage");
-            reportData.add("Total Data Storage");
-            String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-            String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-            String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-            reportData.add("Storage Usage");
-            reportData.add("Registry Content");
-            reportData.add(totalDataStorage);
-            reportData.add(currentDataStorage);
-            reportData.add(historyDataStorage);
-        }
-
-        String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-        if (regBWStats != null) {
-            for (BandwidthStatistics stat : regBWStats) {
-                String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(regInBandwidth);
-                reportData.add(regOutBandwidth);
-                reportData.add(regBandwidth);
-
-            }
-        }
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totRegInBandwidth);
-        reportData.add(totRegOutBandwidth);
-        reportData.add(totRegBandwidth);
-
-        String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-        if (svcBWStats != null) {
-            for (BandwidthStatistics stat : svcBWStats) {
-                String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(svcInBandwidth);
-                reportData.add(svcOutBandwidth);
-                reportData.add(svcBandwidth);
-
-            }
-        }
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totSvcInBandwidth);
-        reportData.add(totSvcOutBandwidth);
-        reportData.add(totSvcBandwidth);
-
-        String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-        BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        if (webappBWStats != null) {
-            for (BandwidthStatistics stat : webappBWStats) {
-                String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(webappInBandwidth);
-                reportData.add(webappOutBandwidth);
-                reportData.add(webappBandwidth);
-            }
-        }
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totWebappInBandwidth);
-        reportData.add(totWebappOutBandwidth);
-        reportData.add(totWebappBandwidth);
-
-
-        long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-        long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-        long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-        RequestStatistics[] svcStats = usage.getRequestStatistics();
-        reportData.add("Service Usage Statistic");
-        reportData.add("Server Name");
-        reportData.add("Request Count");
-        reportData.add("Response Count");
-        reportData.add("Fault Count");
-        if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
-            for (RequestStatistics stat : svcStats) {
-                long svcReqCount = stat.getRequestCount();
-                long svcResCount = stat.getResponseCount();
-                long svcFaultCount = stat.getFaultCount();
-                reportData.add("Server Name****");
-                reportData.add(String.valueOf(svcReqCount));
-                reportData.add(String.valueOf(svcResCount));
-                reportData.add(String.valueOf(svcFaultCount));
-            }
-        }
-        reportData.add("Service Usage Statistic");
-        reportData.add("All Server Total");
-        reportData.add(String.valueOf(totSvcReqCount));
-        reportData.add(String.valueOf(totSvcRespCount));
-        reportData.add(String.valueOf(totSvcFaultCount));
-
-        return reportData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
deleted file mode 100644
index 401342d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.ui.utils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.common.ui.UIException;
-import org.wso2.carbon.usage.stub.beans.xsd.*;
-import org.wso2.carbon.usage.ui.clients.UsageServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class UsageUtil {
-    private static final Log log = LogFactory.getLog(UsageUtil.class);
-
-    private static long KB_LIMIT = 1024;
-    private static long MB_LIMIT = 1024 * 1024;
-    private static long GB_LIMIT = 1024 * 1024 * 1024;
-    private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
-
-    public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
-                                                         ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveCurrentTenantUsage(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get current tenant usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
-                                                     ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveTenantUsages(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage retrieveTenantUsage(ServletRequest request,
-                                                  ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            String tenantIdStr = request.getParameter("tenant-id");
-            if (tenantIdStr == null) {
-                tenantIdStr = "0";
-            }
-            return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
-        } catch (Exception e) {
-            String msg = "Failed to get tenant usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-
-    public static String convertBytesToString(long storage) {
-        if (storage < KB_LIMIT) {
-            return storage + " Byte(s)";
-        } else if (storage < MB_LIMIT) {
-            return storage / KB_LIMIT + " KByte(s)";
-        } else if (storage < GB_LIMIT) {
-            return storage / MB_LIMIT + " MByte(s)";
-        } else if (storage < TB_LIMIT) {
-            return storage / GB_LIMIT + " GByte(s)";
-        } else {
-            return storage / TB_LIMIT + " TByte(s)";
-        }
-    }
-
-    public static String getCurrentYearMonth() {
-        Calendar calendar = Calendar.getInstance();
-        return CommonUtil.getMonthString(calendar);
-    }
-
-    public static String[] getYearMonths() {
-        // we will list 100 months for now
-        List<String> yearMonths = new ArrayList<String>();
-        for (int i = 0; i > -100; i--) {
-            String yearMonth = CommonUtil.getMonthString(i);
-            yearMonths.add(yearMonth);
-        }
-        return yearMonths.toArray(new String[yearMonths.size()]);
-    }
-
-    public static String getCurrentDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (regData != null) {
-            currentData = regData.getRegistryContentCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getHistoryDataStorage(TenantUsage usage) {
-        TenantDataCapacity historyData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (historyData != null) {
-            currentData = historyData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getTotalDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long totalDataStorage = 0;
-        if (regData != null) {
-            totalDataStorage =
-                    regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(totalDataStorage);
-    }
-
-    public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
-                                                               ServletConfig config, HttpSession session)
-            throws Exception {
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
-            return returnInstanceUsage;
-        } catch (Exception e) {
-            String msg = "Failed to get current instance usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get paginated instance usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-    public static String getAPIUsage(TenantUsage usage) {
-        long count = 0;
-
-        if (usage.getApiManagerUsageStats() != null) {
-            count =usage.getApiManagerUsageStats()[0].getRequestCount();
-        }
-        return Long.toString(count);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 19b0510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<component xmlns="http://products.wso2.org/carbon">
-    <!-- sample menu configuration -->
-    <menus>
-        <menu>
-            <id>usage_monitoring_menu</id>
-            <i18n-key>usage.monitoring</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu></parent-menu>
-            <link>#</link>
-            <region>region4</region>
-            <style-class>home</style-class>
-            <order>22</order>
-            <icon>../services/images/services.gif</icon>
-        </menu>
-        <menu>
-            <id>tenant_usage_menu</id>
-            <i18n-key>tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>51</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/user-usage-report.gif</icon>
-            <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
-            <require-not-super-tenant>true</require-not-super-tenant>
-        </menu>
-        <!--menu>
-            <id>all_tenant_instance_usage_menu</id>
-            <i18n-key>instance.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/instance-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu-->
-        <menu>
-            <id>all_tenant_usage_menu</id>
-            <i18n-key>all.tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu>
-    </menus>
-
-</component>


[23/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
new file mode 100644
index 0000000..14c24d5
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
@@ -0,0 +1,209 @@
+<!--
+  ~  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.
+  -->
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
+<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
+<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageData" %>
+<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
+<%@ page import="java.util.List" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+
+<carbon:jsi18n
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
+        request="<%=request%>"/>
+
+
+<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
+    <carbon:breadcrumb
+            label="tenants.usage.report"
+            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+            topPage="true"
+            request="<%=request%>"/>
+    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
+    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
+    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
+    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
+
+
+    <%
+        PaginatedTenantUsageInfo tenantsInfo =
+                UsageUtil.retrievePaginatedTenantUsages(request, config, session);
+        TenantUsage[] tenantUsages = tenantsInfo.getTenantUsages();
+        int pageNumber = tenantsInfo.getPageNumber();
+        int numberOfPages = tenantsInfo.getNumberOfPages();
+        String yearMonth = request.getParameter("year-month");
+        session.setAttribute("year-month", yearMonth);
+
+
+        if (yearMonth == null) {
+            // get the current year month
+            yearMonth = UsageUtil.getCurrentYearMonth();
+        }
+        String currentYearMonth = UsageUtil.getCurrentYearMonth();
+        int rowCount = 5;
+        if (yearMonth.equals(currentYearMonth)) {
+            rowCount = 7;
+        }
+    %>
+
+
+    <%
+        //AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
+        //List<AllTenantUsageData> reportDataArray = usageReport.getUsageReportData();
+        //request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
+    %>
+
+    <div id="middle">
+        <h2><fmt:message key="tenants.usage.report"/> for the Month - <%=yearMonth%> (All
+            Tenants)</h2>
+    </div>
+
+    <div id="workArea">
+
+        <form id="usageForm" action="all_tenant_usage.jsp" method="post">
+
+
+            <table class="styledLeft">
+                <thead>
+                <tr>
+                    <th>
+                        <fmt:message key="report.duration"/>
+                    </th>
+                </tr>
+                </thead>
+                <tbody>
+                <tr>
+                    <td class="nopadding">
+                        <table class="normal-nopadding" cellspacing="0">
+                            <tbody>
+                            <tr>
+                                <td><fmt:message key="year.month"/></td>
+                                <td colspan="2">
+                                    <select onchange="this.form.submit()" name="year-month"
+                                            id="year-month" style="width:400px">
+                                        <%
+                                            for (String ym : UsageUtil.getYearMonths()) {
+                                                String selectedStr = "";
+                                                if (ym.equals(yearMonth)) {
+                                                    selectedStr = "selected=\"true\" ";
+                                                }
+                                        %>
+                                        <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
+                                        </option>
+                                        <%
+                                            }
+                                        %>
+                                    </select>
+                                    <input type="hidden" name="requestedPage" id="requestedPage"
+                                           value="<%=pageNumber%>"/>
+                                </td>
+                            </tr>
+
+                            <tr>
+                                <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
+                                        key="users"/></td>
+                            </tr>
+                            <tr>
+                                <th><fmt:message key="tenant.domain"/></th>
+                                <%
+                                    if (yearMonth.equals(currentYearMonth)) {
+                                %>
+                                <th><fmt:message key="number.of.users"/></th>
+                                <th><fmt:message key="storage.usage"/></th><%}%>
+                                <%--<th><fmt:message key="registry.total.bandwidth"/></th>--%>
+                                <th><fmt:message key="service.total.bandwidth"/></th>
+                                <th><fmt:message key="webapp.total.bandwidth"/></th>
+                                <th><fmt:message key="service.total.request"/></th>
+                                <th><fmt:message key="full.report"/></th>
+                            </tr>
+                            <%
+                                if (tenantUsages != null) {
+                                    for (TenantUsage usage : tenantUsages) {
+                                        String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
+                                        String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
+                                        String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
+                                        String webBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
+                                        long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
+                                        int numberOfUsers = usage.getNumberOfUsers();
+
+                                        String username = (String) request.getSession().getAttribute("logged-user");
+                                        String tenantName = usage.getDomain();
+                                        int tenantId = usage.getTenantId();
+                                        String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
+                            %>
+
+                            <tr>
+                                <td><%=tenantName%>
+                                </td>
+                                <%
+                                    if (yearMonth.equals(currentYearMonth)) {
+                                %>
+                                <td><%=numberOfUsers%>
+                                </td>
+                                <td><%=currentDataStorage%>
+                                </td>
+                                <%
+                                    }
+                                %>
+                                <%--<td><%=regBandwidth%>
+                                </td>--%>
+                                <td><%=svcBandwidth%>
+                                </td>
+                                <td><%=webBandwidth%>
+                                </td>
+                                <td><%=svcTotalRequest%>
+                                </td>
+                                <td><a href="<%=fullReportLink%>">Full Report</a></td>
+                            </tr>
+                            <%
+
+                                }
+                            } else {
+                            %>
+                            <tr>
+                                <td><fmt:message key="empty.usage.data"/></td>
+                            </tr>
+                            </tr>
+                            <%
+                                }
+
+                            %>
+                            <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
+                                                      numberOfPages="<%=numberOfPages%>"
+                                                      resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+                                                      nextKey="next" prevKey="prev"
+                                                      tdColSpan="6"
+                                                      paginationFunction="submitAllTenantPaginatedUsage({0})"/>
+                            </tbody>
+                        </table>
+                    </td>
+                </tr>
+                </tbody>
+            </table>
+        </form>
+        <br/>
+    </div>
+    </div>
+</fmt:bundle>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
new file mode 100644
index 0000000..5da662b
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
@@ -0,0 +1,26 @@
+<!--
+  ~  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.
+  -->
+<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
+    String[] reportDataArray = usageReport.getUsageReportData();
+    System.out.println("Report lenth "+reportDataArray.length);
+    request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/any_tenant_usage.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
new file mode 100644
index 0000000..16970ff
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
@@ -0,0 +1,463 @@
+<!--
+  ~  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.
+  -->
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
+<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.CartridgeStatistics" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+
+<carbon:jsi18n
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
+        request="<%=request%>"/>
+
+
+<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
+<carbon:breadcrumb
+        label="tenant.usage.report"
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+        topPage="false"
+        request="<%=request%>"/>
+<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+<script type="text/javascript" src="../ajax/js/prototype.js"></script>
+<script type="text/javascript" src="js/register_config.js"></script>
+<%
+
+    TenantUsage usage = UsageUtil.retrieveTenantUsage(request, config, session);
+    int numberOfUsers = usage.getNumberOfUsers();
+    String yearMonth = request.getParameter("year-month");
+    if (yearMonth == null) {
+        // get the current year month
+        yearMonth = UsageUtil.getCurrentYearMonth();
+    }
+    String username = (String) request.getSession().getAttribute("logged-user");
+    String tenantName = usage.getDomain();
+    int tenantId = usage.getTenantId();
+    String currentYearMonth = UsageUtil.getCurrentYearMonth();
+%>
+
+<div id="middle">
+
+<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
+    )</h2>
+
+<div id="workArea">
+
+<form id="usageForm" action="any_tenant_usage.jsp" method="get">
+
+<table class="styledLeft">
+<thead>
+<tr>
+    <th>
+        <fmt:message key="report.duration"/>
+    </th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="nopadding">
+<table class="normal-nopadding" cellspacing="0">
+<tbody>
+<tr>
+    <td><fmt:message key="year.month"/></td>
+    <td colspan="3">
+        <input type="hidden" name="tenant-id" value="<%=tenantId%>"/>
+        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
+            <%
+                for (String ym : UsageUtil.getYearMonths()) {
+                    String selectedStr = "";
+                    if (ym.equals(yearMonth)) {
+                        selectedStr = "selected=\"true\" ";
+                    }
+            %>
+            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
+            </option>
+            <%
+                }
+            %>
+        </select>
+    </td>
+</tr>
+
+<%
+    if (currentYearMonth.equals(yearMonth)) {
+%>
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="number.of.users"/></td>
+    <td colspan="3">
+        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
+               value="<%=numberOfUsers%>"/>
+    </td>
+</tr>
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
+</tr>
+
+<tr>
+    <td><fmt:message key="data.storage.name"/></td>
+    <td><fmt:message key="current.data.storage"/></td>
+    <td><fmt:message key="history.data.storage"/></td>
+    <td><fmt:message key="total.data.storage"/></td>
+</tr>
+<%
+    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
+    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
+    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
+%>
+<tr>
+    <td><fmt:message key="registry.content.storage.name"/></td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
+               value="<%=currentDataStorage%>"/>
+    </td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
+               value="<%=historyDataStorage%>"/>
+    </td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
+               value="<%=totalDataStorage%>"/>
+    </td>
+</tr>
+
+<%
+    }
+%>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="number.of.api.calls"/></td>
+</tr>
+<%
+    String apiCallCount = UsageUtil.getAPIUsage(usage);
+%>
+
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
+               style="width:200px" value="<%=apiCallCount%>"/>
+    </td>
+</tr>
+
+
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
+    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
+    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
+    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
+    if (regBWStats != null) {
+        for (BandwidthStatistics stat : regBWStats) {
+            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
+               style="width:200px" value="<%=regInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
+               style="width:200px" value="<%=regOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
+               style="width:200px" value="<%=regBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
+               style="width:200px" value="<%=totRegInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
+               style="width:200px" value="<%=totRegOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
+               style="width:200px" value="<%=totRegBandwidth%>"/>
+    </td>
+</tr>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
+    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
+    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
+    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
+    if (svcBWStats != null) {
+        for (BandwidthStatistics stat : svcBWStats) {
+            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
+               style="width:200px" value="<%=svcInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
+               style="width:200px" value="<%=svcOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
+               style="width:200px" value="<%=svcBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
+               style="width:200px" value="<%=totSvcInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
+               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
+               style="width:200px" value="<%=totSvcBandwidth%>"/>
+    </td>
+</tr>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
+    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
+    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
+    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
+    if (webappBWStats != null) {
+        for (BandwidthStatistics stat : webappBWStats) {
+            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
+               style="width:200px" value="<%=webappInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
+               style="width:200px" value="<%=webappOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
+               value="<%=webappBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
+               style="width:200px" value="<%=totWebappInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
+               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
+               style="width:200px" value="<%=totWebappBandwidth%>"/>
+    </td>
+</tr>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="service.usage.request"/></td>
+    <td><fmt:message key="service.usage.response"/></td>
+    <td><fmt:message key="service.usage.fault"/></td>
+</tr>
+<%
+    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
+    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
+    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
+    RequestStatistics[] svcStats = usage.getRequestStatistics();
+    if (svcStats != null) {
+        for (RequestStatistics stat : svcStats) {
+            long svcReqCount = stat.getRequestCount();
+            long svcResCount = stat.getResponseCount();
+            long svcFaultCount = stat.getFaultCount();
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
+               style="width:200px" value="<%=svcReqCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
+               style="width:200px" value="<%=svcResCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
+               style="width:200px" value="<%=svcFaultCount%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
+               style="width:200px" value="<%=totSvcReqCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
+               style="width:200px" value="<%=totSvcRespCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
+               style="width:200px" value="<%=totSvcFaultCount%>"/>
+    </td>
+</tr>
+
+<!--cartridge stats-->
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="cartridge.stat"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="cartridge.type"/></td>
+    <td><fmt:message key="image.id"/></td>
+    <td><fmt:message key="cartridge.hours"/></td>
+        <%--<td><fmt:message key="service.usage.fault"/></td>--%>
+</tr>
+<%
+    long totalHours = usage.getTotalCartridgeHours().getCartridgeHours();
+    CartridgeStatistics[] cs = usage.getCartridgeStatistics();
+    if(cs!=null && cs.length>0 && cs[0] != null) {
+        for(CartridgeStatistics stat: cs) {
+
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="imageId" id="imageId"
+               style="width:200px" value="<%=stat.getInstanceId()%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="cartridgeHours" id="cartridgeHours"
+               style="width:200px" value="<%=stat.getCartridgeHours()%>"/>
+    </td>
+
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totalImageIds" id="totalImageIds"
+               style="width:200px" value=""/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totalCartridgeHours" id="totalCartridgeHours"
+               style="width:200px" value="<%=totalHours%>"/>
+    </td>
+
+</tr>
+
+</tbody>
+</table>
+</td>
+</tr>
+</tbody>
+</table>
+<br/>
+<input type='button' class='button' style="align:right" id="backButtonID"
+       onclick='window.location="../tenant-usage/all_tenant_usage.jsp?region=region4&item=all_tenant_usage_menu"'
+       value='<fmt:message key="back"/>'/>
+</form>
+<br/>
+</div>
+</div>
+</fmt:bundle>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/css/tenant-usage.css b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/css/tenant-usage.css
new file mode 100644
index 0000000..5c85728
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/css/tenant-usage.css
@@ -0,0 +1,28 @@
+.disableLink {
+    color: #aaaaaa;
+}
+
+.pageLinks {
+    background: #FFFFFF none repeat scroll 0%;
+    border: 1px solid #DDDDDD;
+    padding: 2px 3px;
+    text-decoration: none;
+    margin: 0px;
+    margin-left: 2px;
+    margin-right: 2px;
+}
+
+.pageLinks-selected {
+    background: #e8e9ae none repeat scroll 0%;
+    border: 1px solid #DDDDDD;
+    padding: 2px 3px;
+    text-decoration: none;
+    margin: 0px;
+    margin-left: 2px;
+    margin-right: 2px;
+}
+
+a {
+    color: #386698;
+    cursor: pointer;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/images/view-usage.png b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/images/view-usage.png
new file mode 100644
index 0000000..4080da3
Binary files /dev/null and b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/images/view-usage.png differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/userguide.html b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/userguide.html
new file mode 100644
index 0000000..c70d4ad
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/docs/userguide.html
@@ -0,0 +1,78 @@
+<!--
+  ~  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.
+  -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <title>View Tenant Usage - User Guide</title>
+  <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
+</head>
+
+<body>
+<h1>View Usage</h1>
+
+<p>
+You can view usage of the stratos resource by your organization(Tenant) from this page
+</p>
+
+<p>
+<img src="images/view-usage.png" alt="View Usage"/>
+<div><strong>Figure1: View Usage</strong></div>
+</p>
+ <h2> <b>Description of usage data report fields</b></h2>
+<p>
+<table border="1">
+<tr>
+<th>The Form Field</th>
+<th>Description</th>
+</tr>
+<tr>
+<td>Report Duration </td>
+<td>The year and the month the usage is metered.</td>
+</tr>
+        <tr>
+            <td>Number of Users</td>
+            <td>Number of users of your stratos account.(This is valid only for current month)</td>
+        </tr>
+       <tr>
+        <tr>
+            <td>Storage Usage</td>
+            <td>The registry data storage amount.</td>
+        </tr>
+        <tr>
+            <td>Registry Bandwidth Usage</td>
+            <td>Registry bandwidth consumed by the registry resource accesses(registry uploads, downloads).</td>
+        </tr>
+        <tr>
+            <td>Service Bandwidth Usage</td>
+            <td>The bandwidth consumed by the web services hosted by you.</td>
+        </tr>
+        <tr>
+            <td>Webapp Bandwidth Usage</td>
+            <td>The bandwidth consumed by the web services.</td>
+        </tr>
+ 	<tr>
+            <td>Service Usage Statistics</td>
+            <td>Service statistics of requests and responses of services.</td>
+        </tr>
+    </tbody>
+</table>
+</p>
+<div><strong>Table1: Description of usage data report fields</strong></div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/instance-usage-report.gif b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
new file mode 100644
index 0000000..4a1ae6a
Binary files /dev/null and b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/instance-usage-report.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
new file mode 100644
index 0000000..a9b04e2
Binary files /dev/null and b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/user-usage-report.gif b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/user-usage-report.gif
new file mode 100644
index 0000000..9070c35
Binary files /dev/null and b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/images/user-usage-report.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
new file mode 100644
index 0000000..61043f0
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
@@ -0,0 +1,49 @@
+function createXmlHttpRequest() {
+    var request;
+
+    // Lets try using ActiveX to instantiate the XMLHttpRequest
+    // object
+    try {
+        request = new ActiveXObject("Microsoft.XMLHTTP");
+    } catch(ex1) {
+        try {
+            request = new ActiveXObject("Msxml2.XMLHTTP");
+        } catch(ex2) {
+            request = null;
+        }
+    }
+
+    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
+    if (!request && typeof XMLHttpRequest != "undefined") {
+        //The browser does, so lets instantiate the object
+        request = new XMLHttpRequest();
+    }
+    function removeCarriageReturns(string) {
+        return string.replace(/\n/g, "");
+    }
+
+    return request;
+}
+function getUsageReportData() {
+    alert(1);
+    var xmlHttpReq = createXmlHttpRequest();
+    alert(2);
+    // Make sure the XMLHttpRequest object was instantiated
+    if (xmlHttpReq) {
+        // This is a synchronous POST, hence UI blocking.
+        xmlHttpReq.open("GET", "all_tenant_usage_report.jsp", false);
+        xmlHttpReq.send(null);
+        
+        if (xmlHttpReq.status == 200) {
+            return removeCarriageReturns(xmlHttpReq.responseText);
+        }
+
+        return false;
+    }
+
+    return false;
+}
+function removeCarriageReturns(string) {
+	alert(string);
+    return string.replace(/\n/g, "");
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/tenant-usage.js
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/tenant-usage.js b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/tenant-usage.js
new file mode 100644
index 0000000..76c4363
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/tenant-usage.js
@@ -0,0 +1,7 @@
+function submitAllTenantPaginatedUsage(pageNumber) {
+    sessionAwareFunction(function() {
+        document.getElementById("requestedPage").value = pageNumber;
+        var usageForm = document.getElementById("usageForm");
+        usageForm.submit();
+    }, jsi18n["session.timed.out"]);
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js
new file mode 100644
index 0000000..ed9e306
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js
@@ -0,0 +1,48 @@
+function createXmlHttpRequest() {
+    var request;
+
+    // Lets try using ActiveX to instantiate the XMLHttpRequest
+    // object
+    try {
+        request = new ActiveXObject("Microsoft.XMLHTTP");
+    } catch(ex1) {
+        try {
+            request = new ActiveXObject("Msxml2.XMLHTTP");
+        } catch(ex2) {
+            request = null;
+        }
+    }
+
+    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
+    if (!request && typeof XMLHttpRequest != "undefined") {
+        //The browser does, so lets instantiate the object
+        request = new XMLHttpRequest();
+    }
+    function removeCarriageReturns(string) {
+        return string.replace(/\n/g, "");
+    }
+
+    return request;
+}
+function getUsageReportData() {
+
+    var xmlHttpReq = createXmlHttpRequest();
+
+    // Make sure the XMLHttpRequest object was instantiated
+    if (xmlHttpReq) {
+        // This is a synchronous POST, hence UI blocking.
+        xmlHttpReq.open("GET", "usage_report.jsp", false);
+        xmlHttpReq.send(null);
+
+        if (xmlHttpReq.status == 200) {
+            return removeCarriageReturns(xmlHttpReq.responseText);
+        }
+
+        return false;
+    }
+
+    return false;
+}
+function removeCarriageReturns(string) {
+    return string.replace(/\n/g, "");
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp
new file mode 100644
index 0000000..ee0ffd6
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp
@@ -0,0 +1,475 @@
+<!--
+  ~  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.
+  -->
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
+<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
+<%@ page import="java.util.List" %>
+<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
+<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.CartridgeStatistics" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+
+<carbon:jsi18n
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
+        request="<%=request%>"/>
+
+
+<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
+<carbon:breadcrumb
+        label="tenant.menu"
+        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
+        topPage="true"
+        request="<%=request%>"/>
+<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+<script type="text/javascript" src="../ajax/js/prototype.js"></script>
+<script type="text/javascript" src="js/register_config.js"></script>
+<script type="text/javascript" src="js/usage-report.js"></script>
+<%
+
+    TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
+    int numberOfUsers = usage.getNumberOfUsers();
+    String yearMonth = request.getParameter("year-month");
+    session.setAttribute("year-month", yearMonth);
+
+
+    if (yearMonth == null) {
+        // get the current year month
+        yearMonth = UsageUtil.getCurrentYearMonth();
+    }
+    String username = (String) request.getSession().getAttribute("logged-user");
+    String tenantName = usage.getDomain();
+    int tenantId = usage.getTenantId();
+    String currentYearMonth = UsageUtil.getCurrentYearMonth();
+%>
+
+<%
+
+    UsageReport usageReport = new UsageReport(config, session, request);
+	List<String>  reportDataArray = usageReport.getUsageReportData();
+    request.getSession().setAttribute("usage_data", reportDataArray);
+%>
+
+<div id="middle">
+
+<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
+    )</h2>
+
+<%--<div id="report_ui">
+    <carbon:report
+            component="org.wso2.carbon.usage"
+            template="usage_report"
+            pdfReport="true"
+            htmlReport="true"
+            excelReport="true"
+            reportDataSession="usage_data"
+               />
+</div>--%>
+<div id="workArea">
+
+<form id="usageForm" action="tenant_usage.jsp" method="post">
+
+<table class="styledLeft">
+<thead>
+<tr>
+    <th>
+        <fmt:message key="report.duration"/>
+    </th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="nopadding">
+<table class="normal-nopadding" cellspacing="0">
+<tbody>
+<tr>
+    <td><fmt:message key="year.month"/></td>
+    <td colspan="3">
+        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
+            <%
+                for (String ym : UsageUtil.getYearMonths()) {
+                    String selectedStr = "";
+                    if (ym.equals(yearMonth)) {
+                        selectedStr = "selected=\"true\" ";
+                    }
+            %>
+            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
+            </option>
+            <%
+                }
+            %>
+        </select>
+    </td>
+</tr>
+<%
+    if (currentYearMonth.equals(yearMonth)) {
+%>
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="number.of.users"/></td>
+    <td colspan="3">
+        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
+               value="<%=numberOfUsers%>"/>
+    </td>
+</tr>
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
+</tr>
+
+<tr>
+    <td><fmt:message key="data.storage.name"/></td>
+    <td><fmt:message key="current.data.storage"/></td>
+    <td><fmt:message key="history.data.storage"/></td>
+    <td><fmt:message key="total.data.storage"/></td>
+</tr>
+<%
+    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
+    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
+    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
+%>
+<tr>
+    <td><fmt:message key="registry.content.storage.name"/></td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
+               value="<%=currentDataStorage%>"/>
+    </td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
+               value="<%=historyDataStorage%>"/>
+    </td>
+    <td colspan="1">
+        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
+               value="<%=totalDataStorage%>"/>
+    </td>
+</tr>
+<%
+    }
+%>
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="number.of.api.calls"/></td>
+</tr>
+<%
+    String apiCallCount = UsageUtil.getAPIUsage(usage);
+%>
+
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
+               style="width:200px" value="<%=apiCallCount%>"/>
+    </td>
+</tr>
+
+<%--<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
+    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
+    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
+    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
+    if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
+        for (BandwidthStatistics stat : regBWStats) {
+            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
+               style="width:200px" value="<%=regInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
+               style="width:200px" value="<%=regOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
+               style="width:200px" value="<%=regBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
+               style="width:200px" value="<%=totRegInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
+               style="width:200px" value="<%=totRegOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
+               style="width:200px" value="<%=totRegBandwidth%>"/>
+    </td>
+</tr>
+--%>
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
+    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
+    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
+    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
+    if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
+        for (BandwidthStatistics stat : svcBWStats) {
+            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
+               style="width:200px" value="<%=svcInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
+               style="width:200px" value="<%=svcOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
+               style="width:200px" value="<%=svcBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
+               style="width:200px" value="<%=totSvcInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
+               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
+               style="width:200px" value="<%=totSvcBandwidth%>"/>
+    </td>
+</tr>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="incoming.bandwidth"/></td>
+    <td><fmt:message key="outgoing.bandwidth"/></td>
+    <td><fmt:message key="total.bandwidth"/></td>
+</tr>
+<%
+    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
+    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
+    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
+    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
+    if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
+        for (BandwidthStatistics stat : webappBWStats) {
+            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
+            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
+            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
+               style="width:200px" value="<%=webappInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
+               style="width:200px" value="<%=webappOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
+               value="<%=webappBandwidth%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
+               style="width:200px" value="<%=totWebappInBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
+               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
+               style="width:200px" value="<%=totWebappBandwidth%>"/>
+    </td>
+</tr>
+
+
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="server.name"/></td>
+    <td><fmt:message key="service.usage.request"/></td>
+    <td><fmt:message key="service.usage.response"/></td>
+    <td><fmt:message key="service.usage.fault"/></td>
+</tr>
+<%
+    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
+    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
+    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
+    RequestStatistics[] svcStats = usage.getRequestStatistics();
+    if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
+        for (RequestStatistics stat : svcStats) {
+            long svcReqCount = stat.getRequestCount();
+            long svcResCount = stat.getResponseCount();
+            long svcFaultCount = stat.getFaultCount();
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
+               style="width:200px" value="<%=svcReqCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
+               style="width:200px" value="<%=svcResCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
+               style="width:200px" value="<%=svcFaultCount%>"/>
+    </td>
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
+               style="width:200px" value="<%=totSvcReqCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
+               style="width:200px" value="<%=totSvcRespCount%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
+               style="width:200px" value="<%=totSvcFaultCount%>"/>
+    </td>
+</tr>
+
+<!--cartridge stats-->
+<tr>
+    <td colspan="4" class="middle-header"><fmt:message key="cartridge.stat"/></td>
+</tr>
+<tr>
+    <td><fmt:message key="cartridge.type"/></td>
+    <td><fmt:message key="image.id"/></td>
+    <td><fmt:message key="cartridge.hours"/></td>
+    <%--<td><fmt:message key="service.usage.fault"/></td>--%>
+</tr>
+<%
+    long totalHours = usage.getTotalCartridgeHours().getCartridgeHours();
+    CartridgeStatistics[] cs = usage.getCartridgeStatistics();
+    if(cs!=null && cs.length>0 && cs[0] != null) {
+        for(CartridgeStatistics stat: cs) {
+
+%>
+<tr>
+    <td><%=stat.getKey()%>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="imageId" id="imageId"
+               style="width:200px" value="<%=stat.getInstanceId()%>"/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="cartridgeHours" id="cartridgeHours"
+               style="width:200px" value="<%=stat.getCartridgeHours()%>"/>
+    </td>
+
+</tr>
+<%
+        }
+    }
+%>
+<tr>
+    <td><fmt:message key="all.server.name"/></td>
+    <td>
+        <input readonly="1" type="text" name="totalImageIds" id="totalImageIds"
+               style="width:200px" value=""/>
+    </td>
+    <td>
+        <input readonly="1" type="text" name="totalCartridgeHours" id="totalCartridgeHours"
+               style="width:200px" value="<%=totalHours%>"/>
+    </td>
+
+</tr>
+
+</tbody>
+</table>
+</td>
+</tr>
+</tbody>
+</table>
+</form>
+<br/>
+</div>
+</div>
+</fmt:bundle>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp
new file mode 100644
index 0000000..ed85ae0
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp
@@ -0,0 +1,29 @@
+<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
+<!--
+  ~  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.
+  -->
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<carbon:jsi18n
+resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
+request="<%=request%>" />
+<%
+
+    UsageReport usageReport = new UsageReport(config, session, request);
+    String[] reportDataArray = usageReport.getUsageReportData();
+    request.getSession().setAttribute("usage_data", reportDataArray);
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/pom.xml b/components/org.apache.stratos.usage/pom.xml
new file mode 100644
index 0000000..d546f39
--- /dev/null
+++ b/components/org.apache.stratos.usage/pom.xml
@@ -0,0 +1,146 @@
+<!--
+# 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.
+  -->
+<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/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-components-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+	<relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.usage</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Usage</name>
+
+    <build>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>target/generated-code/src</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <ListenerManager-RequiredServices>
+                            org.apache.stratos.usage.api.TenantUsageRetriever
+                        </ListenerManager-RequiredServices>
+                        <Private-Package>
+                            org.apache.stratos.usage.internal.*,
+                            org.apache.stratos.usage.util.*,
+                            org.apache.stratos.usage.services.*,
+                            org.apache.stratos.usage.client.*
+                        </Private-Package>
+                        <Export-Package>
+                            org.apache.stratos.usage.beans.*,
+                            org.apache.stratos.usage.api.*,
+                        </Export-Package>
+                        <Import-Package>
+                            org.wso2.carbon.rule.*,
+                            org.wso2.carbon.registry.core.*;version=1.0.1,
+                            org.wso2.carbon.registry.resource.*,
+                            org.apache.stratos.common.*,
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.user.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.user.mgt</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>2.1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.usage.agent</artifactId>
+	    <version>2.1.2</version>
+        </dependency>
+         <!--<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.ndatasource.core</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+    </dependencies>
+</project>


[09/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/UsageService.wsdl
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/UsageService.wsdl b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/UsageService.wsdl
deleted file mode 100644
index a974e17..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/UsageService.wsdl
+++ /dev/null
@@ -1,604 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-                  xmlns:ns1="http://org.apache.axis2/xsd"
-                  xmlns:ns="http://services.usage.carbon.wso2.org"
-                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
-                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
-                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
-                  xmlns:ax2249="http://beans.usage.carbon.wso2.org/xsd"
-                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
-                  targetNamespace="http://services.usage.carbon.wso2.org">
-    <wsdl:documentation>UsageService</wsdl:documentation>
-    <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://beans.usage.carbon.wso2.org/xsd">
-            <xs:complexType name="TenantUsage">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="domain" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="numberOfUsers" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="registryBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="registryCapacity" nillable="true"
-                                type="ax2249:TenantDataCapacity"/>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="requestStatistics"
-                                nillable="true" type="ax2249:RequestStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="serviceBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    <xs:element minOccurs="0" name="totalIncomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalOutgoingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalRegistryBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="totalRequestStatistics" nillable="true"
-                                type="ax2249:RequestStatistics"/>
-                    <xs:element minOccurs="0" name="totalServiceBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="totalWebappBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="usageEntries"
-                                nillable="true" type="ax2249:UsageEntry"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="webappBandwidthStatistics"
-                                nillable="true" type="ax2249:BandwidthStatistics"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="BandwidthStatistics">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="incomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="outgoingBandwidth" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="TenantDataCapacity">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="RequestStatistics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="faultCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="requestCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="responseCount" type="xs:long"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:complexType name="UsageEntry">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedTenantUsageInfo">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="tenantUsages"
-                                nillable="true" type="ax2249:TenantUsage"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedInstanceUsage">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceUsages"
-                                nillable="true" type="ax2249:InstanceUsageStatics"/>
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="InstanceUsageStatics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="instanceID" nillable="true" type="xs:int"/>
-                    <xs:element minOccurs="0" name="instanceURL" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="running" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="startTime" nillable="true" type="xs:dateTime"/>
-
-                    <xs:element minOccurs="0" name="stopTime" nillable="true" type="xs:dateTime"/>
-                    <xs:element minOccurs="0" name="usedTimeInSeconds" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax2250="http://beans.usage.carbon.wso2.org/xsd"
-                   attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://services.usage.carbon.wso2.org">
-            <xs:import namespace="http://beans.usage.carbon.wso2.org/xsd"/>
-            <xs:element name="Exception">
-                <xs:complexType>
-
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="Exception" nillable="true"
-                                    type="ns:Exception"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:complexType name="Exception">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:element name="retrieveTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsagesResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsagesResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedTenantUsageInfo"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsage">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedInstanceUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveInstanceUsageResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:InstanceUsageStatics"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-
-                </xs:complexType>
-            </xs:element>
-        </xs:schema>
-    </wsdl:types>
-    <wsdl:message name="retrievePaginatedTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsagesResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="Exception">
-        <wsdl:part name="parameters" element="ns:Exception"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsageResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsagesResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsage"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveInstanceUsageRequest"/>
-    <wsdl:message name="retrieveInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageRequest">
-
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:portType name="UsageServicePortType">
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <wsdl:input message="ns:retrievePaginatedTenantUsagesRequest"
-                        wsaw:Action="urn:retrievePaginatedTenantUsages"/>
-            <wsdl:output message="ns:retrievePaginatedTenantUsagesResponse"
-                         wsaw:Action="urn:retrievePaginatedTenantUsagesResponse"/>
-
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <wsdl:input message="ns:retrieveCurrentTenantUsageRequest"
-                        wsaw:Action="urn:retrieveCurrentTenantUsage"/>
-            <wsdl:output message="ns:retrieveCurrentTenantUsageResponse"
-                         wsaw:Action="urn:retrieveCurrentTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveCurrentTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <wsdl:input message="ns:retrieveTenantUsagesRequest"
-                        wsaw:Action="urn:retrieveTenantUsages"/>
-
-            <wsdl:output message="ns:retrieveTenantUsagesResponse"
-                         wsaw:Action="urn:retrieveTenantUsagesResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <wsdl:input message="ns:retrieveTenantUsageRequest"
-                        wsaw:Action="urn:retrieveTenantUsage"/>
-            <wsdl:output message="ns:retrieveTenantUsageResponse"
-                         wsaw:Action="urn:retrieveTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-
-            <wsdl:input message="ns:retrieveInstanceUsageRequest"
-                        wsaw:Action="urn:retrieveInstanceUsage"/>
-            <wsdl:output message="ns:retrieveInstanceUsageResponse"
-                         wsaw:Action="urn:retrieveInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveInstanceUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <wsdl:input message="ns:retrievePaginatedInstanceUsageRequest"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsage"/>
-            <wsdl:output message="ns:retrievePaginatedInstanceUsageResponse"
-                         wsaw:Action="urn:retrievePaginatedInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsageException"/>
-        </wsdl:operation>
-
-    </wsdl:portType>
-    <wsdl:binding name="UsageServiceSoap11Binding" type="ns:UsageServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceSoap12Binding" type="ns:UsageServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap12:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap12:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap12:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap12:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap12:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap12:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceHttpBinding" type="ns:UsageServicePortType">
-        <http:binding verb="POST"/>
-
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <http:operation location="retrievePaginatedTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <http:operation location="retrieveCurrentTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <http:operation location="retrieveTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsage">
-            <http:operation location="retrieveTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <http:operation location="retrieveInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <http:operation location="retrievePaginatedInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-    </wsdl:binding>
-    <wsdl:service name="UsageService">
-        <wsdl:port name="UsageServiceHttpsSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-
-            <soap12:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-            <soap12:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpEndpoint" binding="ns:UsageServiceHttpBinding">
-            <http:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpEndpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsEndpoint" binding="ns:UsageServiceHttpBinding">
-
-            <http:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsEndpoint/"/>
-        </wsdl:port>
-    </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
deleted file mode 100644
index e7490b0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-empty=To make sure the js properties file is not empty
-session.timed.out=Session timed out. Please login again
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
deleted file mode 100644
index 71ffd1d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
+++ /dev/null
@@ -1,53 +0,0 @@
-usage.menu=User Usage
-user.usage.report=User Usage Report
-tenant.menu=Tenant Usage
-tenants.usage.report=Tenant Usage Report
-tenant.usage.report=Usage Report
-data.storage.name=Data Storage
-current.data.storage=Current Data Storage
-history.data.storage=Historical Data Storage
-total.data.storage=Total Data Storage
-registry.content.storage.name=Registry Content
-registry.bandwidth.usage=Registry Bandwidth Usage
-service.bandwidth.usage=Service Bandwidth Usage
-webapp.bandwidth.usage=Webapp Bandwidth Usage
-server.name=Server Name
-all.server.name=All Server Total
-incoming.bandwidth=Incoming Bandwidth
-outgoing.bandwidth=Outgoing Bandwidth
-total.bandwidth=Total Bandwidth
-storage.usage=Storage Usage
-number.of.users=Number of Users
-users=Users
-usage.monitoring=Usage Monitoring
-all.tenant.usage.report=All Tenant Usage
-tenant.domain=Domain
-tenant.id=Id
-full.report=Full Report
-report.duration=Report Duration
-year.month=Year-Month
-back=Back
-page.x.to.y=Page {0}
-prev=Prev
-next=Next
-service.usage.stat=Service Usage Statistics
-service.usage.request=Request Count
-service.usage.response=Response Count
-service.usage.fault=Fault Count
-service.total.request=Service Requests
-registry.total.bandwidth=Total Registry Bandwidth
-service.total.bandwidth=Total Service Bandwidth
-instance.usage.report=Instance Usage Report
-instance.server.url=Instance Server URL
-instance.id=Instance ID
-start.time=Start Time
-stop.time=Stop Time
-used.time.in.hours=Used Time In Hours
-instances.data=Instances Data
-failed.to.get.instance.data=Failed To Get Instance Data
-empty.instance.data=Instance Data Not Found
-usage.data.not.available=Usage Data not available
-empty.usage.data=Usage Data Not Found
-webapp.total.bandwidth=Total WebApp Bandwidth
-number.of.api.calls= Number of API Calls
-api.usage=API Usage

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
deleted file mode 100644
index e4c9510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
+++ /dev/null
@@ -1,216 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-        int pageNumber=0;
-        int rowCount = 5;
-        int numberOfPages=0;
-        InstanceUsageStatics[] instanceUsages=null;
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        try{
-        PaginatedInstanceUsage instanceInfo =
-                UsageUtil.retrievePaginatedInstanceUsages(request, config, session);
-        instanceUsages = instanceInfo.getInstanceUsages();
-        pageNumber = instanceInfo.getPageNumber();
-        numberOfPages = instanceInfo.getNumberOfPages();
-
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-        }
-        catch (Exception e){
-        //No need to handle here it here.Error will show in next try block
-        //To avoid dead page
-        }
-    %>
-
-    <div id="middle">
-
-        <h2><fmt:message key="instance.usage.report"/> for the Month - <%=yearMonth%> (With All
-            Running Instances)</h2>
-
-        <div id="report_ui">
-            <carbon:reportNew
-                    component="org.wso2.carbon.usage"
-                    template="all_tenant_usage_report"
-                    pdfReport="true"
-                    htmlReport="true"
-                    excelReport="true"
-                    reportDataSession="all_tenant_usage_data"
-                    jsFunction="getUsageReportData()"/>
-        </div>
-
-        <div id="workArea">
-
-            <form id="usageForm" action="all_tenant_instance_usage.jsp" method="post">
-
-
-                <table class="styledLeft">
-                    <thead>
-                    <tr>
-                        <th>
-                            <fmt:message key="report.duration"/>
-                        </th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr>
-                        <td class="nopadding">
-                            <table class="normal-nopadding" cellspacing="0">
-                                <tbody>
-                                <tr>
-                                    <td><fmt:message key="year.month"/></td>
-                                    <td colspan="2">
-                                        <select onchange="this.form.submit()" name="year-month"
-                                                id="year-month" style="width:400px">
-                                            <%
-                                                for (String ym : UsageUtil.getYearMonths()) {
-                                                    String selectedStr = "";
-                                                    if (ym.equals(yearMonth)) {
-                                                        selectedStr = "selected=\"true\" ";
-                                                    }
-                                            %>
-                                            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                            </option>
-                                            <%
-                                                }
-                                            %>
-                                        </select>
-                                        <input type="hidden" name="requestedPage" id="requestedPage"
-                                               value="<%=pageNumber%>"/>
-                                    </td>
-                                </tr>
-
-                                <tr>
-                                    <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                            key="instances.data"/></td>
-                                </tr>
-                                <tr>
-                                    <th><fmt:message key="instance.id"/></th>
-                                    <th><fmt:message key="server.name"/></th>
-                                    <th><fmt:message key="start.time"/></th>
-                                    <th><fmt:message key="stop.time"/></th>
-                                    <th><fmt:message key="used.time.in.hours"/></th>
-                                </tr>
-                                <%                
-                                    try{
-                                    InstanceUsageStatics[] iu = UsageUtil.retrieveInstanceUsage(request, config, session);
-                                    java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz");
-                                    if (!iu.equals(null)) {
-                                        for (InstanceUsageStatics usage : instanceUsages) {
-                                            String endDate;
-                                            if (usage.getRunning() == true) {
-                                                endDate="Instance Still Running";
-                                            }
-                                            else{
-                                                endDate=dateFormatter.format(usage.getStopTime().getTime());
-                                            }
-                                            String startDate=dateFormatter.format(usage.getStartTime().getTime());
-                                            long usedHours;
-                                            long usedTimeInSeconds=usage.getUsedTimeInSeconds();
-                                            if(usedTimeInSeconds%3600==0){
-                                                usedHours=usedTimeInSeconds/3600;
-                                            }
-                                            else{
-                                                usedHours=(usedTimeInSeconds/3600)+1;
-                                            }
-                                %>
-                                <tr>
-                                    <td>
-                                        <%=usage.getInstanceID()%>
-                                    </td>
-                                    <td>
-                                        <%=usage.getInstanceURL().toString()%>
-                                    </td>
-                                    <td>
-                                        <%=startDate%>
-                                    </td>
-                                    <td>
-                                        <%=endDate%>
-                                    </td>
-                                    <td>
-
-                                        <%=usedHours%>
-                                    </td>
-                                </tr>
-                                <%
-
-                                        }
-                                    }
-                                    else{
-                                      %>
-                                     <td><fmt:message key="empty.instance.data"/></td>
-                                <%
-                                 }
-                                    }
-                                    catch (Exception e){ %>
-                                      <td><fmt:message key="failed.to.get.instance.data"/></td>
-                                   <% }
-                                %>
-                                <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                          numberOfPages="<%=numberOfPages%>"
-                                                          resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                          nextKey="next" prevKey="prev"
-                                                          tdColSpan="6"
-                                                          paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                                </tbody>
-                            </table>
-                        </td>
-                    </tr>
-                    </tbody>
-                </table>
-            </form>
-            <br/>
-        </div>
-    </div>
-</fmt:bundle>
-
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
deleted file mode 100644
index 6036a19..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
+++ /dev/null
@@ -1,208 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageData" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page import="java.util.List" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        PaginatedTenantUsageInfo tenantsInfo =
-                UsageUtil.retrievePaginatedTenantUsages(request, config, session);
-        TenantUsage[] tenantUsages = tenantsInfo.getTenantUsages();
-        int pageNumber = tenantsInfo.getPageNumber();
-        int numberOfPages = tenantsInfo.getNumberOfPages();
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-
-
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        int rowCount = 5;
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-    %>
-
-
-    <%
-        //AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-        //List<AllTenantUsageData> reportDataArray = usageReport.getUsageReportData();
-        //request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-    %>
-
-    <div id="middle">
-        <h2><fmt:message key="tenants.usage.report"/> for the Month - <%=yearMonth%> (All
-            Tenants)</h2>
-    </div>
-
-    <div id="workArea">
-
-        <form id="usageForm" action="all_tenant_usage.jsp" method="post">
-
-
-            <table class="styledLeft">
-                <thead>
-                <tr>
-                    <th>
-                        <fmt:message key="report.duration"/>
-                    </th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr>
-                    <td class="nopadding">
-                        <table class="normal-nopadding" cellspacing="0">
-                            <tbody>
-                            <tr>
-                                <td><fmt:message key="year.month"/></td>
-                                <td colspan="2">
-                                    <select onchange="this.form.submit()" name="year-month"
-                                            id="year-month" style="width:400px">
-                                        <%
-                                            for (String ym : UsageUtil.getYearMonths()) {
-                                                String selectedStr = "";
-                                                if (ym.equals(yearMonth)) {
-                                                    selectedStr = "selected=\"true\" ";
-                                                }
-                                        %>
-                                        <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                        </option>
-                                        <%
-                                            }
-                                        %>
-                                    </select>
-                                    <input type="hidden" name="requestedPage" id="requestedPage"
-                                           value="<%=pageNumber%>"/>
-                                </td>
-                            </tr>
-
-                            <tr>
-                                <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                        key="users"/></td>
-                            </tr>
-                            <tr>
-                                <th><fmt:message key="tenant.domain"/></th>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <th><fmt:message key="number.of.users"/></th>
-                                <th><fmt:message key="storage.usage"/></th><%}%>
-                                <%--<th><fmt:message key="registry.total.bandwidth"/></th>--%>
-                                <th><fmt:message key="service.total.bandwidth"/></th>
-                                <th><fmt:message key="webapp.total.bandwidth"/></th>
-                                <th><fmt:message key="service.total.request"/></th>
-                                <th><fmt:message key="full.report"/></th>
-                            </tr>
-                            <%
-                                if (tenantUsages != null) {
-                                    for (TenantUsage usage : tenantUsages) {
-                                        String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                                        String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                                        String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                                        String webBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-                                        long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                                        int numberOfUsers = usage.getNumberOfUsers();
-
-                                        String username = (String) request.getSession().getAttribute("logged-user");
-                                        String tenantName = usage.getDomain();
-                                        int tenantId = usage.getTenantId();
-                                        String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-                            %>
-
-                            <tr>
-                                <td><%=tenantName%>
-                                </td>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <td><%=numberOfUsers%>
-                                </td>
-                                <td><%=currentDataStorage%>
-                                </td>
-                                <%
-                                    }
-                                %>
-                                <%--<td><%=regBandwidth%>
-                                </td>--%>
-                                <td><%=svcBandwidth%>
-                                </td>
-                                <td><%=webBandwidth%>
-                                </td>
-                                <td><%=svcTotalRequest%>
-                                </td>
-                                <td><a href="<%=fullReportLink%>">Full Report</a></td>
-                            </tr>
-                            <%
-
-                                }
-                            } else {
-                            %>
-                            <tr>
-                                <td><fmt:message key="empty.usage.data"/></td>
-                            </tr>
-                            </tr>
-                            <%
-                                }
-
-                            %>
-                            <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                      numberOfPages="<%=numberOfPages%>"
-                                                      resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                      nextKey="next" prevKey="prev"
-                                                      tdColSpan="6"
-                                                      paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                            </tbody>
-                        </table>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </form>
-        <br/>
-    </div>
-    </div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
deleted file mode 100644
index ce67752..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%
-    AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    System.out.println("Report lenth "+reportDataArray.length);
-    request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/any_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
deleted file mode 100644
index 7dfde24..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
+++ /dev/null
@@ -1,414 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.usage.report"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="false"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<div id="workArea">
-
-<form id="usageForm" action="any_tenant_usage.jsp" method="get">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <input type="hidden" name="tenant-id" value="<%=tenantId%>"/>
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-
-<%
-    }
-%>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-<br/>
-<input type='button' class='button' style="align:right" id="backButtonID"
-       onclick='window.location="../tenant-usage/all_tenant_usage.jsp?region=region4&item=all_tenant_usage_menu"'
-       value='<fmt:message key="back"/>'/>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/css/tenant-usage.css b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/css/tenant-usage.css
deleted file mode 100644
index 5c85728..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/css/tenant-usage.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.disableLink {
-    color: #aaaaaa;
-}
-
-.pageLinks {
-    background: #FFFFFF none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-.pageLinks-selected {
-    background: #e8e9ae none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-a {
-    color: #386698;
-    cursor: pointer;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/images/view-usage.png b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/images/view-usage.png
deleted file mode 100644
index 4080da3..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/images/view-usage.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/userguide.html b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/userguide.html
deleted file mode 100644
index 9dd0f6c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/docs/userguide.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>View Tenant Usage - User Guide</title>
-  <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
-</head>
-
-<body>
-<h1>View Usage</h1>
-
-<p>
-You can view usage of the stratos resource by your organization(Tenant) from this page
-</p>
-
-<p>
-<img src="images/view-usage.png" alt="View Usage"/>
-<div><strong>Figure1: View Usage</strong></div>
-</p>
- <h2> <b>Description of usage data report fields</b></h2>
-<p>
-<table border="1">
-<tr>
-<th>The Form Field</th>
-<th>Description</th>
-</tr>
-<tr>
-<td>Report Duration </td>
-<td>The year and the month the usage is metered.</td>
-</tr>
-        <tr>
-            <td>Number of Users</td>
-            <td>Number of users of your stratos account.(This is valid only for current month)</td>
-        </tr>
-       <tr>
-        <tr>
-            <td>Storage Usage</td>
-            <td>The registry data storage amount.</td>
-        </tr>
-        <tr>
-            <td>Registry Bandwidth Usage</td>
-            <td>Registry bandwidth consumed by the registry resource accesses(registry uploads, downloads).</td>
-        </tr>
-        <tr>
-            <td>Service Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services hosted by you.</td>
-        </tr>
-        <tr>
-            <td>Webapp Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services.</td>
-        </tr>
- 	<tr>
-            <td>Service Usage Statistics</td>
-            <td>Service statistics of requests and responses of services.</td>
-        </tr>
-    </tbody>
-</table>
-</p>
-<div><strong>Table1: Description of usage data report fields</strong></div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/instance-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
deleted file mode 100644
index 4a1ae6a..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/instance-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
deleted file mode 100644
index a9b04e2..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/user-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/user-usage-report.gif
deleted file mode 100644
index 9070c35..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/images/user-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
deleted file mode 100644
index 61043f0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
+++ /dev/null
@@ -1,49 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-    alert(1);
-    var xmlHttpReq = createXmlHttpRequest();
-    alert(2);
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "all_tenant_usage_report.jsp", false);
-        xmlHttpReq.send(null);
-        
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-	alert(string);
-    return string.replace(/\n/g, "");
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/tenant-usage.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/tenant-usage.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/tenant-usage.js
deleted file mode 100644
index 76c4363..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/tenant-usage.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function submitAllTenantPaginatedUsage(pageNumber) {
-    sessionAwareFunction(function() {
-        document.getElementById("requestedPage").value = pageNumber;
-        var usageForm = document.getElementById("usageForm");
-        usageForm.submit();
-    }, jsi18n["session.timed.out"]);
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/usage-report.js
deleted file mode 100644
index ed9e306..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.2/src/main/resources/web/tenant-usage/js/usage-report.js
+++ /dev/null
@@ -1,48 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-
-    var xmlHttpReq = createXmlHttpRequest();
-
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "usage_report.jsp", false);
-        xmlHttpReq.send(null);
-
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-    return string.replace(/\n/g, "");
-}
\ No newline at end of file


[06/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/tenant_usage.jsp
deleted file mode 100644
index c0f87fe..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/tenant_usage.jsp
+++ /dev/null
@@ -1,474 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="java.util.List" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.CartridgeStatistics" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.menu"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="true"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<script type="text/javascript" src="js/usage-report.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    session.setAttribute("year-month", yearMonth);
-
-
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-	List<String>  reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<%--<div id="report_ui">
-    <carbon:report
-            component="org.wso2.carbon.usage"
-            template="usage_report"
-            pdfReport="true"
-            htmlReport="true"
-            excelReport="true"
-            reportDataSession="usage_data"
-               />
-</div>--%>
-<div id="workArea">
-
-<form id="usageForm" action="tenant_usage.jsp" method="post">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-<%
-    }
-%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-<%--<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
---%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-<!--cartridge stats-->
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="cartridge.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="cartridge.type"/></td>
-    <td><fmt:message key="image.id"/></td>
-    <td><fmt:message key="cartridge.hours"/></td>
-    <%--<td><fmt:message key="service.usage.fault"/></td>--%>
-</tr>
-<%
-    long totalHours = usage.getTotalCartridgeHours().getCartridgeHours();
-    CartridgeStatistics[] cs = usage.getCartridgeStatistics();
-    if(cs!=null && cs.length>0 && cs[0] != null) {
-        for(CartridgeStatistics stat: cs) {
-
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="imageId" id="imageId"
-               style="width:200px" value="<%=stat.getInstanceId()%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="cartridgeHours" id="cartridgeHours"
-               style="width:200px" value="<%=stat.getCartridgeHours()%>"/>
-    </td>
-
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalImageIds" id="totalImageIds"
-               style="width:200px" value=""/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totalCartridgeHours" id="totalCartridgeHours"
-               style="width:200px" value="<%=totalHours%>"/>
-    </td>
-
-</tr>
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/usage_report.jsp
deleted file mode 100644
index cb6a28d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/usage_report.jsp
+++ /dev/null
@@ -1,28 +0,0 @@
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<carbon:jsi18n
-resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-request="<%=request%>" />
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/pom.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/pom.xml
deleted file mode 100644
index c9771c4..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/pom.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage</artifactId>
-    <version>2.1.0</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>add-source</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>target/generated-code/src</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <ListenerManager-RequiredServices>
-                            org.wso2.carbon.usage.api.TenantUsageRetriever
-                        </ListenerManager-RequiredServices>
-                        <Private-Package>
-                            org.wso2.carbon.usage.internal.*,
-                            org.wso2.carbon.usage.util.*,
-                            org.wso2.carbon.usage.services.*,
-                            org.wso2.carbon.usage.client.*
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.beans.*,
-                            org.wso2.carbon.usage.api.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.rule.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            org.wso2.carbon.stratos.common.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-            
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.mgt</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.agent</artifactId>
-        </dependency>
-         <!--<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId>
-        </dependency>-->
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ndatasource.core</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
deleted file mode 100644
index 6a15d0a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.api;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.beans.*;
-import org.wso2.carbon.usage.util.DataAccessObject;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.util.*;
-
-public class TenantUsageRetriever {
-    private static final Log log = LogFactory.getLog(TenantUsageRetriever.class);
-    private static final String DEFAULT_SERVICE_NAME = "Stratos";
-    private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS";
-    private static final String TOTAL_LABEL = "Total";
-    public static final int REG_BANDWIDTH_INDEX = 0;
-    public static final int SVC_BANDWIDTH_INDEX = 1;
-    public static final int WEBAPP_BANDWIDTH_INDEX = 2;
-
-    private RegistryService registryService;
-    private DataAccessObject dao;
-
-    public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext)
-            throws Exception {
-
-        // we are loading the essentials from the constructors in order to restrict the users
-        // to use the usage retrievers.
-        this.registryService = registryService;
-        this.dao = new DataAccessObject();
-    }
-
-
-    public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate,
-                                              boolean currentMonth) throws Exception {
-        TenantDataCapacity dataCapacity = null;
-
-        if(currentMonth){
-            dataCapacity = dao.getTenantDataCapacity(tenantId);
-        } else {
-            //we don't have a way to see the registry usage of last months yet
-        }
-
-        return dataCapacity;
-
-    }
-
-    /**
-     * This returns the number of users in a given tenant
-     * @param tenantId Tenant ID
-     * @return Number of users
-     * @throws RegistryException
-     */
-    public int getCurrentUserCount(int tenantId) throws RegistryException {
-        UserRealm userRealm = registryService.getUserRealm(tenantId);
-        int usersCount;
-        try {
-            String[] users = userRealm.getUserStoreManager().listUsers("*", -1);
-            usersCount = users.length;
-        } catch (UserStoreException e) {
-            String msg = "Error in getting the current users.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-        return usersCount;
-    }
-
-    public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        BandwidthStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-            bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate);
-            
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-            
-            Calendar endHour = Calendar.getInstance();
-            
-            bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour));
-            stats = convertBWListToArray(bwsList);
-            
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>();
-
-        if (stats != null) {
-            for (BandwidthStatistics stat : stats) {
-                //Proceed only if incoming bandwidth or outgoing bandwidth is not zero
-                if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) {
-                    continue;
-                }
-
-                //TODO: fix the extractServiceUrl method properly
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String bandwidthName = stat.getKey();
-
-                HashMap<String, BandwidthStatistics> bwMap;
-                if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) {
-                    bwMap = regBwMap;
-                } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) {
-                    bwMap = svcBwMap;
-                } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) {
-                    bwMap = webappBwMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + bandwidthName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                BandwidthStatistics reqStat = bwMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new BandwidthStatistics(serverName);
-                    bwMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setIncomingBandwidth(
-                        reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth());
-                reqStat.setOutgoingBandwidth(
-                        reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth());
-            }
-        }
-
-        //Convert to array and return it
-        BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][];
-        Collection<BandwidthStatistics> values = regBwMap.values();
-        returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = svcBwMap.values();
-        returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = webappBwMap.values();
-        returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-
-        return returnValue;
-    }
-
-    public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate,
-                                                    Calendar endDate, boolean currentMonth) throws Exception {
-        RequestStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-            rsList = dao.getDailyRequestStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour));
-
-            stats = convertRSListToArray(rsList);
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>();
-
-        if (stats != null) {
-            for (RequestStatistics stat : stats) {
-                //Proceed only if request count is not zero
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-
-                String serverName = extractServiceNameFromUrl(stat.getKey());
-
-                //find whether the map already has this key; If not, insert a new one
-                RequestStatistics reqStat = tempReqStatMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new RequestStatistics(serverName);
-                    tempReqStatMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount());
-                reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount());
-                reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount());
-            }
-        }
-
-        //Convert to array and return it
-        Collection<RequestStatistics> values = tempReqStatMap.values();
-        return values.toArray(new RequestStatistics[values.size()]);
-
-    }
-
-    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
-        //get the domain name
-        TenantManager tenantManger = Util.getRealmService().getTenantManager();
-        String domain = tenantManger.getDomain(tenantId);
-        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);
-
-        //Get the startDate, endDate from yearMonth String
-        Date date = CommonUtil.getDateFromMonthString(yearMonth);
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-
-        //Calculate whether the yearMonth fits to current month; if the current date is less than
-        // endDate, then we treat it as current month
-        boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0);
-
-        //get the data capacity
-        TenantDataCapacity capacity;
-        try {
-            capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting data capacity from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryCapacity(capacity);
-
-        //get the service request statistics
-        RequestStatistics[] reqStats = null;
-        try {
-            reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting request statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRequestStatistics(reqStats);
-
-        //Calculate total Request statistics
-        RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL);
-        long totalReq = 0;
-        long totalRes = 0;
-        long totalFault = 0;
-        if(reqStats!=null){
-            for (RequestStatistics stat : reqStats) {
-                totalReq += stat.getRequestCount();
-                totalRes += stat.getResponseCount();
-                totalFault += stat.getFaultCount();
-            }
-            totalReqStat.setRequestCount(totalReq);
-            totalReqStat.setResponseCount(totalRes);
-            totalReqStat.setFaultCount(totalFault);
-        }
-        tenantUsage.setTotalRequestStatistics(totalReqStat);
-
-        //get Bandwidth statistics
-        BandwidthStatistics[][] bwStats = null;
-        try {
-            bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]);
-        tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]);
-        tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]);
-
-        //get the total bandwidths
-        int index = 0;
-        for (BandwidthStatistics[] bwArray : bwStats) {
-            long incomingBandwidth = 0;
-            long outgoingBandwidth = 0;
-            for (BandwidthStatistics bandwidth : bwArray) {
-                incomingBandwidth += bandwidth.getIncomingBandwidth();
-                outgoingBandwidth += bandwidth.getOutgoingBandwidth();
-            }
-            BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL);
-            total.setIncomingBandwidth(incomingBandwidth);
-            total.setOutgoingBandwidth(outgoingBandwidth);
-            switch (index) {
-                case REG_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalRegistryBandwidth(total);
-                    break;
-                case SVC_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalServiceBandwidth(total);
-                    break;
-                case WEBAPP_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalWebappBandwidth(total);
-                    break;
-            }
-            ++index;
-        }
-
-        // the users count will be calculated only if the yearMonth is the current yearMonth
-        if (isCurrentMonth) {
-            int usersCount = getCurrentUserCount(tenantId);
-            tenantUsage.setNumberOfUsers(usersCount);
-        }
-
-        return tenantUsage;
-    }
-
-    /**
-     * @param serviceURL
-     * @return service name
-     *         <p/>
-     *         Extract the stratos service part from URL; expecting the URL as
-     *         protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant
-     *         We are interested in "service" part only
-     */
-    private String extractServiceNameFromUrl(String serviceURL) {
-        if (serviceURL == null || serviceURL.equals("")) {
-            //No service URL is given, so return a default value
-            return DEFAULT_SERVICE_NAME;
-        }
-
-        int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part
-        if (startIndex != -1) {
-            // protocol://service.domain:port/tenant-domain/ case
-            startIndex += 3;
-        } else {
-            //service.domain:port/tenant case
-            startIndex = 0;
-        }
-
-        int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "."
-        if (endIndex == -1) {
-            // "." is not there; search for ":"
-            endIndex = serviceURL.indexOf(':', startIndex);
-
-            if (endIndex == -1) {
-                //Still could not find ":", then search for "/"
-                endIndex = serviceURL.indexOf('/', startIndex);
-
-                if (endIndex == -1) {
-                    //Noting is there, so take the whole service URL
-                    endIndex = serviceURL.length();
-                }
-            }
-
-        }
-        return serviceURL.substring(startIndex, endIndex);
-    }
-
-    /**
-     * @return Instance Usages Statics Array that contains data
-     * @throws Exception when back end error occurs
-     */
-    public InstanceUsageStatics[] getInstanceUsages() throws Exception {
-
-        //TODO: implement
-        return null;
-        /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats();
-        if (instanceData == null || instanceData.length == 0) {
-            return null;
-        }
-        InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length];
-        int elementID = 0;
-        for (InstanceUsageStat iu : instanceData) {
-            InstanceUsageStatics iu1 = new InstanceUsageStatics();
-            iu1.setInstanceID(iu.getInstanceId().intValue());
-            iu1.setInstanceURL(iu.getServerURL());
-            iu1.setStartTime(iu.getStartTimestamp());
-            iu1.setStopTime(iu.getStopTimestamp());
-            iu1.setRunning(iu.getIsRunning());
-            returnValue[elementID] = iu1;
-            elementID = elementID + 1;
-        }
-        return returnValue;
-        */
-    }
-    
-    
-    private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) {
-        BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-    
-    private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) {
-        RequestStatistics[] rsArray = new RequestStatistics[rsList.size()];
-        rsArray = rsList.toArray(rsArray);
-        return rsArray;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
deleted file mode 100644
index f236e0f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-/**
- * 
- */
-public class BandwidthStatistics {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-
-    public BandwidthStatistics(String key){
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
deleted file mode 100644
index 25cb759..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Calendar;
-
-public class InstanceUsageStatics {
-
-    private Calendar startTime;
-    private Calendar stopTime;
-    private String instanceURL;
-    private Integer instanceID;
-    private long usedTimeInSeconds;
-    private boolean running;
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    public void setRunning(boolean running) {
-        this.running = running;
-    }
-
-    public Calendar getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Calendar startTime) {
-        this.startTime = startTime;
-    }
-
-    public Calendar getStopTime() {
-        return stopTime;
-    }
-
-    public void setStopTime(Calendar stopTime) {
-        //Check weather stop time is Default value in database in that case
-        //server should still running so set isRunning as true
-        Calendar fixedDate = Calendar.getInstance();
-        fixedDate.set(2001, 1, 1, 00, 00, 00);
-        if (stopTime.compareTo(fixedDate) == 0) {
-            this.running = true;
-        }
-        this.stopTime = stopTime;
-    }
-
-    public String getInstanceURL() {
-        return instanceURL;
-    }
-
-    public void setInstanceURL(String instanceURL) {
-        this.instanceURL = instanceURL;
-    }
-
-    public Integer getInstanceID() {
-        return instanceID;
-    }
-
-    public void setInstanceID(Integer instanceID) {
-        this.instanceID = instanceID;
-    }
-
-    public long getUsedTimeInSeconds() {
-        long returnValue = (this.stopTime.getTimeInMillis() -
-                this.startTime.getTimeInMillis()) / 1000;
-        if (returnValue < 0) {
-            running = true;
-        }
-        return usedTimeInSeconds;
-    }
-    public void setUsedTimeInSeconds(long value){
-        this.usedTimeInSeconds=value;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
deleted file mode 100644
index b7407af..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedInstanceUsage {
-    private InstanceUsageStatics[] instanceUsages;
-    private int pageNumber;
-    private int numberOfPages;
-
-    public InstanceUsageStatics[] getInstanceUsages() {
-        if(instanceUsages != null) {
-        return Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-
-        return null;
-    }
-
-    public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) {
-        if(instanceUsages != null) {
-            this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-    }
-
-    public int getPageNumber() {
-        return pageNumber;
-    }
-
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
deleted file mode 100644
index 0a3bd1b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedTenantUsageInfo {
-    private TenantUsage[] tenantUsages;
-    private int pageNumber;
-    private int numberOfPages;
-    
-    public TenantUsage[] getTenantUsages() {
-        return Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public void setTenantUsages(TenantUsage[] tenantUsages) {
-        this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public int getPageNumber() {
-        return pageNumber;
-    }
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
deleted file mode 100644
index 085b91a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-public class RequestStatistics {
-    private String key;
-    private long requestCount;
-    private long responseCount;
-    private long faultCount;
-
-    public RequestStatistics(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public long getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(long responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public long getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(long faultCount) {
-        this.faultCount = faultCount;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
deleted file mode 100644
index 543126d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantDataCapacity {
-
-    private long registryContentCapacity;
-    private long registryContentHistoryCapacity;
-
-    public TenantDataCapacity() {
-    }
-    
-    /**
-     * @param registryContentCapacity
-     * @param registryContentHistoryCapacity
-     */
-    public TenantDataCapacity(
-            long registryContentCapacity, long registryContentHistoryCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-    public long getRegistryContentCapacity() {
-        return registryContentCapacity;
-    }
-
-    public void setRegistryContentCapacity(long registryContentCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-    }
-
-    public long getRegistryContentHistoryCapacity() {
-        return registryContentHistoryCapacity;
-    }
-
-    public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) {
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
deleted file mode 100644
index a7ef7a8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantUsage {
-    private int tenantId;
-    private String domain;
-    private int numberOfUsers;
-    private UsageEntry[] usageEntries;
-    private BandwidthStatistics[] registryBandwidthStatistics;
-    private BandwidthStatistics[] serviceBandwidthStatistics;
-    private BandwidthStatistics[] webappBandwidthStatistics;
-    private RequestStatistics[] requestStatistics;
-    private TenantDataCapacity registryCapacity;
-    private RequestStatistics totalRequestStatistics;
-    private BandwidthStatistics totalRegistryBandwidth;
-    private BandwidthStatistics totalServiceBandwidth;
-    private BandwidthStatistics totalWebappBandwidth;
-
-    
-    public BandwidthStatistics[] getRegistryBandwidthStatistics() {
-        return registryBandwidthStatistics;
-    }
-
-    public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) {
-        this.registryBandwidthStatistics = registryBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getServiceBandwidthStatistics() {
-        return serviceBandwidthStatistics;
-    }
-
-    public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) {
-        this.serviceBandwidthStatistics = serviceBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getWebappBandwidthStatistics() {
-        return webappBandwidthStatistics;
-    }
-
-    public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) {
-        this.webappBandwidthStatistics = webappBandwidthStatistics;
-    }
-
-    public RequestStatistics getTotalRequestStatistics() {
-        return totalRequestStatistics;
-    }
-
-    public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) {
-        this.totalRequestStatistics = totalRequestStatistics;
-    }
-
-    public BandwidthStatistics getTotalRegistryBandwidth() {
-        return totalRegistryBandwidth;
-    }
-
-    public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) {
-        this.totalRegistryBandwidth = totalRegistryBandwidth;
-    }
-
-    public BandwidthStatistics getTotalServiceBandwidth() {
-        return totalServiceBandwidth;
-    }
-
-    public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) {
-        this.totalServiceBandwidth = totalServiceBandwidth;
-    }
-
-    public BandwidthStatistics getTotalWebappBandwidth() {
-        return totalWebappBandwidth;
-    }
-
-    public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) {
-        this.totalWebappBandwidth = totalWebappBandwidth;
-    }
-
-    public TenantUsage() {
-        // empty method required for used in web services
-    }
-
-    public TenantUsage(int tenantId, String domain) {
-        this.tenantId = tenantId;
-        this.domain = domain;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    public UsageEntry[] getUsageEntries() {
-        return usageEntries;
-    }
-
-    public void setUsageEntries(UsageEntry[] usageEntries) {
-        this.usageEntries = usageEntries;
-    }
-    
-    public RequestStatistics[] getRequestStatistics() {
-        return requestStatistics;
-    }
-
-    public void setRequestStatistics(RequestStatistics[] requestStatistics) {
-        this.requestStatistics = requestStatistics;
-    }
-    
-    public TenantDataCapacity getRegistryCapacity() {
-        return registryCapacity;
-    }
-
-    public void setRegistryCapacity(TenantDataCapacity registryCapacity) {
-        this.registryCapacity = registryCapacity;
-    }
-    
-    public int getNumberOfUsers() {
-        return numberOfUsers;
-    }
-
-    public void setNumberOfUsers(int numberOfUsers) {
-        this.numberOfUsers = numberOfUsers;
-    }
-    
-    public long getRegistryContentCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentCapacity();
-        }
-        return retValue;
-    }
-    
-    public long getRegistryContentHistoryCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentHistoryCapacity();
-        }
-        return retValue;
-    }
-    
-    public long getTotalIncomingBandwidth(){
-        long incomingBW =  0;
-        if(totalRegistryBandwidth != null){
-            incomingBW += totalRegistryBandwidth.getIncomingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            incomingBW += totalServiceBandwidth.getIncomingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            incomingBW += totalWebappBandwidth.getIncomingBandwidth();
-        }
-        return incomingBW;
-    }
-    
-    public long getTotalOutgoingBandwidth(){
-        long outgoingBW =  0;
-        if(totalRegistryBandwidth != null){
-            outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            outgoingBW += totalServiceBandwidth.getOutgoingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            outgoingBW += totalWebappBandwidth.getOutgoingBandwidth();
-        }
-        return outgoingBW;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
deleted file mode 100644
index ff9c4be..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class UsageEntry {
-    private String key;
-    private String value;
-
-    public UsageEntry() {
-        // empty constructor to used in web services
-    }
-
-    public UsageEntry(String key, String value) {
-        this.key = key;
-        this.value = value;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
deleted file mode 100644
index cc30312..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.local.LocalTransportReceiver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.usage" immediate="true"
- * @scr.reference name="registry.service"
- * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
- * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
- * @scr.reference name="user.realmservice.default" 
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" 
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service" 
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" 
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageServiceComponent {
-    private static Log log = LogFactory.getLog(UsageServiceComponent.class);
-
-
-    protected void activate(ComponentContext context) {
-        try {
-            Util.registerRetrieverServices(context.getBundleContext());
-            log.debug("******* Usage bundle is activated ******* ");    
-        } catch (Exception e) {
-            log.error("******* Error in activating Usage bundle ******* ");
-        }
-    }
-
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Usage is deactivated ******* ");
-    }
-
-    protected void setRegistryService(RegistryService registryService) {
-        Util.setRegistryService(registryService);
-    }
-
-    protected void unsetRegistryService(RegistryService registryService) {
-        Util.setRegistryService(null);
-    }
-
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-    
-    protected void setConfigurationContextService(ConfigurationContextService ccService) {
-        //commented to work with the local transport
-	/*ConfigurationContext serverCtx = ccService.getServerConfigContext();
-        AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
-        LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
-        LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
-        LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
-	*/
-        Util.setConfigurationContextService(ccService);
-    }
-
-    protected void unsetConfigurationContextService(ConfigurationContextService ccService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(dataSourceService);
-    }
-    
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/services/UsageService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/services/UsageService.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/services/UsageService.java
deleted file mode 100644
index 2348b2b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/services/UsageService.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.services;
-
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.usage.beans.InstanceUsageStatics;
-import org.wso2.carbon.usage.beans.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.beans.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.beans.TenantUsage;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class UsageService extends AbstractAdmin {
-    /**
-     * Return the usage of the current logged in tenant
-     *
-     * @param yearMonth year month
-     * @return the current usage of the tenant
-     * @throws Exception
-     */
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
-        int tenantId = registry.getTenantId();
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    /**
-     * Return the all the tenant usages, requires super admin permissions
-     *
-     * @param yearMonth
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                        tenant.getId(), yearMonth);
-                tenantUsages.add(tenantUsage);
-            }
-        }
-        return tenantUsages.toArray(new TenantUsage[tenantUsages.size()]);
-    }
-
-    /**
-     * Return the all the tenant usages paginated, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param pageNumber
-     * @param entriesPerPage
-     * @return PaginatedTenantUsageInfo
-     * @throws Exception
-     */
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-
-        int i = 0;
-        int numberOfPages = 0;
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                if (i % entriesPerPage == 0) {
-                    numberOfPages++;
-                }
-                if (numberOfPages == pageNumber) {
-                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                            tenant.getId(), yearMonth);
-                    tenantUsages.add(tenantUsage);
-                }
-                i++;
-            }
-        }
-        PaginatedTenantUsageInfo paginatedTenantInfo = new PaginatedTenantUsageInfo();
-        paginatedTenantInfo.setTenantUsages(
-                tenantUsages.toArray(new TenantUsage[tenantUsages.size()]));
-        paginatedTenantInfo.setNumberOfPages(numberOfPages);
-        paginatedTenantInfo.setPageNumber(pageNumber);
-        return paginatedTenantInfo;
-    }
-
-    /**
-     * Returns usage of a particular tenant, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param tenantId
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception {
-        return Util.getTenantUsageRetriever().getInstanceUsages();
-    }
-
-    /**
-     * @param yearMonth      year and month that used to retrieve data
-     * @param pageNumber
-     * @param entriesPerPage number of entries per page
-     * @return PaginatedInstanceUsage object that hold instance data and other parameters
-     * @throws Exception when retrieving Paginated Instance Usage error occurs
-     */
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
-                                                                 int entriesPerPage) throws Exception {
-        InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
-        List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
-        PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
-        int i = 0;
-        int numberOfPages = 0;
-        if (instanceUsages != null && instanceUsages.length > 0) {
-            for (InstanceUsageStatics usage : instanceUsages) {
-                InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
-                if (instance != null) {
-                    if (i % entriesPerPage == 0) {
-                        numberOfPages++;
-                    }
-                }
-            }
-
-            paginatedInstanceUsages.setInstanceUsages(
-                instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
-        } else {
-            paginatedInstanceUsages.setInstanceUsages(null);
-        }
-
-        paginatedInstanceUsages.setNumberOfPages(numberOfPages);
-        paginatedInstanceUsages.setPageNumber(pageNumber);
-        return paginatedInstanceUsages;
-    }
-
-    /**
-     * @param usage     is Instance usage Statics object that holds data
-     * @param yearMonth year and month that need to check with instance usage data
-     * @return instance static if instance usage data match with given year and month, else null
-     */
-    public InstanceUsageStatics getValidUsageEntry(InstanceUsageStatics usage, String yearMonth) {
-        Date date = Calendar.getInstance().getTime();
-        if (yearMonth != null) {
-            try {
-                date = CommonUtil.getDateFromMonthString(yearMonth);
-            } catch (ParseException e) {
-
-            }
-        }
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-        if (usage.getStartTime().compareTo(startDate) <= 0 && usage.getStopTime().compareTo(endDate) >= 0) {
-            usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                    startDate.getTimeInMillis()) / 1000);
-            return usage;
-        }
-        if (usage.getStartTime().compareTo(startDate) > 0 && usage.getStartTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(endDate) < 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            } else if (usage.getStopTime().compareTo(endDate) > 0) {
-                usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            }
-        }
-        if (usage.getStartTime().compareTo(startDate) < 0 && usage.getStopTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(startDate) > 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        startDate.getTimeInMillis()) / 1000);
-                return usage;
-            }
-        }
-        return null;
-    }
-}


[12/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/userguide.html b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/userguide.html
deleted file mode 100644
index 9dd0f6c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/userguide.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>View Tenant Usage - User Guide</title>
-  <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
-</head>
-
-<body>
-<h1>View Usage</h1>
-
-<p>
-You can view usage of the stratos resource by your organization(Tenant) from this page
-</p>
-
-<p>
-<img src="images/view-usage.png" alt="View Usage"/>
-<div><strong>Figure1: View Usage</strong></div>
-</p>
- <h2> <b>Description of usage data report fields</b></h2>
-<p>
-<table border="1">
-<tr>
-<th>The Form Field</th>
-<th>Description</th>
-</tr>
-<tr>
-<td>Report Duration </td>
-<td>The year and the month the usage is metered.</td>
-</tr>
-        <tr>
-            <td>Number of Users</td>
-            <td>Number of users of your stratos account.(This is valid only for current month)</td>
-        </tr>
-       <tr>
-        <tr>
-            <td>Storage Usage</td>
-            <td>The registry data storage amount.</td>
-        </tr>
-        <tr>
-            <td>Registry Bandwidth Usage</td>
-            <td>Registry bandwidth consumed by the registry resource accesses(registry uploads, downloads).</td>
-        </tr>
-        <tr>
-            <td>Service Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services hosted by you.</td>
-        </tr>
-        <tr>
-            <td>Webapp Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services.</td>
-        </tr>
- 	<tr>
-            <td>Service Usage Statistics</td>
-            <td>Service statistics of requests and responses of services.</td>
-        </tr>
-    </tbody>
-</table>
-</p>
-<div><strong>Table1: Description of usage data report fields</strong></div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/instance-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
deleted file mode 100644
index 4a1ae6a..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/instance-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
deleted file mode 100644
index a9b04e2..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/user-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/user-usage-report.gif
deleted file mode 100644
index 9070c35..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/images/user-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
deleted file mode 100644
index 61043f0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
+++ /dev/null
@@ -1,49 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-    alert(1);
-    var xmlHttpReq = createXmlHttpRequest();
-    alert(2);
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "all_tenant_usage_report.jsp", false);
-        xmlHttpReq.send(null);
-        
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-	alert(string);
-    return string.replace(/\n/g, "");
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/tenant-usage.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/tenant-usage.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/tenant-usage.js
deleted file mode 100644
index 76c4363..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/tenant-usage.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function submitAllTenantPaginatedUsage(pageNumber) {
-    sessionAwareFunction(function() {
-        document.getElementById("requestedPage").value = pageNumber;
-        var usageForm = document.getElementById("usageForm");
-        usageForm.submit();
-    }, jsi18n["session.timed.out"]);
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/usage-report.js
deleted file mode 100644
index ed9e306..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/js/usage-report.js
+++ /dev/null
@@ -1,48 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-
-    var xmlHttpReq = createXmlHttpRequest();
-
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "usage_report.jsp", false);
-        xmlHttpReq.send(null);
-
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-    return string.replace(/\n/g, "");
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/tenant_usage.jsp
deleted file mode 100644
index 2946c87..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/tenant_usage.jsp
+++ /dev/null
@@ -1,408 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="java.util.List" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.menu"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="true"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<script type="text/javascript" src="js/usage-report.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    session.setAttribute("year-month", yearMonth);
-
-
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-	List<String>  reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<%--<div id="report_ui">
-    <carbon:report
-            component="org.wso2.carbon.usage"
-            template="usage_report"
-            pdfReport="true"
-            htmlReport="true"
-            excelReport="true"
-            reportDataSession="usage_data"
-               />
-</div>--%>
-<div id="workArea">
-
-<form id="usageForm" action="tenant_usage.jsp" method="post">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-<%
-    }
-%>
-
-<%--<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
---%>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/usage_report.jsp
deleted file mode 100644
index cb6a28d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/usage_report.jsp
+++ /dev/null
@@ -1,28 +0,0 @@
-<%@ page import="org.wso2.carbon.usage.ui.report.UsageReport" %>
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<carbon:jsi18n
-resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-request="<%=request%>" />
-<%
-
-    UsageReport usageReport = new UsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    request.getSession().setAttribute("usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/pom.xml
deleted file mode 100644
index fa3dc40..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage.ui</artifactId>
-    <version>2.1.1</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage - User Interface</name>
-
-    <build>
-
-        <plugins>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Export-Package>
-                            org.wso2.carbon.usage.ui.*,
-                        </Export-Package>
-                        <Import-Package>
-			    org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,                            
-                            org.apache.lucene.*,
-                            *;resolution:=optional
-                        </Import-Package>
-                        <Carbon-Component>UIBundle</Carbon-Component>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-	    <dependency>
-            <groupId>commons-codec.wso2</groupId>
-            <artifactId>commons-codec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.equinox</groupId>
-            <artifactId>javax.servlet</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
-            <artifactId>axiom</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ui</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.stub</artifactId>
-		<version>4.1.1</version>
-        </dependency>
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
deleted file mode 100644
index 64ee922..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/clients/UsageServiceClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.clients;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.ui.CarbonUIUtil;
-import org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.stub.services.UsageServiceStub;
-import org.wso2.carbon.utils.ServerConstants;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpSession;
-
-public class UsageServiceClient {
-    private static final Log log = LogFactory.getLog(UsageServiceClient.class);
-
-    private UsageServiceStub stub;
-    private String epr;
-
-    public UsageServiceClient(
-            String cookie, String backendServerURL, ConfigurationContext configContext)
-            throws RegistryException {
-
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public UsageServiceClient(ServletConfig config, HttpSession session)
-            throws RegistryException {
-
-        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
-        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
-        ConfigurationContext configContext = (ConfigurationContext) config.
-                getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
-        epr = backendServerURL + "UsageService";
-
-        try {
-            stub = new UsageServiceStub(configContext, epr);
-
-            ServiceClient client = stub._getServiceClient();
-            Options option = client.getOptions();
-            option.setManageSession(true);
-            option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
-
-        } catch (AxisFault axisFault) {
-            String msg = "Failed to initiate UsageService service client. " + axisFault.getMessage();
-            log.error(msg, axisFault);
-            throw new RegistryException(msg, axisFault);
-        }
-    }
-
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        return stub.retrieveCurrentTenantUsage(yearMonth);
-    }
-
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        return stub.retrieveTenantUsages(yearMonth);
-    }
-
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        return stub.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-    }
-
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return stub.retrieveTenantUsage(yearMonth, tenantId);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception{
-            return stub.retrieveInstanceUsage();
-    }
-
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage (
-            String yearMonth, int pageNumber, int numbersPerPage) throws Exception {
-            return stub.retrievePaginatedInstanceUsage(yearMonth, pageNumber, numbersPerPage);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
deleted file mode 100755
index 38ff46b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageData.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.wso2.carbon.usage.ui.report;
-
-/**
- * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- * 
- * Licensed 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.
- */
-public class AllTenantUsageData {
-
-	public AllTenantUsageData() {
-	}
-
-	String yearMonth;
-	
-	String tenantName;
-	
-	String numberOfUsers;
-	
-	String currentDataStorage;
-	
-	String regBandwidth;
-	
-	String svcBandwidth;
-	
-	String svcTotalRequest;
-
-	public String getYearMonth() {
-		return yearMonth;
-	}
-
-	public void setYearMonth(String yearMonth) {
-		this.yearMonth = yearMonth;
-	}
-
-	public String getTenantName() {
-		return tenantName;
-	}
-
-	public void setTenantName(String tenantName) {
-		this.tenantName = tenantName;
-	}
-
-	public String getNumberOfUsers() {
-		return numberOfUsers;
-	}
-
-	public void setNumberOfUsers(String numberOfUsers) {
-		this.numberOfUsers = numberOfUsers;
-	}
-
-	public String getCurrentDataStorage() {
-		return currentDataStorage;
-	}
-
-	public void setCurrentDataStorage(String currentDataStorage) {
-		this.currentDataStorage = currentDataStorage;
-	}
-
-	public String getRegBandwidth() {
-		return regBandwidth;
-	}
-
-	public void setRegBandwidth(String regBandwidth) {
-		this.regBandwidth = regBandwidth;
-	}
-
-	public String getSvcBandwidth() {
-		return svcBandwidth;
-	}
-
-	public void setSvcBandwidth(String svcBandwidth) {
-		this.svcBandwidth = svcBandwidth;
-	}
-
-	public String getSvcTotalRequest() {
-		return svcTotalRequest;
-	}
-
-	public void setSvcTotalRequest(String svcTotalRequest) {
-		this.svcTotalRequest = svcTotalRequest;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
deleted file mode 100644
index 00d03b3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/AllTenantUsageReport.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * this class is used to generate reports of all tenant usages
- */
-public class AllTenantUsageReport {
-
-    private TenantUsage[] tenantUsages;
-    private String yearMonth;
-
-    /**
-     * @param config
-     * @param session
-     * @param request
-     * @throws Exception
-     */
-    private static final Log log = LogFactory.getLog(AllTenantUsageReport.class);
-
-    public AllTenantUsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-    	tenantUsages = UsageUtil.retrieveTenantUsages(request, config, session);
-     
- 
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-    }
-
-    public List<AllTenantUsageData> getUsageReportData() {
-
-        List<AllTenantUsageData> reportData = new ArrayList<AllTenantUsageData>();   // all the strings need to be passed to
-        //  generate the report are added to this list
-
-        if (yearMonth == null) {
-            //  get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        //  add all the usage data to the list
-        try {
-            for (TenantUsage usage : tenantUsages) {
-                AllTenantUsageData usageData = new AllTenantUsageData();
-                usageData.setYearMonth(yearMonth);
-                String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                int numberOfUsers = usage.getNumberOfUsers();
-
-                //  String username = (String) request.getSession().getAttribute("logged-user");
-                String tenantName = usage.getDomain();
-                int tenantId = usage.getTenantId();
-                String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-
-                usageData.setTenantName(tenantName);
-                if (yearMonth.equals(currentYearMonth)) {
-                    usageData.setNumberOfUsers(Integer.toString(numberOfUsers));
-                    usageData.setCurrentDataStorage(currentDataStorage);
-                }
-                // if the yearMonth is not current, number of users coloumn and storage usage coloumn are empty
-                else {
-                    usageData.setNumberOfUsers("-");
-                    usageData.setCurrentDataStorage("-");
-                }
-                usageData.setRegBandwidth(regBandwidth);
-                usageData.setSvcBandwidth(svcBandwidth);
-                usageData.setSvcTotalRequest(Long.toString(svcTotalRequest));
-                reportData.add(usageData);
-            }
-        }
-        catch (Exception e) {
-            String msg = "Error while retrieving tenant usages for month : " + yearMonth;
-            log.error(msg, e);
-        }
-        return reportData;         // return as an array
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
deleted file mode 100644
index 6c0ad50..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/report/UsageReport.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.ui.report;
-
-import org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics;
-import org.wso2.carbon.usage.stub.beans.xsd.TenantUsage;
-import org.wso2.carbon.usage.ui.utils.UsageUtil;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This class is used to generate tenant usage report
- */
-public class UsageReport {
-    private TenantUsage usage;
-    private String yearMonth;
-
-    public UsageReport(ServletConfig config, HttpSession session, HttpServletRequest request)
-            throws Exception {
-        usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session);
-        yearMonth = (String) request.getSession().getAttribute("year-month");
-
-    }
-
-
-    public List<String> getUsageReportData() {
-
-        int numberOfUsers = usage.getNumberOfUsers();
-        if (yearMonth == null) {
-
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-
-        String tenantName = usage.getDomain();
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        List<String> reportData = new ArrayList<String>();
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add("Duration");
-        reportData.add("Tenant Name");
-        reportData.add("Number of users");
-        reportData.add("Basic Tenant Details");
-        reportData.add("");
-        reportData.add(yearMonth);
-        reportData.add(tenantName);
-        reportData.add(String.valueOf(numberOfUsers));
-
-
-        if (currentYearMonth.equals(yearMonth)) {
-            reportData.add("Storage Usage");
-            reportData.add("Data Storage");
-            reportData.add("Current Data Storage");
-            reportData.add("Historical Data Storage");
-            reportData.add("Total Data Storage");
-            String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-            String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-            String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-            reportData.add("Storage Usage");
-            reportData.add("Registry Content");
-            reportData.add(totalDataStorage);
-            reportData.add(currentDataStorage);
-            reportData.add(historyDataStorage);
-        }
-
-        String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-        String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-        if (regBWStats != null) {
-            for (BandwidthStatistics stat : regBWStats) {
-                String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(regInBandwidth);
-                reportData.add(regOutBandwidth);
-                reportData.add(regBandwidth);
-
-            }
-        }
-        reportData.add("Registry Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totRegInBandwidth);
-        reportData.add(totRegOutBandwidth);
-        reportData.add(totRegBandwidth);
-
-        String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-        String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-        if (svcBWStats != null) {
-            for (BandwidthStatistics stat : svcBWStats) {
-                String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(svcInBandwidth);
-                reportData.add(svcOutBandwidth);
-                reportData.add(svcBandwidth);
-
-            }
-        }
-        reportData.add("Service Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totSvcInBandwidth);
-        reportData.add(totSvcOutBandwidth);
-        reportData.add(totSvcBandwidth);
-
-        String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-        String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-        BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("Server Name");
-        reportData.add("Incoming Bandwidth");
-        reportData.add("Outgoing Bandwidth");
-        reportData.add("Total Bandwidth");
-        if (webappBWStats != null) {
-            for (BandwidthStatistics stat : webappBWStats) {
-                String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-                String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-                String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-                reportData.add("Server Name****");
-                reportData.add(webappInBandwidth);
-                reportData.add(webappOutBandwidth);
-                reportData.add(webappBandwidth);
-            }
-        }
-        reportData.add("Webapp Bandwidth Usage");
-        reportData.add("All Server Total");
-        reportData.add(totWebappInBandwidth);
-        reportData.add(totWebappOutBandwidth);
-        reportData.add(totWebappBandwidth);
-
-
-        long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-        long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-        long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-        RequestStatistics[] svcStats = usage.getRequestStatistics();
-        reportData.add("Service Usage Statistic");
-        reportData.add("Server Name");
-        reportData.add("Request Count");
-        reportData.add("Response Count");
-        reportData.add("Fault Count");
-        if (svcStats != null && svcStats.length>0 && svcStats[0]!=null) {
-            for (RequestStatistics stat : svcStats) {
-                long svcReqCount = stat.getRequestCount();
-                long svcResCount = stat.getResponseCount();
-                long svcFaultCount = stat.getFaultCount();
-                reportData.add("Server Name****");
-                reportData.add(String.valueOf(svcReqCount));
-                reportData.add(String.valueOf(svcResCount));
-                reportData.add(String.valueOf(svcFaultCount));
-            }
-        }
-        reportData.add("Service Usage Statistic");
-        reportData.add("All Server Total");
-        reportData.add(String.valueOf(totSvcReqCount));
-        reportData.add(String.valueOf(totSvcRespCount));
-        reportData.add(String.valueOf(totSvcFaultCount));
-
-        return reportData;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
deleted file mode 100644
index 401342d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.ui.utils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.common.ui.UIException;
-import org.wso2.carbon.usage.stub.beans.xsd.*;
-import org.wso2.carbon.usage.ui.clients.UsageServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class UsageUtil {
-    private static final Log log = LogFactory.getLog(UsageUtil.class);
-
-    private static long KB_LIMIT = 1024;
-    private static long MB_LIMIT = 1024 * 1024;
-    private static long GB_LIMIT = 1024 * 1024 * 1024;
-    private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
-
-    public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
-                                                         ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveCurrentTenantUsage(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get current tenant usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
-                                                     ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveTenantUsages(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage retrieveTenantUsage(ServletRequest request,
-                                                  ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            String tenantIdStr = request.getParameter("tenant-id");
-            if (tenantIdStr == null) {
-                tenantIdStr = "0";
-            }
-            return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
-        } catch (Exception e) {
-            String msg = "Failed to get tenant usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-
-    public static String convertBytesToString(long storage) {
-        if (storage < KB_LIMIT) {
-            return storage + " Byte(s)";
-        } else if (storage < MB_LIMIT) {
-            return storage / KB_LIMIT + " KByte(s)";
-        } else if (storage < GB_LIMIT) {
-            return storage / MB_LIMIT + " MByte(s)";
-        } else if (storage < TB_LIMIT) {
-            return storage / GB_LIMIT + " GByte(s)";
-        } else {
-            return storage / TB_LIMIT + " TByte(s)";
-        }
-    }
-
-    public static String getCurrentYearMonth() {
-        Calendar calendar = Calendar.getInstance();
-        return CommonUtil.getMonthString(calendar);
-    }
-
-    public static String[] getYearMonths() {
-        // we will list 100 months for now
-        List<String> yearMonths = new ArrayList<String>();
-        for (int i = 0; i > -100; i--) {
-            String yearMonth = CommonUtil.getMonthString(i);
-            yearMonths.add(yearMonth);
-        }
-        return yearMonths.toArray(new String[yearMonths.size()]);
-    }
-
-    public static String getCurrentDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (regData != null) {
-            currentData = regData.getRegistryContentCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getHistoryDataStorage(TenantUsage usage) {
-        TenantDataCapacity historyData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (historyData != null) {
-            currentData = historyData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getTotalDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long totalDataStorage = 0;
-        if (regData != null) {
-            totalDataStorage =
-                    regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(totalDataStorage);
-    }
-
-    public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
-                                                               ServletConfig config, HttpSession session)
-            throws Exception {
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
-            return returnInstanceUsage;
-        } catch (Exception e) {
-            String msg = "Failed to get current instance usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get paginated instance usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-    public static String getAPIUsage(TenantUsage usage) {
-        long count = 0;
-
-        if (usage.getApiManagerUsageStats() != null) {
-            count =usage.getApiManagerUsageStats()[0].getRequestCount();
-        }
-        return Long.toString(count);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 19b0510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<component xmlns="http://products.wso2.org/carbon">
-    <!-- sample menu configuration -->
-    <menus>
-        <menu>
-            <id>usage_monitoring_menu</id>
-            <i18n-key>usage.monitoring</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu></parent-menu>
-            <link>#</link>
-            <region>region4</region>
-            <style-class>home</style-class>
-            <order>22</order>
-            <icon>../services/images/services.gif</icon>
-        </menu>
-        <menu>
-            <id>tenant_usage_menu</id>
-            <i18n-key>tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>51</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/user-usage-report.gif</icon>
-            <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
-            <require-not-super-tenant>true</require-not-super-tenant>
-        </menu>
-        <!--menu>
-            <id>all_tenant_instance_usage_menu</id>
-            <i18n-key>instance.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/instance-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu-->
-        <menu>
-            <id>all_tenant_usage_menu</id>
-            <i18n-key>all.tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu>
-    </menus>
-
-</component>


[17/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
deleted file mode 100644
index b3561b8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.util;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.Agent;
-import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.conf.AgentConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
-import org.wso2.carbon.databridge.commons.Event;
-import org.wso2.carbon.databridge.commons.exception.AuthenticationException;
-import org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException;
-import org.wso2.carbon.databridge.commons.exception.TransportException;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.user.api.Tenant;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.NetworkUtils;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-import org.wso2.carbon.usage.agent.beans.APIManagerRequestStats;
-
-import java.math.BigInteger;
-import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * this class provide utility methods to publish usage statistics
- */
-public class PublisherUtils {
-    private static Log log = LogFactory.getLog(PublisherUtils.class);
-    private static final String TRANSPORT = "https";
-    private static ConfigurationContextService configurationContextService;
-    private static Agent agent;
-    private static DataPublisher dataPublisher;
-    private static AsyncDataPublisher asyncDataPublisher;
-    private static String streamId;
-    private static final String usageEventStream = "org.wso2.carbon.usage.agent";
-    private static final String usageEventStreamVersion = "1.0.0";
-    
-    private static final String reqStatEventStream="org.wso2.carbon.service.request.stats";
-    private static final String reqStatEventStreamVersion="1.0.0";
-    private static String reqStatEventStreamId;
-    
-    private static Map<Integer, String> serverUrlMap = new HashMap<Integer, String>();
-
-
-    /**
-     * method to update server name
-     * @param tenantId tenant id
-     * @return server name
-     * @throws UsageException
-     */
-
-    public static String updateServerName(int tenantId) throws UsageException {
-
-        String serverName;
-        String hostName;
-
-        try {
-            hostName = NetworkUtils.getLocalHostname();
-        } catch (SocketException e) {
-            throw new UsageException("Error getting host name for the registry usage event payload",
-                    e);
-        }
-
-        ConfigurationContextService configurationContextService = PublisherUtils.
-                getConfigurationContextService();
-        ConfigurationContext configurationContext;
-        if (configurationContextService != null) {
-            configurationContext = configurationContextService.getServerConfigContext();
-        } else {
-            throw new UsageException("ConfigurationContext is null");
-        }
-//        int port = CarbonUtils.getTransportPort(configurationContext, "https");
-
-        String carbonHttpsPort = System.getProperty("carbon." + TRANSPORT + ".port");
-        if (carbonHttpsPort == null) {
-            carbonHttpsPort = Integer.toString(
-                    CarbonUtils.getTransportPort(configurationContext, TRANSPORT));
-        }
-        String baseServerUrl = TRANSPORT + "://" + hostName + ":" + carbonHttpsPort;
-        String context = configurationContext.getContextRoot();
-
-        String tenantDomain = null;
-        try {
-            Tenant tenant = Util.getRealmService().getTenantManager().getTenant(tenantId);
-            if(tenant!=null){
-                tenantDomain = tenant.getDomain();
-            }
-        } catch (org.wso2.carbon.user.api.UserStoreException e) {
-            throw new UsageException("Failed to get tenant domain", e);
-        }
-
-        if ((tenantDomain != null) &&
-                !(tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) {
-            serverName = baseServerUrl + context + "t/" + tenantDomain;
-
-        } else if (context.equals("/")) {
-
-            serverName = baseServerUrl + "";
-        } else {
-            serverName = baseServerUrl + context;
-
-        }
-
-        return serverName;
-    }
-    
-    public static String getServerUrl(int tenantId){
-
-        String serverUrl = serverUrlMap.get(tenantId);
-        if(serverUrl!=null){
-            return serverUrl;
-        }
-
-        if(serverUrl==null){
-            try{
-                serverUrl = updateServerName(tenantId);
-            }catch (UsageException e) {
-                log.error("Could not create the server url for tenant id: " + tenantId, e);
-            }
-        }
-
-        if(serverUrl!=null && !"".equals(serverUrl)){
-            serverUrlMap.put(tenantId, serverUrl);
-        }
-        return serverUrl;
-    }
-
-    public static void defineUsageEventStream() throws Exception {
-
-        createDataPublisher();
-
-        if(dataPublisher == null){
-            return;
-        }
-
-        try {
-
-            streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            log.info("Event stream with stream ID: " + streamId + " found.");
-
-        } catch (NoStreamDefinitionExistException e) {
-
-            log.info("Defining the event stream because it was not found in BAM");
-            try {
-                defineStream();    
-            } catch (Exception ex) {
-                String msg = "An error occurred while defining the even stream for Usage agent. " + e.getMessage();
-                log.warn(msg);
-            }
-
-        }
-
-    }
-    
-    private static void defineStream() throws Exception {
-        streamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + usageEventStream +"'," +
-                        "  'version':'" + usageEventStreamVersion +"'," +
-                        "  'nickName': 'usage.agent'," +
-                        "  'description': 'Tenant usage data'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'Type','type':'STRING'}," +
-                        "          {'name':'Value','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-        
-    }
-    
-    private static void defineRequestStatEventStream() throws Exception{
-        reqStatEventStreamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + reqStatEventStream +"'," +
-                        "  'version':'" + reqStatEventStreamVersion +"'," +
-                        "  'nickName': 'service.request.stats'," +
-                        "  'description': 'Tenants service request statistics'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'RequestCount','type':'INT'}," +
-                        "          {'name':'ResponseCount','type':'INT'}," +
-                        "          {'name':'FaultCount','type':'INT'}," +
-                        "          {'name':'ResponseTime','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-    }
-
-    public static void createDataPublisher(){
-
-        ServerConfiguration serverConfig =  CarbonUtils.getServerConfiguration();
-        String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
-        String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
-        String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
-        String adminUsername = CommonUtil.getStratosConfig().getAdminUserName();
-        String adminPassword = CommonUtil.getStratosConfig().getAdminPassword();
-
-        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
-        System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
-
-        try {
-            dataPublisher = new DataPublisher(bamServerUrl, adminUsername, adminPassword);
-        } catch (Exception e) {
-            log.warn("Unable to create a data publisher to " + bamServerUrl +
-                    ". Usage Agent will not function properly. " + e.getMessage());
-        }
-
-    }
-
-    /**
-     * Creates an async data publisher using the existing data publisher object
-     */
-    public static void createAsynDataPublisher(){
-        if(dataPublisher==null){
-            createDataPublisher();
-        }
-
-        if(dataPublisher==null){
-            log.warn("Cannot create the async data publisher because the data publisher is null");
-            return;
-        }
-
-        try {
-            asyncDataPublisher = new AsyncDataPublisher(dataPublisher);
-        } catch (Exception e) {
-            log.error("Could not create an async data publisher using the data publisher", e);
-        }
-    }
-
-
-    /**
-     * this method get the event payload, construct the SOAP envelop and call the publish method in
-     * EventBrokerService.
-     *
-     * @param usage BandwidthUsage
-     * @throws UsageException
-     */
-    public static void publish(BandwidthUsage usage) throws UsageException {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for usage data publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(streamId == null){
-            try{
-                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                                        new Object[]{getServerUrl(usage.getTenantId()),
-                                                    Integer.toString(usage.getTenantId()),
-                                                    usage.getMeasurement(),
-                                                    usage.getValue()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-    
-    public static void publish(SystemStatistics statistics, int tenantId) throws Exception {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for service-stats publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(reqStatEventStreamId == null){
-            try{
-                reqStatEventStreamId = dataPublisher.findStream(reqStatEventStream, reqStatEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineRequestStatEventStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(reqStatEventStreamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                    new Object[]{getServerUrl(tenantId),
-                            Integer.toString(tenantId),
-                            statistics.getCurrentInvocationRequestCount(),
-                            statistics.getCurrentInvocationResponseCount(),
-                            statistics.getCurrentInvocationFaultCount(),
-                            statistics.getCurrentInvocationResponseTime()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-
-    /**
-     * @param statistics APIManagerRequestStats which contains usage data
-     * @param tenantId   Tenant id of tenant associated with usage stat
-     * @throws Exception UsageException when error in usage stat publishing
-     */
-    public static void publish(APIManagerRequestStats statistics, int tenantId) throws Exception {
-
-        if (dataPublisher == null) {
-            log.info("Creating data publisher for usage data publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if (dataPublisher == null) {
-                return;
-            }
-        }
-
-        if (streamId == null) {
-            try {
-                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            } catch (NoStreamDefinitionExistException e) {
-                log.info("Defining the event stream because it was not found in BAM");
-                try {
-                    defineStream();
-                } catch (Exception ex) {
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            } catch (Exception exc) {
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-            //Get data from API manager request stat object and create event
-            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                    new Object[]{getServerUrl(statistics.getTenantId()),
-                            Integer.toString(statistics.getTenantId()),
-                            statistics.getMeasurement(),
-                            statistics.getValue()});
-            //publish usage to bam
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-
-    /**
-     * method to get configurationContextService
-     * @return configurationContextService
-     */
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return configurationContextService;
-    }
-
-    /**
-     * method to setConfigurationContextService
-     * @param configurationContextService
-     */
-    public static void setConfigurationContextService(ConfigurationContextService configurationContextService) {
-        PublisherUtils.configurationContextService = configurationContextService;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
deleted file mode 100644
index 8bbd800..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-/**
- * this class define constants for UsageAgent component
- */
-public class UsageAgentConstants {
-    public static final String ELEMENT_NAME_DATA = "Data";
-    public static final String ELEMENT_NAME_KEY = "Key";
-    public static final String ELEMENT_NAME_VALUE = "Value";
-
-    public static final String STATISTICS_DATA_NS_URI = "http://wso2.org/ns/2009/09/bam/server/user-defined/data";
-    public static final String STATISTICS_DATA_NS_PREFIX = "svrusrdata";
-
-    // OM element names
-    public static final String STATISTICS_DATA_ELEMENT_NAME_EVENT = "Event";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVICE_STATISTICS_DATA = "ServerUserDefinedData";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_TENANT_ID = "TenantID";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVER_NAME = "ServerName";
-
-    public static final String BAM_SERVER_URL = "BamServerURL";
-    public static final String BAM_SERVER_STAT_SERVICE = "BAMServerUserDefinedDataSubscriberService";
-    public static final String BAM_SERVER_STAT_FILTER = "carbon/bam/data/publishers/bandwidth-stat";
-
-    public static final String TOPIC_SEPARATOR = "/";
-    public static final String EVENT_NAME = "UsageMeteringEvent";
-
-    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER;
-//    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER + TOPIC_SEPARATOR + EVENT_NAME;
-
-
-    public static final String BANDWIDTH_USAGE_SERVICES_CONTEXT = "services";
-    public static final String BANDWIDTH_USAGE_WEBAPPS_CONTEXT = "webapps";
-    public static final String BANDWIDTH_CARBON = "carbon";
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
deleted file mode 100644
index f29b261..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.event.core.exception.EventBrokerException;
-import org.wso2.carbon.event.core.subscription.Subscription;
-import org.wso2.carbon.event.core.util.EventBrokerConstants;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.listeners.RegistryUsageListener;
-import org.wso2.carbon.usage.agent.persist.UsageDataPersistenceManager;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.File;
-
-
-/**
- * this class provide utility methods to set and get RealmService, initializing listeners,
- * initializing PersistenceManager etc
- * Further it provide methods to create statistics event subscription
- */
-
-public class Util {
-    private static final Log log = LogFactory.getLog(Util.class);
-    private static final String USAGE_THROTTLING_AGENT_CONFIG_FILE = "usage-throttling-agent-config.xml";
-    private static RealmService realmService;
-    private static ConfigurationContextService contextService;
-    private static UsageDataPersistenceManager persistenceManager;
-    //private static EventBrokerService eventBrokerService;
-    private static EventBroker eventBrokerService;
-    private static ServerConfigurationService serverConfiguration;
-
-    private static SystemStatisticsUtil systemStatisticsUtil;
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static void initializeAllListeners() throws Exception {
-        RegistryUsageListener.registerRegistryUsagePersistingListener(
-                RegistryContext.getBaseInstance());
-    }
-
-    public static void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.contextService = contextService;
-    }
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return Util.contextService;
-    }
-
-    /**
-     * this method create a PersistenceManager instance and start a thread for persisting statistics
-     */
-
-    public static void initializePersistenceManager() {
-        File usageAgentConfigFile  = new File(CarbonUtils.getCarbonConfigDirPath() + File.separator +
-                StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + Util.USAGE_THROTTLING_AGENT_CONFIG_FILE);
-        persistenceManager = new UsageDataPersistenceManager(new UsageAgentConfiguration(usageAgentConfigFile));
-        //start a thread for persisting bandwidth Usage statistics
-        if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            persistenceManager.scheduleBandwidthUsageDataRetrievalTask();
-            persistenceManager.scheduleUsageDataPersistenceTask();
-        }
-    }
-
-    public static void addToPersistingControllerQueue(BandwidthUsage usage) {
-        persistenceManager.addToQueue(usage);
-    }
-
-    public static EventBroker getEventBrokerService() {
-        return eventBrokerService;
-    }
-
-    public static void setEventBrokerService(EventBroker eventBrokerService) {
-        Util.eventBrokerService = eventBrokerService;
-    }
-
-    public static ServerConfigurationService getServerConfiguration() {
-        return serverConfiguration;
-    }
-
-    public static void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.serverConfiguration = serverConfiguration;
-    }
-
-    public static SystemStatisticsUtil getSystemStatisticsUtil() {
-        return systemStatisticsUtil;
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil) {
-        Util.systemStatisticsUtil = systemStatisticsUtil;
-    }
-
-    /**
-     * method to create static subscription to BAM
-     *
-     * @throws EventBrokerException, if creating the static subscription to BAM failed.
-     */
-    public static void createStaticEventSubscription() throws EventBrokerException {
-
-        //Get BAM URL from carbon.xml
-        ServerConfigurationService serverConfiguration = getServerConfiguration();
-        if (serverConfiguration == null) {
-            throw new IllegalArgumentException("Invalid server configuration");
-        }
-        String serverURL = serverConfiguration.getFirstProperty(UsageAgentConstants.BAM_SERVER_URL);
-
-        if(log.isDebugEnabled()){
-            log.debug("Bam url = " + serverURL);
-        }
-
-        //Add static subscription only if bam url is set
-        if (serverURL != null) {
-            String serviceURL = serverURL + UsageAgentConstants.BAM_SERVER_STAT_SERVICE;
-
-            EventBroker eventBrokerService = getEventBrokerService();
-            Subscription subscription = new Subscription();
-            // set the subscription end point to the service url
-            subscription.setEventSinkURL(serviceURL);
-            subscription.setTopicName(UsageAgentConstants.BAM_SERVER_STAT_FILTER);
-            subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);
-
-            try {
-                eventBrokerService.subscribe(subscription);
-            } catch (EventBrokerException e) {
-                String msg = "Cannot subscribe to the event broker ";
-                log.error(msg);
-                throw e;
-            }
-        }
-    }
-    
-    public static int getTenantId(String toAddress) throws Exception {
-        int index = toAddress.indexOf("/t/");
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        if(index >= 0){
-            String tenantDomain = toAddress.substring(index+2, toAddress.indexOf("/", index+3));
-            tenantId = getRealmService().getTenantManager().getTenantId(tenantDomain);
-        }
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 564f65f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage/customUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/module.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/module.xml
deleted file mode 100644
index 23f6025..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<module name="metering" class="org.wso2.carbon.usage.agent.listeners.axis2.RequestMeteringModule">
-   <InFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFlow>
-
-   <InFaultFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFaultFlow>
-
-    <OutFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-    </OutFlow>
-
-    <OutFaultFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-
-    </OutFaultFlow>
-   <parameter name="adminModule" locked="true">true</parameter>
-</module>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 720bdb9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-  <service name="CustomMeteringService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.agent.services.CustomMeteringService
-        </parameter>
-    </service>   
-    <parameter name="adminService" locked="true">true</parameter>
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/usage-throttling-agent-config.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/usage-throttling-agent-config.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/usage-throttling-agent-config.xml
deleted file mode 100644
index 6a222d7..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/resources/META-INF/usage-throttling-agent-config.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<UsageAndThrottlingAgentConfiguration xmlns="http://wso2.com/carbon/multitenancy/usage-throttling-agent/config">
-    <UsageAgent>
-        <UsageDataPersistenceTask>
-            <StartupDelayInMilliSeconds>60000</StartupDelayInMilliSeconds>
-            <NumberOfRecordsPerExecution>100</NumberOfRecordsPerExecution>
-            <ExecutionIntervalInMilliSeconds>100</ExecutionIntervalInMilliSeconds>
-        </UsageDataPersistenceTask>
-    </UsageAgent>
-    <ThrottlingAgent>
-        <ThrottlingInfoCacheUpdaterTask>
-            <StartupDelayInSeconds></StartupDelayInSeconds>
-            <ExecutionIntervalInSeconds></ExecutionIntervalInSeconds>
-        </ThrottlingInfoCacheUpdaterTask>
-    </ThrottlingAgent>
-</UsageAndThrottlingAgentConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/pom.xml
deleted file mode 100644
index 4ed79b5..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/pom.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <version>2.1.2</version>
-    <artifactId>org.wso2.carbon.usage.agent</artifactId>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage Agent</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Private-Package>
-                        	!org.wso2.carbon.usage.agent.api.*,
-                            org.wso2.carbon.usage.agent.*,
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.agent.api.*,
-                            org.wso2.carbon.usage.agent.beans.*,
-                            org.wso2.carbon.usage.agent.util.PublisherUtils,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.stratos.common.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.utils</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-            <version>2.1.2</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.statistics</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.registry.common</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.event.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-	    <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.email.verification</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.server</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.tomcat.ext</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.databridge.agent.thrift</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
deleted file mode 100644
index f8b0b42..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.api;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *   CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists,
- *   to persist and retrieve usage.
- */
-
-public class CustomMeteringAgent {
-    private static final Log log = LogFactory.getLog(CustomMeteringAgent.class);
-    private Registry registry;
-
-    /**
-     * Constructor for the custom metering agent
-     *
-     * @param registry governance registry of super tenant
-     */
-    public CustomMeteringAgent(Registry registry) {
-        this.registry = registry;
-    }
-
-    /**
-     * Get recorded durations
-     * @param measurement  the measurement to get the duration
-     * @return the durations array
-     * @throws UsageException
-     */
-    public String[] getRecordedDurations(String measurement) throws UsageException {
-        String[] durations;
-        String measurementCollectionPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement;
-        try {
-            Resource resource = registry.get(measurementCollectionPath);
-            if (!(resource instanceof Collection)) {
-                String msg =
-                        "The records collection is not a registry collection. path: " +
-                                measurementCollectionPath + ".";
-                log.error(msg);
-                throw new UsageException(msg);
-            }
-            durations = ((Collection) resource).getChildren();
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return durations;
-    }
-
-    /**
-     * Check whether the usage entry exist or not
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return true if usage entry exists
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public boolean isUsageEntryExists(String duration, String measurement)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            if (registry.resourceExists(measurementPath)) {
-                return true;
-            }
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return false;
-    }
-
-    /**
-     * Persist usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public void persistUsage(String duration, String measurement, String value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.newResource();
-            ((ResourceImpl) measurementResource).setVersionableChange(false);
-            // save the measurement value in resource
-            measurementResource.setContent(value);
-            registry.put(measurementPath, measurementResource);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in persisting the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-    }
-
-    /**
-     * Retrieve usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public String retrieveUsage(String duration, String measurement)
-            throws UsageException {
-        String usageValue;
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.get(measurementPath);
-            // save the measurement value in resource
-            byte[] contentBytes = (byte[]) measurementResource.getContent();
-            usageValue = new String(contentBytes);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in retrieving the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return usageValue;
-    }
-
-    /**
-     * Add a long value to the usage, if there were no previous entry, this will
-     * start with value 0
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @return the added measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public long addUsage(String duration, String measurement, long value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        // adding the bandwidth have to be in a transaction
-        boolean transactionSuccess = false;
-        try {
-            registry.beginTransaction();
-            if (isUsageEntryExists(duration, measurement)) {
-                String usageStr = retrieveUsage(duration, measurement);
-                try {
-                    long storedValue = Long.parseLong(usageStr);
-                    value += storedValue;
-                } catch (NumberFormatException e) {
-                    String msg = "Error in parsing the integer string: " + usageStr;
-                    log.error(msg, e);
-                    throw new RegistryException(msg, e);
-                }
-            }
-            String valueStr = Long.toString(value);
-            persistUsage(duration, measurement, valueStr);
-            transactionSuccess = true;
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in invoking the add usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        } finally {
-            try {
-                if (transactionSuccess) {
-                    registry.commitTransaction();
-                } else {
-                    registry.rollbackTransaction();
-                }
-            } catch (RegistryException e) {
-                String msg = "Error in commiting/rollbacking the transaction";
-                log.error(msg, e);
-            }
-        }
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
deleted file mode 100644
index 2448fcc..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.beans;
-
-public class APIManagerRequestStats {
-    private int requestCount;
-    private int responseCount;
-    private int faultCount;
-    private long responseTime;
-    private int tenantId;
-    private String measurement;
-    private long value;
-
-    public APIManagerRequestStats() {
-        requestCount = 0;
-        responseCount = 0;
-        faultCount = 0;
-        responseTime = 0;
-        measurement = "APICall";
-        value = 0;
-        tenantId = 0;
-    }
-
-    public String getMeasurement() {
-        return measurement;
-    }
-
-    public void setMeasurement(String measurement) {
-        this.measurement = measurement;
-    }
-
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(int requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public int getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(int responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public int getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(int faultCount) {
-        this.faultCount = faultCount;
-    }
-
-    public long getResponseTime() {
-        return responseTime;
-    }
-
-    public void setResponseTime(long responseTime) {
-        this.responseTime = responseTime;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
deleted file mode 100644
index a792746..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.beans;
-
-/**
- * the bean class for BandwidthUsage with attributes
- * int tenant id,
- * String measurement
- * long value   *
- */
-
-public class BandwidthUsage {
-    private int tenantId;
-    private String measurement;
-    private long value;
-
-
-    public String getMeasurement() {
-        return measurement;
-    }
-
-    public BandwidthUsage(int tenantId, String measurement, long value) {
-        this.tenantId = tenantId;
-        this.measurement = measurement;
-        this.value = value;
-    }
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
deleted file mode 100644
index 7528171..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-public class UsageAgentConfiguration {
-    private static final Log log = LogFactory.getLog(UsageAgentConfiguration.class);
-
-    private static final Integer DEFAULT_NUMBER_OF_RECORDS_PER_RUN = 100;
-    private static final Integer DEFAULT_EXECUTION_INTERVAL_IN_MILLISECONDS = 100;
-    private static final Integer DEFAULT_STARTUP_DELAY_IN_MILLISECONDS = 60000;
-
-    private int usageTasksNumberOfRecordsPerExecution = -1;
-
-    private int usageTasksExecutionIntervalInMilliSeconds = -1;
-
-    private int usageTasksStartupDelayInMilliSeconds = -1;
-
-    public UsageAgentConfiguration(File configFile) {
-        if (configFile.exists()) {
-            try {
-                OMElement usageAndThrottlingAgentConfiguration =
-                        new StAXOMBuilder(new FileInputStream(configFile)).getDocumentElement();
-                if (usageAndThrottlingAgentConfiguration != null) {
-                    OMElement usageAgent = usageAndThrottlingAgentConfiguration.getFirstChildWithName(
-                            new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config", "UsageAgent"));
-                    if (usageAgent != null) {
-                        OMElement usageDataPersistenceTaskConfig = usageAgent.getFirstChildWithName(
-                                new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                        "UsageDataPersistenceTask"));
-                        if (usageDataPersistenceTaskConfig != null) {
-                            OMElement numberOfRecordsPerExecutionEle = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "NumberOfRecordsPerExecution"));
-                            if (numberOfRecordsPerExecutionEle != null && numberOfRecordsPerExecutionEle.getText() != null &&
-                                    numberOfRecordsPerExecutionEle.getText().length() > 0) {
-                                try {
-                                    usageTasksNumberOfRecordsPerExecution = Integer.parseInt(numberOfRecordsPerExecutionEle.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task number of records value.", ne);
-                                }
-                            }
-
-                            OMElement executionIntervalInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "ExecutionIntervalInMilliSeconds"));
-                            if (executionIntervalInMilliSeconds != null && executionIntervalInMilliSeconds.getText() != null &&
-                                    executionIntervalInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksExecutionIntervalInMilliSeconds =
-                                            Integer.parseInt(executionIntervalInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task  execution interval value.", ne);
-                                }
-                            }
-
-                            OMElement startupDelayInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "StartupDelayInMilliSeconds"));
-                            if (startupDelayInMilliSeconds != null && startupDelayInMilliSeconds.getText() != null &&
-                                    startupDelayInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksStartupDelayInMilliSeconds =
-                                            Integer.parseInt(startupDelayInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task startup delay value.", ne);
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } catch (FileNotFoundException e) {
-                log.error("Cannot find " + configFile.getAbsolutePath(), e);
-            } catch (XMLStreamException e) {
-                log.error("Error reading XML stream of file " + configFile.getAbsolutePath(), e);
-            }
-        }
-    }
-
-    public int getUsageTasksNumberOfRecordsPerExecution() {
-        return usageTasksNumberOfRecordsPerExecution;
-    }
-
-    public int getUsageTasksExecutionIntervalInMilliSeconds() {
-        return usageTasksExecutionIntervalInMilliSeconds;
-    }
-
-    public int getUsageTasksStartupDelayInMilliSeconds() {
-        return usageTasksStartupDelayInMilliSeconds;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
deleted file mode 100644
index 023d16f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.exception;
-
-/**
- * UsageException class to handle usage exception
- */
-public class UsageException extends Exception {
-    public UsageException(String msg, Exception e) {
-        super(msg, e);
-    }
-    public UsageException(String msg) {
-        super(msg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
deleted file mode 100644
index 62ae4cf..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.agent.internal;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.usage.agent.listeners.UsageStatsAxis2ConfigurationContextObserver;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to activate and deactivate the UsageAgentServiceComponent, set and unset
- * Serverconfigurarion, set and unset EventBrokerService.
- *
- * @scr.component name="org.wso2.carbon.usage.agent" immediate="true"
- * @scr.reference name="user.realmservice.default"
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1"
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service"
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="0..1"
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="server.configuration"
- * interface="org.wso2.carbon.base.api.ServerConfigurationService" cardinality="1..1"
- * policy="dynamic" bind="setServerConfiguration" unbind="unsetServerConfiguration"
- * @scr.reference name="eventbroker.service"
- * interface="org.wso2.carbon.event.core.EventBroker" cardinality="1..1"
- * policy="dynamic" bind="setEventBrokerService" unbind="unsetEventBrokerService"
- * @scr.reference name="org.wso2.carbon.statistics.services"
- * interface="org.wso2.carbon.statistics.services.SystemStatisticsUtil"
- * cardinality="0..1" policy="dynamic" bind="setSystemStatisticsUtil" unbind="unsetSystemStatisticsUtil"
- */
-public class UsageAgentServiceComponent {
-    private static Log log = LogFactory.getLog(UsageAgentServiceComponent.class);
-
-    /**
-     * method to activate UsageAgentServiceComponent
-     *
-     * @param context componentContext
-     */
-    protected void activate(ComponentContext context) {
-        try {
-            PrivilegedCarbonContext.startTenantFlow();
-            PrivilegedCarbonContext.getCurrentContext().setTenantId(
-                    MultitenantConstants.SUPER_TENANT_ID);
-            PrivilegedCarbonContext.getCurrentContext().getTenantDomain(true);
-            PrivilegedCarbonContext.getCurrentContext().setUsername(
-                    CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            PrivilegedCarbonContext.getCurrentContext().setUserRealm(
-                    Util.getRealmService().getBootstrapRealm());
-            
-            // initialize listeners
-            // currently we have RegistryUsagePersistingListener only
-            Util.initializeAllListeners();
-
-            //initialize persistenceManager for persisting BandwidthUsage
-            Util.initializePersistenceManager();
-
-            // create statistic event subscription
-            Util.createStaticEventSubscription();
-
-            if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-                //PublisherUtils.defineUsageEventStream();
-
-                UsageStatsAxis2ConfigurationContextObserver statObserver = new UsageStatsAxis2ConfigurationContextObserver();
-                context.getBundleContext().registerService(Axis2ConfigurationContextObserver.class.getName(), statObserver, null);
-                log.info("Observer to register the module for request statistics publishing was registered");
-            }
-
-            // register the request data persistor osgi service so that we can
-            // store service request bandwidths
-            // TODO: Remove this and ServiceDataPersistor after fixing ESB metering
-//            context.getBundleContext().registerService(
-//                    RequestDataPersister.class.getName(), new ServiceDataPersistor(), null);
-
-            log.debug("******* Multitenancy Usage Agent bundle is activated ******* ");
-        } catch (Throwable e) {
-            log.error("******* Failed to activate Multitenancy Usage Agent bundle ****", e);
-        } finally {
-            PrivilegedCarbonContext.endTenantFlow();
-        }
-    }
-
-    /**
-     * method to deactivate bundle
-     *
-     * @param context ComponentContext
-     */
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Multitenancy Metering Usage Agent bundle is deactivated ******* ");
-    }
-
-    /**
-     * method to set RealmService
-     *
-     * @param realmService RealmService
-     */
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    /**
-     * method to unsetRealmService
-     *
-     * @param realmService RealmService
-     */
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-
-    /**
-     * method to set ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(contextService);
-        PublisherUtils.setConfigurationContextService(contextService);
-    }
-
-    /**
-     * method to unset ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    /**
-     * method to set server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(serverConfiguration);
-    }
-
-    /**
-     * method to unset server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void unsetServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(null);
-    }
-
-    /**
-     * method to set EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-
-    protected void setEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(registryEventBrokerService);
-    }
-
-    /**
-     * method to unset EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-    protected void unsetEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(null);
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(systemStatisticsUtil);
-    }
-
-    public static void unsetSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(null);
-    }
-
-}


[04/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
deleted file mode 100644
index 9b6e116..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantUsage {
-    private int tenantId;
-    private String domain;
-    private int numberOfUsers;
-    private UsageEntry[] usageEntries;
-    private BandwidthStatistics[] registryBandwidthStatistics;
-    private BandwidthStatistics[] serviceBandwidthStatistics;
-    private BandwidthStatistics[] webappBandwidthStatistics;
-    private RequestStatistics[] requestStatistics;
-    private TenantDataCapacity registryCapacity;
-    private RequestStatistics totalRequestStatistics;
-    private BandwidthStatistics totalRegistryBandwidth;
-    private BandwidthStatistics totalServiceBandwidth;
-    private BandwidthStatistics totalWebappBandwidth;
-    private APIManagerUsageStats[] apiManagerUsageStats;
-
-    public APIManagerUsageStats[] getApiManagerUsageStats() {
-        return apiManagerUsageStats;
-    }
-
-    public void setApiManagerUsageStats(APIManagerUsageStats[] apiManagerUsageStats) {
-        this.apiManagerUsageStats = apiManagerUsageStats;
-    }
-
-    public BandwidthStatistics[] getRegistryBandwidthStatistics() {
-        return registryBandwidthStatistics;
-    }
-
-    public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) {
-        this.registryBandwidthStatistics = registryBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getServiceBandwidthStatistics() {
-        return serviceBandwidthStatistics;
-    }
-
-    public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) {
-        this.serviceBandwidthStatistics = serviceBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getWebappBandwidthStatistics() {
-        return webappBandwidthStatistics;
-    }
-
-    public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) {
-        this.webappBandwidthStatistics = webappBandwidthStatistics;
-    }
-
-    public RequestStatistics getTotalRequestStatistics() {
-        return totalRequestStatistics;
-    }
-
-    public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) {
-        this.totalRequestStatistics = totalRequestStatistics;
-    }
-
-    public BandwidthStatistics getTotalRegistryBandwidth() {
-        return totalRegistryBandwidth;
-    }
-
-    public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) {
-        this.totalRegistryBandwidth = totalRegistryBandwidth;
-    }
-
-    public BandwidthStatistics getTotalServiceBandwidth() {
-        return totalServiceBandwidth;
-    }
-
-    public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) {
-        this.totalServiceBandwidth = totalServiceBandwidth;
-    }
-
-    public BandwidthStatistics getTotalWebappBandwidth() {
-        return totalWebappBandwidth;
-    }
-
-    public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) {
-        this.totalWebappBandwidth = totalWebappBandwidth;
-    }
-
-    public TenantUsage() {
-        // empty method required for used in web services
-    }
-
-    public TenantUsage(int tenantId, String domain) {
-        this.tenantId = tenantId;
-        this.domain = domain;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    public UsageEntry[] getUsageEntries() {
-        return usageEntries;
-    }
-
-    public void setUsageEntries(UsageEntry[] usageEntries) {
-        this.usageEntries = usageEntries;
-    }
-
-    public RequestStatistics[] getRequestStatistics() {
-        return requestStatistics;
-    }
-
-    public void setRequestStatistics(RequestStatistics[] requestStatistics) {
-        this.requestStatistics = requestStatistics;
-    }
-
-    public TenantDataCapacity getRegistryCapacity() {
-        return registryCapacity;
-    }
-
-    public void setRegistryCapacity(TenantDataCapacity registryCapacity) {
-        this.registryCapacity = registryCapacity;
-    }
-
-    public int getNumberOfUsers() {
-        return numberOfUsers;
-    }
-
-    public void setNumberOfUsers(int numberOfUsers) {
-        this.numberOfUsers = numberOfUsers;
-    }
-
-    public long getRegistryContentCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentCapacity();
-        }
-        return retValue;
-    }
-
-    public long getRegistryContentHistoryCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentHistoryCapacity();
-        }
-        return retValue;
-    }
-
-    public long getTotalIncomingBandwidth(){
-        long incomingBW =  0;
-        if(totalRegistryBandwidth != null){
-            incomingBW += totalRegistryBandwidth.getIncomingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            incomingBW += totalServiceBandwidth.getIncomingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            incomingBW += totalWebappBandwidth.getIncomingBandwidth();
-        }
-        return incomingBW;
-    }
-
-    public long getTotalOutgoingBandwidth(){
-        long outgoingBW =  0;
-        if(totalRegistryBandwidth != null){
-            outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            outgoingBW += totalServiceBandwidth.getOutgoingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            outgoingBW += totalWebappBandwidth.getOutgoingBandwidth();
-        }
-        return outgoingBW;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
deleted file mode 100644
index ff9c4be..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class UsageEntry {
-    private String key;
-    private String value;
-
-    public UsageEntry() {
-        // empty constructor to used in web services
-    }
-
-    public UsageEntry(String key, String value) {
-        this.key = key;
-        this.value = value;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
deleted file mode 100644
index cc30312..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.local.LocalTransportReceiver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.usage" immediate="true"
- * @scr.reference name="registry.service"
- * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
- * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
- * @scr.reference name="user.realmservice.default" 
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" 
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service" 
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" 
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageServiceComponent {
-    private static Log log = LogFactory.getLog(UsageServiceComponent.class);
-
-
-    protected void activate(ComponentContext context) {
-        try {
-            Util.registerRetrieverServices(context.getBundleContext());
-            log.debug("******* Usage bundle is activated ******* ");    
-        } catch (Exception e) {
-            log.error("******* Error in activating Usage bundle ******* ");
-        }
-    }
-
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Usage is deactivated ******* ");
-    }
-
-    protected void setRegistryService(RegistryService registryService) {
-        Util.setRegistryService(registryService);
-    }
-
-    protected void unsetRegistryService(RegistryService registryService) {
-        Util.setRegistryService(null);
-    }
-
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-    
-    protected void setConfigurationContextService(ConfigurationContextService ccService) {
-        //commented to work with the local transport
-	/*ConfigurationContext serverCtx = ccService.getServerConfigContext();
-        AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
-        LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
-        LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
-        LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
-	*/
-        Util.setConfigurationContextService(ccService);
-    }
-
-    protected void unsetConfigurationContextService(ConfigurationContextService ccService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(dataSourceService);
-    }
-    
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/services/UsageService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/services/UsageService.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/services/UsageService.java
deleted file mode 100644
index 2348b2b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/services/UsageService.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.services;
-
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.usage.beans.InstanceUsageStatics;
-import org.wso2.carbon.usage.beans.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.beans.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.beans.TenantUsage;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class UsageService extends AbstractAdmin {
-    /**
-     * Return the usage of the current logged in tenant
-     *
-     * @param yearMonth year month
-     * @return the current usage of the tenant
-     * @throws Exception
-     */
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
-        int tenantId = registry.getTenantId();
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    /**
-     * Return the all the tenant usages, requires super admin permissions
-     *
-     * @param yearMonth
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                        tenant.getId(), yearMonth);
-                tenantUsages.add(tenantUsage);
-            }
-        }
-        return tenantUsages.toArray(new TenantUsage[tenantUsages.size()]);
-    }
-
-    /**
-     * Return the all the tenant usages paginated, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param pageNumber
-     * @param entriesPerPage
-     * @return PaginatedTenantUsageInfo
-     * @throws Exception
-     */
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-
-        int i = 0;
-        int numberOfPages = 0;
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                if (i % entriesPerPage == 0) {
-                    numberOfPages++;
-                }
-                if (numberOfPages == pageNumber) {
-                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                            tenant.getId(), yearMonth);
-                    tenantUsages.add(tenantUsage);
-                }
-                i++;
-            }
-        }
-        PaginatedTenantUsageInfo paginatedTenantInfo = new PaginatedTenantUsageInfo();
-        paginatedTenantInfo.setTenantUsages(
-                tenantUsages.toArray(new TenantUsage[tenantUsages.size()]));
-        paginatedTenantInfo.setNumberOfPages(numberOfPages);
-        paginatedTenantInfo.setPageNumber(pageNumber);
-        return paginatedTenantInfo;
-    }
-
-    /**
-     * Returns usage of a particular tenant, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param tenantId
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception {
-        return Util.getTenantUsageRetriever().getInstanceUsages();
-    }
-
-    /**
-     * @param yearMonth      year and month that used to retrieve data
-     * @param pageNumber
-     * @param entriesPerPage number of entries per page
-     * @return PaginatedInstanceUsage object that hold instance data and other parameters
-     * @throws Exception when retrieving Paginated Instance Usage error occurs
-     */
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
-                                                                 int entriesPerPage) throws Exception {
-        InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
-        List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
-        PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
-        int i = 0;
-        int numberOfPages = 0;
-        if (instanceUsages != null && instanceUsages.length > 0) {
-            for (InstanceUsageStatics usage : instanceUsages) {
-                InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
-                if (instance != null) {
-                    if (i % entriesPerPage == 0) {
-                        numberOfPages++;
-                    }
-                }
-            }
-
-            paginatedInstanceUsages.setInstanceUsages(
-                instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
-        } else {
-            paginatedInstanceUsages.setInstanceUsages(null);
-        }
-
-        paginatedInstanceUsages.setNumberOfPages(numberOfPages);
-        paginatedInstanceUsages.setPageNumber(pageNumber);
-        return paginatedInstanceUsages;
-    }
-
-    /**
-     * @param usage     is Instance usage Statics object that holds data
-     * @param yearMonth year and month that need to check with instance usage data
-     * @return instance static if instance usage data match with given year and month, else null
-     */
-    public InstanceUsageStatics getValidUsageEntry(InstanceUsageStatics usage, String yearMonth) {
-        Date date = Calendar.getInstance().getTime();
-        if (yearMonth != null) {
-            try {
-                date = CommonUtil.getDateFromMonthString(yearMonth);
-            } catch (ParseException e) {
-
-            }
-        }
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-        if (usage.getStartTime().compareTo(startDate) <= 0 && usage.getStopTime().compareTo(endDate) >= 0) {
-            usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                    startDate.getTimeInMillis()) / 1000);
-            return usage;
-        }
-        if (usage.getStartTime().compareTo(startDate) > 0 && usage.getStartTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(endDate) < 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            } else if (usage.getStopTime().compareTo(endDate) > 0) {
-                usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            }
-        }
-        if (usage.getStartTime().compareTo(startDate) < 0 && usage.getStopTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(startDate) > 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        startDate.getTimeInMillis()) / 1000);
-                return usage;
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
deleted file mode 100644
index d5b5072..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
+++ /dev/null
@@ -1,498 +0,0 @@
-package org.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.beans.APIManagerUsageStats;
-import org.wso2.carbon.usage.beans.BandwidthStatistics;
-import org.wso2.carbon.usage.beans.RequestStatistics;
-import org.wso2.carbon.usage.beans.TenantDataCapacity;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class DataAccessObject {
-
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-    private DataSource dataSource;
-
-
-    public DataAccessObject(){
-        if(Util.getDataSourceService()!=null){
-            try{
-                this.dataSource = (DataSource)Util.getDataSourceService().
-                        getDataSource(Util.BILLING_DATA_SOURCE_NAME).getDSObject();
-            }catch(Exception e){
-                log.error("Error occurred while obtaining " + Util.BILLING_DATA_SOURCE_NAME +
-                        " datasource from data source service.", e);
-                dataSource=null;
-            }
-        }else{
-            log.error("Cannot obtain data source " + Util.BILLING_DATA_SOURCE_NAME + ". Datasource service is null");
-            dataSource=null;
-        }
-    }
-
-
-    public List<BandwidthStatistics> getHourlyBandwidthStats(int tenantId, Calendar startDate,
-                                                             Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getDailyBandwidthStats(int tenantId, Calendar startDate,
-                                                            Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Stats of this month will be retrieved
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getMonthlyBandwidthStats(int tenantId,
-                                                              Calendar month) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_DATA");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getHourlyRequestStats(int tenantId, Calendar startDate,
-                                                         Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getDailyRequestStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Month - Stats of this month will be retrieved
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getMonthlyRequestStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    public TenantDataCapacity getTenantDataCapacity(int tenantId) throws Exception{
-        Connection connection = null;
-        TenantDataCapacity tenantDataCapacity = null;
-
-        try{
-            connection = dataSource.getConnection();
-            String id = ""  + tenantId + "Final";
-            String sql = "SELECT * FROM REGISTRY_USAGE_HOURLY_ANALYTICS WHERE ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, id);
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                long currentCapacity = resultSet.getLong("CURRENT_USAGE");
-                long historyCapacity = resultSet.getLong("HISTORY_USAGE");
-
-                tenantDataCapacity = new TenantDataCapacity(currentCapacity, historyCapacity);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving registry data usage from . ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return tenantDataCapacity;
-    }
-
-    /**
-     * @param tenantId  Tenant Id of associated tenant
-     * @param startDate Start Date start time stamp of hour
-     * @param endDate   End date end time stamp of hour
-     * @return APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getHourlyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                    Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     * @param tenantId  Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate   End date - Stats of this date will be included
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getDailyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                   Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if ("API-Call".equals(key)) {
-                    stats.setRequestCount(resultSet.getLong("PAYLOAD_VALUE"));
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-        return bwsList;
-    }
-
-    /**
-     * @param tenantId Tenant ID
-     * @param month    Stats of this month will be retrieved
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getMonthlyAPIManagerUsageStats(int tenantId,
-                                                                     Calendar month) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_DATA");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/Util.java
deleted file mode 100644
index 6c9ebae..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/util/Util.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-
-import javax.sql.DataSource;
-
-/**
- * Util methods for usage.
- */
-public class Util {
-
-    private static final Log log = LogFactory.getLog(Util.class);
-
-    private static RegistryService registryService;
-    private static RealmService realmService;
-    private static TenantUsageRetriever tenantUsageRetriever;
-    private static ConfigurationContextService configurationContextService;
-    private static DataSourceService dataSourceService;
-    public static String BILLING_DATA_SOURCE_NAME="WSO2BillingDS";
-
-    public static synchronized void setRegistryService(RegistryService service) {
-        if (registryService == null) {
-            registryService = service;
-        }
-    }
-    
-    public static void setConfigurationContextService(
-            ConfigurationContextService configurationContextService) {
-        Util.configurationContextService = configurationContextService;
-    }
-    
-    public static ConfigurationContextService getConfigurationContextService(){
-        return configurationContextService;
-    }
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static RegistryService getRegistryService() {
-        return registryService;
-    }
-
-    public static TenantUsageRetriever getTenantUsageRetriever() {
-        return tenantUsageRetriever;
-    }
-
-    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
-        return registryService.getUserRealm(tenantId);
-    }
-
-    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
-        return registryService.getGovernanceSystemRegistry();
-    }
-
-    public static void registerRetrieverServices(BundleContext bundleContext) throws Exception {
-        ConfigurationContextService confCtxSvc = Util.getConfigurationContextService();
-
-        // creating and registering tenant and user usage retrievers
-        tenantUsageRetriever = new TenantUsageRetriever(
-                registryService, confCtxSvc.getServerConfigContext());
-        bundleContext.registerService(
-                TenantUsageRetriever.class.getName(), tenantUsageRetriever, null);
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        Util.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 2d2f81e..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <!--<ManagementPermission>
-            <DisplayName>User-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/userUsage</ResourceId>
-        </ManagementPermission> -->
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Protected</DisplayName>
-            <ResourceId>/permission/protected</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/protected/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Any-Tenant-Usage</DisplayName>
-            <ResourceId>/permission/protected/monitor/anytenantUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 8e82415..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-    <service name="UsageService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.services.UsageService
-        </parameter>
-
-        <operation name="retrieveCurrentTenantUsage">
-            <parameter name="AuthorizationAction" locked="true">/permission/admin/monitor/tenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrievePaginatedTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsage">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-    </service>
-    <parameter name="adminService" locked="true">true</parameter>
-
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/all_tenant_usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/all_tenant_usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/all_tenant_usage_report.jrxml
deleted file mode 100644
index b9483aa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/all_tenant_usage_report.jrxml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="all_tenant_usage_report"  pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="yearMonth" class="java.lang.String"/>
-	<field name="tenantName" class="java.lang.String"/>
-	<field name="numberOfUsers" class="java.lang.String"/>
-	<field name="currentDataStorage" class="java.lang.String"/>
-	<field name="regBandwidth" class="java.lang.String"/>
-	<field name="svcBandwidth" class="java.lang.String"/>
-	<field name="svcTotalRequest" class="java.lang.String"/>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="79" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="35" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Transparent" x="0" y="0" width="279" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<text><![CDATA[Tenant Usage Report for the month]]></text>
-			</staticText>
-			<textField>
-				<reportElement mode="Transparent" x="279" y="0" width="276" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{yearMonth}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band height="61" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Opaque" x="0" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Domain]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="100" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Number of users]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="200" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Storage Usage]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="300" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Registry Bandwidth]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="400" y="29" width="73" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Service Bandwidht]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="473" y="29" width="82" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Service Requests]]></text>
-			</staticText>
-		</band>
-	</columnHeader>
-	<detail>
-		<band height="103" splitType="Stretch">
-			<textField>
-				<reportElement x="0" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantName}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="100" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{numberOfUsers}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="200" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{currentDataStorage}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="300" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{regBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="400" y="21" width="73" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="473" y="21" width="82" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcTotalRequest}]]></textFieldExpression>
-			</textField>
-		</band>
-	</detail>
-	<columnFooter>
-		<band height="45" splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="54" splitType="Stretch">
-			<textField>
-				<reportElement x="455" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
-			</textField>
-			<textField pattern="MMMMM dd, yyyy">
-				<reportElement x="0" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageFooter>
-	<summary>
-		<band height="42" splitType="Stretch"/>
-	</summary>
-</jasperReport>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/usage_report.jrxml
deleted file mode 100644
index 5b43c2f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/resources/reports/usage_report.jrxml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="task" class="java.lang.String"/>
-	<field name="usagecol1" class="java.lang.String"/>
-	<field name="usagecol2" class="java.lang.String"/>
-	<field name="usagecol3" class="java.lang.String"/>
-	<field name="usagecol4" class="java.lang.String"/>
-	<field name="usagecol1Value" class="java.lang.String"/>
-	<field name="usagecol2Value" class="java.lang.String"/>
-	<field name="usagecol3Value" class="java.lang.String"/>
-	<field name="usagecol4Value" class="java.lang.String"/>
-	<field name="tenantDomain" class="java.lang.String"/>
-	<group name="usagedatagroup">
-		<groupExpression><![CDATA[$F{task}]]></groupExpression>
-		<groupHeader>
-			<band height="72" splitType="Stretch">
-				<rectangle>
-					<reportElement x="0" y="21" width="555" height="16" backcolor="#D0F5E8"/>
-				</rectangle>
-				<textField>
-					<reportElement x="0" y="22" width="555" height="16"/>
-					<textElement>
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{task}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="38" width="555" height="16" backcolor="#E6F1B6"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="39" width="132" height="17"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="39" width="132" height="15"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="288" y="39" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="38" width="132" height="16"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="55" width="555" height="15" backcolor="#DBE596"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="57" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="55" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="287" y="55" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="56" width="132" height="15"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4Value}]]></textFieldExpression>
-				</textField>
-			</band>
-		</groupHeader>
-		<groupFooter>
-			<band splitType="Stretch"/>
-		</groupFooter>
-	</group>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="17" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="19" splitType="Stretch">
-			<textField pattern="dd/MM/yyyy h.mm a">
-				<reportElement x="403" y="0" width="132" height="16"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-			<staticText>
-				<reportElement x="0" y="1" width="169" height="15"/>
-				<textElement textAlignment="Right">
-					<font size="12" isUnderline="true"/>
-				</textElement>
-				<text><![CDATA[Usage Report For : ]]></text>
-			</staticText>
-			<textField>
-				<reportElement x="169" y="0" width="234" height="16"/>
-				<textElement verticalAlignment="Middle">
-					<font size="12"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantDomain}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band splitType="Stretch"/>
-	</columnHeader>
-	<detail>
-		<band height="5" splitType="Stretch"/>
-	</detail>
-	<columnFooter>
-		<band splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="8" splitType="Stretch"/>
-	</pageFooter>
-	<summary>
-		<band height="7" splitType="Stretch"/>
-	</summary>
-</jasperReport>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/pom.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/pom.xml
deleted file mode 100644
index c05576a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/pom.xml
+++ /dev/null
@@ -1,143 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage</artifactId>
-    <version>2.1.2</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>add-source</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>target/generated-code/src</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <ListenerManager-RequiredServices>
-                            org.wso2.carbon.usage.api.TenantUsageRetriever
-                        </ListenerManager-RequiredServices>
-                        <Private-Package>
-                            org.wso2.carbon.usage.internal.*,
-                            org.wso2.carbon.usage.util.*,
-                            org.wso2.carbon.usage.services.*,
-                            org.wso2.carbon.usage.client.*
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.beans.*,
-                            org.wso2.carbon.usage.api.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.rule.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            org.wso2.carbon.stratos.common.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-            
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.mgt</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-            <version>2.1.2</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.agent</artifactId>
-        </dependency>
-         <!--<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId>
-        </dependency>-->
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ndatasource.core</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-    </dependencies>
-</project>


[11/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/UsageService.wsdl
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/UsageService.wsdl b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/UsageService.wsdl
deleted file mode 100644
index a974e17..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/UsageService.wsdl
+++ /dev/null
@@ -1,604 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-                  xmlns:ns1="http://org.apache.axis2/xsd"
-                  xmlns:ns="http://services.usage.carbon.wso2.org"
-                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
-                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
-                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
-                  xmlns:ax2249="http://beans.usage.carbon.wso2.org/xsd"
-                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
-                  targetNamespace="http://services.usage.carbon.wso2.org">
-    <wsdl:documentation>UsageService</wsdl:documentation>
-    <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://beans.usage.carbon.wso2.org/xsd">
-            <xs:complexType name="TenantUsage">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="domain" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="numberOfUsers" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="registryBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="registryCapacity" nillable="true"
-                                type="ax2249:TenantDataCapacity"/>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="requestStatistics"
-                                nillable="true" type="ax2249:RequestStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="serviceBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    <xs:element minOccurs="0" name="totalIncomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalOutgoingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalRegistryBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="totalRequestStatistics" nillable="true"
-                                type="ax2249:RequestStatistics"/>
-                    <xs:element minOccurs="0" name="totalServiceBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="totalWebappBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="usageEntries"
-                                nillable="true" type="ax2249:UsageEntry"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="webappBandwidthStatistics"
-                                nillable="true" type="ax2249:BandwidthStatistics"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="BandwidthStatistics">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="incomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="outgoingBandwidth" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="TenantDataCapacity">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="RequestStatistics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="faultCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="requestCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="responseCount" type="xs:long"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:complexType name="UsageEntry">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedTenantUsageInfo">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="tenantUsages"
-                                nillable="true" type="ax2249:TenantUsage"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedInstanceUsage">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceUsages"
-                                nillable="true" type="ax2249:InstanceUsageStatics"/>
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="InstanceUsageStatics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="instanceID" nillable="true" type="xs:int"/>
-                    <xs:element minOccurs="0" name="instanceURL" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="running" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="startTime" nillable="true" type="xs:dateTime"/>
-
-                    <xs:element minOccurs="0" name="stopTime" nillable="true" type="xs:dateTime"/>
-                    <xs:element minOccurs="0" name="usedTimeInSeconds" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax2250="http://beans.usage.carbon.wso2.org/xsd"
-                   attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://services.usage.carbon.wso2.org">
-            <xs:import namespace="http://beans.usage.carbon.wso2.org/xsd"/>
-            <xs:element name="Exception">
-                <xs:complexType>
-
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="Exception" nillable="true"
-                                    type="ns:Exception"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:complexType name="Exception">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:element name="retrieveTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsagesResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsagesResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedTenantUsageInfo"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsage">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedInstanceUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveInstanceUsageResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:InstanceUsageStatics"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-
-                </xs:complexType>
-            </xs:element>
-        </xs:schema>
-    </wsdl:types>
-    <wsdl:message name="retrievePaginatedTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsagesResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="Exception">
-        <wsdl:part name="parameters" element="ns:Exception"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsageResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsagesResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsage"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveInstanceUsageRequest"/>
-    <wsdl:message name="retrieveInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageRequest">
-
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:portType name="UsageServicePortType">
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <wsdl:input message="ns:retrievePaginatedTenantUsagesRequest"
-                        wsaw:Action="urn:retrievePaginatedTenantUsages"/>
-            <wsdl:output message="ns:retrievePaginatedTenantUsagesResponse"
-                         wsaw:Action="urn:retrievePaginatedTenantUsagesResponse"/>
-
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <wsdl:input message="ns:retrieveCurrentTenantUsageRequest"
-                        wsaw:Action="urn:retrieveCurrentTenantUsage"/>
-            <wsdl:output message="ns:retrieveCurrentTenantUsageResponse"
-                         wsaw:Action="urn:retrieveCurrentTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveCurrentTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <wsdl:input message="ns:retrieveTenantUsagesRequest"
-                        wsaw:Action="urn:retrieveTenantUsages"/>
-
-            <wsdl:output message="ns:retrieveTenantUsagesResponse"
-                         wsaw:Action="urn:retrieveTenantUsagesResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <wsdl:input message="ns:retrieveTenantUsageRequest"
-                        wsaw:Action="urn:retrieveTenantUsage"/>
-            <wsdl:output message="ns:retrieveTenantUsageResponse"
-                         wsaw:Action="urn:retrieveTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-
-            <wsdl:input message="ns:retrieveInstanceUsageRequest"
-                        wsaw:Action="urn:retrieveInstanceUsage"/>
-            <wsdl:output message="ns:retrieveInstanceUsageResponse"
-                         wsaw:Action="urn:retrieveInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveInstanceUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <wsdl:input message="ns:retrievePaginatedInstanceUsageRequest"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsage"/>
-            <wsdl:output message="ns:retrievePaginatedInstanceUsageResponse"
-                         wsaw:Action="urn:retrievePaginatedInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsageException"/>
-        </wsdl:operation>
-
-    </wsdl:portType>
-    <wsdl:binding name="UsageServiceSoap11Binding" type="ns:UsageServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceSoap12Binding" type="ns:UsageServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap12:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap12:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap12:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap12:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap12:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap12:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceHttpBinding" type="ns:UsageServicePortType">
-        <http:binding verb="POST"/>
-
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <http:operation location="retrievePaginatedTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <http:operation location="retrieveCurrentTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <http:operation location="retrieveTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsage">
-            <http:operation location="retrieveTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <http:operation location="retrieveInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <http:operation location="retrievePaginatedInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-    </wsdl:binding>
-    <wsdl:service name="UsageService">
-        <wsdl:port name="UsageServiceHttpsSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-
-            <soap12:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-            <soap12:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpEndpoint" binding="ns:UsageServiceHttpBinding">
-            <http:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpEndpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsEndpoint" binding="ns:UsageServiceHttpBinding">
-
-            <http:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsEndpoint/"/>
-        </wsdl:port>
-    </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
deleted file mode 100644
index e7490b0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-empty=To make sure the js properties file is not empty
-session.timed.out=Session timed out. Please login again
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
deleted file mode 100644
index 71ffd1d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
+++ /dev/null
@@ -1,53 +0,0 @@
-usage.menu=User Usage
-user.usage.report=User Usage Report
-tenant.menu=Tenant Usage
-tenants.usage.report=Tenant Usage Report
-tenant.usage.report=Usage Report
-data.storage.name=Data Storage
-current.data.storage=Current Data Storage
-history.data.storage=Historical Data Storage
-total.data.storage=Total Data Storage
-registry.content.storage.name=Registry Content
-registry.bandwidth.usage=Registry Bandwidth Usage
-service.bandwidth.usage=Service Bandwidth Usage
-webapp.bandwidth.usage=Webapp Bandwidth Usage
-server.name=Server Name
-all.server.name=All Server Total
-incoming.bandwidth=Incoming Bandwidth
-outgoing.bandwidth=Outgoing Bandwidth
-total.bandwidth=Total Bandwidth
-storage.usage=Storage Usage
-number.of.users=Number of Users
-users=Users
-usage.monitoring=Usage Monitoring
-all.tenant.usage.report=All Tenant Usage
-tenant.domain=Domain
-tenant.id=Id
-full.report=Full Report
-report.duration=Report Duration
-year.month=Year-Month
-back=Back
-page.x.to.y=Page {0}
-prev=Prev
-next=Next
-service.usage.stat=Service Usage Statistics
-service.usage.request=Request Count
-service.usage.response=Response Count
-service.usage.fault=Fault Count
-service.total.request=Service Requests
-registry.total.bandwidth=Total Registry Bandwidth
-service.total.bandwidth=Total Service Bandwidth
-instance.usage.report=Instance Usage Report
-instance.server.url=Instance Server URL
-instance.id=Instance ID
-start.time=Start Time
-stop.time=Stop Time
-used.time.in.hours=Used Time In Hours
-instances.data=Instances Data
-failed.to.get.instance.data=Failed To Get Instance Data
-empty.instance.data=Instance Data Not Found
-usage.data.not.available=Usage Data not available
-empty.usage.data=Usage Data Not Found
-webapp.total.bandwidth=Total WebApp Bandwidth
-number.of.api.calls= Number of API Calls
-api.usage=API Usage

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
deleted file mode 100644
index e4c9510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
+++ /dev/null
@@ -1,216 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-        int pageNumber=0;
-        int rowCount = 5;
-        int numberOfPages=0;
-        InstanceUsageStatics[] instanceUsages=null;
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        try{
-        PaginatedInstanceUsage instanceInfo =
-                UsageUtil.retrievePaginatedInstanceUsages(request, config, session);
-        instanceUsages = instanceInfo.getInstanceUsages();
-        pageNumber = instanceInfo.getPageNumber();
-        numberOfPages = instanceInfo.getNumberOfPages();
-
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-        }
-        catch (Exception e){
-        //No need to handle here it here.Error will show in next try block
-        //To avoid dead page
-        }
-    %>
-
-    <div id="middle">
-
-        <h2><fmt:message key="instance.usage.report"/> for the Month - <%=yearMonth%> (With All
-            Running Instances)</h2>
-
-        <div id="report_ui">
-            <carbon:reportNew
-                    component="org.wso2.carbon.usage"
-                    template="all_tenant_usage_report"
-                    pdfReport="true"
-                    htmlReport="true"
-                    excelReport="true"
-                    reportDataSession="all_tenant_usage_data"
-                    jsFunction="getUsageReportData()"/>
-        </div>
-
-        <div id="workArea">
-
-            <form id="usageForm" action="all_tenant_instance_usage.jsp" method="post">
-
-
-                <table class="styledLeft">
-                    <thead>
-                    <tr>
-                        <th>
-                            <fmt:message key="report.duration"/>
-                        </th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr>
-                        <td class="nopadding">
-                            <table class="normal-nopadding" cellspacing="0">
-                                <tbody>
-                                <tr>
-                                    <td><fmt:message key="year.month"/></td>
-                                    <td colspan="2">
-                                        <select onchange="this.form.submit()" name="year-month"
-                                                id="year-month" style="width:400px">
-                                            <%
-                                                for (String ym : UsageUtil.getYearMonths()) {
-                                                    String selectedStr = "";
-                                                    if (ym.equals(yearMonth)) {
-                                                        selectedStr = "selected=\"true\" ";
-                                                    }
-                                            %>
-                                            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                            </option>
-                                            <%
-                                                }
-                                            %>
-                                        </select>
-                                        <input type="hidden" name="requestedPage" id="requestedPage"
-                                               value="<%=pageNumber%>"/>
-                                    </td>
-                                </tr>
-
-                                <tr>
-                                    <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                            key="instances.data"/></td>
-                                </tr>
-                                <tr>
-                                    <th><fmt:message key="instance.id"/></th>
-                                    <th><fmt:message key="server.name"/></th>
-                                    <th><fmt:message key="start.time"/></th>
-                                    <th><fmt:message key="stop.time"/></th>
-                                    <th><fmt:message key="used.time.in.hours"/></th>
-                                </tr>
-                                <%                
-                                    try{
-                                    InstanceUsageStatics[] iu = UsageUtil.retrieveInstanceUsage(request, config, session);
-                                    java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz");
-                                    if (!iu.equals(null)) {
-                                        for (InstanceUsageStatics usage : instanceUsages) {
-                                            String endDate;
-                                            if (usage.getRunning() == true) {
-                                                endDate="Instance Still Running";
-                                            }
-                                            else{
-                                                endDate=dateFormatter.format(usage.getStopTime().getTime());
-                                            }
-                                            String startDate=dateFormatter.format(usage.getStartTime().getTime());
-                                            long usedHours;
-                                            long usedTimeInSeconds=usage.getUsedTimeInSeconds();
-                                            if(usedTimeInSeconds%3600==0){
-                                                usedHours=usedTimeInSeconds/3600;
-                                            }
-                                            else{
-                                                usedHours=(usedTimeInSeconds/3600)+1;
-                                            }
-                                %>
-                                <tr>
-                                    <td>
-                                        <%=usage.getInstanceID()%>
-                                    </td>
-                                    <td>
-                                        <%=usage.getInstanceURL().toString()%>
-                                    </td>
-                                    <td>
-                                        <%=startDate%>
-                                    </td>
-                                    <td>
-                                        <%=endDate%>
-                                    </td>
-                                    <td>
-
-                                        <%=usedHours%>
-                                    </td>
-                                </tr>
-                                <%
-
-                                        }
-                                    }
-                                    else{
-                                      %>
-                                     <td><fmt:message key="empty.instance.data"/></td>
-                                <%
-                                 }
-                                    }
-                                    catch (Exception e){ %>
-                                      <td><fmt:message key="failed.to.get.instance.data"/></td>
-                                   <% }
-                                %>
-                                <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                          numberOfPages="<%=numberOfPages%>"
-                                                          resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                          nextKey="next" prevKey="prev"
-                                                          tdColSpan="6"
-                                                          paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                                </tbody>
-                            </table>
-                        </td>
-                    </tr>
-                    </tbody>
-                </table>
-            </form>
-            <br/>
-        </div>
-    </div>
-</fmt:bundle>
-
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
deleted file mode 100644
index 6036a19..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
+++ /dev/null
@@ -1,208 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageData" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page import="java.util.List" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        PaginatedTenantUsageInfo tenantsInfo =
-                UsageUtil.retrievePaginatedTenantUsages(request, config, session);
-        TenantUsage[] tenantUsages = tenantsInfo.getTenantUsages();
-        int pageNumber = tenantsInfo.getPageNumber();
-        int numberOfPages = tenantsInfo.getNumberOfPages();
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-
-
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        int rowCount = 5;
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-    %>
-
-
-    <%
-        //AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-        //List<AllTenantUsageData> reportDataArray = usageReport.getUsageReportData();
-        //request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-    %>
-
-    <div id="middle">
-        <h2><fmt:message key="tenants.usage.report"/> for the Month - <%=yearMonth%> (All
-            Tenants)</h2>
-    </div>
-
-    <div id="workArea">
-
-        <form id="usageForm" action="all_tenant_usage.jsp" method="post">
-
-
-            <table class="styledLeft">
-                <thead>
-                <tr>
-                    <th>
-                        <fmt:message key="report.duration"/>
-                    </th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr>
-                    <td class="nopadding">
-                        <table class="normal-nopadding" cellspacing="0">
-                            <tbody>
-                            <tr>
-                                <td><fmt:message key="year.month"/></td>
-                                <td colspan="2">
-                                    <select onchange="this.form.submit()" name="year-month"
-                                            id="year-month" style="width:400px">
-                                        <%
-                                            for (String ym : UsageUtil.getYearMonths()) {
-                                                String selectedStr = "";
-                                                if (ym.equals(yearMonth)) {
-                                                    selectedStr = "selected=\"true\" ";
-                                                }
-                                        %>
-                                        <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                        </option>
-                                        <%
-                                            }
-                                        %>
-                                    </select>
-                                    <input type="hidden" name="requestedPage" id="requestedPage"
-                                           value="<%=pageNumber%>"/>
-                                </td>
-                            </tr>
-
-                            <tr>
-                                <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                        key="users"/></td>
-                            </tr>
-                            <tr>
-                                <th><fmt:message key="tenant.domain"/></th>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <th><fmt:message key="number.of.users"/></th>
-                                <th><fmt:message key="storage.usage"/></th><%}%>
-                                <%--<th><fmt:message key="registry.total.bandwidth"/></th>--%>
-                                <th><fmt:message key="service.total.bandwidth"/></th>
-                                <th><fmt:message key="webapp.total.bandwidth"/></th>
-                                <th><fmt:message key="service.total.request"/></th>
-                                <th><fmt:message key="full.report"/></th>
-                            </tr>
-                            <%
-                                if (tenantUsages != null) {
-                                    for (TenantUsage usage : tenantUsages) {
-                                        String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                                        String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                                        String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                                        String webBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-                                        long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                                        int numberOfUsers = usage.getNumberOfUsers();
-
-                                        String username = (String) request.getSession().getAttribute("logged-user");
-                                        String tenantName = usage.getDomain();
-                                        int tenantId = usage.getTenantId();
-                                        String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-                            %>
-
-                            <tr>
-                                <td><%=tenantName%>
-                                </td>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <td><%=numberOfUsers%>
-                                </td>
-                                <td><%=currentDataStorage%>
-                                </td>
-                                <%
-                                    }
-                                %>
-                                <%--<td><%=regBandwidth%>
-                                </td>--%>
-                                <td><%=svcBandwidth%>
-                                </td>
-                                <td><%=webBandwidth%>
-                                </td>
-                                <td><%=svcTotalRequest%>
-                                </td>
-                                <td><a href="<%=fullReportLink%>">Full Report</a></td>
-                            </tr>
-                            <%
-
-                                }
-                            } else {
-                            %>
-                            <tr>
-                                <td><fmt:message key="empty.usage.data"/></td>
-                            </tr>
-                            </tr>
-                            <%
-                                }
-
-                            %>
-                            <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                      numberOfPages="<%=numberOfPages%>"
-                                                      resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                      nextKey="next" prevKey="prev"
-                                                      tdColSpan="6"
-                                                      paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                            </tbody>
-                        </table>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </form>
-        <br/>
-    </div>
-    </div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
deleted file mode 100644
index ce67752..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%
-    AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    System.out.println("Report lenth "+reportDataArray.length);
-    request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/any_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
deleted file mode 100644
index 7dfde24..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
+++ /dev/null
@@ -1,414 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.usage.report"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="false"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<div id="workArea">
-
-<form id="usageForm" action="any_tenant_usage.jsp" method="get">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <input type="hidden" name="tenant-id" value="<%=tenantId%>"/>
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-
-<%
-    }
-%>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-<br/>
-<input type='button' class='button' style="align:right" id="backButtonID"
-       onclick='window.location="../tenant-usage/all_tenant_usage.jsp?region=region4&item=all_tenant_usage_menu"'
-       value='<fmt:message key="back"/>'/>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/css/tenant-usage.css b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/css/tenant-usage.css
deleted file mode 100644
index 5c85728..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/css/tenant-usage.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.disableLink {
-    color: #aaaaaa;
-}
-
-.pageLinks {
-    background: #FFFFFF none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-.pageLinks-selected {
-    background: #e8e9ae none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-a {
-    color: #386698;
-    cursor: pointer;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/images/view-usage.png b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/images/view-usage.png
deleted file mode 100644
index 4080da3..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/images/view-usage.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/userguide.html b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/userguide.html
deleted file mode 100644
index 9dd0f6c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/docs/userguide.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>View Tenant Usage - User Guide</title>
-  <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
-</head>
-
-<body>
-<h1>View Usage</h1>
-
-<p>
-You can view usage of the stratos resource by your organization(Tenant) from this page
-</p>
-
-<p>
-<img src="images/view-usage.png" alt="View Usage"/>
-<div><strong>Figure1: View Usage</strong></div>
-</p>
- <h2> <b>Description of usage data report fields</b></h2>
-<p>
-<table border="1">
-<tr>
-<th>The Form Field</th>
-<th>Description</th>
-</tr>
-<tr>
-<td>Report Duration </td>
-<td>The year and the month the usage is metered.</td>
-</tr>
-        <tr>
-            <td>Number of Users</td>
-            <td>Number of users of your stratos account.(This is valid only for current month)</td>
-        </tr>
-       <tr>
-        <tr>
-            <td>Storage Usage</td>
-            <td>The registry data storage amount.</td>
-        </tr>
-        <tr>
-            <td>Registry Bandwidth Usage</td>
-            <td>Registry bandwidth consumed by the registry resource accesses(registry uploads, downloads).</td>
-        </tr>
-        <tr>
-            <td>Service Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services hosted by you.</td>
-        </tr>
-        <tr>
-            <td>Webapp Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services.</td>
-        </tr>
- 	<tr>
-            <td>Service Usage Statistics</td>
-            <td>Service statistics of requests and responses of services.</td>
-        </tr>
-    </tbody>
-</table>
-</p>
-<div><strong>Table1: Description of usage data report fields</strong></div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/instance-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
deleted file mode 100644
index 4a1ae6a..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/instance-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
deleted file mode 100644
index a9b04e2..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/user-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/user-usage-report.gif
deleted file mode 100644
index 9070c35..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/images/user-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
deleted file mode 100644
index 61043f0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
+++ /dev/null
@@ -1,49 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-    alert(1);
-    var xmlHttpReq = createXmlHttpRequest();
-    alert(2);
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "all_tenant_usage_report.jsp", false);
-        xmlHttpReq.send(null);
-        
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-	alert(string);
-    return string.replace(/\n/g, "");
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/tenant-usage.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/tenant-usage.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/tenant-usage.js
deleted file mode 100644
index 76c4363..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/tenant-usage.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function submitAllTenantPaginatedUsage(pageNumber) {
-    sessionAwareFunction(function() {
-        document.getElementById("requestedPage").value = pageNumber;
-        var usageForm = document.getElementById("usageForm");
-        usageForm.submit();
-    }, jsi18n["session.timed.out"]);
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/usage-report.js
deleted file mode 100644
index ed9e306..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.1/src/main/resources/web/tenant-usage/js/usage-report.js
+++ /dev/null
@@ -1,48 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-
-    var xmlHttpReq = createXmlHttpRequest();
-
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "usage_report.jsp", false);
-        xmlHttpReq.send(null);
-
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-    return string.replace(/\n/g, "");
-}
\ No newline at end of file


[26/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsagePersistingListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsagePersistingListener.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsagePersistingListener.java
new file mode 100644
index 0000000..8ea0ac1
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsagePersistingListener.java
@@ -0,0 +1,311 @@
+/*
+ *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.usage.agent.listeners;
+
+import org.apache.stratos.usage.agent.persist.BandwidthPersistor;
+import org.apache.stratos.usage.agent.util.MonitoredReader;
+import org.apache.stratos.usage.agent.util.MonitoredWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.registry.core.*;
+import org.wso2.carbon.registry.core.config.RegistryContext;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
+import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
+import org.wso2.carbon.registry.core.session.CurrentSession;
+import org.wso2.carbon.registry.core.utils.RegistryUtils;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Handler that intercept the registry calls
+ * Currently this handler is not registered because there is a similar handler RegistryUsageHandler
+ * After examining properly this class will be deleted.
+ */
+public class RegistryUsagePersistingListener extends Handler {
+
+    private static final Log log = LogFactory.getLog(RegistryUsagePersistingListener.class);
+
+    public void put(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+
+        // called only once per request
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+        ResourcePath path = context.getResourcePath();
+        Resource resource = context.getResource();
+        ((ResourceImpl) resource).setPath(path.getCompletePath());
+        if (resource instanceof CollectionImpl) {
+            return;
+        }
+        Object contentObj = resource.getContent();
+        if (contentObj == null) {
+            return;
+        }
+        int size;
+        if (contentObj instanceof String) {
+            size = ((String) contentObj).length();
+        } else if (contentObj instanceof byte[]) {
+            size = ((byte[]) contentObj).length;
+        } else {
+            String msg = "Unsupported type for the content.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+
+        // persisting bandwidth
+        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
+
+        //we will pass through, so that normal registry operation will put the resource
+    }
+
+    public void importResource(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+//        ResourcePath resourcePath = context.getResourcePath();
+        String sourceURL = context.getSourceURL();
+     
+
+        // the import resource logic
+        URL url;
+        try {
+            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
+                String msg = "The source URL must not be file in the server's local file system";
+                throw new RegistryException(msg);
+            }
+            url = new URL(sourceURL);
+        } catch (MalformedURLException e) {
+            String msg = "Given source URL " + sourceURL + "is not valid.";
+            throw new RegistryException(msg, e);
+        }
+
+        try {
+            URLConnection uc = url.openConnection();
+            InputStream in = uc.getInputStream();
+            byte[] inByteArr = RegistryUtils.getByteArray(in);
+            int size = inByteArr.length;
+
+            // persisting bandwidth
+            BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
+
+        } catch (IOException e) {
+
+            String msg = "Could not read from the given URL: " + sourceURL;
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public Resource get(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return null;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return null;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return null;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+
+        // get the resource
+        Resource resource = context.getResource();
+        if (resource == null) {
+            ResourcePath resourcePath = context.getResourcePath();
+            Registry registry = context.getRegistry();
+            if (registry.resourceExists(resourcePath.getPath())) {
+                resource = registry.get(resourcePath.getPath());
+                context.setResource(resource);
+                context.setProcessingComplete(true); // nothing else to do.
+            }
+        }
+        if (resource == null) {
+            return null;
+        }
+        if (resource instanceof CollectionImpl) {
+            return resource;
+        }
+        Object contentObj = resource.getContent();
+        if (contentObj == null) {
+            return resource;
+        }
+        int size;
+        if (contentObj instanceof String) {
+            size = ((String) contentObj).length();
+        } else if (contentObj instanceof byte[]) {
+            size = ((byte[]) contentObj).length;
+        } else {
+            String msg = "Unsupported type for the content.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+        // persisting bandwidth
+        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
+        return resource;
+    }
+
+    public void dump(RequestContext requestContext) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        long size = requestContext.getBytesWritten();
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+        if (size == 0) {
+            //Still not dumped
+            Registry registry = requestContext.getRegistry();
+            String path = requestContext.getResourcePath().getPath();
+            Writer writer = requestContext.getDumpingWriter();
+            // we wrap the writer with the monitored writer
+            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
+            registry.dump(path, monitoredWriter);
+            size = monitoredWriter.getTotalWritten();
+            requestContext.setProcessingComplete(true);
+        }
+
+        // persisting bandwidth
+        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
+
+    }
+
+    public void restore(RequestContext requestContext) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+        long size = requestContext.getBytesRead();
+
+        if (size == 0) {
+            //not restored yet
+            Registry registry = requestContext.getRegistry();
+            String path = requestContext.getResourcePath().getPath();
+            Reader reader = requestContext.getDumpingReader();
+            // we wrap the reader with the monitored reader
+            MonitoredReader monitoredReader = new MonitoredReader(reader);
+            registry.restore(path, monitoredReader);
+            size = monitoredReader.getTotalRead();
+            requestContext.setProcessingComplete(true);
+        }
+        // persisting bandwidth
+        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
+
+    }
+
+    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
+            throws RegistryException {
+
+        //This was commented out because there is a similar class RegistryUsageListener
+        //After examiming properly this class will be deleted
+        /*HandlerManager handlerManager = registryContext.getHandlerManager();
+        RegistryUsagePersistingListener handler = new RegistryUsagePersistingListener();
+        URLMatcher anyUrlMatcher = new URLMatcher();
+        anyUrlMatcher.setPattern(".*");
+        String[] applyingFilters = new String[]{
+                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE,};
+
+        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
+                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
+        */
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsInHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsInHandler.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsInHandler.java
new file mode 100644
index 0000000..d8ecb66
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsInHandler.java
@@ -0,0 +1,73 @@
+/*
+ *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.usage.agent.listeners;
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.stratos.usage.agent.util.PublisherUtils;
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.core.util.SystemFilter;
+import org.wso2.carbon.statistics.services.util.SystemStatistics;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+public class StatisticsInHandler extends AbstractHandler{
+    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
+
+    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
+        AxisService axisService =  messageContext.getAxisService();
+        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
+                axisService.isClientSide()){
+            return InvocationResponse.CONTINUE;
+        }
+
+        if(Util.getSystemStatisticsUtil()==null){
+            return InvocationResponse.CONTINUE;
+        }
+
+        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
+
+        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
+        tenantId = CarbonContext.getCurrentContext().getTenantId();
+
+        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
+                tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+            return Handler.InvocationResponse.CONTINUE;
+        }
+
+        try {
+            PublisherUtils.publish(systemStatistics, tenantId);
+        } catch (Exception e) {
+            //Logging the complete stacktrace in debug mode
+            if(log.isDebugEnabled()){
+                log.debug(e);
+            }
+
+            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
+        }
+
+        return InvocationResponse.CONTINUE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsOutHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsOutHandler.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsOutHandler.java
new file mode 100644
index 0000000..9f61518
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/StatisticsOutHandler.java
@@ -0,0 +1,83 @@
+/*
+ *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.usage.agent.listeners;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.util.SystemFilter;
+import org.wso2.carbon.statistics.services.util.SystemStatistics;
+import org.apache.stratos.usage.agent.util.PublisherUtils;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+
+public class StatisticsOutHandler extends AbstractHandler{
+
+    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
+
+    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
+
+
+        AxisService axisService =  messageContext.getAxisService();
+        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
+                axisService.isClientSide()){
+
+            PrivilegedCarbonContext.destroyCurrentContext();
+            return InvocationResponse.CONTINUE;
+        }
+
+        if(Util.getSystemStatisticsUtil()==null){
+
+            PrivilegedCarbonContext.destroyCurrentContext();
+            return InvocationResponse.CONTINUE;
+        }
+        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
+        
+        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
+        tenantId = CarbonContext.getCurrentContext().getTenantId();
+
+        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
+            tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+
+            PrivilegedCarbonContext.destroyCurrentContext();
+            return Handler.InvocationResponse.CONTINUE;
+        }
+
+        try {
+            PublisherUtils.publish(systemStatistics, tenantId);
+        } catch (Exception e) {
+            //Logging the complete stacktrace in debug mode
+            if(log.isDebugEnabled()){
+                log.debug(e);
+            }
+
+            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
+        }
+
+        PrivilegedCarbonContext.destroyCurrentContext();
+        return InvocationResponse.CONTINUE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
new file mode 100644
index 0000000..152442b
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.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.usage.agent.listeners;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver;
+
+
+public class UsageStatsAxis2ConfigurationContextObserver extends AbstractAxis2ConfigurationContextObserver {
+
+    private static final Log log = LogFactory.getLog(UsageStatsAxis2ConfigurationContextObserver.class);
+
+    @Override
+    public void createdConfigurationContext(ConfigurationContext configContext) {
+
+        AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
+        int tenantId = PrivilegedCarbonContext.getCurrentContext().getTenantId(false);
+        try {
+            axisConfiguration.engageModule("metering");
+        } catch (AxisFault axisFault) {
+            log.error("Could not engage metering module for tenant: " + tenantId, axisFault);
+        }
+
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringHandler.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringHandler.java
new file mode 100644
index 0000000..09a5f78
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringHandler.java
@@ -0,0 +1,109 @@
+/*
+ *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.usage.agent.listeners.axis2;
+
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * this class is used to obtain tenant id from MeteredServletRequest or MessageContext
+ */
+
+public class RequestMeteringHandler extends AbstractHandler {
+    private static final Log log = LogFactory.getLog(RequestMeteringHandler.class);
+
+    /**
+     * this method  invoke  MeteredServletRequest and return a InvocationResponse
+     * @param messageContext  MessageContext
+     * @return InvocationResponse
+     * @throws AxisFault
+     */
+
+    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
+        if (log.isDebugEnabled()) {
+            log.debug("Staring metering handler invocation. Incoming message: " +
+                    messageContext.getEnvelope().toString());
+        }
+        AxisService service = messageContext.getAxisService();
+        Parameter param = service.getParameter("adminService");
+
+        Object obj = messageContext.getProperty("transport.http.servletRequest");
+        if (obj == null) {
+            // TODO: check for cause of the error.
+            log.debug("Servlet request is null. Skip monitoring.");
+            return InvocationResponse.CONTINUE;
+        }
+        if (!(obj instanceof MeteredServletRequest)) {
+            log.debug("HttpServletRequest is not of type MeteredServletRequest. Skip monitoring.");
+            return InvocationResponse.CONTINUE;
+        }
+
+        MeteredServletRequest servletRequest = (MeteredServletRequest) obj;
+
+        if (param != null && "true".equals(param.getValue())) {
+            servletRequest.setAttribute(StratosConstants.ADMIN_SERVICE_SERVLET_ATTR, "true");
+            return InvocationResponse.CONTINUE;
+        }
+        servletRequest.setAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR, service.getName());
+
+        int tenantId = getTenantId(servletRequest);
+        servletRequest.setAttribute(StratosConstants.TENANT_ID_SERVLET_ATTR, tenantId);
+
+        return InvocationResponse.CONTINUE;
+    }
+
+    /**
+     * method to get tenant id from MeteredServletRequest
+     * @param servletRequest MeteredServletRequest
+     * @return tenant id
+     */
+
+    private int getTenantId(MeteredServletRequest servletRequest) {
+        String address = servletRequest.getRequestURI();
+        String servicesPrefix = "/services/t/";
+        if (address != null && address.contains(servicesPrefix)) {
+            int domainNameStartIndex =
+                    address.indexOf(servicesPrefix) + servicesPrefix.length();
+            int domainNameEndIndex = address.indexOf('/', domainNameStartIndex);
+            String domainName = address.substring(domainNameStartIndex,
+                    domainNameEndIndex == -1 ? address.length() : domainNameEndIndex);
+
+            // return tenant id if domain name is not null
+            if (domainName != null) {
+                try {
+                    return Util.getRealmService().getTenantManager().getTenantId(domainName);
+                } catch (org.wso2.carbon.user.api.UserStoreException e) {
+                    log.error("An error occurred while obtaining the tenant id.", e);
+                }
+            }
+        }
+
+        // return 0 if the domain name is null
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringModule.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringModule.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringModule.java
new file mode 100644
index 0000000..6d1bb2f
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/axis2/RequestMeteringModule.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.usage.agent.listeners.axis2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public class RequestMeteringModule implements Module {
+
+    public void init(ConfigurationContext configurationContext, AxisModule axisModule)
+            throws AxisFault {
+    }
+
+    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+    }
+
+    public boolean canSupportAssertion(Assertion assertion) {
+        return true;
+    }
+
+    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+    }
+
+    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthPersistor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthPersistor.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthPersistor.java
new file mode 100644
index 0000000..d99fd3c
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthPersistor.java
@@ -0,0 +1,58 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.stratos.common.constants.UsageConstants;
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.util.Util;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+/**
+ * this class is used to store incoming and outgoing bandwidth
+ */
+
+public class BandwidthPersistor {
+
+    /**
+     * method to store incoming bandwidth
+     * @param tenantId tenant id
+     * @param size value of the incoming bandwidth
+     */
+
+    public static void storeIncomingBandwidth(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+
+    /**
+     * method to store outgoingBandwidth
+     * @param tenantId tenant id
+     * @param size value of the outgoing bandwidth
+     */
+    public static void storeOutgoingBandwidth(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthUsageDataRetrievalTask.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
new file mode 100644
index 0000000..8174c07
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
@@ -0,0 +1,114 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.config.UsageAgentConfiguration;
+import org.apache.stratos.usage.agent.util.UsageAgentConstants;
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.apache.stratos.common.constants.UsageConstants;
+import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsContainer;
+import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsEntry;
+import org.wso2.carbon.user.api.UserStoreException;
+
+import java.util.Queue;
+
+public class BandwidthUsageDataRetrievalTask implements Runnable {
+    private static final Log log = LogFactory.getLog(BandwidthUsageDataRetrievalTask.class);
+
+    private Queue<TransportStatisticsEntry> transportStats;
+    private UsageAgentConfiguration configuration;
+
+    //This will be decided based on whether a BAM Server URL is provided or not
+    private boolean isBamAvailable=false;
+
+    public BandwidthUsageDataRetrievalTask(UsageAgentConfiguration configuration) {
+        transportStats = TransportStatisticsContainer.getTransportStatistics();
+        this.configuration = configuration;
+
+        //Checking for the BAM Server URL
+        String bamServerUrl = ServerConfiguration.getInstance().getFirstProperty("BamServerURL");
+        if(bamServerUrl != null){
+            this.isBamAvailable = true;
+        }
+    }
+
+    public void run() {
+        /*if (log.isDebugEnabled()) {
+            log.debug("Retrieving Service and Web App bandwidth usage statistics.");
+        }*/
+
+        if (!transportStats.isEmpty()) {
+            for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !transportStats.isEmpty(); i++) {
+                TransportStatisticsEntry entry = transportStats.remove();
+                try {
+                    if(!isBamAvailable){
+                        return;
+                    }
+
+                    int tenantId = getTenantID(entry.getTenantName());
+                    //if the tenant does not exist, no need and no way of updating the usage data
+                    //therefore ignore it
+                    if(tenantId<0){
+                        return;
+                    }
+                    if (inferMeasurement(entry).equals(UsageConstants.SERVICE_BANDWIDTH)) {
+                        if (entry.getRequestSize() > 0) {
+                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_INCOMING_BW, entry.getRequestSize()));
+                        }
+                        if (entry.getResponseSize() > 0) {
+                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_OUTGOING_BW, entry.getResponseSize()));
+                        }
+                    } else if (inferMeasurement(entry).equals(UsageConstants.WEBAPP_BANDWIDTH)) {
+                        if (entry.getRequestSize() > 0) {
+                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_INCOMING_BW, entry.getRequestSize()));
+                        }
+                        if (entry.getResponseSize() > 0) {
+                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_OUTGOING_BW, entry.getResponseSize()));
+                        }
+                    }
+                } catch (UserStoreException e) {
+                    log.error("Error persisting bandwidth usage statistics.", e);
+                }
+
+            }
+        }
+    }
+
+
+    private String inferMeasurement(TransportStatisticsEntry entry) {
+        if (entry.getContext() != null) {
+            if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_SERVICES_CONTEXT)) {
+                return UsageConstants.SERVICE_BANDWIDTH;
+            } else if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_WEBAPPS_CONTEXT)) {
+                return UsageConstants.WEBAPP_BANDWIDTH;
+            }
+        }
+
+        return UsageAgentConstants.BANDWIDTH_CARBON;
+    }
+
+    private int getTenantID(String tenantDomain) throws UserStoreException {
+        return Util.getRealmService().getTenantManager().getTenantId(tenantDomain);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/RegistryUsagePersister.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/RegistryUsagePersister.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/RegistryUsagePersister.java
new file mode 100644
index 0000000..f56d9b9
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/RegistryUsagePersister.java
@@ -0,0 +1,76 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.stratos.common.constants.UsageConstants;
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.util.Util;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.lang.System;
+
+/**
+ * this class is used to store incoming and outgoing bandwidth
+ */
+
+public class RegistryUsagePersister {
+
+    /**
+     * method to store incoming bandwidth
+     * @param tenantId tenant id
+     * @param size value of the incoming bandwidth
+     */
+
+    public static void storeIncomingBandwidth(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+    //=============================================================
+
+    public static void storeAddContent(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, "ContentBandwidth-In", size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+    public static void storeDeleteContent(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, "ContentBandwidth-Out", size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+   //=============================================================
+    /**
+     * method to store outgoingBandwidth
+     * @param tenantId tenant id
+     * @param size value of the outgoing bandwidth
+     */
+    public static void storeOutgoingBandwidth(int tenantId, long size) {
+        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
+            BandwidthUsage usage = new BandwidthUsage(
+                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/ServiceDataPersistor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/ServiceDataPersistor.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/ServiceDataPersistor.java
new file mode 100644
index 0000000..c7e7fb7
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/ServiceDataPersistor.java
@@ -0,0 +1,72 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
+import org.wso2.carbon.core.transports.metering.MeteredServletResponse;
+import org.wso2.carbon.core.transports.metering.RequestDataPersister;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.common.constants.UsageConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+/**
+ * this class is used to persist service data
+ */
+public class ServiceDataPersistor implements RequestDataPersister {
+    private static final Log log = LogFactory.getLog(ServiceDataPersistor.class);
+
+    /**
+     * this method get tenant id, inDataSize and outDataSize from the wrappedRequest, construct a
+     * BandwidthUsage object and add it to PersistingControllerQueue
+     * @param wrappedRequest  MeteredServletRequest
+     * @param wrappedResponse MeteredServletResponse
+     */
+    public void persist(MeteredServletRequest wrappedRequest, MeteredServletResponse wrappedResponse) {
+        if ("true".equals(wrappedRequest.getAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR))) {
+            return;
+        }
+
+        Integer tenantId = (Integer) wrappedRequest.getAttribute(
+                StratosConstants.TENANT_ID_SERVLET_ATTR);
+        if (tenantId == null || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+            return;
+        }
+        long inDataSize = wrappedRequest.getReadSize();
+        long outDataSize = wrappedResponse.getWrittenSize();
+
+        if(log.isTraceEnabled()){
+            log.trace("Persisting service bandwidth usage for tenant " + tenantId + " in size: " + inDataSize + " out size: " + outDataSize);
+        }
+        // add the job to queue
+        if (inDataSize > 0) {
+            BandwidthUsage usage = new BandwidthUsage(tenantId,
+                    UsageConstants.SERVICE_INCOMING_BW, inDataSize);
+            Util.addToPersistingControllerQueue(usage);
+        }
+        if (outDataSize > 0) {
+            BandwidthUsage usage = new BandwidthUsage(tenantId,
+                    UsageConstants.SERVICE_OUTGOING_BW, outDataSize);
+            Util.addToPersistingControllerQueue(usage);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceManager.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceManager.java
new file mode 100644
index 0000000..5c27e20
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceManager.java
@@ -0,0 +1,91 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.config.UsageAgentConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Queue;
+import java.util.concurrent.*;
+
+public class UsageDataPersistenceManager {
+    private static final Log log = LogFactory.getLog(UsageDataPersistenceManager.class);
+
+    // queue to store Bandwidth usage statistics.
+    // usage of  LinkedBlockingQueue ensures operations on the queue to wait for the queue to be non
+    // empty when retrieving and wait for space when storing element.
+    private Queue<BandwidthUsage> persistenceJobs = new LinkedBlockingQueue<BandwidthUsage>();
+
+    private final ScheduledExecutorService scheduler;
+
+    private UsageAgentConfiguration configuration;
+
+    public UsageDataPersistenceManager(UsageAgentConfiguration configuration) {
+        scheduler = Executors.newScheduledThreadPool(2, new UsageDataPersistenceThreadFactory());
+        this.configuration = configuration;
+    }
+
+    /**
+     * this method add bandwidth usage entries to the jobQueue
+     *
+     * @param usage Bandwidth usage
+     */
+
+    public void addToQueue(BandwidthUsage usage) {
+        persistenceJobs.add(usage);
+    }
+
+    public void scheduleUsageDataPersistenceTask() {
+        //we will schedule the usage data persistence task only if interval is not -1
+        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
+            scheduler.scheduleWithFixedDelay(new UsageDataPersistenceTask(persistenceJobs, configuration),
+                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
+                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
+                    TimeUnit.MILLISECONDS);
+            log.debug("Usage data persistence task was scheduled");
+        }else{
+            log.debug("Usage data persistence task is disabled");
+        }
+    }
+
+
+    public void scheduleBandwidthUsageDataRetrievalTask() {
+        //we will schedule the usage data retrieval task only if interval is not -1
+        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
+            scheduler.scheduleWithFixedDelay(new BandwidthUsageDataRetrievalTask(configuration),
+                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
+                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
+                    TimeUnit.MILLISECONDS);
+            log.debug("Bandwidth Usage data retrieval task was scheduled");
+        }else {
+            log.debug("Bandwidth Usage data retrieval task was disabled");
+        }
+    }
+
+    class UsageDataPersistenceThreadFactory implements ThreadFactory {
+        private int counter = 0;
+
+        public Thread newThread(Runnable r) {
+            return new Thread(r, "UsageDataPersistenceThread-" + counter++);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceTask.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceTask.java
new file mode 100644
index 0000000..59b5a7e
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceTask.java
@@ -0,0 +1,166 @@
+/*
+ *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.usage.agent.persist;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.MultitenantConstants;
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.config.UsageAgentConfiguration;
+import org.apache.stratos.usage.agent.exception.UsageException;
+import org.apache.stratos.usage.agent.util.PublisherUtils;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Queue;
+
+public class UsageDataPersistenceTask implements Runnable {
+
+    private static final Log log = LogFactory.getLog(UsageDataPersistenceTask.class);
+
+    private Queue<BandwidthUsage> usagePersistenceJobs;
+    private UsageAgentConfiguration configuration;
+
+    public UsageDataPersistenceTask(Queue<BandwidthUsage> jobs, UsageAgentConfiguration configuration) {
+        usagePersistenceJobs = jobs;
+        this.configuration = configuration;
+    }
+
+    public void run() {
+        if (!usagePersistenceJobs.isEmpty()) {
+            if (log.isDebugEnabled()) {
+                log.debug("Persisting Service and Web App bandwidth usage statistics");
+            }
+            try {
+                persistUsage(usagePersistenceJobs);
+            } catch (UsageException e) {
+                log.error("Error when persisting usage statistics.", e);
+            }
+        }
+    }
+
+    /**
+     * this method create a Summarizer object for each tenant and call accumulate() method to
+     * accumulate usage statistics
+     *
+     * @param jobQueue usage data persistence jobs
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     *
+     */
+
+    public void persistUsage(Queue<BandwidthUsage> jobQueue) throws UsageException {
+
+        // create a map to hold summarizer objects against tenant id
+        HashMap<Integer, Summarizer> summarizerMap = new HashMap<Integer, Summarizer>();
+
+        // if the jobQueue is not empty
+        for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !jobQueue.isEmpty(); i++) {
+
+            // get the first element from the queue, which is a BandwidthUsage object
+            BandwidthUsage usage = jobQueue.poll();
+
+            // get the tenant id
+            int tenantId = usage.getTenantId();
+
+            //get the Summarizer object corresponds to the tenant id
+            Summarizer summarizer = summarizerMap.get(tenantId);
+
+            // when tenant invoke service for the first time, no corresponding summarizer object in
+            // the map
+            if (summarizer == null) {
+                //create a Summarizer object and put to the summarizerMap
+                summarizer = new Summarizer();
+                summarizerMap.put(tenantId, summarizer);
+            }
+
+            //  now accumulate usage
+            summarizer.accumulate(usage);
+        }
+
+        //Finished accumulating. Now publish the events
+
+        // get the collection view of values in summarizerMap
+        Collection<Summarizer> summarizers = summarizerMap.values();
+
+        // for each summarizer object call the publish method
+        for (Summarizer summarizer : summarizers) {
+            summarizer.publish();
+        }
+    }
+
+    /**
+     * inner class Summarizer
+     * this class is used to accumulate and publish usage statistics.
+     * for each tenant this keeps a map to store BandwidthUsage values
+     */
+    private static class Summarizer {
+        private HashMap<String, BandwidthUsage> usageMap;
+
+        public Summarizer() {
+            usageMap = new HashMap<String, BandwidthUsage>();
+        }
+
+        /**
+         * the method to accumulate usage data
+         *
+         * @param usage BandwidthUsage
+         */
+
+        public void accumulate(BandwidthUsage usage) {
+            // get the measurement name of usage entry
+            String key = usage.getMeasurement();
+
+            // get the existing value of measurement
+            BandwidthUsage existingUsage = usageMap.get(key);
+
+            // if this measurement is metered earlier add the new value to the existing value
+            if (existingUsage != null) {
+                existingUsage.setValue(existingUsage.getValue() + usage.getValue());
+            } else {
+                // if this measurement is not metered previously we need to add it to the usageMap
+                usageMap.put(key, usage);
+            }
+        }
+
+        /**
+         * this method reads usage items from the usageMap and call publish method to publish to
+         * the BAM
+         *
+         * @throws UsageException
+         */
+
+        public void publish() throws UsageException {
+
+            // get the collection view of values in usageMap
+            Collection<BandwidthUsage> usages = usageMap.values();
+
+            for (BandwidthUsage usage : usages) {
+                try {
+                    // publish the usage entry if it is not the super-tenant
+                    if(MultitenantConstants.SUPER_TENANT_ID != usage.getTenantId()){
+                        PublisherUtils.publish(usage);
+                    }
+                } catch (UsageException e) {
+                    log.error("Error in publishing bandwidth usage data", e);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/services/CustomMeteringService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/services/CustomMeteringService.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/services/CustomMeteringService.java
new file mode 100644
index 0000000..dcb6c12
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/services/CustomMeteringService.java
@@ -0,0 +1,95 @@
+/*
+ *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.usage.agent.services;
+
+import org.wso2.carbon.core.AbstractAdmin;
+import org.apache.stratos.usage.agent.api.CustomMeteringAgent;
+import org.apache.stratos.usage.agent.exception.UsageException;
+
+/**
+ *      CustomMeteringService class defines methods to get recorded duration, to check whether
+ *      usage entries exists, persist usage, retrieve usage and add usage.
+ */
+public class CustomMeteringService extends AbstractAdmin {
+
+    /**
+     * method to get recorded durations
+     * @param measurement  the measurement name
+     * @return  duration array
+     * @throws Exception
+     */
+
+    public String[] getRecordedDurations(String measurement) throws Exception {
+        return new CustomMeteringAgent(getGovernanceRegistry()).getRecordedDurations(measurement);
+    }
+
+    /**
+     * method to check whether usage entry exists or not
+     * @param duration  duration
+     * @param measurement measurement name
+     * @return true if usage entry exist
+     * @throws Exception
+     */
+    public boolean isUsageEntryExists( String duration, String measurement)
+            throws Exception {
+        return new CustomMeteringAgent(getGovernanceRegistry()).isUsageEntryExists(duration,
+                measurement);
+    }
+
+    /**
+     * method to persist usage
+     * @param duration
+     * @param measurement measurement name
+     * @param value   value of measurement
+     * @throws Exception
+     */
+    public void persistUsage( String duration, String measurement, String value)
+            throws Exception {
+        new CustomMeteringAgent(getGovernanceRegistry()).persistUsage(duration, measurement, value);
+    }
+
+    /**
+     * method to retrieve usage
+     * @param duration
+     * @param measurement measurement name
+     * @return usage value
+     * @throws UsageException
+     */
+
+    public String retrieveUsage( String duration, String measurement)
+            throws UsageException {
+        return new CustomMeteringAgent(getGovernanceRegistry())
+                .retrieveUsage(duration, measurement);
+    }
+
+    /**
+     * method to add usage entries
+     * @param userName user name
+     * @param duration duration of the measurement
+     * @param measurement measurement name
+     * @param value usage value
+     * @return usage value
+     * @throws Exception
+     */
+    public long addUsage(String userName, String duration, String measurement, long value)
+            throws Exception {
+        return new CustomMeteringAgent(getGovernanceRegistry()).addUsage(duration, measurement,
+                value);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredReader.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredReader.java
new file mode 100644
index 0000000..e61d9b9
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredReader.java
@@ -0,0 +1,50 @@
+/*
+ *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.usage.agent.util;
+
+import java.io.IOException;
+import java.io.Reader;
+
+
+/**
+ * this class is used to wrap the Reader object
+ */
+public class MonitoredReader extends Reader {
+    Reader reader;
+    long totalRead;
+
+    public MonitoredReader(Reader reader) {
+        this.reader = reader;
+        totalRead = 0;
+    }
+
+    public int read(char cbuf[], int off, int len) throws IOException {
+        int read = reader.read(cbuf, off, len);
+        totalRead += read;
+        return read;
+    }
+
+    public void close() throws IOException {
+        reader.close();
+    }
+
+    public long getTotalRead() {
+        return totalRead;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredWriter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredWriter.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredWriter.java
new file mode 100644
index 0000000..307a2e4
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredWriter.java
@@ -0,0 +1,53 @@
+/*
+ *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.usage.agent.util;
+
+import java.io.IOException;
+import java.io.Writer;
+
+
+/**
+ * this class is used to wrap Writer object
+ */
+public class MonitoredWriter extends Writer {
+    Writer writer;
+    long totalWritten;
+
+    public MonitoredWriter(Writer writer) {
+        this.writer = writer;
+        totalWritten = 0;
+    }
+
+    public void write(char cbuf[], int off, int len) throws IOException {
+        totalWritten += (len - off);
+        writer.write(cbuf, off, len);
+    }
+
+    public void flush() throws IOException {
+        writer.flush();
+    }
+
+    public void close() throws IOException {
+        writer.close();
+    }
+
+    public long getTotalWritten() {
+        return totalWritten;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/PublisherUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/PublisherUtils.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/PublisherUtils.java
new file mode 100644
index 0000000..607b30b
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/PublisherUtils.java
@@ -0,0 +1,442 @@
+/*
+ *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.usage.agent.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.databridge.agent.thrift.Agent;
+import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
+import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
+import org.wso2.carbon.databridge.commons.Event;
+import org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException;
+import org.wso2.carbon.statistics.services.util.SystemStatistics;
+import org.apache.stratos.common.util.CommonUtil;
+import org.apache.stratos.usage.agent.exception.UsageException;
+import org.wso2.carbon.user.api.Tenant;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.wso2.carbon.utils.NetworkUtils;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+import org.apache.stratos.usage.agent.beans.APIManagerRequestStats;
+
+import java.math.BigInteger;
+import java.net.MalformedURLException;
+import java.net.SocketException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * this class provide utility methods to publish usage statistics
+ */
+public class PublisherUtils {
+    private static Log log = LogFactory.getLog(PublisherUtils.class);
+    private static final String TRANSPORT = "https";
+    private static ConfigurationContextService configurationContextService;
+    private static Agent agent;
+    private static DataPublisher dataPublisher;
+    private static AsyncDataPublisher asyncDataPublisher;
+    private static String streamId;
+    private static final String usageEventStream = "org.wso2.carbon.usage.agent";
+    private static final String usageEventStreamVersion = "1.0.0";
+    
+    private static final String reqStatEventStream="org.wso2.carbon.service.request.stats";
+    private static final String reqStatEventStreamVersion="1.0.0";
+    private static String reqStatEventStreamId;
+    
+    private static Map<Integer, String> serverUrlMap = new HashMap<Integer, String>();
+
+
+    /**
+     * method to update server name
+     * @param tenantId tenant id
+     * @return server name
+     * @throws UsageException
+     */
+
+    public static String updateServerName(int tenantId) throws UsageException {
+
+        String serverName;
+        String hostName;
+
+        try {
+            hostName = NetworkUtils.getLocalHostname();
+        } catch (SocketException e) {
+            throw new UsageException("Error getting host name for the registry usage event payload",
+                    e);
+        }
+
+        ConfigurationContextService configurationContextService = PublisherUtils.
+                getConfigurationContextService();
+        ConfigurationContext configurationContext;
+        if (configurationContextService != null) {
+            configurationContext = configurationContextService.getServerConfigContext();
+        } else {
+            throw new UsageException("ConfigurationContext is null");
+        }
+//        int port = CarbonUtils.getTransportPort(configurationContext, "https");
+
+        String carbonHttpsPort = System.getProperty("carbon." + TRANSPORT + ".port");
+        if (carbonHttpsPort == null) {
+            carbonHttpsPort = Integer.toString(
+                    CarbonUtils.getTransportPort(configurationContext, TRANSPORT));
+        }
+        String baseServerUrl = TRANSPORT + "://" + hostName + ":" + carbonHttpsPort;
+        String context = configurationContext.getContextRoot();
+
+        String tenantDomain = null;
+        try {
+            Tenant tenant = Util.getRealmService().getTenantManager().getTenant(tenantId);
+            if(tenant!=null){
+                tenantDomain = tenant.getDomain();
+            }
+        } catch (org.wso2.carbon.user.api.UserStoreException e) {
+            throw new UsageException("Failed to get tenant domain", e);
+        }
+
+        if ((tenantDomain != null) &&
+                !(tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) {
+            serverName = baseServerUrl + context + "t/" + tenantDomain;
+
+        } else if (context.equals("/")) {
+
+            serverName = baseServerUrl + "";
+        } else {
+            serverName = baseServerUrl + context;
+
+        }
+
+        return serverName;
+    }
+    
+    public static String getServerUrl(int tenantId){
+
+        String serverUrl = serverUrlMap.get(tenantId);
+        if(serverUrl!=null){
+            return serverUrl;
+        }
+
+        if(serverUrl==null){
+            try{
+                serverUrl = updateServerName(tenantId);
+            }catch (UsageException e) {
+                log.error("Could not create the server url for tenant id: " + tenantId, e);
+            }
+        }
+
+        if(serverUrl!=null && !"".equals(serverUrl)){
+            serverUrlMap.put(tenantId, serverUrl);
+        }
+        return serverUrl;
+    }
+
+    public static void defineUsageEventStream() throws Exception {
+
+        createDataPublisher();
+
+        if(dataPublisher == null){
+            return;
+        }
+
+        try {
+
+            streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
+            log.info("Event stream with stream ID: " + streamId + " found.");
+
+        } catch (NoStreamDefinitionExistException e) {
+
+            log.info("Defining the event stream because it was not found in BAM");
+            try {
+                defineStream();    
+            } catch (Exception ex) {
+                String msg = "An error occurred while defining the even stream for Usage agent. " + e.getMessage();
+                log.warn(msg);
+            }
+
+        }
+
+    }
+    
+    private static void defineStream() throws Exception {
+        streamId = dataPublisher.
+                defineStream("{" +
+                        "  'name':'" + usageEventStream +"'," +
+                        "  'version':'" + usageEventStreamVersion +"'," +
+                        "  'nickName': 'usage.agent'," +
+                        "  'description': 'Tenant usage data'," +
+                        "  'metaData':[" +
+                        "          {'name':'clientType','type':'STRING'}" +
+                        "  ]," +
+                        "  'payloadData':[" +
+                        "          {'name':'ServerName','type':'STRING'}," +
+                        "          {'name':'TenantID','type':'STRING'}," +
+                        "          {'name':'Type','type':'STRING'}," +
+                        "          {'name':'Value','type':'LONG'}" +
+                        "  ]" +
+                        "}");
+        
+    }
+    
+    private static void defineRequestStatEventStream() throws Exception{
+        reqStatEventStreamId = dataPublisher.
+                defineStream("{" +
+                        "  'name':'" + reqStatEventStream +"'," +
+                        "  'version':'" + reqStatEventStreamVersion +"'," +
+                        "  'nickName': 'service.request.stats'," +
+                        "  'description': 'Tenants service request statistics'," +
+                        "  'metaData':[" +
+                        "          {'name':'clientType','type':'STRING'}" +
+                        "  ]," +
+                        "  'payloadData':[" +
+                        "          {'name':'ServerName','type':'STRING'}," +
+                        "          {'name':'TenantID','type':'STRING'}," +
+                        "          {'name':'RequestCount','type':'INT'}," +
+                        "          {'name':'ResponseCount','type':'INT'}," +
+                        "          {'name':'FaultCount','type':'INT'}," +
+                        "          {'name':'ResponseTime','type':'LONG'}" +
+                        "  ]" +
+                        "}");
+    }
+
+    public static void createDataPublisher(){
+
+        ServerConfiguration serverConfig =  CarbonUtils.getServerConfiguration();
+        String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
+        String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
+        String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
+        String adminUsername = CommonUtil.getStratosConfig().getAdminUserName();
+        String adminPassword = CommonUtil.getStratosConfig().getAdminPassword();
+
+        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+        System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+
+        try {
+            dataPublisher = new DataPublisher(bamServerUrl, adminUsername, adminPassword);
+        } catch (Exception e) {
+            log.warn("Unable to create a data publisher to " + bamServerUrl +
+                    ". Usage Agent will not function properly. " + e.getMessage());
+        }
+
+    }
+
+    /**
+     * Creates an async data publisher using the existing data publisher object
+     */
+    public static void createAsynDataPublisher(){
+        if(dataPublisher==null){
+            createDataPublisher();
+        }
+
+        if(dataPublisher==null){
+            log.warn("Cannot create the async data publisher because the data publisher is null");
+            return;
+        }
+
+        try {
+            asyncDataPublisher = new AsyncDataPublisher(dataPublisher);
+        } catch (Exception e) {
+            log.error("Could not create an async data publisher using the data publisher", e);
+        }
+    }
+
+
+    /**
+     * this method get the event payload, construct the SOAP envelop and call the publish method in
+     * EventBrokerService.
+     *
+     * @param usage BandwidthUsage
+     * @throws UsageException
+     */
+    public static void publish(BandwidthUsage usage) throws UsageException {
+
+        if(dataPublisher==null){
+            log.info("Creating data publisher for usage data publishing");
+            createDataPublisher();
+
+            //If we cannot create a data publisher we should give up
+            //this means data will not be published
+            if(dataPublisher == null){
+                return;
+            }
+        }
+
+        if(streamId == null){
+            try{
+                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
+            }catch (NoStreamDefinitionExistException e){
+                log.info("Defining the event stream because it was not found in BAM");
+                try{
+                    defineStream();
+                } catch(Exception ex){
+                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
+                    log.error(msg);
+                    //We do not want to proceed without an event stream. Therefore we return.
+                    return;
+                }
+            }catch (Exception exc){
+                log.error("Error occurred while searching for stream id. " + exc.getMessage());
+                //We do not want to proceed without an event stream. Therefore we return.
+                return;
+            }
+        }
+
+        try {
+
+            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
+                                        new Object[]{getServerUrl(usage.getTenantId()),
+                                                    Integer.toString(usage.getTenantId()),
+                                                    usage.getMeasurement(),
+                                                    usage.getValue()});
+
+            dataPublisher.publish(usageEvent);
+
+        } catch (Exception e) {
+            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
+            throw new UsageException(e.getMessage(), e);
+        }
+
+    }
+    
+    public static void publish(SystemStatistics statistics, int tenantId) throws Exception {
+
+        if(dataPublisher==null){
+            log.info("Creating data publisher for service-stats publishing");
+            createDataPublisher();
+
+            //If we cannot create a data publisher we should give up
+            //this means data will not be published
+            if(dataPublisher == null){
+                return;
+            }
+        }
+
+        if(reqStatEventStreamId == null){
+            try{
+                reqStatEventStreamId = dataPublisher.findStream(reqStatEventStream, reqStatEventStreamVersion);
+            }catch (NoStreamDefinitionExistException e){
+                log.info("Defining the event stream because it was not found in BAM");
+                try{
+                    defineRequestStatEventStream();
+                } catch(Exception ex){
+                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
+                    log.error(msg);
+                    //We do not want to proceed without an event stream. Therefore we return.
+                    return;
+                }
+            }catch (Exception exc){
+                log.error("Error occurred while searching for stream id. " + exc.getMessage());
+                //We do not want to proceed without an event stream. Therefore we return.
+                return;
+            }
+        }
+
+        try {
+
+            Event usageEvent = new Event(reqStatEventStreamId, System.currentTimeMillis(), new Object[]{"external"}, null,
+                    new Object[]{getServerUrl(tenantId),
+                            Integer.toString(tenantId),
+                            statistics.getCurrentInvocationRequestCount(),
+                            statistics.getCurrentInvocationResponseCount(),
+                            statistics.getCurrentInvocationFaultCount(),
+                            statistics.getCurrentInvocationResponseTime()});
+
+            dataPublisher.publish(usageEvent);
+
+        } catch (Exception e) {
+            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
+            throw new UsageException(e.getMessage(), e);
+        }
+
+    }
+
+    /**
+     * @param statistics APIManagerRequestStats which contains usage data
+     * @param tenantId   Tenant id of tenant associated with usage stat
+     * @throws Exception UsageException when error in usage stat publishing
+     */
+    public static void publish(APIManagerRequestStats statistics, int tenantId) throws Exception {
+
+        if (dataPublisher == null) {
+            log.info("Creating data publisher for usage data publishing");
+            createDataPublisher();
+
+            //If we cannot create a data publisher we should give up
+            //this means data will not be published
+            if (dataPublisher == null) {
+                return;
+            }
+        }
+
+        if (streamId == null) {
+            try {
+                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
+            } catch (NoStreamDefinitionExistException e) {
+                log.info("Defining the event stream because it was not found in BAM");
+                try {
+                    defineStream();
+                } catch (Exception ex) {
+                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
+                    log.error(msg);
+                    //We do not want to proceed without an event stream. Therefore we return.
+                    return;
+                }
+            } catch (Exception exc) {
+                log.error("Error occurred while searching for stream id. " + exc.getMessage());
+                //We do not want to proceed without an event stream. Therefore we return.
+                return;
+            }
+        }
+
+        try {
+            //Get data from API manager request stat object and create event
+            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
+                    new Object[]{getServerUrl(statistics.getTenantId()),
+                            Integer.toString(statistics.getTenantId()),
+                            statistics.getMeasurement(),
+                            statistics.getValue()});
+            //publish usage to bam
+            dataPublisher.publish(usageEvent);
+
+        } catch (Exception e) {
+            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
+            throw new UsageException(e.getMessage(), e);
+        }
+
+    }
+
+    /**
+     * method to get configurationContextService
+     * @return configurationContextService
+     */
+
+    public static ConfigurationContextService getConfigurationContextService() {
+        return configurationContextService;
+    }
+
+    /**
+     * method to setConfigurationContextService
+     * @param configurationContextService
+     */
+    public static void setConfigurationContextService(ConfigurationContextService configurationContextService) {
+        PublisherUtils.configurationContextService = configurationContextService;
+    }
+
+}


[20/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
deleted file mode 100644
index 2286516..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.RegistryUsagePersister;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- */
-public class RegistryUsageListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsageListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-        //persisting to registry content addition
-        RegistryUsagePersister.storeAddContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //If metering is disabled, we do not need to register the handler
-        if(!"true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            return;
-        }
-
-        HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsageListener handler = new RegistryUsageListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE, Filter.DELETE};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-    }
-
-    //===========================================================================================
-    public void delete(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getRegistry().get(path.getCompletePath());
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size = 0;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else if (contentObj instanceof String[]) {
-            // of type collection
-            for (String str : (String[]) contentObj) {
-                size += str.length();
-            }
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        RegistryUsagePersister.storeDeleteContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
deleted file mode 100644
index 0e7e75a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.BandwidthPersistor;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- * Currently this handler is not registered because there is a similar handler RegistryUsageHandler
- * After examining properly this class will be deleted.
- */
-public class RegistryUsagePersistingListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsagePersistingListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-     
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //This was commented out because there is a similar class RegistryUsageListener
-        //After examiming properly this class will be deleted
-        /*HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsagePersistingListener handler = new RegistryUsagePersistingListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE,};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-        */
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
deleted file mode 100644
index cd4d2d9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-public class StatisticsInHandler extends AbstractHandler{
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-            return InvocationResponse.CONTINUE;
-        }
-
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-                tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
deleted file mode 100644
index 9e21058..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-
-public class StatisticsOutHandler extends AbstractHandler{
-
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-
-
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-        
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-            tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        PrivilegedCarbonContext.destroyCurrentContext();
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
deleted file mode 100644
index 3c30ed3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver;
-
-
-public class UsageStatsAxis2ConfigurationContextObserver extends AbstractAxis2ConfigurationContextObserver {
-
-    private static final Log log = LogFactory.getLog(UsageStatsAxis2ConfigurationContextObserver.class);
-
-    @Override
-    public void createdConfigurationContext(ConfigurationContext configContext) {
-
-        AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
-        int tenantId = PrivilegedCarbonContext.getCurrentContext().getTenantId(false);
-        try {
-            axisConfiguration.engageModule("metering");
-        } catch (AxisFault axisFault) {
-            log.error("Could not engage metering module for tenant: " + tenantId, axisFault);
-        }
-
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
deleted file mode 100644
index 0eab461..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.usage.agent.util.Util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * this class is used to obtain tenant id from MeteredServletRequest or MessageContext
- */
-
-public class RequestMeteringHandler extends AbstractHandler {
-    private static final Log log = LogFactory.getLog(RequestMeteringHandler.class);
-
-    /**
-     * this method  invoke  MeteredServletRequest and return a InvocationResponse
-     * @param messageContext  MessageContext
-     * @return InvocationResponse
-     * @throws AxisFault
-     */
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        if (log.isDebugEnabled()) {
-            log.debug("Staring metering handler invocation. Incoming message: " +
-                    messageContext.getEnvelope().toString());
-        }
-        AxisService service = messageContext.getAxisService();
-        Parameter param = service.getParameter("adminService");
-
-        Object obj = messageContext.getProperty("transport.http.servletRequest");
-        if (obj == null) {
-            // TODO: check for cause of the error.
-            log.debug("Servlet request is null. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-        if (!(obj instanceof MeteredServletRequest)) {
-            log.debug("HttpServletRequest is not of type MeteredServletRequest. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-
-        MeteredServletRequest servletRequest = (MeteredServletRequest) obj;
-
-        if (param != null && "true".equals(param.getValue())) {
-            servletRequest.setAttribute(StratosConstants.ADMIN_SERVICE_SERVLET_ATTR, "true");
-            return InvocationResponse.CONTINUE;
-        }
-        servletRequest.setAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR, service.getName());
-
-        int tenantId = getTenantId(servletRequest);
-        servletRequest.setAttribute(StratosConstants.TENANT_ID_SERVLET_ATTR, tenantId);
-
-        return InvocationResponse.CONTINUE;
-    }
-
-    /**
-     * method to get tenant id from MeteredServletRequest
-     * @param servletRequest MeteredServletRequest
-     * @return tenant id
-     */
-
-    private int getTenantId(MeteredServletRequest servletRequest) {
-        String address = servletRequest.getRequestURI();
-        String servicesPrefix = "/services/t/";
-        if (address != null && address.contains(servicesPrefix)) {
-            int domainNameStartIndex =
-                    address.indexOf(servicesPrefix) + servicesPrefix.length();
-            int domainNameEndIndex = address.indexOf('/', domainNameStartIndex);
-            String domainName = address.substring(domainNameStartIndex,
-                    domainNameEndIndex == -1 ? address.length() : domainNameEndIndex);
-
-            // return tenant id if domain name is not null
-            if (domainName != null) {
-                try {
-                    return Util.getRealmService().getTenantManager().getTenantId(domainName);
-                } catch (org.wso2.carbon.user.api.UserStoreException e) {
-                    log.error("An error occurred while obtaining the tenant id.", e);
-                }
-            }
-        }
-
-        // return 0 if the domain name is null
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
deleted file mode 100644
index f45b8b5..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisDescription;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.modules.Module;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.Policy;
-
-public class RequestMeteringModule implements Module {
-
-    public void init(ConfigurationContext configurationContext, AxisModule axisModule)
-            throws AxisFault {
-    }
-
-    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public boolean canSupportAssertion(Assertion assertion) {
-        return true;
-    }
-
-    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
deleted file mode 100644
index e52384d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class BandwidthPersistor {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
deleted file mode 100644
index 7824fe8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsContainer;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsEntry;
-import org.wso2.carbon.usage.agent.util.UsageAgentConstants;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.util.Queue;
-
-public class BandwidthUsageDataRetrievalTask implements Runnable {
-    private static final Log log = LogFactory.getLog(BandwidthUsageDataRetrievalTask.class);
-
-    private Queue<TransportStatisticsEntry> transportStats;
-    private UsageAgentConfiguration configuration;
-
-    //This will be decided based on whether a BAM Server URL is provided or not
-    private boolean isBamAvailable=false;
-
-    public BandwidthUsageDataRetrievalTask(UsageAgentConfiguration configuration) {
-        transportStats = TransportStatisticsContainer.getTransportStatistics();
-        this.configuration = configuration;
-
-        //Checking for the BAM Server URL
-        String bamServerUrl = ServerConfiguration.getInstance().getFirstProperty("BamServerURL");
-        if(bamServerUrl != null){
-            this.isBamAvailable = true;
-        }
-    }
-
-    public void run() {
-        /*if (log.isDebugEnabled()) {
-            log.debug("Retrieving Service and Web App bandwidth usage statistics.");
-        }*/
-
-        if (!transportStats.isEmpty()) {
-            for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !transportStats.isEmpty(); i++) {
-                TransportStatisticsEntry entry = transportStats.remove();
-                try {
-                    if(!isBamAvailable){
-                        return;
-                    }
-
-                    int tenantId = getTenantID(entry.getTenantName());
-                    //if the tenant does not exist, no need and no way of updating the usage data
-                    //therefore ignore it
-                    if(tenantId<0){
-                        return;
-                    }
-                    if (inferMeasurement(entry).equals(UsageConstants.SERVICE_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    } else if (inferMeasurement(entry).equals(UsageConstants.WEBAPP_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    }
-                } catch (UserStoreException e) {
-                    log.error("Error persisting bandwidth usage statistics.", e);
-                }
-
-            }
-        }
-    }
-
-
-    private String inferMeasurement(TransportStatisticsEntry entry) {
-        if (entry.getContext() != null) {
-            if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_SERVICES_CONTEXT)) {
-                return UsageConstants.SERVICE_BANDWIDTH;
-            } else if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_WEBAPPS_CONTEXT)) {
-                return UsageConstants.WEBAPP_BANDWIDTH;
-            }
-        }
-
-        return UsageAgentConstants.BANDWIDTH_CARBON;
-    }
-
-    private int getTenantID(String tenantDomain) throws UserStoreException {
-        return Util.getRealmService().getTenantManager().getTenantId(tenantDomain);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
deleted file mode 100644
index 0bd7ab1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.lang.System;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class RegistryUsagePersister {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    //=============================================================
-
-    public static void storeAddContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-In", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    public static void storeDeleteContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-Out", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-   //=============================================================
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
deleted file mode 100644
index 9b0902c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.core.transports.metering.MeteredServletResponse;
-import org.wso2.carbon.core.transports.metering.RequestDataPersister;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to persist service data
- */
-public class ServiceDataPersistor implements RequestDataPersister {
-    private static final Log log = LogFactory.getLog(ServiceDataPersistor.class);
-
-    /**
-     * this method get tenant id, inDataSize and outDataSize from the wrappedRequest, construct a
-     * BandwidthUsage object and add it to PersistingControllerQueue
-     * @param wrappedRequest  MeteredServletRequest
-     * @param wrappedResponse MeteredServletResponse
-     */
-    public void persist(MeteredServletRequest wrappedRequest, MeteredServletResponse wrappedResponse) {
-        if ("true".equals(wrappedRequest.getAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR))) {
-            return;
-        }
-
-        Integer tenantId = (Integer) wrappedRequest.getAttribute(
-                StratosConstants.TENANT_ID_SERVLET_ATTR);
-        if (tenantId == null || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return;
-        }
-        long inDataSize = wrappedRequest.getReadSize();
-        long outDataSize = wrappedResponse.getWrittenSize();
-
-        if(log.isTraceEnabled()){
-            log.trace("Persisting service bandwidth usage for tenant " + tenantId + " in size: " + inDataSize + " out size: " + outDataSize);
-        }
-        // add the job to queue
-        if (inDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_INCOMING_BW, inDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-        if (outDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_OUTGOING_BW, outDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
deleted file mode 100644
index 5cf4491..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-
-import java.util.Queue;
-import java.util.concurrent.*;
-
-public class UsageDataPersistenceManager {
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceManager.class);
-
-    // queue to store Bandwidth usage statistics.
-    // usage of  LinkedBlockingQueue ensures operations on the queue to wait for the queue to be non
-    // empty when retrieving and wait for space when storing element.
-    private Queue<BandwidthUsage> persistenceJobs = new LinkedBlockingQueue<BandwidthUsage>();
-
-    private final ScheduledExecutorService scheduler;
-
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceManager(UsageAgentConfiguration configuration) {
-        scheduler = Executors.newScheduledThreadPool(2, new UsageDataPersistenceThreadFactory());
-        this.configuration = configuration;
-    }
-
-    /**
-     * this method add bandwidth usage entries to the jobQueue
-     *
-     * @param usage Bandwidth usage
-     */
-
-    public void addToQueue(BandwidthUsage usage) {
-        persistenceJobs.add(usage);
-    }
-
-    public void scheduleUsageDataPersistenceTask() {
-        //we will schedule the usage data persistence task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new UsageDataPersistenceTask(persistenceJobs, configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Usage data persistence task was scheduled");
-        }else{
-            log.debug("Usage data persistence task is disabled");
-        }
-    }
-
-
-    public void scheduleBandwidthUsageDataRetrievalTask() {
-        //we will schedule the usage data retrieval task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new BandwidthUsageDataRetrievalTask(configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Bandwidth Usage data retrieval task was scheduled");
-        }else {
-            log.debug("Bandwidth Usage data retrieval task was disabled");
-        }
-    }
-
-    class UsageDataPersistenceThreadFactory implements ThreadFactory {
-        private int counter = 0;
-
-        public Thread newThread(Runnable r) {
-            return new Thread(r, "UsageDataPersistenceThread-" + counter++);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
deleted file mode 100644
index 64f3b0a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.MultitenantConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Queue;
-
-public class UsageDataPersistenceTask implements Runnable {
-
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceTask.class);
-
-    private Queue<BandwidthUsage> usagePersistenceJobs;
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceTask(Queue<BandwidthUsage> jobs, UsageAgentConfiguration configuration) {
-        usagePersistenceJobs = jobs;
-        this.configuration = configuration;
-    }
-
-    public void run() {
-        if (!usagePersistenceJobs.isEmpty()) {
-            if (log.isDebugEnabled()) {
-                log.debug("Persisting Service and Web App bandwidth usage statistics");
-            }
-            try {
-                persistUsage(usagePersistenceJobs);
-            } catch (UsageException e) {
-                log.error("Error when persisting usage statistics.", e);
-            }
-        }
-    }
-
-    /**
-     * this method create a Summarizer object for each tenant and call accumulate() method to
-     * accumulate usage statistics
-     *
-     * @param jobQueue usage data persistence jobs
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     *
-     */
-
-    public void persistUsage(Queue<BandwidthUsage> jobQueue) throws UsageException {
-
-        // create a map to hold summarizer objects against tenant id
-        HashMap<Integer, Summarizer> summarizerMap = new HashMap<Integer, Summarizer>();
-
-        // if the jobQueue is not empty
-        for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !jobQueue.isEmpty(); i++) {
-
-            // get the first element from the queue, which is a BandwidthUsage object
-            BandwidthUsage usage = jobQueue.poll();
-
-            // get the tenant id
-            int tenantId = usage.getTenantId();
-
-            //get the Summarizer object corresponds to the tenant id
-            Summarizer summarizer = summarizerMap.get(tenantId);
-
-            // when tenant invoke service for the first time, no corresponding summarizer object in
-            // the map
-            if (summarizer == null) {
-                //create a Summarizer object and put to the summarizerMap
-                summarizer = new Summarizer();
-                summarizerMap.put(tenantId, summarizer);
-            }
-
-            //  now accumulate usage
-            summarizer.accumulate(usage);
-        }
-
-        //Finished accumulating. Now publish the events
-
-        // get the collection view of values in summarizerMap
-        Collection<Summarizer> summarizers = summarizerMap.values();
-
-        // for each summarizer object call the publish method
-        for (Summarizer summarizer : summarizers) {
-            summarizer.publish();
-        }
-    }
-
-    /**
-     * inner class Summarizer
-     * this class is used to accumulate and publish usage statistics.
-     * for each tenant this keeps a map to store BandwidthUsage values
-     */
-    private static class Summarizer {
-        private HashMap<String, BandwidthUsage> usageMap;
-
-        public Summarizer() {
-            usageMap = new HashMap<String, BandwidthUsage>();
-        }
-
-        /**
-         * the method to accumulate usage data
-         *
-         * @param usage BandwidthUsage
-         */
-
-        public void accumulate(BandwidthUsage usage) {
-            // get the measurement name of usage entry
-            String key = usage.getMeasurement();
-
-            // get the existing value of measurement
-            BandwidthUsage existingUsage = usageMap.get(key);
-
-            // if this measurement is metered earlier add the new value to the existing value
-            if (existingUsage != null) {
-                existingUsage.setValue(existingUsage.getValue() + usage.getValue());
-            } else {
-                // if this measurement is not metered previously we need to add it to the usageMap
-                usageMap.put(key, usage);
-            }
-        }
-
-        /**
-         * this method reads usage items from the usageMap and call publish method to publish to
-         * the BAM
-         *
-         * @throws UsageException
-         */
-
-        public void publish() throws UsageException {
-
-            // get the collection view of values in usageMap
-            Collection<BandwidthUsage> usages = usageMap.values();
-
-            for (BandwidthUsage usage : usages) {
-                try {
-                    // publish the usage entry if it is not the super-tenant
-                    if(MultitenantConstants.SUPER_TENANT_ID != usage.getTenantId()){
-                        PublisherUtils.publish(usage);
-                    }
-                } catch (UsageException e) {
-                    log.error("Error in publishing bandwidth usage data", e);
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
deleted file mode 100644
index 23e684d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.services;
-
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.usage.agent.api.CustomMeteringAgent;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *      CustomMeteringService class defines methods to get recorded duration, to check whether
- *      usage entries exists, persist usage, retrieve usage and add usage.
- */
-public class CustomMeteringService extends AbstractAdmin {
-
-    /**
-     * method to get recorded durations
-     * @param measurement  the measurement name
-     * @return  duration array
-     * @throws Exception
-     */
-
-    public String[] getRecordedDurations(String measurement) throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).getRecordedDurations(measurement);
-    }
-
-    /**
-     * method to check whether usage entry exists or not
-     * @param duration  duration
-     * @param measurement measurement name
-     * @return true if usage entry exist
-     * @throws Exception
-     */
-    public boolean isUsageEntryExists( String duration, String measurement)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).isUsageEntryExists(duration,
-                measurement);
-    }
-
-    /**
-     * method to persist usage
-     * @param duration
-     * @param measurement measurement name
-     * @param value   value of measurement
-     * @throws Exception
-     */
-    public void persistUsage( String duration, String measurement, String value)
-            throws Exception {
-        new CustomMeteringAgent(getGovernanceRegistry()).persistUsage(duration, measurement, value);
-    }
-
-    /**
-     * method to retrieve usage
-     * @param duration
-     * @param measurement measurement name
-     * @return usage value
-     * @throws UsageException
-     */
-
-    public String retrieveUsage( String duration, String measurement)
-            throws UsageException {
-        return new CustomMeteringAgent(getGovernanceRegistry())
-                .retrieveUsage(duration, measurement);
-    }
-
-    /**
-     * method to add usage entries
-     * @param userName user name
-     * @param duration duration of the measurement
-     * @param measurement measurement name
-     * @param value usage value
-     * @return usage value
-     * @throws Exception
-     */
-    public long addUsage(String userName, String duration, String measurement, long value)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).addUsage(duration, measurement,
-                value);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
deleted file mode 100644
index 821ed82..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * this class is used to wrap the Reader object
- */
-public class MonitoredReader extends Reader {
-    Reader reader;
-    long totalRead;
-
-    public MonitoredReader(Reader reader) {
-        this.reader = reader;
-        totalRead = 0;
-    }
-
-    public int read(char cbuf[], int off, int len) throws IOException {
-        int read = reader.read(cbuf, off, len);
-        totalRead += read;
-        return read;
-    }
-
-    public void close() throws IOException {
-        reader.close();
-    }
-
-    public long getTotalRead() {
-        return totalRead;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
deleted file mode 100644
index 856fd18..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Writer;
-
-
-/**
- * this class is used to wrap Writer object
- */
-public class MonitoredWriter extends Writer {
-    Writer writer;
-    long totalWritten;
-
-    public MonitoredWriter(Writer writer) {
-        this.writer = writer;
-        totalWritten = 0;
-    }
-
-    public void write(char cbuf[], int off, int len) throws IOException {
-        totalWritten += (len - off);
-        writer.write(cbuf, off, len);
-    }
-
-    public void flush() throws IOException {
-        writer.flush();
-    }
-
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    public long getTotalWritten() {
-        return totalWritten;
-    }
-}


[27/27] git commit: aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
aplying 0001-Refactor-usage-module-to-apache-stratos.patch


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

Branch: refs/heads/master
Commit: df3475cc59da8f911164fda97871654f5beb0e35
Parents: 99508a5
Author: Lakmal Warusawithana <la...@wso2.com>
Authored: Thu Jul 11 10:47:20 2013 +0530
Committer: Lakmal Warusawithana <la...@wso2.com>
Committed: Thu Jul 11 10:47:20 2013 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.usage.agent/pom.xml      | 146 +++++
 .../usage/agent/api/CustomMeteringAgent.java    | 223 +++++++
 .../agent/beans/APIManagerRequestStats.java     |  98 +++
 .../usage/agent/beans/BandwidthUsage.java       |  60 ++
 .../agent/config/UsageAgentConfiguration.java   | 119 ++++
 .../usage/agent/exception/UsageException.java   |  31 +
 .../internal/UsageAgentServiceComponent.java    | 202 ++++++
 .../agent/listeners/RegistryUsageListener.java  | 365 +++++++++++
 .../RegistryUsagePersistingListener.java        | 311 +++++++++
 .../agent/listeners/StatisticsInHandler.java    |  73 +++
 .../agent/listeners/StatisticsOutHandler.java   |  83 +++
 ...eStatsAxis2ConfigurationContextObserver.java |  48 ++
 .../listeners/axis2/RequestMeteringHandler.java | 109 ++++
 .../listeners/axis2/RequestMeteringModule.java  |  47 ++
 .../usage/agent/persist/BandwidthPersistor.java |  58 ++
 .../BandwidthUsageDataRetrievalTask.java        | 114 ++++
 .../agent/persist/RegistryUsagePersister.java   |  76 +++
 .../agent/persist/ServiceDataPersistor.java     |  72 +++
 .../persist/UsageDataPersistenceManager.java    |  91 +++
 .../agent/persist/UsageDataPersistenceTask.java | 166 +++++
 .../agent/services/CustomMeteringService.java   |  95 +++
 .../usage/agent/util/MonitoredReader.java       |  50 ++
 .../usage/agent/util/MonitoredWriter.java       |  53 ++
 .../usage/agent/util/PublisherUtils.java        | 442 +++++++++++++
 .../usage/agent/util/UsageAgentConstants.java   |  52 ++
 .../apache/stratos/usage/agent/util/Util.java   | 178 +++++
 .../src/main/resources/META-INF/component.xml   |  36 ++
 .../src/main/resources/META-INF/module.xml      |  51 ++
 .../src/main/resources/META-INF/services.xml    |  32 +
 .../META-INF/usage-throttling-agent-config.xml  |  33 +
 .../pom.xml                                     | 139 ++++
 .../DailyCartridgeStatsSummarizerHelper.java    |  58 ++
 .../DailyServiceStatsSummarizerHelper.java      |  58 ++
 .../summary/helper/DailySummarizerHelper.java   |  58 ++
 .../HourlyCartridgeStatsSummarizerHelper.java   |  55 ++
 .../HourlyServiceStatsSummarizerHelper.java     |  55 ++
 .../summary/helper/HourlySummarizerHelper.java  |  55 ++
 .../MonthlyCartridgeStatsSummarizerHelper.java  |  60 ++
 .../MonthlyServiceStatsSummarizerHelper.java    |  60 ++
 .../summary/helper/MonthlySummarizerHelper.java |  60 ++
 .../UsageSummaryHelperServiceComponent.java     |  84 +++
 .../summary/helper/util/DataAccessObject.java   | 399 ++++++++++++
 .../usage/summary/helper/util/DataHolder.java   |  50 ++
 components/org.apache.stratos.usage.ui/pom.xml  | 138 ++++
 .../usage/ui/clients/UsageServiceClient.java    | 116 ++++
 .../usage/ui/report/AllTenantUsageData.java     |  96 +++
 .../usage/ui/report/AllTenantUsageReport.java   | 110 ++++
 .../stratos/usage/ui/report/UsageReport.java    | 195 ++++++
 .../stratos/usage/ui/utils/UsageUtil.java       | 251 ++++++++
 .../src/main/resources/META-INF/component.xml   |  74 +++
 .../src/main/resources/UsageService.wsdl        | 605 +++++++++++++++++
 .../carbon/usage/ui/i18n/JSResources.properties |   2 +
 .../carbon/usage/ui/i18n/Resources.properties   |  57 ++
 .../tenant-usage/all_tenant_instance_usage.jsp  | 217 +++++++
 .../web/tenant-usage/all_tenant_usage.jsp       | 209 ++++++
 .../tenant-usage/all_tenant_usage_report.jsp    |  26 +
 .../web/tenant-usage/any_tenant_usage.jsp       | 463 +++++++++++++
 .../web/tenant-usage/css/tenant-usage.css       |  28 +
 .../web/tenant-usage/docs/images/view-usage.png | Bin 0 -> 61024 bytes
 .../web/tenant-usage/docs/userguide.html        |  78 +++
 .../images/instance-usage-report.gif            | Bin 0 -> 849 bytes
 .../tenant-usage/images/tenant-usage-report.gif | Bin 0 -> 1008 bytes
 .../tenant-usage/images/user-usage-report.gif   | Bin 0 -> 1033 bytes
 .../tenant-usage/js/all-tenant-usage-report.js  |  49 ++
 .../web/tenant-usage/js/tenant-usage.js         |   7 +
 .../web/tenant-usage/js/usage-report.js         |  48 ++
 .../resources/web/tenant-usage/tenant_usage.jsp | 475 ++++++++++++++
 .../resources/web/tenant-usage/usage_report.jsp |  29 +
 components/org.apache.stratos.usage/pom.xml     | 146 +++++
 .../stratos/usage/api/TenantUsageRetriever.java | 607 ++++++++++++++++++
 .../usage/beans/APIManagerUsageStats.java       |  72 +++
 .../usage/beans/BandwidthStatistics.java        |  65 ++
 .../usage/beans/CartridgeStatistics.java        |  59 ++
 .../usage/beans/InstanceUsageStatics.java       |  91 +++
 .../usage/beans/PaginatedInstanceUsage.java     |  59 ++
 .../usage/beans/PaginatedTenantUsageInfo.java   |  47 ++
 .../stratos/usage/beans/RequestStatistics.java  |  63 ++
 .../stratos/usage/beans/TenantDataCapacity.java |  55 ++
 .../apache/stratos/usage/beans/TenantUsage.java | 219 +++++++
 .../apache/stratos/usage/beans/UsageEntry.java  |  49 ++
 .../usage/internal/UsageServiceComponent.java   | 101 +++
 .../stratos/usage/services/UsageService.java    | 204 ++++++
 .../stratos/usage/util/DataAccessObject.java    | 642 +++++++++++++++++++
 .../org/apache/stratos/usage/util/Util.java     | 108 ++++
 .../src/main/resources/META-INF/component.xml   |  48 ++
 .../src/main/resources/META-INF/services.xml    |  49 ++
 .../reports/all_tenant_usage_report.jrxml       | 137 ++++
 .../main/resources/reports/usage_report.jrxml   | 135 ++++
 .../org.wso2.carbon.usage.agent/2.1.0/pom.xml   | 141 ----
 .../usage/agent/api/CustomMeteringAgent.java    | 222 -------
 .../usage/agent/beans/BandwidthUsage.java       |  60 --
 .../agent/config/UsageAgentConfiguration.java   | 116 ----
 .../usage/agent/exception/UsageException.java   |  28 -
 .../internal/UsageAgentServiceComponent.java    | 204 ------
 .../agent/listeners/RegistryUsageListener.java  | 362 -----------
 .../RegistryUsagePersistingListener.java        | 312 ---------
 .../agent/listeners/StatisticsInHandler.java    |  56 --
 .../agent/listeners/StatisticsOutHandler.java   |  67 --
 ...eStatsAxis2ConfigurationContextObserver.java |  31 -
 .../listeners/axis2/RequestMeteringHandler.java | 108 ----
 .../listeners/axis2/RequestMeteringModule.java  |  44 --
 .../usage/agent/persist/BandwidthPersistor.java |  55 --
 .../BandwidthUsageDataRetrievalTask.java        | 115 ----
 .../agent/persist/RegistryUsagePersister.java   |  73 ---
 .../agent/persist/ServiceDataPersistor.java     |  69 --
 .../persist/UsageDataPersistenceManager.java    |  88 ---
 .../agent/persist/UsageDataPersistenceTask.java | 163 -----
 .../agent/services/CustomMeteringService.java   |  92 ---
 .../usage/agent/util/MonitoredReader.java       |  47 --
 .../usage/agent/util/MonitoredWriter.java       |  50 --
 .../carbon/usage/agent/util/PublisherUtils.java | 395 ------------
 .../usage/agent/util/UsageAgentConstants.java   |  49 --
 .../org/wso2/carbon/usage/agent/util/Util.java  | 175 -----
 .../src/main/resources/META-INF/component.xml   |  33 -
 .../src/main/resources/META-INF/module.xml      |  50 --
 .../src/main/resources/META-INF/services.xml    |  30 -
 .../META-INF/usage-throttling-agent-config.xml  |  15 -
 .../org.wso2.carbon.usage.agent/2.1.1/pom.xml   | 143 -----
 .../usage/agent/api/CustomMeteringAgent.java    | 222 -------
 .../agent/beans/APIManagerRequestStats.java     |  97 ---
 .../usage/agent/beans/BandwidthUsage.java       |  60 --
 .../agent/config/UsageAgentConfiguration.java   | 116 ----
 .../usage/agent/exception/UsageException.java   |  28 -
 .../internal/UsageAgentServiceComponent.java    | 204 ------
 .../agent/listeners/RegistryUsageListener.java  | 362 -----------
 .../RegistryUsagePersistingListener.java        | 312 ---------
 .../agent/listeners/StatisticsInHandler.java    |  56 --
 .../agent/listeners/StatisticsOutHandler.java   |  67 --
 ...eStatsAxis2ConfigurationContextObserver.java |  31 -
 .../listeners/axis2/RequestMeteringHandler.java | 108 ----
 .../listeners/axis2/RequestMeteringModule.java  |  44 --
 .../usage/agent/persist/BandwidthPersistor.java |  55 --
 .../BandwidthUsageDataRetrievalTask.java        | 115 ----
 .../agent/persist/RegistryUsagePersister.java   |  73 ---
 .../agent/persist/ServiceDataPersistor.java     |  69 --
 .../persist/UsageDataPersistenceManager.java    |  88 ---
 .../agent/persist/UsageDataPersistenceTask.java | 163 -----
 .../agent/services/CustomMeteringService.java   |  92 ---
 .../usage/agent/util/MonitoredReader.java       |  47 --
 .../usage/agent/util/MonitoredWriter.java       |  50 --
 .../carbon/usage/agent/util/PublisherUtils.java | 451 -------------
 .../usage/agent/util/UsageAgentConstants.java   |  49 --
 .../org/wso2/carbon/usage/agent/util/Util.java  | 175 -----
 .../src/main/resources/META-INF/component.xml   |  33 -
 .../src/main/resources/META-INF/module.xml      |  50 --
 .../src/main/resources/META-INF/services.xml    |  30 -
 .../META-INF/usage-throttling-agent-config.xml  |  15 -
 .../org.wso2.carbon.usage.agent/2.1.2/pom.xml   | 144 -----
 .../usage/agent/api/CustomMeteringAgent.java    | 222 -------
 .../agent/beans/APIManagerRequestStats.java     |  97 ---
 .../usage/agent/beans/BandwidthUsage.java       |  60 --
 .../agent/config/UsageAgentConfiguration.java   | 116 ----
 .../usage/agent/exception/UsageException.java   |  28 -
 .../internal/UsageAgentServiceComponent.java    | 204 ------
 .../agent/listeners/RegistryUsageListener.java  | 362 -----------
 .../RegistryUsagePersistingListener.java        | 312 ---------
 .../agent/listeners/StatisticsInHandler.java    |  56 --
 .../agent/listeners/StatisticsOutHandler.java   |  67 --
 ...eStatsAxis2ConfigurationContextObserver.java |  31 -
 .../listeners/axis2/RequestMeteringHandler.java | 108 ----
 .../listeners/axis2/RequestMeteringModule.java  |  44 --
 .../usage/agent/persist/BandwidthPersistor.java |  55 --
 .../BandwidthUsageDataRetrievalTask.java        | 115 ----
 .../agent/persist/RegistryUsagePersister.java   |  73 ---
 .../agent/persist/ServiceDataPersistor.java     |  69 --
 .../persist/UsageDataPersistenceManager.java    |  88 ---
 .../agent/persist/UsageDataPersistenceTask.java | 163 -----
 .../agent/services/CustomMeteringService.java   |  92 ---
 .../usage/agent/util/MonitoredReader.java       |  47 --
 .../usage/agent/util/MonitoredWriter.java       |  50 --
 .../carbon/usage/agent/util/PublisherUtils.java | 451 -------------
 .../usage/agent/util/UsageAgentConstants.java   |  49 --
 .../org/wso2/carbon/usage/agent/util/Util.java  | 175 -----
 .../src/main/resources/META-INF/component.xml   |  33 -
 .../src/main/resources/META-INF/module.xml      |  50 --
 .../src/main/resources/META-INF/services.xml    |  30 -
 .../META-INF/usage-throttling-agent-config.xml  |  15 -
 .../2.1.0/pom.xml                               | 136 ----
 .../DailyServiceStatsSummarizerHelper.java      |  57 --
 .../summary/helper/DailySummarizerHelper.java   |  57 --
 .../HourlyServiceStatsSummarizerHelper.java     |  54 --
 .../summary/helper/HourlySummarizerHelper.java  |  54 --
 .../MonthlyServiceStatsSummarizerHelper.java    |  59 --
 .../summary/helper/MonthlySummarizerHelper.java |  59 --
 .../UsageSummaryHelperServiceComponent.java     |  83 ---
 .../summary/helper/util/DataAccessObject.java   | 291 ---------
 .../usage/summary/helper/util/DataHolder.java   |  50 --
 .../2.1.3/pom.xml                               | 136 ----
 .../DailyCartridgeStatsSummarizerHelper.java    |  57 --
 .../DailyServiceStatsSummarizerHelper.java      |  57 --
 .../summary/helper/DailySummarizerHelper.java   |  57 --
 .../HourlyCartridgeStatsSummarizerHelper.java   |  54 --
 .../HourlyServiceStatsSummarizerHelper.java     |  54 --
 .../summary/helper/HourlySummarizerHelper.java  |  54 --
 .../MonthlyCartridgeStatsSummarizerHelper.java  |  59 --
 .../MonthlyServiceStatsSummarizerHelper.java    |  59 --
 .../summary/helper/MonthlySummarizerHelper.java |  59 --
 .../UsageSummaryHelperServiceComponent.java     |  83 ---
 .../summary/helper/util/DataAccessObject.java   | 399 ------------
 .../usage/summary/helper/util/DataHolder.java   |  50 --
 .../org.wso2.carbon.usage.ui/2.1.0/pom.xml      | 130 ----
 .../usage/ui/clients/UsageServiceClient.java    | 115 ----
 .../usage/ui/report/AllTenantUsageData.java     |  93 ---
 .../usage/ui/report/AllTenantUsageReport.java   | 110 ----
 .../carbon/usage/ui/report/UsageReport.java     | 194 ------
 .../wso2/carbon/usage/ui/utils/UsageUtil.java   | 245 -------
 .../src/main/resources/META-INF/component.xml   |  73 ---
 .../2.1.0/src/main/resources/UsageService.wsdl  | 604 -----------------
 .../carbon/usage/ui/i18n/JSResources.properties |   2 -
 .../carbon/usage/ui/i18n/Resources.properties   |  51 --
 .../tenant-usage/all_tenant_instance_usage.jsp  | 216 -------
 .../web/tenant-usage/all_tenant_usage.jsp       | 208 ------
 .../tenant-usage/all_tenant_usage_report.jsp    |  25 -
 .../web/tenant-usage/any_tenant_usage.jsp       | 390 -----------
 .../web/tenant-usage/css/tenant-usage.css       |  28 -
 .../web/tenant-usage/docs/images/view-usage.png | Bin 61024 -> 0 bytes
 .../web/tenant-usage/docs/userguide.html        |  77 ---
 .../images/instance-usage-report.gif            | Bin 849 -> 0 bytes
 .../tenant-usage/images/tenant-usage-report.gif | Bin 1008 -> 0 bytes
 .../tenant-usage/images/user-usage-report.gif   | Bin 1033 -> 0 bytes
 .../tenant-usage/js/all-tenant-usage-report.js  |  49 --
 .../web/tenant-usage/js/tenant-usage.js         |   7 -
 .../web/tenant-usage/js/usage-report.js         |  48 --
 .../resources/web/tenant-usage/tenant_usage.jsp | 408 ------------
 .../resources/web/tenant-usage/usage_report.jsp |  28 -
 .../org.wso2.carbon.usage.ui/2.1.1/pom.xml      | 130 ----
 .../usage/ui/clients/UsageServiceClient.java    | 115 ----
 .../usage/ui/report/AllTenantUsageData.java     |  93 ---
 .../usage/ui/report/AllTenantUsageReport.java   | 110 ----
 .../carbon/usage/ui/report/UsageReport.java     | 194 ------
 .../wso2/carbon/usage/ui/utils/UsageUtil.java   | 251 --------
 .../src/main/resources/META-INF/component.xml   |  73 ---
 .../2.1.1/src/main/resources/UsageService.wsdl  | 604 -----------------
 .../carbon/usage/ui/i18n/JSResources.properties |   2 -
 .../carbon/usage/ui/i18n/Resources.properties   |  53 --
 .../tenant-usage/all_tenant_instance_usage.jsp  | 216 -------
 .../web/tenant-usage/all_tenant_usage.jsp       | 208 ------
 .../tenant-usage/all_tenant_usage_report.jsp    |  25 -
 .../web/tenant-usage/any_tenant_usage.jsp       | 414 ------------
 .../web/tenant-usage/css/tenant-usage.css       |  28 -
 .../web/tenant-usage/docs/images/view-usage.png | Bin 61024 -> 0 bytes
 .../web/tenant-usage/docs/userguide.html        |  77 ---
 .../images/instance-usage-report.gif            | Bin 849 -> 0 bytes
 .../tenant-usage/images/tenant-usage-report.gif | Bin 1008 -> 0 bytes
 .../tenant-usage/images/user-usage-report.gif   | Bin 1033 -> 0 bytes
 .../tenant-usage/js/all-tenant-usage-report.js  |  49 --
 .../web/tenant-usage/js/tenant-usage.js         |   7 -
 .../web/tenant-usage/js/usage-report.js         |  48 --
 .../resources/web/tenant-usage/tenant_usage.jsp | 427 ------------
 .../resources/web/tenant-usage/usage_report.jsp |  28 -
 .../org.wso2.carbon.usage.ui/2.1.2/pom.xml      | 131 ----
 .../usage/ui/clients/UsageServiceClient.java    | 115 ----
 .../usage/ui/report/AllTenantUsageData.java     |  93 ---
 .../usage/ui/report/AllTenantUsageReport.java   | 110 ----
 .../carbon/usage/ui/report/UsageReport.java     | 194 ------
 .../wso2/carbon/usage/ui/utils/UsageUtil.java   | 251 --------
 .../src/main/resources/META-INF/component.xml   |  73 ---
 .../2.1.2/src/main/resources/UsageService.wsdl  | 604 -----------------
 .../carbon/usage/ui/i18n/JSResources.properties |   2 -
 .../carbon/usage/ui/i18n/Resources.properties   |  53 --
 .../tenant-usage/all_tenant_instance_usage.jsp  | 216 -------
 .../web/tenant-usage/all_tenant_usage.jsp       | 208 ------
 .../tenant-usage/all_tenant_usage_report.jsp    |  25 -
 .../web/tenant-usage/any_tenant_usage.jsp       | 414 ------------
 .../web/tenant-usage/css/tenant-usage.css       |  28 -
 .../web/tenant-usage/docs/images/view-usage.png | Bin 61024 -> 0 bytes
 .../web/tenant-usage/docs/userguide.html        |  77 ---
 .../images/instance-usage-report.gif            | Bin 849 -> 0 bytes
 .../tenant-usage/images/tenant-usage-report.gif | Bin 1008 -> 0 bytes
 .../tenant-usage/images/user-usage-report.gif   | Bin 1033 -> 0 bytes
 .../tenant-usage/js/all-tenant-usage-report.js  |  49 --
 .../web/tenant-usage/js/tenant-usage.js         |   7 -
 .../web/tenant-usage/js/usage-report.js         |  48 --
 .../resources/web/tenant-usage/tenant_usage.jsp | 427 ------------
 .../resources/web/tenant-usage/usage_report.jsp |  28 -
 .../org.wso2.carbon.usage.ui/2.1.3/pom.xml      | 131 ----
 .../usage/ui/clients/UsageServiceClient.java    | 115 ----
 .../usage/ui/report/AllTenantUsageData.java     |  93 ---
 .../usage/ui/report/AllTenantUsageReport.java   | 110 ----
 .../carbon/usage/ui/report/UsageReport.java     | 194 ------
 .../wso2/carbon/usage/ui/utils/UsageUtil.java   | 251 --------
 .../src/main/resources/META-INF/component.xml   |  73 ---
 .../2.1.3/src/main/resources/UsageService.wsdl  | 604 -----------------
 .../carbon/usage/ui/i18n/JSResources.properties |   2 -
 .../carbon/usage/ui/i18n/Resources.properties   |  57 --
 .../tenant-usage/all_tenant_instance_usage.jsp  | 216 -------
 .../web/tenant-usage/all_tenant_usage.jsp       | 208 ------
 .../tenant-usage/all_tenant_usage_report.jsp    |  25 -
 .../web/tenant-usage/any_tenant_usage.jsp       | 462 -------------
 .../web/tenant-usage/css/tenant-usage.css       |  28 -
 .../web/tenant-usage/docs/images/view-usage.png | Bin 61024 -> 0 bytes
 .../web/tenant-usage/docs/userguide.html        |  77 ---
 .../images/instance-usage-report.gif            | Bin 849 -> 0 bytes
 .../tenant-usage/images/tenant-usage-report.gif | Bin 1008 -> 0 bytes
 .../tenant-usage/images/user-usage-report.gif   | Bin 1033 -> 0 bytes
 .../tenant-usage/js/all-tenant-usage-report.js  |  49 --
 .../web/tenant-usage/js/tenant-usage.js         |   7 -
 .../web/tenant-usage/js/usage-report.js         |  48 --
 .../resources/web/tenant-usage/tenant_usage.jsp | 474 --------------
 .../resources/web/tenant-usage/usage_report.jsp |  28 -
 .../usage/org.wso2.carbon.usage/2.1.0/pom.xml   | 142 ----
 .../carbon/usage/api/TenantUsageRetriever.java  | 435 -------------
 .../carbon/usage/beans/BandwidthStatistics.java |  62 --
 .../usage/beans/InstanceUsageStatics.java       |  90 ---
 .../usage/beans/PaginatedInstanceUsage.java     |  58 --
 .../usage/beans/PaginatedTenantUsageInfo.java   |  46 --
 .../carbon/usage/beans/RequestStatistics.java   |  60 --
 .../carbon/usage/beans/TenantDataCapacity.java  |  52 --
 .../wso2/carbon/usage/beans/TenantUsage.java    | 190 ------
 .../org/wso2/carbon/usage/beans/UsageEntry.java |  46 --
 .../usage/internal/UsageServiceComponent.java   | 103 ---
 .../carbon/usage/services/UsageService.java     | 203 ------
 .../carbon/usage/util/DataAccessObject.java     | 358 -----------
 .../java/org/wso2/carbon/usage/util/Util.java   | 108 ----
 .../src/main/resources/META-INF/component.xml   |  45 --
 .../src/main/resources/META-INF/services.xml    |  47 --
 .../reports/all_tenant_usage_report.jrxml       | 137 ----
 .../main/resources/reports/usage_report.jrxml   | 135 ----
 .../usage/org.wso2.carbon.usage/2.1.1/pom.xml   | 142 ----
 .../carbon/usage/api/TenantUsageRetriever.java  | 518 ---------------
 .../usage/beans/APIManagerUsageStats.java       |  71 --
 .../carbon/usage/beans/BandwidthStatistics.java |  62 --
 .../usage/beans/InstanceUsageStatics.java       |  90 ---
 .../usage/beans/PaginatedInstanceUsage.java     |  58 --
 .../usage/beans/PaginatedTenantUsageInfo.java   |  46 --
 .../carbon/usage/beans/RequestStatistics.java   |  60 --
 .../carbon/usage/beans/TenantDataCapacity.java  |  52 --
 .../wso2/carbon/usage/beans/TenantUsage.java    | 198 ------
 .../org/wso2/carbon/usage/beans/UsageEntry.java |  46 --
 .../usage/internal/UsageServiceComponent.java   | 103 ---
 .../carbon/usage/services/UsageService.java     | 203 ------
 .../carbon/usage/util/DataAccessObject.java     | 498 --------------
 .../java/org/wso2/carbon/usage/util/Util.java   | 108 ----
 .../src/main/resources/META-INF/component.xml   |  45 --
 .../src/main/resources/META-INF/services.xml    |  47 --
 .../reports/all_tenant_usage_report.jrxml       | 137 ----
 .../main/resources/reports/usage_report.jrxml   | 135 ----
 .../usage/org.wso2.carbon.usage/2.1.2/pom.xml   | 143 -----
 .../carbon/usage/api/TenantUsageRetriever.java  | 518 ---------------
 .../usage/beans/APIManagerUsageStats.java       |  71 --
 .../carbon/usage/beans/BandwidthStatistics.java |  62 --
 .../usage/beans/InstanceUsageStatics.java       |  90 ---
 .../usage/beans/PaginatedInstanceUsage.java     |  58 --
 .../usage/beans/PaginatedTenantUsageInfo.java   |  46 --
 .../carbon/usage/beans/RequestStatistics.java   |  60 --
 .../carbon/usage/beans/TenantDataCapacity.java  |  52 --
 .../wso2/carbon/usage/beans/TenantUsage.java    | 198 ------
 .../org/wso2/carbon/usage/beans/UsageEntry.java |  46 --
 .../usage/internal/UsageServiceComponent.java   | 103 ---
 .../carbon/usage/services/UsageService.java     | 203 ------
 .../carbon/usage/util/DataAccessObject.java     | 498 --------------
 .../java/org/wso2/carbon/usage/util/Util.java   | 108 ----
 .../src/main/resources/META-INF/component.xml   |  45 --
 .../src/main/resources/META-INF/services.xml    |  47 --
 .../reports/all_tenant_usage_report.jrxml       | 137 ----
 .../main/resources/reports/usage_report.jrxml   | 135 ----
 .../usage/org.wso2.carbon.usage/2.1.3/pom.xml   | 143 -----
 .../carbon/usage/api/TenantUsageRetriever.java  | 604 -----------------
 .../usage/beans/APIManagerUsageStats.java       |  71 --
 .../carbon/usage/beans/BandwidthStatistics.java |  62 --
 .../carbon/usage/beans/CartridgeStatistics.java |  41 --
 .../usage/beans/InstanceUsageStatics.java       |  90 ---
 .../usage/beans/PaginatedInstanceUsage.java     |  58 --
 .../usage/beans/PaginatedTenantUsageInfo.java   |  46 --
 .../carbon/usage/beans/RequestStatistics.java   |  60 --
 .../carbon/usage/beans/TenantDataCapacity.java  |  52 --
 .../wso2/carbon/usage/beans/TenantUsage.java    | 216 -------
 .../org/wso2/carbon/usage/beans/UsageEntry.java |  46 --
 .../usage/internal/UsageServiceComponent.java   | 103 ---
 .../carbon/usage/services/UsageService.java     | 203 ------
 .../carbon/usage/util/DataAccessObject.java     | 624 ------------------
 .../java/org/wso2/carbon/usage/util/Util.java   | 108 ----
 .../src/main/resources/META-INF/component.xml   |  45 --
 .../src/main/resources/META-INF/services.xml    |  47 --
 .../reports/all_tenant_usage_report.jrxml       | 137 ----
 .../main/resources/reports/usage_report.jrxml   | 135 ----
 components/stratos/usage/pom.xml                |  43 --
 377 files changed, 10934 insertions(+), 35287 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/pom.xml b/components/org.apache.stratos.usage.agent/pom.xml
new file mode 100644
index 0000000..92a9174
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/pom.xml
@@ -0,0 +1,146 @@
+<!--
+# 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.
+  -->
+<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/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-components-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+	<relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.usage.agent</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Usage Agent</name>
+
+    <build>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Private-Package>
+                        	!org.apache.stratos.usage.agent.api.*,
+                            org.apache.stratos.usage.agent.*,
+                        </Private-Package>
+                        <Export-Package>
+                            org.apache.stratos.usage.agent.api.*,
+                            org.apache.stratos.usage.agent.beans.*,
+                            org.apache.stratos.usage.agent.util.PublisherUtils,
+                        </Export-Package>
+                        <Import-Package>
+                            org.apache.stratos.common.*,
+                            org.wso2.carbon.registry.core.*;version=1.0.1,
+                            org.wso2.carbon.registry.resource.*,
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>2.1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.statistics</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+	    <artifactId>org.wso2.carbon.registry.common</artifactId>
+            <version>${carbon.platform.version}</version>
+	</dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.event.core</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+	<dependency>
+	    <groupId>org.wso2.carbon</groupId>
+	    <artifactId>org.wso2.carbon.email.verification</artifactId>
+            <version>${carbon.platform.version}</version>
+	</dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.server</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.tomcat.ext</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.databridge.agent.thrift</artifactId>
+            <version>${carbon.platform.version}</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/api/CustomMeteringAgent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/api/CustomMeteringAgent.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/api/CustomMeteringAgent.java
new file mode 100644
index 0000000..9b63790
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/api/CustomMeteringAgent.java
@@ -0,0 +1,223 @@
+/*
+ *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.usage.agent.api;
+
+import org.apache.stratos.usage.agent.exception.UsageException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.registry.core.*;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.apache.stratos.common.constants.UsageConstants;
+
+/**
+ *   CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists,
+ *   to persist and retrieve usage.
+ */
+
+public class CustomMeteringAgent {
+    private static final Log log = LogFactory.getLog(CustomMeteringAgent.class);
+    private Registry registry;
+
+    /**
+     * Constructor for the custom metering agent
+     *
+     * @param registry governance registry of super tenant
+     */
+    public CustomMeteringAgent(Registry registry) {
+        this.registry = registry;
+    }
+
+    /**
+     * Get recorded durations
+     * @param measurement  the measurement to get the duration
+     * @return the durations array
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     */
+    public String[] getRecordedDurations(String measurement) throws UsageException {
+        String[] durations;
+        String measurementCollectionPath =
+                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
+                        measurement;
+        try {
+            Resource resource = registry.get(measurementCollectionPath);
+            if (!(resource instanceof Collection)) {
+                String msg =
+                        "The records collection is not a registry collection. path: " +
+                                measurementCollectionPath + ".";
+                log.error(msg);
+                throw new UsageException(msg);
+            }
+            durations = ((Collection) resource).getChildren();
+        } catch (RegistryException e) {
+            String msg =
+                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
+            log.error(msg, e);
+            throw new UsageException(msg, e);
+        }
+        return durations;
+    }
+
+    /**
+     * Check whether the usage entry exist or not
+     *
+     * @param duration    the duration (e.g. year month), null for any duration
+     * @param measurement measurement key
+     * @return true if usage entry exists
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     */
+    public boolean isUsageEntryExists(String duration, String measurement)
+            throws UsageException {
+        if (duration == null) {
+            duration = UsageConstants.ANY_DURATION;
+        }
+        String measurementPath =
+                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
+                        measurement +
+                        RegistryConstants.PATH_SEPARATOR + duration;
+        try {
+            if (registry.resourceExists(measurementPath)) {
+                return true;
+            }
+        } catch (RegistryException e) {
+            String msg =
+                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
+            log.error(msg, e);
+            throw new UsageException(msg, e);
+        }
+        return false;
+    }
+
+    /**
+     * Persist usage of a user
+     *
+     * @param duration    the duration (e.g. year month), null for any duration
+     * @param measurement measurement key
+     * @param value       measurement value
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     */
+    public void persistUsage(String duration, String measurement, String value)
+            throws UsageException {
+        if (duration == null) {
+            duration = UsageConstants.ANY_DURATION;
+        }
+        Resource measurementResource;
+        String measurementPath =
+                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
+                        measurement +
+                        RegistryConstants.PATH_SEPARATOR + duration;
+        try {
+            measurementResource = registry.newResource();
+            ((ResourceImpl) measurementResource).setVersionableChange(false);
+            // save the measurement value in resource
+            measurementResource.setContent(value);
+            registry.put(measurementPath, measurementResource);
+        } catch (RegistryException e) {
+            String msg =
+                    "Error in persisting the usage. measurement: " +
+                            measurement + ".";
+            log.error(msg, e);
+            throw new UsageException(msg, e);
+        }
+    }
+
+    /**
+     * Retrieve usage of a user
+     *
+     * @param duration    the duration (e.g. year month), null for any duration
+     * @param measurement measurement key
+     * @return measurement value
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     */
+    public String retrieveUsage(String duration, String measurement)
+            throws UsageException {
+        String usageValue;
+        Resource measurementResource;
+        String measurementPath =
+                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
+                        measurement +
+                        RegistryConstants.PATH_SEPARATOR + duration;
+        try {
+            measurementResource = registry.get(measurementPath);
+            // save the measurement value in resource
+            byte[] contentBytes = (byte[]) measurementResource.getContent();
+            usageValue = new String(contentBytes);
+        } catch (RegistryException e) {
+            String msg =
+                    "Error in retrieving the usage. measurement: " +
+                            measurement + ".";
+            log.error(msg, e);
+            throw new UsageException(msg, e);
+        }
+        return usageValue;
+    }
+
+    /**
+     * Add a long value to the usage, if there were no previous entry, this will
+     * start with value 0
+     *
+     * @param duration    the duration (e.g. year month), null for any duration
+     * @param measurement measurement key
+     * @param value       measurement value
+     * @return the added measurement value
+     * @throws org.apache.stratos.usage.agent.exception.UsageException
+     */
+    public long addUsage(String duration, String measurement, long value)
+            throws UsageException {
+        if (duration == null) {
+            duration = UsageConstants.ANY_DURATION;
+        }
+        // adding the bandwidth have to be in a transaction
+        boolean transactionSuccess = false;
+        try {
+            registry.beginTransaction();
+            if (isUsageEntryExists(duration, measurement)) {
+                String usageStr = retrieveUsage(duration, measurement);
+                try {
+                    long storedValue = Long.parseLong(usageStr);
+                    value += storedValue;
+                } catch (NumberFormatException e) {
+                    String msg = "Error in parsing the integer string: " + usageStr;
+                    log.error(msg, e);
+                    throw new RegistryException(msg, e);
+                }
+            }
+            String valueStr = Long.toString(value);
+            persistUsage(duration, measurement, valueStr);
+            transactionSuccess = true;
+        } catch (RegistryException e) {
+            String msg =
+                    "Error in invoking the add usage. measurement: " +
+                            measurement + ".";
+            log.error(msg, e);
+            throw new UsageException(msg, e);
+        } finally {
+            try {
+                if (transactionSuccess) {
+                    registry.commitTransaction();
+                } else {
+                    registry.rollbackTransaction();
+                }
+            } catch (RegistryException e) {
+                String msg = "Error in commiting/rollbacking the transaction";
+                log.error(msg, e);
+            }
+        }
+        return value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/APIManagerRequestStats.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/APIManagerRequestStats.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/APIManagerRequestStats.java
new file mode 100644
index 0000000..62d33b6
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/APIManagerRequestStats.java
@@ -0,0 +1,98 @@
+/*
+ *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.usage.agent.beans;
+
+public class APIManagerRequestStats {
+    private int requestCount;
+    private int responseCount;
+    private int faultCount;
+    private long responseTime;
+    private int tenantId;
+    private String measurement;
+    private long value;
+
+    public APIManagerRequestStats() {
+        requestCount = 0;
+        responseCount = 0;
+        faultCount = 0;
+        responseTime = 0;
+        measurement = "APICall";
+        value = 0;
+        tenantId = 0;
+    }
+
+    public String getMeasurement() {
+        return measurement;
+    }
+
+    public void setMeasurement(String measurement) {
+        this.measurement = measurement;
+    }
+
+
+    public long getValue() {
+        return value;
+    }
+
+    public void setValue(long value) {
+        this.value = value;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public int getRequestCount() {
+        return requestCount;
+    }
+
+    public void setRequestCount(int requestCount) {
+        this.requestCount = requestCount;
+    }
+
+    public int getResponseCount() {
+        return responseCount;
+    }
+
+    public void setResponseCount(int responseCount) {
+        this.responseCount = responseCount;
+    }
+
+    public int getFaultCount() {
+        return faultCount;
+    }
+
+    public void setFaultCount(int faultCount) {
+        this.faultCount = faultCount;
+    }
+
+    public long getResponseTime() {
+        return responseTime;
+    }
+
+    public void setResponseTime(long responseTime) {
+        this.responseTime = responseTime;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/BandwidthUsage.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/BandwidthUsage.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/BandwidthUsage.java
new file mode 100644
index 0000000..5d2481d
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/beans/BandwidthUsage.java
@@ -0,0 +1,60 @@
+/*
+ *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.usage.agent.beans;
+
+/**
+ * the bean class for BandwidthUsage with attributes
+ * int tenant id,
+ * String measurement
+ * long value   *
+ */
+
+public class BandwidthUsage {
+    private int tenantId;
+    private String measurement;
+    private long value;
+
+
+    public String getMeasurement() {
+        return measurement;
+    }
+
+    public BandwidthUsage(int tenantId, String measurement, long value) {
+        this.tenantId = tenantId;
+        this.measurement = measurement;
+        this.value = value;
+    }
+
+    public long getValue() {
+        return value;
+    }
+
+    public void setValue(long value) {
+        this.value = value;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/config/UsageAgentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/config/UsageAgentConfiguration.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/config/UsageAgentConfiguration.java
new file mode 100644
index 0000000..d31ebe1
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/config/UsageAgentConfiguration.java
@@ -0,0 +1,119 @@
+/*
+ *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.usage.agent.config;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+public class UsageAgentConfiguration {
+    private static final Log log = LogFactory.getLog(UsageAgentConfiguration.class);
+
+    private static final Integer DEFAULT_NUMBER_OF_RECORDS_PER_RUN = 100;
+    private static final Integer DEFAULT_EXECUTION_INTERVAL_IN_MILLISECONDS = 100;
+    private static final Integer DEFAULT_STARTUP_DELAY_IN_MILLISECONDS = 60000;
+
+    private int usageTasksNumberOfRecordsPerExecution = -1;
+
+    private int usageTasksExecutionIntervalInMilliSeconds = -1;
+
+    private int usageTasksStartupDelayInMilliSeconds = -1;
+
+    public UsageAgentConfiguration(File configFile) {
+        if (configFile.exists()) {
+            try {
+                OMElement usageAndThrottlingAgentConfiguration =
+                        new StAXOMBuilder(new FileInputStream(configFile)).getDocumentElement();
+                if (usageAndThrottlingAgentConfiguration != null) {
+                    OMElement usageAgent = usageAndThrottlingAgentConfiguration.getFirstChildWithName(
+                            new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config", "UsageAgent"));
+                    if (usageAgent != null) {
+                        OMElement usageDataPersistenceTaskConfig = usageAgent.getFirstChildWithName(
+                                new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
+                                        "UsageDataPersistenceTask"));
+                        if (usageDataPersistenceTaskConfig != null) {
+                            OMElement numberOfRecordsPerExecutionEle = usageDataPersistenceTaskConfig.getFirstChildWithName(
+                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
+                                            "NumberOfRecordsPerExecution"));
+                            if (numberOfRecordsPerExecutionEle != null && numberOfRecordsPerExecutionEle.getText() != null &&
+                                    numberOfRecordsPerExecutionEle.getText().length() > 0) {
+                                try {
+                                    usageTasksNumberOfRecordsPerExecution = Integer.parseInt(numberOfRecordsPerExecutionEle.getText());
+                                } catch (NumberFormatException ne) {
+                                    log.error("Error while parsing usage persistence task number of records value.", ne);
+                                }
+                            }
+
+                            OMElement executionIntervalInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
+                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
+                                            "ExecutionIntervalInMilliSeconds"));
+                            if (executionIntervalInMilliSeconds != null && executionIntervalInMilliSeconds.getText() != null &&
+                                    executionIntervalInMilliSeconds.getText().length() > 0) {
+                                try {
+                                    usageTasksExecutionIntervalInMilliSeconds =
+                                            Integer.parseInt(executionIntervalInMilliSeconds.getText());
+                                } catch (NumberFormatException ne) {
+                                    log.error("Error while parsing usage persistence task  execution interval value.", ne);
+                                }
+                            }
+
+                            OMElement startupDelayInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
+                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
+                                            "StartupDelayInMilliSeconds"));
+                            if (startupDelayInMilliSeconds != null && startupDelayInMilliSeconds.getText() != null &&
+                                    startupDelayInMilliSeconds.getText().length() > 0) {
+                                try {
+                                    usageTasksStartupDelayInMilliSeconds =
+                                            Integer.parseInt(startupDelayInMilliSeconds.getText());
+                                } catch (NumberFormatException ne) {
+                                    log.error("Error while parsing usage persistence task startup delay value.", ne);
+                                }
+                            }
+                        }
+                    }
+                }
+
+            } catch (FileNotFoundException e) {
+                log.error("Cannot find " + configFile.getAbsolutePath(), e);
+            } catch (XMLStreamException e) {
+                log.error("Error reading XML stream of file " + configFile.getAbsolutePath(), e);
+            }
+        }
+    }
+
+    public int getUsageTasksNumberOfRecordsPerExecution() {
+        return usageTasksNumberOfRecordsPerExecution;
+    }
+
+    public int getUsageTasksExecutionIntervalInMilliSeconds() {
+        return usageTasksExecutionIntervalInMilliSeconds;
+    }
+
+    public int getUsageTasksStartupDelayInMilliSeconds() {
+        return usageTasksStartupDelayInMilliSeconds;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/exception/UsageException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/exception/UsageException.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/exception/UsageException.java
new file mode 100644
index 0000000..06f2dbe
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/exception/UsageException.java
@@ -0,0 +1,31 @@
+/*
+ *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.usage.agent.exception;
+
+/**
+ * UsageException class to handle usage exception
+ */
+public class UsageException extends Exception {
+    public UsageException(String msg, Exception e) {
+        super(msg, e);
+    }
+    public UsageException(String msg) {
+        super(msg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/internal/UsageAgentServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/internal/UsageAgentServiceComponent.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/internal/UsageAgentServiceComponent.java
new file mode 100644
index 0000000..ea8ca29
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/internal/UsageAgentServiceComponent.java
@@ -0,0 +1,202 @@
+/*
+ *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.usage.agent.internal;
+
+import org.apache.stratos.usage.agent.listeners.UsageStatsAxis2ConfigurationContextObserver;
+import org.apache.stratos.usage.agent.util.PublisherUtils;
+import org.apache.stratos.usage.agent.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.base.api.ServerConfigurationService;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.event.core.EventBroker;
+import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+/**
+ * this class is used to activate and deactivate the UsageAgentServiceComponent, set and unset
+ * Serverconfigurarion, set and unset EventBrokerService.
+ *
+ * @scr.component name="org.wso2.carbon.usage.agent" immediate="true"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1"
+ * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
+ * @scr.reference name="config.context.service"
+ * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="0..1"
+ * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
+ * @scr.reference name="server.configuration"
+ * interface="org.wso2.carbon.base.api.ServerConfigurationService" cardinality="1..1"
+ * policy="dynamic" bind="setServerConfiguration" unbind="unsetServerConfiguration"
+ * @scr.reference name="eventbroker.service"
+ * interface="org.wso2.carbon.event.core.EventBroker" cardinality="1..1"
+ * policy="dynamic" bind="setEventBrokerService" unbind="unsetEventBrokerService"
+ * @scr.reference name="org.wso2.carbon.statistics.services"
+ * interface="org.wso2.carbon.statistics.services.SystemStatisticsUtil"
+ * cardinality="0..1" policy="dynamic" bind="setSystemStatisticsUtil" unbind="unsetSystemStatisticsUtil"
+ */
+public class UsageAgentServiceComponent {
+    private static Log log = LogFactory.getLog(UsageAgentServiceComponent.class);
+
+    /**
+     * method to activate UsageAgentServiceComponent
+     *
+     * @param context componentContext
+     */
+    protected void activate(ComponentContext context) {
+        try {
+            PrivilegedCarbonContext.startTenantFlow();
+            PrivilegedCarbonContext.getCurrentContext().setTenantId(
+                    MultitenantConstants.SUPER_TENANT_ID);
+            PrivilegedCarbonContext.getCurrentContext().getTenantDomain(true);
+            PrivilegedCarbonContext.getCurrentContext().setUsername(
+                    CarbonConstants.REGISTRY_SYSTEM_USERNAME);
+            PrivilegedCarbonContext.getCurrentContext().setUserRealm(
+                    Util.getRealmService().getBootstrapRealm());
+            
+            // initialize listeners
+            // currently we have RegistryUsagePersistingListener only
+            Util.initializeAllListeners();
+
+            //initialize persistenceManager for persisting BandwidthUsage
+            Util.initializePersistenceManager();
+
+            // create statistic event subscription
+            Util.createStaticEventSubscription();
+
+            if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
+                //PublisherUtils.defineUsageEventStream();
+
+                UsageStatsAxis2ConfigurationContextObserver statObserver = new UsageStatsAxis2ConfigurationContextObserver();
+                context.getBundleContext().registerService(Axis2ConfigurationContextObserver.class.getName(), statObserver, null);
+                log.info("Observer to register the module for request statistics publishing was registered");
+            }
+
+            // register the request data persistor osgi service so that we can
+            // store service request bandwidths
+            // TODO: Remove this and ServiceDataPersistor after fixing ESB metering
+//            context.getBundleContext().registerService(
+//                    RequestDataPersister.class.getName(), new ServiceDataPersistor(), null);
+
+            log.debug("******* Multitenancy Usage Agent bundle is activated ******* ");
+        } catch (Throwable e) {
+            log.error("******* Failed to activate Multitenancy Usage Agent bundle ****", e);
+        } finally {
+            PrivilegedCarbonContext.endTenantFlow();
+        }
+    }
+
+    /**
+     * method to deactivate bundle
+     *
+     * @param context ComponentContext
+     */
+    protected void deactivate(ComponentContext context) {
+        log.debug("******* Multitenancy Metering Usage Agent bundle is deactivated ******* ");
+    }
+
+    /**
+     * method to set RealmService
+     *
+     * @param realmService RealmService
+     */
+    protected void setRealmService(RealmService realmService) {
+        Util.setRealmService(realmService);
+    }
+
+    /**
+     * method to unsetRealmService
+     *
+     * @param realmService RealmService
+     */
+
+    protected void unsetRealmService(RealmService realmService) {
+        Util.setRealmService(null);
+    }
+
+    /**
+     * method to set ConfigurationContextService
+     *
+     * @param contextService ConfigurationContextService
+     */
+    protected void setConfigurationContextService(ConfigurationContextService contextService) {
+        Util.setConfigurationContextService(contextService);
+        PublisherUtils.setConfigurationContextService(contextService);
+    }
+
+    /**
+     * method to unset ConfigurationContextService
+     *
+     * @param contextService ConfigurationContextService
+     */
+    protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
+        Util.setConfigurationContextService(null);
+    }
+
+    /**
+     * method to set server configurations
+     *
+     * @param serverConfiguration ServerConfiguration
+     */
+    protected void setServerConfiguration(ServerConfigurationService serverConfiguration) {
+        Util.setServerConfiguration(serverConfiguration);
+    }
+
+    /**
+     * method to unset server configurations
+     *
+     * @param serverConfiguration ServerConfiguration
+     */
+    protected void unsetServerConfiguration(ServerConfigurationService serverConfiguration) {
+        Util.setServerConfiguration(null);
+    }
+
+    /**
+     * method to set EventBrokerService
+     *
+     * @param registryEventBrokerService EventBroker
+     */
+
+    protected void setEventBrokerService(EventBroker registryEventBrokerService) {
+        Util.setEventBrokerService(registryEventBrokerService);
+    }
+
+    /**
+     * method to unset EventBrokerService
+     *
+     * @param registryEventBrokerService EventBroker
+     */
+    protected void unsetEventBrokerService(EventBroker registryEventBrokerService) {
+        Util.setEventBrokerService(null);
+    }
+
+    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
+        Util.setSystemStatisticsUtil(systemStatisticsUtil);
+    }
+
+    public static void unsetSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
+        Util.setSystemStatisticsUtil(null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsageListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsageListener.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsageListener.java
new file mode 100644
index 0000000..f84e727
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/listeners/RegistryUsageListener.java
@@ -0,0 +1,365 @@
+/*
+ *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.usage.agent.listeners;
+
+import org.apache.stratos.usage.agent.persist.RegistryUsagePersister;
+import org.apache.stratos.usage.agent.util.MonitoredReader;
+import org.apache.stratos.usage.agent.util.MonitoredWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.registry.core.*;
+import org.wso2.carbon.registry.core.config.RegistryContext;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
+import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
+import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
+import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
+import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
+import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
+import org.wso2.carbon.registry.core.session.CurrentSession;
+import org.wso2.carbon.registry.core.utils.RegistryUtils;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Handler that intercept the registry calls
+ */
+public class RegistryUsageListener extends Handler {
+
+    private static final Log log = LogFactory.getLog(RegistryUsageListener.class);
+
+    public void put(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+
+        // called only once per request
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+        ResourcePath path = context.getResourcePath();
+        Resource resource = context.getResource();
+        ((ResourceImpl) resource).setPath(path.getCompletePath());
+        if (resource instanceof CollectionImpl) {
+            return;
+        }
+        Object contentObj = resource.getContent();
+        if (contentObj == null) {
+            return;
+        }
+        int size;
+        if (contentObj instanceof String) {
+            size = ((String) contentObj).length();
+        } else if (contentObj instanceof byte[]) {
+            size = ((byte[]) contentObj).length;
+        } else {
+            String msg = "Unsupported type for the content.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+
+        // persisting bandwidth
+        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
+        //persisting to registry content addition
+        RegistryUsagePersister.storeAddContent(tenantId, size);
+
+        //we will pass through, so that normal registry operation will put the resource
+    }
+
+    public void importResource(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+//        ResourcePath resourcePath = context.getResourcePath();
+        String sourceURL = context.getSourceURL();
+
+
+        // the import resource logic
+        URL url;
+        try {
+            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
+                String msg = "The source URL must not be file in the server's local file system";
+                throw new RegistryException(msg);
+            }
+            url = new URL(sourceURL);
+        } catch (MalformedURLException e) {
+            String msg = "Given source URL " + sourceURL + "is not valid.";
+            throw new RegistryException(msg, e);
+        }
+
+        try {
+            URLConnection uc = url.openConnection();
+            InputStream in = uc.getInputStream();
+            byte[] inByteArr = RegistryUtils.getByteArray(in);
+            int size = inByteArr.length;
+
+            // persisting bandwidth
+            //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
+
+        } catch (IOException e) {
+
+            String msg = "Could not read from the given URL: " + sourceURL;
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    public Resource get(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return null;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return null;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return null;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+
+        // get the resource
+        Resource resource = context.getResource();
+        if (resource == null) {
+            ResourcePath resourcePath = context.getResourcePath();
+            Registry registry = context.getRegistry();
+            if (registry.resourceExists(resourcePath.getPath())) {
+                resource = registry.get(resourcePath.getPath());
+                context.setResource(resource);
+                context.setProcessingComplete(true); // nothing else to do.
+            }
+        }
+        if (resource == null) {
+            return null;
+        }
+        if (resource instanceof CollectionImpl) {
+            return resource;
+        }
+        Object contentObj = resource.getContent();
+        if (contentObj == null) {
+            return resource;
+        }
+        int size;
+        if (contentObj instanceof String) {
+            size = ((String) contentObj).length();
+        } else if (contentObj instanceof byte[]) {
+            size = ((byte[]) contentObj).length;
+        } else {
+            String msg = "Unsupported type for the content.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+        // persisting bandwidth
+        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
+        return resource;
+    }
+
+    public void dump(RequestContext requestContext) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        long size = requestContext.getBytesWritten();
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+        if (size == 0) {
+            //Still not dumped
+            Registry registry = requestContext.getRegistry();
+            String path = requestContext.getResourcePath().getPath();
+            Writer writer = requestContext.getDumpingWriter();
+            // we wrap the writer with the monitored writer
+            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
+            registry.dump(path, monitoredWriter);
+            size = monitoredWriter.getTotalWritten();
+            requestContext.setProcessingComplete(true);
+        }
+
+        // persisting bandwidth
+        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
+
+    }
+
+    public void restore(RequestContext requestContext) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request..
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+        long size = requestContext.getBytesRead();
+
+        if (size == 0) {
+            //not restored yet
+            Registry registry = requestContext.getRegistry();
+            String path = requestContext.getResourcePath().getPath();
+            Reader reader = requestContext.getDumpingReader();
+            // we wrap the reader with the monitored reader
+            MonitoredReader monitoredReader = new MonitoredReader(reader);
+            registry.restore(path, monitoredReader);
+            size = monitoredReader.getTotalRead();
+            requestContext.setProcessingComplete(true);
+        }
+        // persisting bandwidth
+        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
+
+    }
+
+    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
+            throws RegistryException {
+
+        //If metering is disabled, we do not need to register the handler
+        if(!"true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
+            return;
+        }
+
+        HandlerManager handlerManager = registryContext.getHandlerManager();
+        RegistryUsageListener handler = new RegistryUsageListener();
+        URLMatcher anyUrlMatcher = new URLMatcher();
+        anyUrlMatcher.setPattern(".*");
+        String[] applyingFilters = new String[]{
+                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE, Filter.DELETE};
+
+        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
+                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
+    }
+
+    //===========================================================================================
+    public void delete(RequestContext context) throws RegistryException {
+        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
+                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
+            // no limitations for the super tenant
+            return;
+        }
+        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
+                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
+            // skipping tracking for anonymous and system user
+            return;
+        }
+        // called only once per request
+        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
+                != null) {
+            return;
+        }
+        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
+        // pre triggering
+        int tenantId = CurrentSession.getTenantId();
+
+        ResourcePath path = context.getResourcePath();
+        Resource resource = context.getRegistry().get(path.getCompletePath());
+        Object contentObj = resource.getContent();
+        if (contentObj == null) {
+            return;
+        }
+        int size = 0;
+        if (contentObj instanceof String) {
+            size = ((String) contentObj).length();
+        } else if (contentObj instanceof byte[]) {
+            size = ((byte[]) contentObj).length;
+        } else if (contentObj instanceof String[]) {
+            // of type collection
+            for (String str : (String[]) contentObj) {
+                size += str.length();
+            }
+        } else {
+            String msg = "Unsupported type for the content.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+        RegistryUsagePersister.storeDeleteContent(tenantId, size);
+
+        //we will pass through, so that normal registry operation will put the resource
+    }
+}


[18/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
deleted file mode 100644
index 2286516..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.RegistryUsagePersister;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- */
-public class RegistryUsageListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsageListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-        //persisting to registry content addition
-        RegistryUsagePersister.storeAddContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //If metering is disabled, we do not need to register the handler
-        if(!"true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            return;
-        }
-
-        HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsageListener handler = new RegistryUsageListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE, Filter.DELETE};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-    }
-
-    //===========================================================================================
-    public void delete(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getRegistry().get(path.getCompletePath());
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size = 0;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else if (contentObj instanceof String[]) {
-            // of type collection
-            for (String str : (String[]) contentObj) {
-                size += str.length();
-            }
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        RegistryUsagePersister.storeDeleteContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
deleted file mode 100644
index 0e7e75a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.BandwidthPersistor;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- * Currently this handler is not registered because there is a similar handler RegistryUsageHandler
- * After examining properly this class will be deleted.
- */
-public class RegistryUsagePersistingListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsagePersistingListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-     
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //This was commented out because there is a similar class RegistryUsageListener
-        //After examiming properly this class will be deleted
-        /*HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsagePersistingListener handler = new RegistryUsagePersistingListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE,};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-        */
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
deleted file mode 100644
index cd4d2d9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-public class StatisticsInHandler extends AbstractHandler{
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-            return InvocationResponse.CONTINUE;
-        }
-
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-                tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
deleted file mode 100644
index 9e21058..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-
-public class StatisticsOutHandler extends AbstractHandler{
-
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-
-
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-        
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-            tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        PrivilegedCarbonContext.destroyCurrentContext();
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
deleted file mode 100644
index 3c30ed3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver;
-
-
-public class UsageStatsAxis2ConfigurationContextObserver extends AbstractAxis2ConfigurationContextObserver {
-
-    private static final Log log = LogFactory.getLog(UsageStatsAxis2ConfigurationContextObserver.class);
-
-    @Override
-    public void createdConfigurationContext(ConfigurationContext configContext) {
-
-        AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
-        int tenantId = PrivilegedCarbonContext.getCurrentContext().getTenantId(false);
-        try {
-            axisConfiguration.engageModule("metering");
-        } catch (AxisFault axisFault) {
-            log.error("Could not engage metering module for tenant: " + tenantId, axisFault);
-        }
-
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
deleted file mode 100644
index 0eab461..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.usage.agent.util.Util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * this class is used to obtain tenant id from MeteredServletRequest or MessageContext
- */
-
-public class RequestMeteringHandler extends AbstractHandler {
-    private static final Log log = LogFactory.getLog(RequestMeteringHandler.class);
-
-    /**
-     * this method  invoke  MeteredServletRequest and return a InvocationResponse
-     * @param messageContext  MessageContext
-     * @return InvocationResponse
-     * @throws AxisFault
-     */
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        if (log.isDebugEnabled()) {
-            log.debug("Staring metering handler invocation. Incoming message: " +
-                    messageContext.getEnvelope().toString());
-        }
-        AxisService service = messageContext.getAxisService();
-        Parameter param = service.getParameter("adminService");
-
-        Object obj = messageContext.getProperty("transport.http.servletRequest");
-        if (obj == null) {
-            // TODO: check for cause of the error.
-            log.debug("Servlet request is null. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-        if (!(obj instanceof MeteredServletRequest)) {
-            log.debug("HttpServletRequest is not of type MeteredServletRequest. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-
-        MeteredServletRequest servletRequest = (MeteredServletRequest) obj;
-
-        if (param != null && "true".equals(param.getValue())) {
-            servletRequest.setAttribute(StratosConstants.ADMIN_SERVICE_SERVLET_ATTR, "true");
-            return InvocationResponse.CONTINUE;
-        }
-        servletRequest.setAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR, service.getName());
-
-        int tenantId = getTenantId(servletRequest);
-        servletRequest.setAttribute(StratosConstants.TENANT_ID_SERVLET_ATTR, tenantId);
-
-        return InvocationResponse.CONTINUE;
-    }
-
-    /**
-     * method to get tenant id from MeteredServletRequest
-     * @param servletRequest MeteredServletRequest
-     * @return tenant id
-     */
-
-    private int getTenantId(MeteredServletRequest servletRequest) {
-        String address = servletRequest.getRequestURI();
-        String servicesPrefix = "/services/t/";
-        if (address != null && address.contains(servicesPrefix)) {
-            int domainNameStartIndex =
-                    address.indexOf(servicesPrefix) + servicesPrefix.length();
-            int domainNameEndIndex = address.indexOf('/', domainNameStartIndex);
-            String domainName = address.substring(domainNameStartIndex,
-                    domainNameEndIndex == -1 ? address.length() : domainNameEndIndex);
-
-            // return tenant id if domain name is not null
-            if (domainName != null) {
-                try {
-                    return Util.getRealmService().getTenantManager().getTenantId(domainName);
-                } catch (org.wso2.carbon.user.api.UserStoreException e) {
-                    log.error("An error occurred while obtaining the tenant id.", e);
-                }
-            }
-        }
-
-        // return 0 if the domain name is null
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
deleted file mode 100644
index f45b8b5..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisDescription;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.modules.Module;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.Policy;
-
-public class RequestMeteringModule implements Module {
-
-    public void init(ConfigurationContext configurationContext, AxisModule axisModule)
-            throws AxisFault {
-    }
-
-    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public boolean canSupportAssertion(Assertion assertion) {
-        return true;
-    }
-
-    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
deleted file mode 100644
index e52384d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class BandwidthPersistor {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
deleted file mode 100644
index 7824fe8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsContainer;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsEntry;
-import org.wso2.carbon.usage.agent.util.UsageAgentConstants;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.util.Queue;
-
-public class BandwidthUsageDataRetrievalTask implements Runnable {
-    private static final Log log = LogFactory.getLog(BandwidthUsageDataRetrievalTask.class);
-
-    private Queue<TransportStatisticsEntry> transportStats;
-    private UsageAgentConfiguration configuration;
-
-    //This will be decided based on whether a BAM Server URL is provided or not
-    private boolean isBamAvailable=false;
-
-    public BandwidthUsageDataRetrievalTask(UsageAgentConfiguration configuration) {
-        transportStats = TransportStatisticsContainer.getTransportStatistics();
-        this.configuration = configuration;
-
-        //Checking for the BAM Server URL
-        String bamServerUrl = ServerConfiguration.getInstance().getFirstProperty("BamServerURL");
-        if(bamServerUrl != null){
-            this.isBamAvailable = true;
-        }
-    }
-
-    public void run() {
-        /*if (log.isDebugEnabled()) {
-            log.debug("Retrieving Service and Web App bandwidth usage statistics.");
-        }*/
-
-        if (!transportStats.isEmpty()) {
-            for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !transportStats.isEmpty(); i++) {
-                TransportStatisticsEntry entry = transportStats.remove();
-                try {
-                    if(!isBamAvailable){
-                        return;
-                    }
-
-                    int tenantId = getTenantID(entry.getTenantName());
-                    //if the tenant does not exist, no need and no way of updating the usage data
-                    //therefore ignore it
-                    if(tenantId<0){
-                        return;
-                    }
-                    if (inferMeasurement(entry).equals(UsageConstants.SERVICE_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    } else if (inferMeasurement(entry).equals(UsageConstants.WEBAPP_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    }
-                } catch (UserStoreException e) {
-                    log.error("Error persisting bandwidth usage statistics.", e);
-                }
-
-            }
-        }
-    }
-
-
-    private String inferMeasurement(TransportStatisticsEntry entry) {
-        if (entry.getContext() != null) {
-            if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_SERVICES_CONTEXT)) {
-                return UsageConstants.SERVICE_BANDWIDTH;
-            } else if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_WEBAPPS_CONTEXT)) {
-                return UsageConstants.WEBAPP_BANDWIDTH;
-            }
-        }
-
-        return UsageAgentConstants.BANDWIDTH_CARBON;
-    }
-
-    private int getTenantID(String tenantDomain) throws UserStoreException {
-        return Util.getRealmService().getTenantManager().getTenantId(tenantDomain);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
deleted file mode 100644
index 0bd7ab1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.lang.System;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class RegistryUsagePersister {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    //=============================================================
-
-    public static void storeAddContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-In", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    public static void storeDeleteContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-Out", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-   //=============================================================
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
deleted file mode 100644
index 9b0902c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.core.transports.metering.MeteredServletResponse;
-import org.wso2.carbon.core.transports.metering.RequestDataPersister;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to persist service data
- */
-public class ServiceDataPersistor implements RequestDataPersister {
-    private static final Log log = LogFactory.getLog(ServiceDataPersistor.class);
-
-    /**
-     * this method get tenant id, inDataSize and outDataSize from the wrappedRequest, construct a
-     * BandwidthUsage object and add it to PersistingControllerQueue
-     * @param wrappedRequest  MeteredServletRequest
-     * @param wrappedResponse MeteredServletResponse
-     */
-    public void persist(MeteredServletRequest wrappedRequest, MeteredServletResponse wrappedResponse) {
-        if ("true".equals(wrappedRequest.getAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR))) {
-            return;
-        }
-
-        Integer tenantId = (Integer) wrappedRequest.getAttribute(
-                StratosConstants.TENANT_ID_SERVLET_ATTR);
-        if (tenantId == null || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return;
-        }
-        long inDataSize = wrappedRequest.getReadSize();
-        long outDataSize = wrappedResponse.getWrittenSize();
-
-        if(log.isTraceEnabled()){
-            log.trace("Persisting service bandwidth usage for tenant " + tenantId + " in size: " + inDataSize + " out size: " + outDataSize);
-        }
-        // add the job to queue
-        if (inDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_INCOMING_BW, inDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-        if (outDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_OUTGOING_BW, outDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
deleted file mode 100644
index 5cf4491..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-
-import java.util.Queue;
-import java.util.concurrent.*;
-
-public class UsageDataPersistenceManager {
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceManager.class);
-
-    // queue to store Bandwidth usage statistics.
-    // usage of  LinkedBlockingQueue ensures operations on the queue to wait for the queue to be non
-    // empty when retrieving and wait for space when storing element.
-    private Queue<BandwidthUsage> persistenceJobs = new LinkedBlockingQueue<BandwidthUsage>();
-
-    private final ScheduledExecutorService scheduler;
-
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceManager(UsageAgentConfiguration configuration) {
-        scheduler = Executors.newScheduledThreadPool(2, new UsageDataPersistenceThreadFactory());
-        this.configuration = configuration;
-    }
-
-    /**
-     * this method add bandwidth usage entries to the jobQueue
-     *
-     * @param usage Bandwidth usage
-     */
-
-    public void addToQueue(BandwidthUsage usage) {
-        persistenceJobs.add(usage);
-    }
-
-    public void scheduleUsageDataPersistenceTask() {
-        //we will schedule the usage data persistence task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new UsageDataPersistenceTask(persistenceJobs, configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Usage data persistence task was scheduled");
-        }else{
-            log.debug("Usage data persistence task is disabled");
-        }
-    }
-
-
-    public void scheduleBandwidthUsageDataRetrievalTask() {
-        //we will schedule the usage data retrieval task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new BandwidthUsageDataRetrievalTask(configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Bandwidth Usage data retrieval task was scheduled");
-        }else {
-            log.debug("Bandwidth Usage data retrieval task was disabled");
-        }
-    }
-
-    class UsageDataPersistenceThreadFactory implements ThreadFactory {
-        private int counter = 0;
-
-        public Thread newThread(Runnable r) {
-            return new Thread(r, "UsageDataPersistenceThread-" + counter++);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
deleted file mode 100644
index 64f3b0a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.MultitenantConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Queue;
-
-public class UsageDataPersistenceTask implements Runnable {
-
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceTask.class);
-
-    private Queue<BandwidthUsage> usagePersistenceJobs;
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceTask(Queue<BandwidthUsage> jobs, UsageAgentConfiguration configuration) {
-        usagePersistenceJobs = jobs;
-        this.configuration = configuration;
-    }
-
-    public void run() {
-        if (!usagePersistenceJobs.isEmpty()) {
-            if (log.isDebugEnabled()) {
-                log.debug("Persisting Service and Web App bandwidth usage statistics");
-            }
-            try {
-                persistUsage(usagePersistenceJobs);
-            } catch (UsageException e) {
-                log.error("Error when persisting usage statistics.", e);
-            }
-        }
-    }
-
-    /**
-     * this method create a Summarizer object for each tenant and call accumulate() method to
-     * accumulate usage statistics
-     *
-     * @param jobQueue usage data persistence jobs
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     *
-     */
-
-    public void persistUsage(Queue<BandwidthUsage> jobQueue) throws UsageException {
-
-        // create a map to hold summarizer objects against tenant id
-        HashMap<Integer, Summarizer> summarizerMap = new HashMap<Integer, Summarizer>();
-
-        // if the jobQueue is not empty
-        for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !jobQueue.isEmpty(); i++) {
-
-            // get the first element from the queue, which is a BandwidthUsage object
-            BandwidthUsage usage = jobQueue.poll();
-
-            // get the tenant id
-            int tenantId = usage.getTenantId();
-
-            //get the Summarizer object corresponds to the tenant id
-            Summarizer summarizer = summarizerMap.get(tenantId);
-
-            // when tenant invoke service for the first time, no corresponding summarizer object in
-            // the map
-            if (summarizer == null) {
-                //create a Summarizer object and put to the summarizerMap
-                summarizer = new Summarizer();
-                summarizerMap.put(tenantId, summarizer);
-            }
-
-            //  now accumulate usage
-            summarizer.accumulate(usage);
-        }
-
-        //Finished accumulating. Now publish the events
-
-        // get the collection view of values in summarizerMap
-        Collection<Summarizer> summarizers = summarizerMap.values();
-
-        // for each summarizer object call the publish method
-        for (Summarizer summarizer : summarizers) {
-            summarizer.publish();
-        }
-    }
-
-    /**
-     * inner class Summarizer
-     * this class is used to accumulate and publish usage statistics.
-     * for each tenant this keeps a map to store BandwidthUsage values
-     */
-    private static class Summarizer {
-        private HashMap<String, BandwidthUsage> usageMap;
-
-        public Summarizer() {
-            usageMap = new HashMap<String, BandwidthUsage>();
-        }
-
-        /**
-         * the method to accumulate usage data
-         *
-         * @param usage BandwidthUsage
-         */
-
-        public void accumulate(BandwidthUsage usage) {
-            // get the measurement name of usage entry
-            String key = usage.getMeasurement();
-
-            // get the existing value of measurement
-            BandwidthUsage existingUsage = usageMap.get(key);
-
-            // if this measurement is metered earlier add the new value to the existing value
-            if (existingUsage != null) {
-                existingUsage.setValue(existingUsage.getValue() + usage.getValue());
-            } else {
-                // if this measurement is not metered previously we need to add it to the usageMap
-                usageMap.put(key, usage);
-            }
-        }
-
-        /**
-         * this method reads usage items from the usageMap and call publish method to publish to
-         * the BAM
-         *
-         * @throws UsageException
-         */
-
-        public void publish() throws UsageException {
-
-            // get the collection view of values in usageMap
-            Collection<BandwidthUsage> usages = usageMap.values();
-
-            for (BandwidthUsage usage : usages) {
-                try {
-                    // publish the usage entry if it is not the super-tenant
-                    if(MultitenantConstants.SUPER_TENANT_ID != usage.getTenantId()){
-                        PublisherUtils.publish(usage);
-                    }
-                } catch (UsageException e) {
-                    log.error("Error in publishing bandwidth usage data", e);
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
deleted file mode 100644
index 23e684d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.services;
-
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.usage.agent.api.CustomMeteringAgent;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *      CustomMeteringService class defines methods to get recorded duration, to check whether
- *      usage entries exists, persist usage, retrieve usage and add usage.
- */
-public class CustomMeteringService extends AbstractAdmin {
-
-    /**
-     * method to get recorded durations
-     * @param measurement  the measurement name
-     * @return  duration array
-     * @throws Exception
-     */
-
-    public String[] getRecordedDurations(String measurement) throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).getRecordedDurations(measurement);
-    }
-
-    /**
-     * method to check whether usage entry exists or not
-     * @param duration  duration
-     * @param measurement measurement name
-     * @return true if usage entry exist
-     * @throws Exception
-     */
-    public boolean isUsageEntryExists( String duration, String measurement)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).isUsageEntryExists(duration,
-                measurement);
-    }
-
-    /**
-     * method to persist usage
-     * @param duration
-     * @param measurement measurement name
-     * @param value   value of measurement
-     * @throws Exception
-     */
-    public void persistUsage( String duration, String measurement, String value)
-            throws Exception {
-        new CustomMeteringAgent(getGovernanceRegistry()).persistUsage(duration, measurement, value);
-    }
-
-    /**
-     * method to retrieve usage
-     * @param duration
-     * @param measurement measurement name
-     * @return usage value
-     * @throws UsageException
-     */
-
-    public String retrieveUsage( String duration, String measurement)
-            throws UsageException {
-        return new CustomMeteringAgent(getGovernanceRegistry())
-                .retrieveUsage(duration, measurement);
-    }
-
-    /**
-     * method to add usage entries
-     * @param userName user name
-     * @param duration duration of the measurement
-     * @param measurement measurement name
-     * @param value usage value
-     * @return usage value
-     * @throws Exception
-     */
-    public long addUsage(String userName, String duration, String measurement, long value)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).addUsage(duration, measurement,
-                value);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
deleted file mode 100644
index 821ed82..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * this class is used to wrap the Reader object
- */
-public class MonitoredReader extends Reader {
-    Reader reader;
-    long totalRead;
-
-    public MonitoredReader(Reader reader) {
-        this.reader = reader;
-        totalRead = 0;
-    }
-
-    public int read(char cbuf[], int off, int len) throws IOException {
-        int read = reader.read(cbuf, off, len);
-        totalRead += read;
-        return read;
-    }
-
-    public void close() throws IOException {
-        reader.close();
-    }
-
-    public long getTotalRead() {
-        return totalRead;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
deleted file mode 100644
index 856fd18..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Writer;
-
-
-/**
- * this class is used to wrap Writer object
- */
-public class MonitoredWriter extends Writer {
-    Writer writer;
-    long totalWritten;
-
-    public MonitoredWriter(Writer writer) {
-        this.writer = writer;
-        totalWritten = 0;
-    }
-
-    public void write(char cbuf[], int off, int len) throws IOException {
-        totalWritten += (len - off);
-        writer.write(cbuf, off, len);
-    }
-
-    public void flush() throws IOException {
-        writer.flush();
-    }
-
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    public long getTotalWritten() {
-        return totalWritten;
-    }
-}


[07/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/UsageService.wsdl
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/UsageService.wsdl b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/UsageService.wsdl
deleted file mode 100644
index a974e17..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/UsageService.wsdl
+++ /dev/null
@@ -1,604 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-                  xmlns:ns1="http://org.apache.axis2/xsd"
-                  xmlns:ns="http://services.usage.carbon.wso2.org"
-                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
-                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
-                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
-                  xmlns:ax2249="http://beans.usage.carbon.wso2.org/xsd"
-                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
-                  targetNamespace="http://services.usage.carbon.wso2.org">
-    <wsdl:documentation>UsageService</wsdl:documentation>
-    <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://beans.usage.carbon.wso2.org/xsd">
-            <xs:complexType name="TenantUsage">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="domain" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="numberOfUsers" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="registryBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="registryCapacity" nillable="true"
-                                type="ax2249:TenantDataCapacity"/>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="requestStatistics"
-                                nillable="true" type="ax2249:RequestStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="serviceBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    <xs:element minOccurs="0" name="totalIncomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalOutgoingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalRegistryBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="totalRequestStatistics" nillable="true"
-                                type="ax2249:RequestStatistics"/>
-                    <xs:element minOccurs="0" name="totalServiceBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="totalWebappBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="usageEntries"
-                                nillable="true" type="ax2249:UsageEntry"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="webappBandwidthStatistics"
-                                nillable="true" type="ax2249:BandwidthStatistics"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="BandwidthStatistics">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="incomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="outgoingBandwidth" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="TenantDataCapacity">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="RequestStatistics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="faultCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="requestCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="responseCount" type="xs:long"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:complexType name="UsageEntry">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedTenantUsageInfo">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="tenantUsages"
-                                nillable="true" type="ax2249:TenantUsage"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedInstanceUsage">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceUsages"
-                                nillable="true" type="ax2249:InstanceUsageStatics"/>
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="InstanceUsageStatics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="instanceID" nillable="true" type="xs:int"/>
-                    <xs:element minOccurs="0" name="instanceURL" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="running" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="startTime" nillable="true" type="xs:dateTime"/>
-
-                    <xs:element minOccurs="0" name="stopTime" nillable="true" type="xs:dateTime"/>
-                    <xs:element minOccurs="0" name="usedTimeInSeconds" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax2250="http://beans.usage.carbon.wso2.org/xsd"
-                   attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://services.usage.carbon.wso2.org">
-            <xs:import namespace="http://beans.usage.carbon.wso2.org/xsd"/>
-            <xs:element name="Exception">
-                <xs:complexType>
-
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="Exception" nillable="true"
-                                    type="ns:Exception"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:complexType name="Exception">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:element name="retrieveTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsagesResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsagesResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedTenantUsageInfo"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsage">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedInstanceUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveInstanceUsageResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:InstanceUsageStatics"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-
-                </xs:complexType>
-            </xs:element>
-        </xs:schema>
-    </wsdl:types>
-    <wsdl:message name="retrievePaginatedTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsagesResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="Exception">
-        <wsdl:part name="parameters" element="ns:Exception"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsageResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsagesResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsage"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveInstanceUsageRequest"/>
-    <wsdl:message name="retrieveInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageRequest">
-
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:portType name="UsageServicePortType">
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <wsdl:input message="ns:retrievePaginatedTenantUsagesRequest"
-                        wsaw:Action="urn:retrievePaginatedTenantUsages"/>
-            <wsdl:output message="ns:retrievePaginatedTenantUsagesResponse"
-                         wsaw:Action="urn:retrievePaginatedTenantUsagesResponse"/>
-
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <wsdl:input message="ns:retrieveCurrentTenantUsageRequest"
-                        wsaw:Action="urn:retrieveCurrentTenantUsage"/>
-            <wsdl:output message="ns:retrieveCurrentTenantUsageResponse"
-                         wsaw:Action="urn:retrieveCurrentTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveCurrentTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <wsdl:input message="ns:retrieveTenantUsagesRequest"
-                        wsaw:Action="urn:retrieveTenantUsages"/>
-
-            <wsdl:output message="ns:retrieveTenantUsagesResponse"
-                         wsaw:Action="urn:retrieveTenantUsagesResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <wsdl:input message="ns:retrieveTenantUsageRequest"
-                        wsaw:Action="urn:retrieveTenantUsage"/>
-            <wsdl:output message="ns:retrieveTenantUsageResponse"
-                         wsaw:Action="urn:retrieveTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-
-            <wsdl:input message="ns:retrieveInstanceUsageRequest"
-                        wsaw:Action="urn:retrieveInstanceUsage"/>
-            <wsdl:output message="ns:retrieveInstanceUsageResponse"
-                         wsaw:Action="urn:retrieveInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveInstanceUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <wsdl:input message="ns:retrievePaginatedInstanceUsageRequest"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsage"/>
-            <wsdl:output message="ns:retrievePaginatedInstanceUsageResponse"
-                         wsaw:Action="urn:retrievePaginatedInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsageException"/>
-        </wsdl:operation>
-
-    </wsdl:portType>
-    <wsdl:binding name="UsageServiceSoap11Binding" type="ns:UsageServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceSoap12Binding" type="ns:UsageServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap12:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap12:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap12:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap12:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap12:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap12:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceHttpBinding" type="ns:UsageServicePortType">
-        <http:binding verb="POST"/>
-
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <http:operation location="retrievePaginatedTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <http:operation location="retrieveCurrentTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <http:operation location="retrieveTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsage">
-            <http:operation location="retrieveTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <http:operation location="retrieveInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <http:operation location="retrievePaginatedInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-    </wsdl:binding>
-    <wsdl:service name="UsageService">
-        <wsdl:port name="UsageServiceHttpsSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-
-            <soap12:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-            <soap12:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpEndpoint" binding="ns:UsageServiceHttpBinding">
-            <http:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpEndpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsEndpoint" binding="ns:UsageServiceHttpBinding">
-
-            <http:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsEndpoint/"/>
-        </wsdl:port>
-    </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
deleted file mode 100644
index e7490b0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-empty=To make sure the js properties file is not empty
-session.timed.out=Session timed out. Please login again
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
deleted file mode 100644
index d7eda93..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
+++ /dev/null
@@ -1,57 +0,0 @@
-usage.menu=User Usage
-user.usage.report=User Usage Report
-tenant.menu=Tenant Usage
-tenants.usage.report=Tenant Usage Report
-tenant.usage.report=Usage Report
-data.storage.name=Data Storage
-current.data.storage=Current Data Storage
-history.data.storage=Historical Data Storage
-total.data.storage=Total Data Storage
-registry.content.storage.name=Registry Content
-registry.bandwidth.usage=Registry Bandwidth Usage
-service.bandwidth.usage=Service Bandwidth Usage
-webapp.bandwidth.usage=Webapp Bandwidth Usage
-server.name=Server Name
-all.server.name=All Server Total
-incoming.bandwidth=Incoming Bandwidth
-outgoing.bandwidth=Outgoing Bandwidth
-total.bandwidth=Total Bandwidth
-storage.usage=Storage Usage
-number.of.users=Number of Users
-users=Users
-usage.monitoring=Usage Monitoring
-all.tenant.usage.report=All Tenant Usage
-tenant.domain=Domain
-tenant.id=Id
-full.report=Full Report
-report.duration=Report Duration
-year.month=Year-Month
-back=Back
-page.x.to.y=Page {0}
-prev=Prev
-next=Next
-service.usage.stat=Service Usage Statistics
-service.usage.request=Request Count
-service.usage.response=Response Count
-service.usage.fault=Fault Count
-service.total.request=Service Requests
-registry.total.bandwidth=Total Registry Bandwidth
-service.total.bandwidth=Total Service Bandwidth
-instance.usage.report=Instance Usage Report
-instance.server.url=Instance Server URL
-instance.id=Instance ID
-start.time=Start Time
-stop.time=Stop Time
-used.time.in.hours=Used Time In Hours
-instances.data=Instances Data
-failed.to.get.instance.data=Failed To Get Instance Data
-empty.instance.data=Instance Data Not Found
-usage.data.not.available=Usage Data not available
-empty.usage.data=Usage Data Not Found
-webapp.total.bandwidth=Total WebApp Bandwidth
-number.of.api.calls= Number of API Calls
-api.usage=API Usage
-cartridge.stat=Cartridge Usage
-cartridge.type=Cartridge Type
-image.id=Image ID
-cartridge.hours=Hours
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
deleted file mode 100644
index e4c9510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
+++ /dev/null
@@ -1,216 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-        int pageNumber=0;
-        int rowCount = 5;
-        int numberOfPages=0;
-        InstanceUsageStatics[] instanceUsages=null;
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        try{
-        PaginatedInstanceUsage instanceInfo =
-                UsageUtil.retrievePaginatedInstanceUsages(request, config, session);
-        instanceUsages = instanceInfo.getInstanceUsages();
-        pageNumber = instanceInfo.getPageNumber();
-        numberOfPages = instanceInfo.getNumberOfPages();
-
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-        }
-        catch (Exception e){
-        //No need to handle here it here.Error will show in next try block
-        //To avoid dead page
-        }
-    %>
-
-    <div id="middle">
-
-        <h2><fmt:message key="instance.usage.report"/> for the Month - <%=yearMonth%> (With All
-            Running Instances)</h2>
-
-        <div id="report_ui">
-            <carbon:reportNew
-                    component="org.wso2.carbon.usage"
-                    template="all_tenant_usage_report"
-                    pdfReport="true"
-                    htmlReport="true"
-                    excelReport="true"
-                    reportDataSession="all_tenant_usage_data"
-                    jsFunction="getUsageReportData()"/>
-        </div>
-
-        <div id="workArea">
-
-            <form id="usageForm" action="all_tenant_instance_usage.jsp" method="post">
-
-
-                <table class="styledLeft">
-                    <thead>
-                    <tr>
-                        <th>
-                            <fmt:message key="report.duration"/>
-                        </th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr>
-                        <td class="nopadding">
-                            <table class="normal-nopadding" cellspacing="0">
-                                <tbody>
-                                <tr>
-                                    <td><fmt:message key="year.month"/></td>
-                                    <td colspan="2">
-                                        <select onchange="this.form.submit()" name="year-month"
-                                                id="year-month" style="width:400px">
-                                            <%
-                                                for (String ym : UsageUtil.getYearMonths()) {
-                                                    String selectedStr = "";
-                                                    if (ym.equals(yearMonth)) {
-                                                        selectedStr = "selected=\"true\" ";
-                                                    }
-                                            %>
-                                            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                            </option>
-                                            <%
-                                                }
-                                            %>
-                                        </select>
-                                        <input type="hidden" name="requestedPage" id="requestedPage"
-                                               value="<%=pageNumber%>"/>
-                                    </td>
-                                </tr>
-
-                                <tr>
-                                    <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                            key="instances.data"/></td>
-                                </tr>
-                                <tr>
-                                    <th><fmt:message key="instance.id"/></th>
-                                    <th><fmt:message key="server.name"/></th>
-                                    <th><fmt:message key="start.time"/></th>
-                                    <th><fmt:message key="stop.time"/></th>
-                                    <th><fmt:message key="used.time.in.hours"/></th>
-                                </tr>
-                                <%                
-                                    try{
-                                    InstanceUsageStatics[] iu = UsageUtil.retrieveInstanceUsage(request, config, session);
-                                    java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz");
-                                    if (!iu.equals(null)) {
-                                        for (InstanceUsageStatics usage : instanceUsages) {
-                                            String endDate;
-                                            if (usage.getRunning() == true) {
-                                                endDate="Instance Still Running";
-                                            }
-                                            else{
-                                                endDate=dateFormatter.format(usage.getStopTime().getTime());
-                                            }
-                                            String startDate=dateFormatter.format(usage.getStartTime().getTime());
-                                            long usedHours;
-                                            long usedTimeInSeconds=usage.getUsedTimeInSeconds();
-                                            if(usedTimeInSeconds%3600==0){
-                                                usedHours=usedTimeInSeconds/3600;
-                                            }
-                                            else{
-                                                usedHours=(usedTimeInSeconds/3600)+1;
-                                            }
-                                %>
-                                <tr>
-                                    <td>
-                                        <%=usage.getInstanceID()%>
-                                    </td>
-                                    <td>
-                                        <%=usage.getInstanceURL().toString()%>
-                                    </td>
-                                    <td>
-                                        <%=startDate%>
-                                    </td>
-                                    <td>
-                                        <%=endDate%>
-                                    </td>
-                                    <td>
-
-                                        <%=usedHours%>
-                                    </td>
-                                </tr>
-                                <%
-
-                                        }
-                                    }
-                                    else{
-                                      %>
-                                     <td><fmt:message key="empty.instance.data"/></td>
-                                <%
-                                 }
-                                    }
-                                    catch (Exception e){ %>
-                                      <td><fmt:message key="failed.to.get.instance.data"/></td>
-                                   <% }
-                                %>
-                                <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                          numberOfPages="<%=numberOfPages%>"
-                                                          resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                          nextKey="next" prevKey="prev"
-                                                          tdColSpan="6"
-                                                          paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                                </tbody>
-                            </table>
-                        </td>
-                    </tr>
-                    </tbody>
-                </table>
-            </form>
-            <br/>
-        </div>
-    </div>
-</fmt:bundle>
-
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
deleted file mode 100644
index 6036a19..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
+++ /dev/null
@@ -1,208 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageData" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page import="java.util.List" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        PaginatedTenantUsageInfo tenantsInfo =
-                UsageUtil.retrievePaginatedTenantUsages(request, config, session);
-        TenantUsage[] tenantUsages = tenantsInfo.getTenantUsages();
-        int pageNumber = tenantsInfo.getPageNumber();
-        int numberOfPages = tenantsInfo.getNumberOfPages();
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-
-
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        int rowCount = 5;
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-    %>
-
-
-    <%
-        //AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-        //List<AllTenantUsageData> reportDataArray = usageReport.getUsageReportData();
-        //request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-    %>
-
-    <div id="middle">
-        <h2><fmt:message key="tenants.usage.report"/> for the Month - <%=yearMonth%> (All
-            Tenants)</h2>
-    </div>
-
-    <div id="workArea">
-
-        <form id="usageForm" action="all_tenant_usage.jsp" method="post">
-
-
-            <table class="styledLeft">
-                <thead>
-                <tr>
-                    <th>
-                        <fmt:message key="report.duration"/>
-                    </th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr>
-                    <td class="nopadding">
-                        <table class="normal-nopadding" cellspacing="0">
-                            <tbody>
-                            <tr>
-                                <td><fmt:message key="year.month"/></td>
-                                <td colspan="2">
-                                    <select onchange="this.form.submit()" name="year-month"
-                                            id="year-month" style="width:400px">
-                                        <%
-                                            for (String ym : UsageUtil.getYearMonths()) {
-                                                String selectedStr = "";
-                                                if (ym.equals(yearMonth)) {
-                                                    selectedStr = "selected=\"true\" ";
-                                                }
-                                        %>
-                                        <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                        </option>
-                                        <%
-                                            }
-                                        %>
-                                    </select>
-                                    <input type="hidden" name="requestedPage" id="requestedPage"
-                                           value="<%=pageNumber%>"/>
-                                </td>
-                            </tr>
-
-                            <tr>
-                                <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                        key="users"/></td>
-                            </tr>
-                            <tr>
-                                <th><fmt:message key="tenant.domain"/></th>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <th><fmt:message key="number.of.users"/></th>
-                                <th><fmt:message key="storage.usage"/></th><%}%>
-                                <%--<th><fmt:message key="registry.total.bandwidth"/></th>--%>
-                                <th><fmt:message key="service.total.bandwidth"/></th>
-                                <th><fmt:message key="webapp.total.bandwidth"/></th>
-                                <th><fmt:message key="service.total.request"/></th>
-                                <th><fmt:message key="full.report"/></th>
-                            </tr>
-                            <%
-                                if (tenantUsages != null) {
-                                    for (TenantUsage usage : tenantUsages) {
-                                        String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                                        String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                                        String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                                        String webBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-                                        long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                                        int numberOfUsers = usage.getNumberOfUsers();
-
-                                        String username = (String) request.getSession().getAttribute("logged-user");
-                                        String tenantName = usage.getDomain();
-                                        int tenantId = usage.getTenantId();
-                                        String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-                            %>
-
-                            <tr>
-                                <td><%=tenantName%>
-                                </td>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <td><%=numberOfUsers%>
-                                </td>
-                                <td><%=currentDataStorage%>
-                                </td>
-                                <%
-                                    }
-                                %>
-                                <%--<td><%=regBandwidth%>
-                                </td>--%>
-                                <td><%=svcBandwidth%>
-                                </td>
-                                <td><%=webBandwidth%>
-                                </td>
-                                <td><%=svcTotalRequest%>
-                                </td>
-                                <td><a href="<%=fullReportLink%>">Full Report</a></td>
-                            </tr>
-                            <%
-
-                                }
-                            } else {
-                            %>
-                            <tr>
-                                <td><fmt:message key="empty.usage.data"/></td>
-                            </tr>
-                            </tr>
-                            <%
-                                }
-
-                            %>
-                            <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                      numberOfPages="<%=numberOfPages%>"
-                                                      resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                      nextKey="next" prevKey="prev"
-                                                      tdColSpan="6"
-                                                      paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                            </tbody>
-                        </table>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </form>
-        <br/>
-    </div>
-    </div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
deleted file mode 100644
index ce67752..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%
-    AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    System.out.println("Report lenth "+reportDataArray.length);
-    request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/any_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
deleted file mode 100644
index ab96fd2..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
+++ /dev/null
@@ -1,462 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.CartridgeStatistics" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.usage.report"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="false"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<div id="workArea">
-
-<form id="usageForm" action="any_tenant_usage.jsp" method="get">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <input type="hidden" name="tenant-id" value="<%=tenantId%>"/>
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-
-<%
-    }
-%>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="number.of.api.calls"/></td>
-</tr>
-<%
-    String apiCallCount = UsageUtil.getAPIUsage(usage);
-%>
-
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalAPICalls" id="APICalls"
-               style="width:200px" value="<%=apiCallCount%>"/>
-    </td>
-</tr>
-
-
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-<!--cartridge stats-->
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="cartridge.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="cartridge.type"/></td>
-    <td><fmt:message key="image.id"/></td>
-    <td><fmt:message key="cartridge.hours"/></td>
-        <%--<td><fmt:message key="service.usage.fault"/></td>--%>
-</tr>
-<%
-    long totalHours = usage.getTotalCartridgeHours().getCartridgeHours();
-    CartridgeStatistics[] cs = usage.getCartridgeStatistics();
-    if(cs!=null && cs.length>0 && cs[0] != null) {
-        for(CartridgeStatistics stat: cs) {
-
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="imageId" id="imageId"
-               style="width:200px" value="<%=stat.getInstanceId()%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="cartridgeHours" id="cartridgeHours"
-               style="width:200px" value="<%=stat.getCartridgeHours()%>"/>
-    </td>
-
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totalImageIds" id="totalImageIds"
-               style="width:200px" value=""/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totalCartridgeHours" id="totalCartridgeHours"
-               style="width:200px" value="<%=totalHours%>"/>
-    </td>
-
-</tr>
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-<br/>
-<input type='button' class='button' style="align:right" id="backButtonID"
-       onclick='window.location="../tenant-usage/all_tenant_usage.jsp?region=region4&item=all_tenant_usage_menu"'
-       value='<fmt:message key="back"/>'/>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/css/tenant-usage.css b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/css/tenant-usage.css
deleted file mode 100644
index 5c85728..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/css/tenant-usage.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.disableLink {
-    color: #aaaaaa;
-}
-
-.pageLinks {
-    background: #FFFFFF none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-.pageLinks-selected {
-    background: #e8e9ae none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-a {
-    color: #386698;
-    cursor: pointer;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/images/view-usage.png b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/images/view-usage.png
deleted file mode 100644
index 4080da3..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/images/view-usage.png and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/userguide.html b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/userguide.html
deleted file mode 100644
index 9dd0f6c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/docs/userguide.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>View Tenant Usage - User Guide</title>
-  <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
-</head>
-
-<body>
-<h1>View Usage</h1>
-
-<p>
-You can view usage of the stratos resource by your organization(Tenant) from this page
-</p>
-
-<p>
-<img src="images/view-usage.png" alt="View Usage"/>
-<div><strong>Figure1: View Usage</strong></div>
-</p>
- <h2> <b>Description of usage data report fields</b></h2>
-<p>
-<table border="1">
-<tr>
-<th>The Form Field</th>
-<th>Description</th>
-</tr>
-<tr>
-<td>Report Duration </td>
-<td>The year and the month the usage is metered.</td>
-</tr>
-        <tr>
-            <td>Number of Users</td>
-            <td>Number of users of your stratos account.(This is valid only for current month)</td>
-        </tr>
-       <tr>
-        <tr>
-            <td>Storage Usage</td>
-            <td>The registry data storage amount.</td>
-        </tr>
-        <tr>
-            <td>Registry Bandwidth Usage</td>
-            <td>Registry bandwidth consumed by the registry resource accesses(registry uploads, downloads).</td>
-        </tr>
-        <tr>
-            <td>Service Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services hosted by you.</td>
-        </tr>
-        <tr>
-            <td>Webapp Bandwidth Usage</td>
-            <td>The bandwidth consumed by the web services.</td>
-        </tr>
- 	<tr>
-            <td>Service Usage Statistics</td>
-            <td>Service statistics of requests and responses of services.</td>
-        </tr>
-    </tbody>
-</table>
-</p>
-<div><strong>Table1: Description of usage data report fields</strong></div>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/instance-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/instance-usage-report.gif
deleted file mode 100644
index 4a1ae6a..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/instance-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif
deleted file mode 100644
index a9b04e2..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/tenant-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/user-usage-report.gif b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/user-usage-report.gif
deleted file mode 100644
index 9070c35..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/images/user-usage-report.gif and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
deleted file mode 100644
index 61043f0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/all-tenant-usage-report.js
+++ /dev/null
@@ -1,49 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-    alert(1);
-    var xmlHttpReq = createXmlHttpRequest();
-    alert(2);
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "all_tenant_usage_report.jsp", false);
-        xmlHttpReq.send(null);
-        
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-	alert(string);
-    return string.replace(/\n/g, "");
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/tenant-usage.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/tenant-usage.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/tenant-usage.js
deleted file mode 100644
index 76c4363..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/tenant-usage.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function submitAllTenantPaginatedUsage(pageNumber) {
-    sessionAwareFunction(function() {
-        document.getElementById("requestedPage").value = pageNumber;
-        var usageForm = document.getElementById("usageForm");
-        usageForm.submit();
-    }, jsi18n["session.timed.out"]);
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/usage-report.js
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/usage-report.js b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/usage-report.js
deleted file mode 100644
index ed9e306..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.3/src/main/resources/web/tenant-usage/js/usage-report.js
+++ /dev/null
@@ -1,48 +0,0 @@
-function createXmlHttpRequest() {
-    var request;
-
-    // Lets try using ActiveX to instantiate the XMLHttpRequest
-    // object
-    try {
-        request = new ActiveXObject("Microsoft.XMLHTTP");
-    } catch(ex1) {
-        try {
-            request = new ActiveXObject("Msxml2.XMLHTTP");
-        } catch(ex2) {
-            request = null;
-        }
-    }
-
-    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest
-    if (!request && typeof XMLHttpRequest != "undefined") {
-        //The browser does, so lets instantiate the object
-        request = new XMLHttpRequest();
-    }
-    function removeCarriageReturns(string) {
-        return string.replace(/\n/g, "");
-    }
-
-    return request;
-}
-function getUsageReportData() {
-
-    var xmlHttpReq = createXmlHttpRequest();
-
-    // Make sure the XMLHttpRequest object was instantiated
-    if (xmlHttpReq) {
-        // This is a synchronous POST, hence UI blocking.
-        xmlHttpReq.open("GET", "usage_report.jsp", false);
-        xmlHttpReq.send(null);
-
-        if (xmlHttpReq.status == 200) {
-            return removeCarriageReturns(xmlHttpReq.responseText);
-        }
-
-        return false;
-    }
-
-    return false;
-}
-function removeCarriageReturns(string) {
-    return string.replace(/\n/g, "");
-}
\ No newline at end of file


[03/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
deleted file mode 100644
index 22037e2..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.api;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.beans.*;
-import org.wso2.carbon.usage.util.DataAccessObject;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.util.*;
-
-public class TenantUsageRetriever {
-    private static final Log log = LogFactory.getLog(TenantUsageRetriever.class);
-    private static final String DEFAULT_SERVICE_NAME = "Stratos";
-    private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS";
-    private static final String TOTAL_LABEL = "Total";
-    public static final int REG_BANDWIDTH_INDEX = 0;
-    public static final int SVC_BANDWIDTH_INDEX = 1;
-    public static final int WEBAPP_BANDWIDTH_INDEX = 2;
-    public static final int API_CALL_STATS=3;
-
-    private RegistryService registryService;
-    private DataAccessObject dao;
-
-    public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext)
-            throws Exception {
-
-        // we are loading the essentials from the constructors in order to restrict the users
-        // to use the usage retrievers.
-        this.registryService = registryService;
-        this.dao = new DataAccessObject();
-    }
-
-
-    public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate,
-                                              boolean currentMonth) throws Exception {
-        TenantDataCapacity dataCapacity = null;
-
-        if(currentMonth){
-            dataCapacity = dao.getTenantDataCapacity(tenantId);
-        } else {
-            //we don't have a way to see the registry usage of last months yet
-        }
-
-        return dataCapacity;
-
-    }
-
-    /**
-     * This returns the number of users in a given tenant
-     * @param tenantId Tenant ID
-     * @return Number of users
-     * @throws RegistryException
-     */
-    public int getCurrentUserCount(int tenantId) throws RegistryException {
-        UserRealm userRealm = registryService.getUserRealm(tenantId);
-        int usersCount;
-        try {
-            String[] users = userRealm.getUserStoreManager().listUsers("*", -1);
-            usersCount = users.length;
-        } catch (UserStoreException e) {
-            String msg = "Error in getting the current users.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-        return usersCount;
-    }
-
-    public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        BandwidthStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-            bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour));
-            stats = convertBWListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>();
-
-        if (stats != null) {
-            for (BandwidthStatistics stat : stats) {
-                //Proceed only if incoming bandwidth or outgoing bandwidth is not zero
-                if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) {
-                    continue;
-                }
-
-                //TODO: fix the extractServiceUrl method properly
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String bandwidthName = stat.getKey();
-
-                HashMap<String, BandwidthStatistics> bwMap;
-                if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) {
-                    bwMap = regBwMap;
-                } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) {
-                    bwMap = svcBwMap;
-                } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) {
-                    bwMap = webappBwMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + bandwidthName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                BandwidthStatistics reqStat = bwMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new BandwidthStatistics(serverName);
-                    bwMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setIncomingBandwidth(
-                        reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth());
-                reqStat.setOutgoingBandwidth(
-                        reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth());
-            }
-        }
-
-        //Convert to array and return it
-        BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][];
-        Collection<BandwidthStatistics> values = regBwMap.values();
-        returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = svcBwMap.values();
-        returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = webappBwMap.values();
-        returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-
-        return returnValue;
-    }
-
-
-    public APIManagerUsageStats[] getAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        APIManagerUsageStats[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-            bwsList = dao.getDailyAPIManagerUsageStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyAPIManagerUsageStats(tenantId, startHour, endHour));
-            stats = convertAPIStatListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertAPIStatListToArray(dao.getMonthlyAPIManagerUsageStats(tenantId, monthCal));
-        }
-        HashMap<String, APIManagerUsageStats> statMap = new HashMap<String, APIManagerUsageStats>();
-        if (stats != null) {
-            for (APIManagerUsageStats stat : stats) {
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String statName = stat.getKey();
-
-                HashMap<String, APIManagerUsageStats> statsHashMap;
-                if (statName.equals("API-Call")) {
-                    statsHashMap = statMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + statName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                APIManagerUsageStats reqStat = statsHashMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new APIManagerUsageStats(serverName);
-                    statsHashMap.put(serverName, reqStat);
-                }
-                reqStat.setRequestCount(stat.getRequestCount());
-            }
-        }
-
-        //Convert to array and return it
-        APIManagerUsageStats[] returnValue = new APIManagerUsageStats[0];
-        Collection<APIManagerUsageStats> values = statMap.values();
-        returnValue = values.toArray(new APIManagerUsageStats[values.size()]);
-        return returnValue;
-    }
-
-
-    public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate,
-                                                    Calendar endDate, boolean currentMonth) throws Exception {
-        RequestStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-            rsList = dao.getDailyRequestStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour));
-
-            stats = convertRSListToArray(rsList);
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>();
-
-        if (stats != null) {
-            for (RequestStatistics stat : stats) {
-                //Proceed only if request count is not zero
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-
-                String serverName = extractServiceNameFromUrl(stat.getKey());
-
-                //find whether the map already has this key; If not, insert a new one
-                RequestStatistics reqStat = tempReqStatMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new RequestStatistics(serverName);
-                    tempReqStatMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount());
-                reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount());
-                reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount());
-            }
-        }
-
-        //Convert to array and return it
-        Collection<RequestStatistics> values = tempReqStatMap.values();
-        return values.toArray(new RequestStatistics[values.size()]);
-
-    }
-
-    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
-        //get the domain name
-        TenantManager tenantManger = Util.getRealmService().getTenantManager();
-        String domain = tenantManger.getDomain(tenantId);
-        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);
-
-        //Get the startDate, endDate from yearMonth String
-        Date date = CommonUtil.getDateFromMonthString(yearMonth);
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-
-        //Calculate whether the yearMonth fits to current month; if the current date is less than
-        // endDate, then we treat it as current month
-        boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0);
-
-        //get the data capacity
-        TenantDataCapacity capacity;
-        try {
-            capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting data capacity from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryCapacity(capacity);
-
-        //get the service request statistics
-        RequestStatistics[] reqStats = null;
-        try {
-            reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting request statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRequestStatistics(reqStats);
-
-        //Calculate total Request statistics
-        RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL);
-        long totalReq = 0;
-        long totalRes = 0;
-        long totalFault = 0;
-        if(reqStats!=null){
-            for (RequestStatistics stat : reqStats) {
-                totalReq += stat.getRequestCount();
-                totalRes += stat.getResponseCount();
-                totalFault += stat.getFaultCount();
-            }
-            totalReqStat.setRequestCount(totalReq);
-            totalReqStat.setResponseCount(totalRes);
-            totalReqStat.setFaultCount(totalFault);
-        }
-        tenantUsage.setTotalRequestStatistics(totalReqStat);
-
-        //get Bandwidth statistics
-        BandwidthStatistics[][] bwStats = null;
-        try {
-            bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]);
-        tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]);
-        tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]);
-
-        //get the total bandwidths
-        int index = 0;
-        for (BandwidthStatistics[] bwArray : bwStats) {
-            long incomingBandwidth = 0;
-            long outgoingBandwidth = 0;
-            for (BandwidthStatistics bandwidth : bwArray) {
-                incomingBandwidth += bandwidth.getIncomingBandwidth();
-                outgoingBandwidth += bandwidth.getOutgoingBandwidth();
-            }
-            BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL);
-            total.setIncomingBandwidth(incomingBandwidth);
-            total.setOutgoingBandwidth(outgoingBandwidth);
-            switch (index) {
-                case REG_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalRegistryBandwidth(total);
-                    break;
-                case SVC_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalServiceBandwidth(total);
-                    break;
-                case WEBAPP_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalWebappBandwidth(total);
-                    break;
-            }
-            ++index;
-        }
-
-        // the users count will be calculated only if the yearMonth is the current yearMonth
-        if (isCurrentMonth) {
-            int usersCount = getCurrentUserCount(tenantId);
-            tenantUsage.setNumberOfUsers(usersCount);
-        }
-        // get the API invocation data
-        APIManagerUsageStats[] apiStats = null;
-        try {
-            apiStats = getAPIManagerUsageStats(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setApiManagerUsageStats(apiStats);
-        return tenantUsage;
-    }
-
-    /**
-     * @param serviceURL
-     * @return service name
-     *         <p/>
-     *         Extract the stratos service part from URL; expecting the URL as
-     *         protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant
-     *         We are interested in "service" part only
-     */
-    private String extractServiceNameFromUrl(String serviceURL) {
-        if (serviceURL == null || serviceURL.equals("")) {
-            //No service URL is given, so return a default value
-            return DEFAULT_SERVICE_NAME;
-        }
-
-        int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part
-        if (startIndex != -1) {
-            // protocol://service.domain:port/tenant-domain/ case
-            startIndex += 3;
-        } else {
-            //service.domain:port/tenant case
-            startIndex = 0;
-        }
-
-        int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "."
-        if (endIndex == -1) {
-            // "." is not there; search for ":"
-            endIndex = serviceURL.indexOf(':', startIndex);
-
-            if (endIndex == -1) {
-                //Still could not find ":", then search for "/"
-                endIndex = serviceURL.indexOf('/', startIndex);
-
-                if (endIndex == -1) {
-                    //Noting is there, so take the whole service URL
-                    endIndex = serviceURL.length();
-                }
-            }
-
-        }
-        return serviceURL.substring(startIndex, endIndex);
-    }
-
-    /**
-     * @return Instance Usages Statics Array that contains data
-     * @throws Exception when back end error occurs
-     */
-    public InstanceUsageStatics[] getInstanceUsages() throws Exception {
-
-        //TODO: implement
-        return null;
-        /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats();
-        if (instanceData == null || instanceData.length == 0) {
-            return null;
-        }
-        InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length];
-        int elementID = 0;
-        for (InstanceUsageStat iu : instanceData) {
-            InstanceUsageStatics iu1 = new InstanceUsageStatics();
-            iu1.setInstanceID(iu.getInstanceId().intValue());
-            iu1.setInstanceURL(iu.getServerURL());
-            iu1.setStartTime(iu.getStartTimestamp());
-            iu1.setStopTime(iu.getStopTimestamp());
-            iu1.setRunning(iu.getIsRunning());
-            returnValue[elementID] = iu1;
-            elementID = elementID + 1;
-        }
-        return returnValue;
-        */
-    }
-
-
-    private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) {
-        BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private APIManagerUsageStats[] convertAPIStatListToArray(List<APIManagerUsageStats> bwsList) {
-        APIManagerUsageStats[] bwsArray = new APIManagerUsageStats[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) {
-        RequestStatistics[] rsArray = new RequestStatistics[rsList.size()];
-        rsArray = rsList.toArray(rsArray);
-        return rsArray;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
deleted file mode 100644
index 9321011..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-public class APIManagerUsageStats {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-    private long requestCount;
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-
-    public APIManagerUsageStats(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
deleted file mode 100644
index f236e0f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-/**
- * 
- */
-public class BandwidthStatistics {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-
-    public BandwidthStatistics(String key){
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
deleted file mode 100644
index 25cb759..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Calendar;
-
-public class InstanceUsageStatics {
-
-    private Calendar startTime;
-    private Calendar stopTime;
-    private String instanceURL;
-    private Integer instanceID;
-    private long usedTimeInSeconds;
-    private boolean running;
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    public void setRunning(boolean running) {
-        this.running = running;
-    }
-
-    public Calendar getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Calendar startTime) {
-        this.startTime = startTime;
-    }
-
-    public Calendar getStopTime() {
-        return stopTime;
-    }
-
-    public void setStopTime(Calendar stopTime) {
-        //Check weather stop time is Default value in database in that case
-        //server should still running so set isRunning as true
-        Calendar fixedDate = Calendar.getInstance();
-        fixedDate.set(2001, 1, 1, 00, 00, 00);
-        if (stopTime.compareTo(fixedDate) == 0) {
-            this.running = true;
-        }
-        this.stopTime = stopTime;
-    }
-
-    public String getInstanceURL() {
-        return instanceURL;
-    }
-
-    public void setInstanceURL(String instanceURL) {
-        this.instanceURL = instanceURL;
-    }
-
-    public Integer getInstanceID() {
-        return instanceID;
-    }
-
-    public void setInstanceID(Integer instanceID) {
-        this.instanceID = instanceID;
-    }
-
-    public long getUsedTimeInSeconds() {
-        long returnValue = (this.stopTime.getTimeInMillis() -
-                this.startTime.getTimeInMillis()) / 1000;
-        if (returnValue < 0) {
-            running = true;
-        }
-        return usedTimeInSeconds;
-    }
-    public void setUsedTimeInSeconds(long value){
-        this.usedTimeInSeconds=value;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
deleted file mode 100644
index b7407af..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedInstanceUsage {
-    private InstanceUsageStatics[] instanceUsages;
-    private int pageNumber;
-    private int numberOfPages;
-
-    public InstanceUsageStatics[] getInstanceUsages() {
-        if(instanceUsages != null) {
-        return Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-
-        return null;
-    }
-
-    public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) {
-        if(instanceUsages != null) {
-            this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-    }
-
-    public int getPageNumber() {
-        return pageNumber;
-    }
-
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
deleted file mode 100644
index 0a3bd1b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedTenantUsageInfo {
-    private TenantUsage[] tenantUsages;
-    private int pageNumber;
-    private int numberOfPages;
-    
-    public TenantUsage[] getTenantUsages() {
-        return Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public void setTenantUsages(TenantUsage[] tenantUsages) {
-        this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public int getPageNumber() {
-        return pageNumber;
-    }
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
deleted file mode 100644
index 085b91a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-public class RequestStatistics {
-    private String key;
-    private long requestCount;
-    private long responseCount;
-    private long faultCount;
-
-    public RequestStatistics(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public long getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(long responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public long getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(long faultCount) {
-        this.faultCount = faultCount;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
deleted file mode 100644
index 543126d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantDataCapacity {
-
-    private long registryContentCapacity;
-    private long registryContentHistoryCapacity;
-
-    public TenantDataCapacity() {
-    }
-    
-    /**
-     * @param registryContentCapacity
-     * @param registryContentHistoryCapacity
-     */
-    public TenantDataCapacity(
-            long registryContentCapacity, long registryContentHistoryCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-    public long getRegistryContentCapacity() {
-        return registryContentCapacity;
-    }
-
-    public void setRegistryContentCapacity(long registryContentCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-    }
-
-    public long getRegistryContentHistoryCapacity() {
-        return registryContentHistoryCapacity;
-    }
-
-    public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) {
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
deleted file mode 100644
index 9b6e116..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/TenantUsage.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantUsage {
-    private int tenantId;
-    private String domain;
-    private int numberOfUsers;
-    private UsageEntry[] usageEntries;
-    private BandwidthStatistics[] registryBandwidthStatistics;
-    private BandwidthStatistics[] serviceBandwidthStatistics;
-    private BandwidthStatistics[] webappBandwidthStatistics;
-    private RequestStatistics[] requestStatistics;
-    private TenantDataCapacity registryCapacity;
-    private RequestStatistics totalRequestStatistics;
-    private BandwidthStatistics totalRegistryBandwidth;
-    private BandwidthStatistics totalServiceBandwidth;
-    private BandwidthStatistics totalWebappBandwidth;
-    private APIManagerUsageStats[] apiManagerUsageStats;
-
-    public APIManagerUsageStats[] getApiManagerUsageStats() {
-        return apiManagerUsageStats;
-    }
-
-    public void setApiManagerUsageStats(APIManagerUsageStats[] apiManagerUsageStats) {
-        this.apiManagerUsageStats = apiManagerUsageStats;
-    }
-
-    public BandwidthStatistics[] getRegistryBandwidthStatistics() {
-        return registryBandwidthStatistics;
-    }
-
-    public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) {
-        this.registryBandwidthStatistics = registryBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getServiceBandwidthStatistics() {
-        return serviceBandwidthStatistics;
-    }
-
-    public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) {
-        this.serviceBandwidthStatistics = serviceBandwidthStatistics;
-    }
-
-    public BandwidthStatistics[] getWebappBandwidthStatistics() {
-        return webappBandwidthStatistics;
-    }
-
-    public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) {
-        this.webappBandwidthStatistics = webappBandwidthStatistics;
-    }
-
-    public RequestStatistics getTotalRequestStatistics() {
-        return totalRequestStatistics;
-    }
-
-    public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) {
-        this.totalRequestStatistics = totalRequestStatistics;
-    }
-
-    public BandwidthStatistics getTotalRegistryBandwidth() {
-        return totalRegistryBandwidth;
-    }
-
-    public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) {
-        this.totalRegistryBandwidth = totalRegistryBandwidth;
-    }
-
-    public BandwidthStatistics getTotalServiceBandwidth() {
-        return totalServiceBandwidth;
-    }
-
-    public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) {
-        this.totalServiceBandwidth = totalServiceBandwidth;
-    }
-
-    public BandwidthStatistics getTotalWebappBandwidth() {
-        return totalWebappBandwidth;
-    }
-
-    public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) {
-        this.totalWebappBandwidth = totalWebappBandwidth;
-    }
-
-    public TenantUsage() {
-        // empty method required for used in web services
-    }
-
-    public TenantUsage(int tenantId, String domain) {
-        this.tenantId = tenantId;
-        this.domain = domain;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    public UsageEntry[] getUsageEntries() {
-        return usageEntries;
-    }
-
-    public void setUsageEntries(UsageEntry[] usageEntries) {
-        this.usageEntries = usageEntries;
-    }
-
-    public RequestStatistics[] getRequestStatistics() {
-        return requestStatistics;
-    }
-
-    public void setRequestStatistics(RequestStatistics[] requestStatistics) {
-        this.requestStatistics = requestStatistics;
-    }
-
-    public TenantDataCapacity getRegistryCapacity() {
-        return registryCapacity;
-    }
-
-    public void setRegistryCapacity(TenantDataCapacity registryCapacity) {
-        this.registryCapacity = registryCapacity;
-    }
-
-    public int getNumberOfUsers() {
-        return numberOfUsers;
-    }
-
-    public void setNumberOfUsers(int numberOfUsers) {
-        this.numberOfUsers = numberOfUsers;
-    }
-
-    public long getRegistryContentCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentCapacity();
-        }
-        return retValue;
-    }
-
-    public long getRegistryContentHistoryCapacity(){
-        long retValue = 0;
-        if (registryCapacity != null) {
-            retValue = registryCapacity.getRegistryContentHistoryCapacity();
-        }
-        return retValue;
-    }
-
-    public long getTotalIncomingBandwidth(){
-        long incomingBW =  0;
-        if(totalRegistryBandwidth != null){
-            incomingBW += totalRegistryBandwidth.getIncomingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            incomingBW += totalServiceBandwidth.getIncomingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            incomingBW += totalWebappBandwidth.getIncomingBandwidth();
-        }
-        return incomingBW;
-    }
-
-    public long getTotalOutgoingBandwidth(){
-        long outgoingBW =  0;
-        if(totalRegistryBandwidth != null){
-            outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth();
-        }
-        if(totalServiceBandwidth != null){
-            outgoingBW += totalServiceBandwidth.getOutgoingBandwidth();
-        }
-        if(totalWebappBandwidth != null){
-            outgoingBW += totalWebappBandwidth.getOutgoingBandwidth();
-        }
-        return outgoingBW;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
deleted file mode 100644
index ff9c4be..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/beans/UsageEntry.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class UsageEntry {
-    private String key;
-    private String value;
-
-    public UsageEntry() {
-        // empty constructor to used in web services
-    }
-
-    public UsageEntry(String key, String value) {
-        this.key = key;
-        this.value = value;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
deleted file mode 100644
index cc30312..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/internal/UsageServiceComponent.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.local.LocalTransportReceiver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-
-/**
- * @scr.component name="org.wso2.carbon.usage" immediate="true"
- * @scr.reference name="registry.service"
- * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
- * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
- * @scr.reference name="user.realmservice.default" 
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" 
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service" 
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" 
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="datasources.service"
- * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
- * cardinality="1..1" policy="dynamic"
- * bind="setDataSourceService" unbind="unsetDataSourceService"
- */
-public class UsageServiceComponent {
-    private static Log log = LogFactory.getLog(UsageServiceComponent.class);
-
-
-    protected void activate(ComponentContext context) {
-        try {
-            Util.registerRetrieverServices(context.getBundleContext());
-            log.debug("******* Usage bundle is activated ******* ");    
-        } catch (Exception e) {
-            log.error("******* Error in activating Usage bundle ******* ");
-        }
-    }
-
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Usage is deactivated ******* ");
-    }
-
-    protected void setRegistryService(RegistryService registryService) {
-        Util.setRegistryService(registryService);
-    }
-
-    protected void unsetRegistryService(RegistryService registryService) {
-        Util.setRegistryService(null);
-    }
-
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-    
-    protected void setConfigurationContextService(ConfigurationContextService ccService) {
-        //commented to work with the local transport
-	/*ConfigurationContext serverCtx = ccService.getServerConfigContext();
-        AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
-        LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
-        LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
-        LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
-	*/
-        Util.setConfigurationContextService(ccService);
-    }
-
-    protected void unsetConfigurationContextService(ConfigurationContextService ccService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    protected void setDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(dataSourceService);
-    }
-    
-    protected void unsetDataSourceService(DataSourceService dataSourceService){
-        Util.setDataSourceService(null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/services/UsageService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/services/UsageService.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/services/UsageService.java
deleted file mode 100644
index 2348b2b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/services/UsageService.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.services;
-
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.usage.beans.InstanceUsageStatics;
-import org.wso2.carbon.usage.beans.PaginatedInstanceUsage;
-import org.wso2.carbon.usage.beans.PaginatedTenantUsageInfo;
-import org.wso2.carbon.usage.beans.TenantUsage;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class UsageService extends AbstractAdmin {
-    /**
-     * Return the usage of the current logged in tenant
-     *
-     * @param yearMonth year month
-     * @return the current usage of the tenant
-     * @throws Exception
-     */
-    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
-        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
-        int tenantId = registry.getTenantId();
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    /**
-     * Return the all the tenant usages, requires super admin permissions
-     *
-     * @param yearMonth
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                        tenant.getId(), yearMonth);
-                tenantUsages.add(tenantUsage);
-            }
-        }
-        return tenantUsages.toArray(new TenantUsage[tenantUsages.size()]);
-    }
-
-    /**
-     * Return the all the tenant usages paginated, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param pageNumber
-     * @param entriesPerPage
-     * @return PaginatedTenantUsageInfo
-     * @throws Exception
-     */
-    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
-                                                                  int entriesPerPage) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
-        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
-
-        int i = 0;
-        int numberOfPages = 0;
-        for (Tenant tenant : tenants) {
-            if (tenant.isActive()) {
-                if (i % entriesPerPage == 0) {
-                    numberOfPages++;
-                }
-                if (numberOfPages == pageNumber) {
-                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
-                            tenant.getId(), yearMonth);
-                    tenantUsages.add(tenantUsage);
-                }
-                i++;
-            }
-        }
-        PaginatedTenantUsageInfo paginatedTenantInfo = new PaginatedTenantUsageInfo();
-        paginatedTenantInfo.setTenantUsages(
-                tenantUsages.toArray(new TenantUsage[tenantUsages.size()]));
-        paginatedTenantInfo.setNumberOfPages(numberOfPages);
-        paginatedTenantInfo.setPageNumber(pageNumber);
-        return paginatedTenantInfo;
-    }
-
-    /**
-     * Returns usage of a particular tenant, requires super admin permissions
-     *
-     * @param yearMonth
-     * @param tenantId
-     * @return
-     * @throws Exception
-     */
-    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
-        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
-    }
-
-    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception {
-        return Util.getTenantUsageRetriever().getInstanceUsages();
-    }
-
-    /**
-     * @param yearMonth      year and month that used to retrieve data
-     * @param pageNumber
-     * @param entriesPerPage number of entries per page
-     * @return PaginatedInstanceUsage object that hold instance data and other parameters
-     * @throws Exception when retrieving Paginated Instance Usage error occurs
-     */
-    public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
-                                                                 int entriesPerPage) throws Exception {
-        InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
-        List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
-        PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
-        int i = 0;
-        int numberOfPages = 0;
-        if (instanceUsages != null && instanceUsages.length > 0) {
-            for (InstanceUsageStatics usage : instanceUsages) {
-                InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
-                if (instance != null) {
-                    if (i % entriesPerPage == 0) {
-                        numberOfPages++;
-                    }
-                }
-            }
-
-            paginatedInstanceUsages.setInstanceUsages(
-                instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
-        } else {
-            paginatedInstanceUsages.setInstanceUsages(null);
-        }
-
-        paginatedInstanceUsages.setNumberOfPages(numberOfPages);
-        paginatedInstanceUsages.setPageNumber(pageNumber);
-        return paginatedInstanceUsages;
-    }
-
-    /**
-     * @param usage     is Instance usage Statics object that holds data
-     * @param yearMonth year and month that need to check with instance usage data
-     * @return instance static if instance usage data match with given year and month, else null
-     */
-    public InstanceUsageStatics getValidUsageEntry(InstanceUsageStatics usage, String yearMonth) {
-        Date date = Calendar.getInstance().getTime();
-        if (yearMonth != null) {
-            try {
-                date = CommonUtil.getDateFromMonthString(yearMonth);
-            } catch (ParseException e) {
-
-            }
-        }
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-        if (usage.getStartTime().compareTo(startDate) <= 0 && usage.getStopTime().compareTo(endDate) >= 0) {
-            usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                    startDate.getTimeInMillis()) / 1000);
-            return usage;
-        }
-        if (usage.getStartTime().compareTo(startDate) > 0 && usage.getStartTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(endDate) < 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            } else if (usage.getStopTime().compareTo(endDate) > 0) {
-                usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
-                        usage.getStartTime().getTimeInMillis()) / 1000);
-                return usage;
-
-            }
-        }
-        if (usage.getStartTime().compareTo(startDate) < 0 && usage.getStopTime().compareTo(endDate) < 0) {
-            if (usage.getStopTime().compareTo(startDate) > 0) {
-                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
-                        startDate.getTimeInMillis()) / 1000);
-                return usage;
-            }
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
deleted file mode 100644
index d5b5072..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.2/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
+++ /dev/null
@@ -1,498 +0,0 @@
-package org.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.beans.APIManagerUsageStats;
-import org.wso2.carbon.usage.beans.BandwidthStatistics;
-import org.wso2.carbon.usage.beans.RequestStatistics;
-import org.wso2.carbon.usage.beans.TenantDataCapacity;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class DataAccessObject {
-
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-    private DataSource dataSource;
-
-
-    public DataAccessObject(){
-        if(Util.getDataSourceService()!=null){
-            try{
-                this.dataSource = (DataSource)Util.getDataSourceService().
-                        getDataSource(Util.BILLING_DATA_SOURCE_NAME).getDSObject();
-            }catch(Exception e){
-                log.error("Error occurred while obtaining " + Util.BILLING_DATA_SOURCE_NAME +
-                        " datasource from data source service.", e);
-                dataSource=null;
-            }
-        }else{
-            log.error("Cannot obtain data source " + Util.BILLING_DATA_SOURCE_NAME + ". Datasource service is null");
-            dataSource=null;
-        }
-    }
-
-
-    public List<BandwidthStatistics> getHourlyBandwidthStats(int tenantId, Calendar startDate,
-                                                             Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getDailyBandwidthStats(int tenantId, Calendar startDate,
-                                                            Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Stats of this month will be retrieved
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getMonthlyBandwidthStats(int tenantId,
-                                                              Calendar month) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_DATA");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getHourlyRequestStats(int tenantId, Calendar startDate,
-                                                         Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getDailyRequestStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Month - Stats of this month will be retrieved
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getMonthlyRequestStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    public TenantDataCapacity getTenantDataCapacity(int tenantId) throws Exception{
-        Connection connection = null;
-        TenantDataCapacity tenantDataCapacity = null;
-
-        try{
-            connection = dataSource.getConnection();
-            String id = ""  + tenantId + "Final";
-            String sql = "SELECT * FROM REGISTRY_USAGE_HOURLY_ANALYTICS WHERE ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, id);
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                long currentCapacity = resultSet.getLong("CURRENT_USAGE");
-                long historyCapacity = resultSet.getLong("HISTORY_USAGE");
-
-                tenantDataCapacity = new TenantDataCapacity(currentCapacity, historyCapacity);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving registry data usage from . ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return tenantDataCapacity;
-    }
-
-    /**
-     * @param tenantId  Tenant Id of associated tenant
-     * @param startDate Start Date start time stamp of hour
-     * @param endDate   End date end time stamp of hour
-     * @return APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getHourlyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                    Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     * @param tenantId  Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate   End date - Stats of this date will be included
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getDailyAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                                   Calendar endDate) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if ("API-Call".equals(key)) {
-                    stats.setRequestCount(resultSet.getLong("PAYLOAD_VALUE"));
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-        return bwsList;
-    }
-
-    /**
-     * @param tenantId Tenant ID
-     * @param month    Stats of this month will be retrieved
-     * @return A list of APIManagerUsageStats objects
-     * @throws Exception
-     */
-    public List<APIManagerUsageStats> getMonthlyAPIManagerUsageStats(int tenantId,
-                                                                     Calendar month) throws Exception {
-        Connection connection = null;
-        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-
-        try {
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while (resultSet.next()) {
-                String key = resultSet.getString("PAYLOAD_DATA");
-                APIManagerUsageStats stats = new APIManagerUsageStats(key);
-
-                if (UsageConstants.API_CALL_COUNT.equals(key)) {
-                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                } else {
-                    //Do nothing
-                }
-
-                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
-                bwsList.add(stats);
-            }
-        } catch (SQLException e) {
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        } finally {
-            if (connection != null) {
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-}


[13/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
deleted file mode 100644
index 72de105..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/java/org/wso2/carbon/usage/ui/utils/UsageUtil.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.ui.utils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.common.ui.UIException;
-import org.wso2.carbon.usage.stub.beans.xsd.*;
-import org.wso2.carbon.usage.ui.clients.UsageServiceClient;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpSession;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class UsageUtil {
-    private static final Log log = LogFactory.getLog(UsageUtil.class);
-
-    private static long KB_LIMIT = 1024;
-    private static long MB_LIMIT = 1024 * 1024;
-    private static long GB_LIMIT = 1024 * 1024 * 1024;
-    private static long TB_LIMIT = (long) 1024 * 1024 * 1024 * 1024;
-
-    public static TenantUsage retrieveCurrentTenantUsage(ServletRequest request,
-                                                         ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveCurrentTenantUsage(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get current tenant usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage[] retrieveTenantUsages(ServletRequest request,
-                                                     ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrieveTenantUsages(yearMonth);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedTenantUsageInfo retrievePaginatedTenantUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedTenantUsages(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get all tenants usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static TenantUsage retrieveTenantUsage(ServletRequest request,
-                                                  ServletConfig config, HttpSession session) throws Exception {
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            String tenantIdStr = request.getParameter("tenant-id");
-            if (tenantIdStr == null) {
-                tenantIdStr = "0";
-            }
-            return serviceClient.retrieveTenantUsage(yearMonth, Integer.parseInt(tenantIdStr));
-        } catch (Exception e) {
-            String msg = "Failed to get tenant usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-
-    public static String convertBytesToString(long storage) {
-        if (storage < KB_LIMIT) {
-            return storage + " Byte(s)";
-        } else if (storage < MB_LIMIT) {
-            return storage / KB_LIMIT + " KByte(s)";
-        } else if (storage < GB_LIMIT) {
-            return storage / MB_LIMIT + " MByte(s)";
-        } else if (storage < TB_LIMIT) {
-            return storage / GB_LIMIT + " GByte(s)";
-        } else {
-            return storage / TB_LIMIT + " TByte(s)";
-        }
-    }
-
-    public static String getCurrentYearMonth() {
-        Calendar calendar = Calendar.getInstance();
-        return CommonUtil.getMonthString(calendar);
-    }
-
-    public static String[] getYearMonths() {
-        // we will list 100 months for now
-        List<String> yearMonths = new ArrayList<String>();
-        for (int i = 0; i > -100; i--) {
-            String yearMonth = CommonUtil.getMonthString(i);
-            yearMonths.add(yearMonth);
-        }
-        return yearMonths.toArray(new String[yearMonths.size()]);
-    }
-
-    public static String getCurrentDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (regData != null) {
-            currentData = regData.getRegistryContentCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getHistoryDataStorage(TenantUsage usage) {
-        TenantDataCapacity historyData = usage.getRegistryCapacity();
-        long currentData = 0;
-        if (historyData != null) {
-            currentData = historyData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(currentData);
-    }
-
-    public static String getTotalDataStorage(TenantUsage usage) {
-        TenantDataCapacity regData = usage.getRegistryCapacity();
-        long totalDataStorage = 0;
-        if (regData != null) {
-            totalDataStorage =
-                    regData.getRegistryContentCapacity() + regData.getRegistryContentHistoryCapacity();
-        }
-        return convertBytesToString(totalDataStorage);
-    }
-
-    public static String getIncomingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getOutgoingBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static String getTotalBandwidth(BandwidthStatistics bandwidth) {
-        long totalBW = 0;
-        if (bandwidth != null) {
-            totalBW = bandwidth.getIncomingBandwidth() + bandwidth.getOutgoingBandwidth();
-        }
-        return convertBytesToString(totalBW);
-    }
-
-    public static InstanceUsageStatics[] retrieveInstanceUsage(ServletRequest request,
-                                                               ServletConfig config, HttpSession session)
-            throws Exception {
-
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            InstanceUsageStatics[] returnInstanceUsage = serviceClient.retrieveInstanceUsage();
-            return returnInstanceUsage;
-        } catch (Exception e) {
-            String msg = "Failed to get current instance usage.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-    public static PaginatedInstanceUsage retrievePaginatedInstanceUsages(ServletRequest request,
-                                                                         ServletConfig config, HttpSession session) throws Exception {
-        String requestedPage = request.getParameter("requestedPage");
-        int pageNumber = 1;
-        int numberOfPages = 1;
-        int entriesPerPage = 15;
-        if (requestedPage != null && requestedPage.length() > 0) {
-            pageNumber = new Integer(requestedPage);
-        }
-        try {
-            UsageServiceClient serviceClient = new UsageServiceClient(config, session);
-            String yearMonth = request.getParameter("year-month");
-            if (yearMonth == null) {
-                // get the current year month
-                yearMonth = getCurrentYearMonth();
-            }
-            return serviceClient.retrievePaginatedInstanceUsage(yearMonth, pageNumber, entriesPerPage);
-        } catch (Exception e) {
-            String msg = "Failed to get paginated instance usages.";
-            log.error(msg, e);
-            throw new UIException(msg, e);
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 19b0510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<component xmlns="http://products.wso2.org/carbon">
-    <!-- sample menu configuration -->
-    <menus>
-        <menu>
-            <id>usage_monitoring_menu</id>
-            <i18n-key>usage.monitoring</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu></parent-menu>
-            <link>#</link>
-            <region>region4</region>
-            <style-class>home</style-class>
-            <order>22</order>
-            <icon>../services/images/services.gif</icon>
-        </menu>
-        <menu>
-            <id>tenant_usage_menu</id>
-            <i18n-key>tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>51</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/user-usage-report.gif</icon>
-            <require-permission>/permission/admin/monitor/tenantUsage</require-permission>
-            <require-not-super-tenant>true</require-not-super-tenant>
-        </menu>
-        <!--menu>
-            <id>all_tenant_instance_usage_menu</id>
-            <i18n-key>instance.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_instance_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/instance-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu-->
-        <menu>
-            <id>all_tenant_usage_menu</id>
-            <i18n-key>all.tenant.usage.report</i18n-key>
-            <i18n-bundle>org.wso2.carbon.usage.ui.i18n.Resources</i18n-bundle>
-            <parent-menu>monitor_menu</parent-menu>
-            <link>../tenant-usage/all_tenant_usage.jsp</link>
-            <region>region4</region>
-            <order>50</order>
-            <style-class>manage</style-class>
-            <icon>../tenant-usage/images/tenant-usage-report.gif</icon>
-            <require-permission>/permission/protected/monitor/userUsage</require-permission>
-            <require-super-tenant>true</require-super-tenant>
-        </menu>
-    </menus>
-
-</component>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/UsageService.wsdl
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/UsageService.wsdl b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/UsageService.wsdl
deleted file mode 100644
index a974e17..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/UsageService.wsdl
+++ /dev/null
@@ -1,604 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-                  xmlns:ns1="http://org.apache.axis2/xsd"
-                  xmlns:ns="http://services.usage.carbon.wso2.org"
-                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
-                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
-                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
-                  xmlns:ax2249="http://beans.usage.carbon.wso2.org/xsd"
-                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
-                  targetNamespace="http://services.usage.carbon.wso2.org">
-    <wsdl:documentation>UsageService</wsdl:documentation>
-    <wsdl:types>
-        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://beans.usage.carbon.wso2.org/xsd">
-            <xs:complexType name="TenantUsage">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="domain" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="numberOfUsers" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="registryBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="registryCapacity" nillable="true"
-                                type="ax2249:TenantDataCapacity"/>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="requestStatistics"
-                                nillable="true" type="ax2249:RequestStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0"
-                                name="serviceBandwidthStatistics" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    <xs:element minOccurs="0" name="totalIncomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalOutgoingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="totalRegistryBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-
-                    <xs:element minOccurs="0" name="totalRequestStatistics" nillable="true"
-                                type="ax2249:RequestStatistics"/>
-                    <xs:element minOccurs="0" name="totalServiceBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element minOccurs="0" name="totalWebappBandwidth" nillable="true"
-                                type="ax2249:BandwidthStatistics"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="usageEntries"
-                                nillable="true" type="ax2249:UsageEntry"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="webappBandwidthStatistics"
-                                nillable="true" type="ax2249:BandwidthStatistics"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="BandwidthStatistics">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="incomingBandwidth" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="outgoingBandwidth" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="TenantDataCapacity">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="registryContentCapacity" type="xs:long"/>
-                    <xs:element minOccurs="0" name="registryContentHistoryCapacity" type="xs:long"/>
-
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="RequestStatistics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="faultCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="requestCount" type="xs:long"/>
-                    <xs:element minOccurs="0" name="responseCount" type="xs:long"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:complexType name="UsageEntry">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="key" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedTenantUsageInfo">
-                <xs:sequence>
-
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="tenantUsages"
-                                nillable="true" type="ax2249:TenantUsage"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="PaginatedInstanceUsage">
-                <xs:sequence>
-                    <xs:element maxOccurs="unbounded" minOccurs="0" name="instanceUsages"
-                                nillable="true" type="ax2249:InstanceUsageStatics"/>
-                    <xs:element minOccurs="0" name="numberOfPages" type="xs:int"/>
-
-                    <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                </xs:sequence>
-            </xs:complexType>
-            <xs:complexType name="InstanceUsageStatics">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="instanceID" nillable="true" type="xs:int"/>
-                    <xs:element minOccurs="0" name="instanceURL" nillable="true" type="xs:string"/>
-                    <xs:element minOccurs="0" name="running" type="xs:boolean"/>
-                    <xs:element minOccurs="0" name="startTime" nillable="true" type="xs:dateTime"/>
-
-                    <xs:element minOccurs="0" name="stopTime" nillable="true" type="xs:dateTime"/>
-                    <xs:element minOccurs="0" name="usedTimeInSeconds" type="xs:long"/>
-                </xs:sequence>
-            </xs:complexType>
-        </xs:schema>
-        <xs:schema xmlns:ax2250="http://beans.usage.carbon.wso2.org/xsd"
-                   attributeFormDefault="qualified" elementFormDefault="qualified"
-                   targetNamespace="http://services.usage.carbon.wso2.org">
-            <xs:import namespace="http://beans.usage.carbon.wso2.org/xsd"/>
-            <xs:element name="Exception">
-                <xs:complexType>
-
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="Exception" nillable="true"
-                                    type="ns:Exception"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:complexType name="Exception">
-                <xs:sequence>
-                    <xs:element minOccurs="0" name="Message" nillable="true" type="xs:string"/>
-                </xs:sequence>
-
-            </xs:complexType>
-            <xs:element name="retrieveTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsagesResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="tenantId" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsages">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrievePaginatedTenantUsagesResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedTenantUsageInfo"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsage">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                        <xs:element minOccurs="0" name="pageNumber" type="xs:int"/>
-                        <xs:element minOccurs="0" name="entriesPerPage" type="xs:int"/>
-                    </xs:sequence>
-                </xs:complexType>
-
-            </xs:element>
-            <xs:element name="retrievePaginatedInstanceUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:PaginatedInstanceUsage"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveInstanceUsageResponse">
-
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
-                                    nillable="true" type="ax2250:InstanceUsageStatics"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsage">
-                <xs:complexType>
-                    <xs:sequence>
-
-                        <xs:element minOccurs="0" name="yearMonth" nillable="true"
-                                    type="xs:string"/>
-                    </xs:sequence>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="retrieveCurrentTenantUsageResponse">
-                <xs:complexType>
-                    <xs:sequence>
-                        <xs:element minOccurs="0" name="return" nillable="true"
-                                    type="ax2250:TenantUsage"/>
-                    </xs:sequence>
-
-                </xs:complexType>
-            </xs:element>
-        </xs:schema>
-    </wsdl:types>
-    <wsdl:message name="retrievePaginatedTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedTenantUsagesResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="Exception">
-        <wsdl:part name="parameters" element="ns:Exception"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveCurrentTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveCurrentTenantUsageResponse"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsages"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsagesResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsagesResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageRequest">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsage"/>
-
-    </wsdl:message>
-    <wsdl:message name="retrieveTenantUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveTenantUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrieveInstanceUsageRequest"/>
-    <wsdl:message name="retrieveInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrieveInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageRequest">
-
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsage"/>
-    </wsdl:message>
-    <wsdl:message name="retrievePaginatedInstanceUsageResponse">
-        <wsdl:part name="parameters" element="ns:retrievePaginatedInstanceUsageResponse"/>
-    </wsdl:message>
-    <wsdl:portType name="UsageServicePortType">
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <wsdl:input message="ns:retrievePaginatedTenantUsagesRequest"
-                        wsaw:Action="urn:retrievePaginatedTenantUsages"/>
-            <wsdl:output message="ns:retrievePaginatedTenantUsagesResponse"
-                         wsaw:Action="urn:retrievePaginatedTenantUsagesResponse"/>
-
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <wsdl:input message="ns:retrieveCurrentTenantUsageRequest"
-                        wsaw:Action="urn:retrieveCurrentTenantUsage"/>
-            <wsdl:output message="ns:retrieveCurrentTenantUsageResponse"
-                         wsaw:Action="urn:retrieveCurrentTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveCurrentTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <wsdl:input message="ns:retrieveTenantUsagesRequest"
-                        wsaw:Action="urn:retrieveTenantUsages"/>
-
-            <wsdl:output message="ns:retrieveTenantUsagesResponse"
-                         wsaw:Action="urn:retrieveTenantUsagesResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsagesException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <wsdl:input message="ns:retrieveTenantUsageRequest"
-                        wsaw:Action="urn:retrieveTenantUsage"/>
-            <wsdl:output message="ns:retrieveTenantUsageResponse"
-                         wsaw:Action="urn:retrieveTenantUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveTenantUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-
-            <wsdl:input message="ns:retrieveInstanceUsageRequest"
-                        wsaw:Action="urn:retrieveInstanceUsage"/>
-            <wsdl:output message="ns:retrieveInstanceUsageResponse"
-                         wsaw:Action="urn:retrieveInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrieveInstanceUsageException"/>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <wsdl:input message="ns:retrievePaginatedInstanceUsageRequest"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsage"/>
-            <wsdl:output message="ns:retrievePaginatedInstanceUsageResponse"
-                         wsaw:Action="urn:retrievePaginatedInstanceUsageResponse"/>
-            <wsdl:fault message="ns:Exception" name="Exception"
-                        wsaw:Action="urn:retrievePaginatedInstanceUsageException"/>
-        </wsdl:operation>
-
-    </wsdl:portType>
-    <wsdl:binding name="UsageServiceSoap11Binding" type="ns:UsageServicePortType">
-        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceSoap12Binding" type="ns:UsageServicePortType">
-        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <soap12:operation soapAction="urn:retrievePaginatedTenantUsages" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <soap12:operation soapAction="urn:retrieveCurrentTenantUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsages">
-            <soap12:operation soapAction="urn:retrieveTenantUsages" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrieveTenantUsage">
-            <soap12:operation soapAction="urn:retrieveTenantUsage" style="document"/>
-            <wsdl:input>
-
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <soap12:operation soapAction="urn:retrieveInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <soap12:operation soapAction="urn:retrievePaginatedInstanceUsage" style="document"/>
-            <wsdl:input>
-                <soap12:body use="literal"/>
-            </wsdl:input>
-            <wsdl:output>
-
-                <soap12:body use="literal"/>
-            </wsdl:output>
-            <wsdl:fault name="Exception">
-                <soap12:fault use="literal" name="Exception"/>
-            </wsdl:fault>
-        </wsdl:operation>
-    </wsdl:binding>
-    <wsdl:binding name="UsageServiceHttpBinding" type="ns:UsageServicePortType">
-        <http:binding verb="POST"/>
-
-        <wsdl:operation name="retrievePaginatedTenantUsages">
-            <http:operation location="retrievePaginatedTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveCurrentTenantUsage">
-            <http:operation location="retrieveCurrentTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsages">
-            <http:operation location="retrieveTenantUsages"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveTenantUsage">
-            <http:operation location="retrieveTenantUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrieveInstanceUsage">
-            <http:operation location="retrieveInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-        <wsdl:operation name="retrievePaginatedInstanceUsage">
-            <http:operation location="retrievePaginatedInstanceUsage"/>
-            <wsdl:input>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:input>
-            <wsdl:output>
-                <mime:content type="text/xml" part="parameters"/>
-            </wsdl:output>
-        </wsdl:operation>
-
-    </wsdl:binding>
-    <wsdl:service name="UsageService">
-        <wsdl:port name="UsageServiceHttpsSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap11Endpoint" binding="ns:UsageServiceSoap11Binding">
-            <soap:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap11Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-
-            <soap12:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsSoap12Endpoint" binding="ns:UsageServiceSoap12Binding">
-            <soap12:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsSoap12Endpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpEndpoint" binding="ns:UsageServiceHttpBinding">
-            <http:address
-                    location="http://10.100.0.19:9765/services/UsageService.UsageServiceHttpEndpoint/"/>
-        </wsdl:port>
-        <wsdl:port name="UsageServiceHttpsEndpoint" binding="ns:UsageServiceHttpBinding">
-
-            <http:address
-                    location="https://10.100.0.19:9446/services/UsageService.UsageServiceHttpsEndpoint/"/>
-        </wsdl:port>
-    </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
deleted file mode 100644
index e7490b0..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/JSResources.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-empty=To make sure the js properties file is not empty
-session.timed.out=Session timed out. Please login again
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
deleted file mode 100644
index 087e439..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/org/wso2/carbon/usage/ui/i18n/Resources.properties
+++ /dev/null
@@ -1,51 +0,0 @@
-usage.menu=User Usage
-user.usage.report=User Usage Report
-tenant.menu=Tenant Usage
-tenants.usage.report=Tenant Usage Report
-tenant.usage.report=Usage Report
-data.storage.name=Data Storage
-current.data.storage=Current Data Storage
-history.data.storage=Historical Data Storage
-total.data.storage=Total Data Storage
-registry.content.storage.name=Registry Content
-registry.bandwidth.usage=Registry Bandwidth Usage
-service.bandwidth.usage=Service Bandwidth Usage
-webapp.bandwidth.usage=Webapp Bandwidth Usage
-server.name=Server Name
-all.server.name=All Server Total
-incoming.bandwidth=Incoming Bandwidth
-outgoing.bandwidth=Outgoing Bandwidth
-total.bandwidth=Total Bandwidth
-storage.usage=Storage Usage
-number.of.users=Number of Users
-users=Users
-usage.monitoring=Usage Monitoring
-all.tenant.usage.report=All Tenant Usage
-tenant.domain=Domain
-tenant.id=Id
-full.report=Full Report
-report.duration=Report Duration
-year.month=Year-Month
-back=Back
-page.x.to.y=Page {0}
-prev=Prev
-next=Next
-service.usage.stat=Service Usage Statistics
-service.usage.request=Request Count
-service.usage.response=Response Count
-service.usage.fault=Fault Count
-service.total.request=Service Requests
-registry.total.bandwidth=Total Registry Bandwidth
-service.total.bandwidth=Total Service Bandwidth
-instance.usage.report=Instance Usage Report
-instance.server.url=Instance Server URL
-instance.id=Instance ID
-start.time=Start Time
-stop.time=Stop Time
-used.time.in.hours=Used Time In Hours
-instances.data=Instances Data
-failed.to.get.instance.data=Failed To Get Instance Data
-empty.instance.data=Instance Data Not Found
-usage.data.not.available=Usage Data not available
-empty.usage.data=Usage Data Not Found
-webapp.total.bandwidth=Total WebApp Bandwidth

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
deleted file mode 100644
index e4c9510..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_instance_usage.jsp
+++ /dev/null
@@ -1,216 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.InstanceUsageStatics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedInstanceUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-        int pageNumber=0;
-        int rowCount = 5;
-        int numberOfPages=0;
-        InstanceUsageStatics[] instanceUsages=null;
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        try{
-        PaginatedInstanceUsage instanceInfo =
-                UsageUtil.retrievePaginatedInstanceUsages(request, config, session);
-        instanceUsages = instanceInfo.getInstanceUsages();
-        pageNumber = instanceInfo.getPageNumber();
-        numberOfPages = instanceInfo.getNumberOfPages();
-
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-        }
-        catch (Exception e){
-        //No need to handle here it here.Error will show in next try block
-        //To avoid dead page
-        }
-    %>
-
-    <div id="middle">
-
-        <h2><fmt:message key="instance.usage.report"/> for the Month - <%=yearMonth%> (With All
-            Running Instances)</h2>
-
-        <div id="report_ui">
-            <carbon:reportNew
-                    component="org.wso2.carbon.usage"
-                    template="all_tenant_usage_report"
-                    pdfReport="true"
-                    htmlReport="true"
-                    excelReport="true"
-                    reportDataSession="all_tenant_usage_data"
-                    jsFunction="getUsageReportData()"/>
-        </div>
-
-        <div id="workArea">
-
-            <form id="usageForm" action="all_tenant_instance_usage.jsp" method="post">
-
-
-                <table class="styledLeft">
-                    <thead>
-                    <tr>
-                        <th>
-                            <fmt:message key="report.duration"/>
-                        </th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr>
-                        <td class="nopadding">
-                            <table class="normal-nopadding" cellspacing="0">
-                                <tbody>
-                                <tr>
-                                    <td><fmt:message key="year.month"/></td>
-                                    <td colspan="2">
-                                        <select onchange="this.form.submit()" name="year-month"
-                                                id="year-month" style="width:400px">
-                                            <%
-                                                for (String ym : UsageUtil.getYearMonths()) {
-                                                    String selectedStr = "";
-                                                    if (ym.equals(yearMonth)) {
-                                                        selectedStr = "selected=\"true\" ";
-                                                    }
-                                            %>
-                                            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                            </option>
-                                            <%
-                                                }
-                                            %>
-                                        </select>
-                                        <input type="hidden" name="requestedPage" id="requestedPage"
-                                               value="<%=pageNumber%>"/>
-                                    </td>
-                                </tr>
-
-                                <tr>
-                                    <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                            key="instances.data"/></td>
-                                </tr>
-                                <tr>
-                                    <th><fmt:message key="instance.id"/></th>
-                                    <th><fmt:message key="server.name"/></th>
-                                    <th><fmt:message key="start.time"/></th>
-                                    <th><fmt:message key="stop.time"/></th>
-                                    <th><fmt:message key="used.time.in.hours"/></th>
-                                </tr>
-                                <%                
-                                    try{
-                                    InstanceUsageStatics[] iu = UsageUtil.retrieveInstanceUsage(request, config, session);
-                                    java.text.SimpleDateFormat dateFormatter = new java.text.SimpleDateFormat("yyyy.MM.dd 'at' hh:mm:ss a zzz");
-                                    if (!iu.equals(null)) {
-                                        for (InstanceUsageStatics usage : instanceUsages) {
-                                            String endDate;
-                                            if (usage.getRunning() == true) {
-                                                endDate="Instance Still Running";
-                                            }
-                                            else{
-                                                endDate=dateFormatter.format(usage.getStopTime().getTime());
-                                            }
-                                            String startDate=dateFormatter.format(usage.getStartTime().getTime());
-                                            long usedHours;
-                                            long usedTimeInSeconds=usage.getUsedTimeInSeconds();
-                                            if(usedTimeInSeconds%3600==0){
-                                                usedHours=usedTimeInSeconds/3600;
-                                            }
-                                            else{
-                                                usedHours=(usedTimeInSeconds/3600)+1;
-                                            }
-                                %>
-                                <tr>
-                                    <td>
-                                        <%=usage.getInstanceID()%>
-                                    </td>
-                                    <td>
-                                        <%=usage.getInstanceURL().toString()%>
-                                    </td>
-                                    <td>
-                                        <%=startDate%>
-                                    </td>
-                                    <td>
-                                        <%=endDate%>
-                                    </td>
-                                    <td>
-
-                                        <%=usedHours%>
-                                    </td>
-                                </tr>
-                                <%
-
-                                        }
-                                    }
-                                    else{
-                                      %>
-                                     <td><fmt:message key="empty.instance.data"/></td>
-                                <%
-                                 }
-                                    }
-                                    catch (Exception e){ %>
-                                      <td><fmt:message key="failed.to.get.instance.data"/></td>
-                                   <% }
-                                %>
-                                <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                          numberOfPages="<%=numberOfPages%>"
-                                                          resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                          nextKey="next" prevKey="prev"
-                                                          tdColSpan="6"
-                                                          paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                                </tbody>
-                            </table>
-                        </td>
-                    </tr>
-                    </tbody>
-                </table>
-            </form>
-            <br/>
-        </div>
-    </div>
-</fmt:bundle>
-
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
deleted file mode 100644
index 6036a19..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage.jsp
+++ /dev/null
@@ -1,208 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.PaginatedTenantUsageInfo" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageData" %>
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page import="java.util.List" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-    <carbon:breadcrumb
-            label="tenants.usage.report"
-            resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-            topPage="true"
-            request="<%=request%>"/>
-    <jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-    <script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-    <script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-    <script type="text/javascript" src="../ajax/js/prototype.js"></script>
-    <script type="text/javascript" src="../tenant-usage/js/tenant-usage.js"></script>
-    <script type="text/javascript" src="js/all-tenant-usage-report.js"></script>
-    <link rel="stylesheet" type="text/css" href="../tenant-usage/css/tenant-usage.css"/>
-
-
-    <%
-        PaginatedTenantUsageInfo tenantsInfo =
-                UsageUtil.retrievePaginatedTenantUsages(request, config, session);
-        TenantUsage[] tenantUsages = tenantsInfo.getTenantUsages();
-        int pageNumber = tenantsInfo.getPageNumber();
-        int numberOfPages = tenantsInfo.getNumberOfPages();
-        String yearMonth = request.getParameter("year-month");
-        session.setAttribute("year-month", yearMonth);
-
-
-        if (yearMonth == null) {
-            // get the current year month
-            yearMonth = UsageUtil.getCurrentYearMonth();
-        }
-        String currentYearMonth = UsageUtil.getCurrentYearMonth();
-        int rowCount = 5;
-        if (yearMonth.equals(currentYearMonth)) {
-            rowCount = 7;
-        }
-    %>
-
-
-    <%
-        //AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-        //List<AllTenantUsageData> reportDataArray = usageReport.getUsageReportData();
-        //request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-    %>
-
-    <div id="middle">
-        <h2><fmt:message key="tenants.usage.report"/> for the Month - <%=yearMonth%> (All
-            Tenants)</h2>
-    </div>
-
-    <div id="workArea">
-
-        <form id="usageForm" action="all_tenant_usage.jsp" method="post">
-
-
-            <table class="styledLeft">
-                <thead>
-                <tr>
-                    <th>
-                        <fmt:message key="report.duration"/>
-                    </th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr>
-                    <td class="nopadding">
-                        <table class="normal-nopadding" cellspacing="0">
-                            <tbody>
-                            <tr>
-                                <td><fmt:message key="year.month"/></td>
-                                <td colspan="2">
-                                    <select onchange="this.form.submit()" name="year-month"
-                                            id="year-month" style="width:400px">
-                                        <%
-                                            for (String ym : UsageUtil.getYearMonths()) {
-                                                String selectedStr = "";
-                                                if (ym.equals(yearMonth)) {
-                                                    selectedStr = "selected=\"true\" ";
-                                                }
-                                        %>
-                                        <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-                                        </option>
-                                        <%
-                                            }
-                                        %>
-                                    </select>
-                                    <input type="hidden" name="requestedPage" id="requestedPage"
-                                           value="<%=pageNumber%>"/>
-                                </td>
-                            </tr>
-
-                            <tr>
-                                <td colspan="<%=rowCount%>" class="middle-header"><fmt:message
-                                        key="users"/></td>
-                            </tr>
-                            <tr>
-                                <th><fmt:message key="tenant.domain"/></th>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <th><fmt:message key="number.of.users"/></th>
-                                <th><fmt:message key="storage.usage"/></th><%}%>
-                                <%--<th><fmt:message key="registry.total.bandwidth"/></th>--%>
-                                <th><fmt:message key="service.total.bandwidth"/></th>
-                                <th><fmt:message key="webapp.total.bandwidth"/></th>
-                                <th><fmt:message key="service.total.request"/></th>
-                                <th><fmt:message key="full.report"/></th>
-                            </tr>
-                            <%
-                                if (tenantUsages != null) {
-                                    for (TenantUsage usage : tenantUsages) {
-                                        String currentDataStorage = UsageUtil.getTotalDataStorage(usage);
-                                        String regBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-                                        String svcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-                                        String webBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-                                        long svcTotalRequest = usage.getTotalRequestStatistics().getRequestCount();
-                                        int numberOfUsers = usage.getNumberOfUsers();
-
-                                        String username = (String) request.getSession().getAttribute("logged-user");
-                                        String tenantName = usage.getDomain();
-                                        int tenantId = usage.getTenantId();
-                                        String fullReportLink = "any_tenant_usage.jsp?tenant-id=" + tenantId + "&year-month=" + yearMonth;
-                            %>
-
-                            <tr>
-                                <td><%=tenantName%>
-                                </td>
-                                <%
-                                    if (yearMonth.equals(currentYearMonth)) {
-                                %>
-                                <td><%=numberOfUsers%>
-                                </td>
-                                <td><%=currentDataStorage%>
-                                </td>
-                                <%
-                                    }
-                                %>
-                                <%--<td><%=regBandwidth%>
-                                </td>--%>
-                                <td><%=svcBandwidth%>
-                                </td>
-                                <td><%=webBandwidth%>
-                                </td>
-                                <td><%=svcTotalRequest%>
-                                </td>
-                                <td><a href="<%=fullReportLink%>">Full Report</a></td>
-                            </tr>
-                            <%
-
-                                }
-                            } else {
-                            %>
-                            <tr>
-                                <td><fmt:message key="empty.usage.data"/></td>
-                            </tr>
-                            </tr>
-                            <%
-                                }
-
-                            %>
-                            <carbon:resourcePaginator pageNumber="<%=pageNumber%>"
-                                                      numberOfPages="<%=numberOfPages%>"
-                                                      resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-                                                      nextKey="next" prevKey="prev"
-                                                      tdColSpan="6"
-                                                      paginationFunction="submitAllTenantPaginatedUsage({0})"/>
-                            </tbody>
-                        </table>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </form>
-        <br/>
-    </div>
-    </div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
deleted file mode 100644
index ce67752..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/all_tenant_usage_report.jsp
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.ui.report.AllTenantUsageReport" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%
-    AllTenantUsageReport usageReport = new AllTenantUsageReport(config, session, request);
-    String[] reportDataArray = usageReport.getUsageReportData();
-    System.out.println("Report lenth "+reportDataArray.length);
-    request.getSession().setAttribute("all_tenant_usage_data", reportDataArray);
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/any_tenant_usage.jsp b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
deleted file mode 100644
index a00d327..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/any_tenant_usage.jsp
+++ /dev/null
@@ -1,390 +0,0 @@
-<!--
-~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-~
-~ WSO2 Inc. 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.
--->
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.BandwidthStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.RequestStatistics" %>
-<%@ page import="org.wso2.carbon.usage.stub.beans.xsd.TenantUsage" %>
-<%@ page import="org.wso2.carbon.usage.ui.utils.UsageUtil" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
-
-<carbon:jsi18n
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.JSResources"
-        request="<%=request%>"/>
-
-
-<fmt:bundle basename="org.wso2.carbon.usage.ui.i18n.Resources">
-<carbon:breadcrumb
-        label="tenant.usage.report"
-        resourceBundle="org.wso2.carbon.usage.ui.i18n.Resources"
-        topPage="false"
-        request="<%=request%>"/>
-<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
-<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
-<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
-<script type="text/javascript" src="../ajax/js/prototype.js"></script>
-<script type="text/javascript" src="js/register_config.js"></script>
-<%
-
-    TenantUsage usage = UsageUtil.retrieveTenantUsage(request, config, session);
-    int numberOfUsers = usage.getNumberOfUsers();
-    String yearMonth = request.getParameter("year-month");
-    if (yearMonth == null) {
-        // get the current year month
-        yearMonth = UsageUtil.getCurrentYearMonth();
-    }
-    String username = (String) request.getSession().getAttribute("logged-user");
-    String tenantName = usage.getDomain();
-    int tenantId = usage.getTenantId();
-    String currentYearMonth = UsageUtil.getCurrentYearMonth();
-%>
-
-<div id="middle">
-
-<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%>
-    )</h2>
-
-<div id="workArea">
-
-<form id="usageForm" action="any_tenant_usage.jsp" method="get">
-
-<table class="styledLeft">
-<thead>
-<tr>
-    <th>
-        <fmt:message key="report.duration"/>
-    </th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td class="nopadding">
-<table class="normal-nopadding" cellspacing="0">
-<tbody>
-<tr>
-    <td><fmt:message key="year.month"/></td>
-    <td colspan="3">
-        <input type="hidden" name="tenant-id" value="<%=tenantId%>"/>
-        <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px">
-            <%
-                for (String ym : UsageUtil.getYearMonths()) {
-                    String selectedStr = "";
-                    if (ym.equals(yearMonth)) {
-                        selectedStr = "selected=\"true\" ";
-                    }
-            %>
-            <option <%=selectedStr%> value="<%=ym%>"><%=ym%>
-            </option>
-            <%
-                }
-            %>
-        </select>
-    </td>
-</tr>
-
-<%
-    if (currentYearMonth.equals(yearMonth)) {
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="users"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="number.of.users"/></td>
-    <td colspan="3">
-        <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px"
-               value="<%=numberOfUsers%>"/>
-    </td>
-</tr>
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td>
-</tr>
-
-<tr>
-    <td><fmt:message key="data.storage.name"/></td>
-    <td><fmt:message key="current.data.storage"/></td>
-    <td><fmt:message key="history.data.storage"/></td>
-    <td><fmt:message key="total.data.storage"/></td>
-</tr>
-<%
-    String totalDataStorage = UsageUtil.getTotalDataStorage(usage);
-    String currentDataStorage = UsageUtil.getCurrentDataStorage(usage);
-    String historyDataStorage = UsageUtil.getHistoryDataStorage(usage);
-%>
-<tr>
-    <td><fmt:message key="registry.content.storage.name"/></td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px"
-               value="<%=currentDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px"
-               value="<%=historyDataStorage%>"/>
-    </td>
-    <td colspan="1">
-        <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px"
-               value="<%=totalDataStorage%>"/>
-    </td>
-</tr>
-
-<%
-    }
-%>
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth());
-    String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth());
-    BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics();
-    if (regBWStats != null) {
-        for (BandwidthStatistics stat : regBWStats) {
-            String regInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String regBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW"
-               style="width:200px" value="<%=regInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW"
-               style="width:200px" value="<%=regOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW"
-               style="width:200px" value="<%=regBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW"
-               style="width:200px" value="<%=totRegInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW"
-               style="width:200px" value="<%=totRegOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW"
-               style="width:200px" value="<%=totRegBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth());
-    String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth());
-    BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics();
-    if (svcBWStats != null) {
-        for (BandwidthStatistics stat : svcBWStats) {
-            String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String svcBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW"
-               style="width:200px" value="<%=svcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW"
-               style="width:200px" value="<%=svcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW"
-               style="width:200px" value="<%=svcBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW"
-               style="width:200px" value="<%=totSvcInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW"
-               style="width:200px" value="<%=totSvcOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW"
-               style="width:200px" value="<%=totSvcBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="incoming.bandwidth"/></td>
-    <td><fmt:message key="outgoing.bandwidth"/></td>
-    <td><fmt:message key="total.bandwidth"/></td>
-</tr>
-<%
-    String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth());
-    String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth());
-    BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics();
-    if (webappBWStats != null) {
-        for (BandwidthStatistics stat : webappBWStats) {
-            String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat);
-            String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat);
-            String webappBandwidth = UsageUtil.getTotalBandwidth(stat);
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW"
-               style="width:200px" value="<%=webappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW"
-               style="width:200px" value="<%=webappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px"
-               value="<%=webappBandwidth%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW"
-               style="width:200px" value="<%=totWebappInBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW"
-               style="width:200px" value="<%=totWebappOutBandwidth%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW"
-               style="width:200px" value="<%=totWebappBandwidth%>"/>
-    </td>
-</tr>
-
-
-<tr>
-    <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td>
-</tr>
-<tr>
-    <td><fmt:message key="server.name"/></td>
-    <td><fmt:message key="service.usage.request"/></td>
-    <td><fmt:message key="service.usage.response"/></td>
-    <td><fmt:message key="service.usage.fault"/></td>
-</tr>
-<%
-    long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount();
-    long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount();
-    long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount();
-    RequestStatistics[] svcStats = usage.getRequestStatistics();
-    if (svcStats != null) {
-        for (RequestStatistics stat : svcStats) {
-            long svcReqCount = stat.getRequestCount();
-            long svcResCount = stat.getResponseCount();
-            long svcFaultCount = stat.getFaultCount();
-%>
-<tr>
-    <td><%=stat.getKey()%>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount"
-               style="width:200px" value="<%=svcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount"
-               style="width:200px" value="<%=svcResCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount"
-               style="width:200px" value="<%=svcFaultCount%>"/>
-    </td>
-</tr>
-<%
-        }
-    }
-%>
-<tr>
-    <td><fmt:message key="all.server.name"/></td>
-    <td>
-        <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount"
-               style="width:200px" value="<%=totSvcReqCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount"
-               style="width:200px" value="<%=totSvcRespCount%>"/>
-    </td>
-    <td>
-        <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount"
-               style="width:200px" value="<%=totSvcFaultCount%>"/>
-    </td>
-</tr>
-
-</tbody>
-</table>
-</td>
-</tr>
-</tbody>
-</table>
-<br/>
-<input type='button' class='button' style="align:right" id="backButtonID"
-       onclick='window.location="../tenant-usage/all_tenant_usage.jsp?region=region4&item=all_tenant_usage_menu"'
-       value='<fmt:message key="back"/>'/>
-</form>
-<br/>
-</div>
-</div>
-</fmt:bundle>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/css/tenant-usage.css b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/css/tenant-usage.css
deleted file mode 100644
index 5c85728..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/css/tenant-usage.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.disableLink {
-    color: #aaaaaa;
-}
-
-.pageLinks {
-    background: #FFFFFF none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-.pageLinks-selected {
-    background: #e8e9ae none repeat scroll 0%;
-    border: 1px solid #DDDDDD;
-    padding: 2px 3px;
-    text-decoration: none;
-    margin: 0px;
-    margin-left: 2px;
-    margin-right: 2px;
-}
-
-a {
-    color: #386698;
-    cursor: pointer;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/images/view-usage.png b/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/images/view-usage.png
deleted file mode 100644
index 4080da3..0000000
Binary files a/components/stratos/usage/org.wso2.carbon.usage.ui/2.1.0/src/main/resources/web/tenant-usage/docs/images/view-usage.png and /dev/null differ


[22/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java
new file mode 100644
index 0000000..8bb190c
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java
@@ -0,0 +1,607 @@
+/*
+ *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.usage.api;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.stratos.usage.beans.*;
+import org.apache.stratos.usage.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.constants.UsageConstants;
+import org.apache.stratos.common.util.CommonUtil;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.apache.stratos.usage.util.DataAccessObject;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+
+import java.util.*;
+
+public class TenantUsageRetriever {
+    private static final Log log = LogFactory.getLog(TenantUsageRetriever.class);
+    private static final String DEFAULT_SERVICE_NAME = "Stratos";
+    private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS";
+    private static final String TOTAL_LABEL = "Total";
+    public static final int REG_BANDWIDTH_INDEX = 0;
+    public static final int SVC_BANDWIDTH_INDEX = 1;
+    public static final int WEBAPP_BANDWIDTH_INDEX = 2;
+    public static final int API_CALL_STATS=3;
+
+    private RegistryService registryService;
+    private DataAccessObject dao;
+
+    public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext)
+            throws Exception {
+
+        // we are loading the essentials from the constructors in order to restrict the users
+        // to use the usage retrievers.
+        this.registryService = registryService;
+        this.dao = new DataAccessObject();
+    }
+
+
+    public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate,
+                                              boolean currentMonth) throws Exception {
+        TenantDataCapacity dataCapacity = null;
+
+        if(currentMonth){
+            dataCapacity = dao.getTenantDataCapacity(tenantId);
+        } else {
+            //we don't have a way to see the registry usage of last months yet
+        }
+
+        return dataCapacity;
+
+    }
+
+    /**
+     * This returns the number of users in a given tenant
+     * @param tenantId Tenant ID
+     * @return Number of users
+     * @throws RegistryException
+     */
+    public int getCurrentUserCount(int tenantId) throws RegistryException {
+        UserRealm userRealm = registryService.getUserRealm(tenantId);
+        int usersCount;
+        try {
+            String[] users = userRealm.getUserStoreManager().listUsers("*", -1);
+            usersCount = users.length;
+        } catch (UserStoreException e) {
+            String msg = "Error in getting the current users.";
+            log.error(msg, e);
+            throw new RegistryException(msg, e);
+        }
+        return usersCount;
+    }
+
+    public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate,
+                                                          Calendar endDate, boolean currentMonth) throws Exception {
+        //return the bandwidth usage of a user for a given period
+        BandwidthStatistics[] stats;
+        if (currentMonth) {
+            //get from daily usage stats
+            List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
+            bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate);
+
+            //next we'll get from the houlry stats to get the stats which are not yet
+            //summarized to the daily stats table
+            Calendar startHour = Calendar.getInstance();
+            startHour.set(Calendar.HOUR, 0);
+            startHour.set(Calendar.MINUTE, 0);
+            startHour.set(Calendar.SECOND, 0);
+
+            Calendar endHour = Calendar.getInstance();
+
+            bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour));
+            stats = convertBWListToArray(bwsList);
+
+        } else {
+            //get from monthly usage stats
+            Calendar monthCal = (Calendar) endDate.clone();
+            monthCal.set(Calendar.DATE, 0);
+            monthCal.set(Calendar.HOUR, 0);
+            monthCal.set(Calendar.MINUTE, 0);
+            monthCal.set(Calendar.SECOND, 0);
+
+            stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal));
+        }
+
+        // store the statistics in a temporary map. This is because, we are getting the server name
+        // from the URL and there might be two distinct URL gives same server name.
+        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
+        // Hence, the value should be accumulated value
+        HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>();
+        HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>();
+        HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>();
+
+        if (stats != null) {
+            for (BandwidthStatistics stat : stats) {
+                //Proceed only if incoming bandwidth or outgoing bandwidth is not zero
+                if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) {
+                    continue;
+                }
+
+                //TODO: fix the extractServiceUrl method properly
+                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
+                String bandwidthName = stat.getKey();
+
+                HashMap<String, BandwidthStatistics> bwMap;
+                if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) ||
+                        bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) {
+                    bwMap = regBwMap;
+                } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) ||
+                        bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) {
+                    bwMap = svcBwMap;
+                } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) ||
+                        bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) {
+                    bwMap = webappBwMap;
+                } else {
+                    log.warn("Unable to identify bandwidth name " + bandwidthName);
+                    continue;
+                }
+
+                //find whether the map already has this key; If not, insert a new one
+                BandwidthStatistics reqStat = bwMap.get(serverName);
+                if (reqStat == null) {
+                    reqStat = new BandwidthStatistics(serverName);
+                    bwMap.put(serverName, reqStat);
+                }
+
+                // Update the service specific statistics
+                reqStat.setIncomingBandwidth(
+                        reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth());
+                reqStat.setOutgoingBandwidth(
+                        reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth());
+            }
+        }
+
+        //Convert to array and return it
+        BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][];
+        Collection<BandwidthStatistics> values = regBwMap.values();
+        returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
+        values = svcBwMap.values();
+        returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
+        values = webappBwMap.values();
+        returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
+
+        return returnValue;
+    }
+
+
+    public APIManagerUsageStats[] getAPIManagerUsageStats(int tenantId, Calendar startDate,
+                                                          Calendar endDate, boolean currentMonth) throws Exception {
+        //return the bandwidth usage of a user for a given period
+        APIManagerUsageStats[] stats;
+        if (currentMonth) {
+            //get from daily usage stats
+            List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
+            bwsList = dao.getDailyAPIManagerUsageStats(tenantId, startDate, endDate);
+
+            //next we'll get from the houlry stats to get the stats which are not yet
+            //summarized to the daily stats table
+            Calendar startHour = Calendar.getInstance();
+            startHour.set(Calendar.HOUR, 0);
+            startHour.set(Calendar.MINUTE, 0);
+            startHour.set(Calendar.SECOND, 0);
+
+            Calendar endHour = Calendar.getInstance();
+
+            bwsList.addAll(dao.getHourlyAPIManagerUsageStats(tenantId, startHour, endHour));
+            stats = convertAPIStatListToArray(bwsList);
+
+        } else {
+            //get from monthly usage stats
+            Calendar monthCal = (Calendar) endDate.clone();
+            monthCal.set(Calendar.DATE, 0);
+            monthCal.set(Calendar.HOUR, 0);
+            monthCal.set(Calendar.MINUTE, 0);
+            monthCal.set(Calendar.SECOND, 0);
+
+            stats = convertAPIStatListToArray(dao.getMonthlyAPIManagerUsageStats(tenantId, monthCal));
+        }
+        HashMap<String, APIManagerUsageStats> statMap = new HashMap<String, APIManagerUsageStats>();
+        if (stats != null) {
+            for (APIManagerUsageStats stat : stats) {
+                if (stat.getRequestCount() == 0) {
+                    continue;
+                }
+                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
+                String statName = stat.getKey();
+
+                HashMap<String, APIManagerUsageStats> statsHashMap;
+                if (statName.equals("API-Call")) {
+                    statsHashMap = statMap;
+                } else {
+                    log.warn("Unable to identify bandwidth name " + statName);
+                    continue;
+                }
+
+                //find whether the map already has this key; If not, insert a new one
+                APIManagerUsageStats reqStat = statsHashMap.get(serverName);
+                if (reqStat == null) {
+                    reqStat = new APIManagerUsageStats(serverName);
+                    statsHashMap.put(serverName, reqStat);
+                }
+                reqStat.setRequestCount(stat.getRequestCount());
+            }
+        }
+
+        //Convert to array and return it
+        APIManagerUsageStats[] returnValue = new APIManagerUsageStats[0];
+        Collection<APIManagerUsageStats> values = statMap.values();
+        returnValue = values.toArray(new APIManagerUsageStats[values.size()]);
+        return returnValue;
+    }
+
+
+    public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate,
+                                                    Calendar endDate, boolean currentMonth) throws Exception {
+        RequestStatistics[] stats;
+        if (currentMonth) {
+            //get from daily usage stats
+            List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
+            rsList = dao.getDailyRequestStats(tenantId, startDate, endDate);
+
+            //next we'll get from the houlry stats to get the stats which are not yet
+            //summarized to the daily stats table
+            Calendar startHour = Calendar.getInstance();
+            startHour.set(Calendar.HOUR, 0);
+            startHour.set(Calendar.MINUTE, 0);
+            startHour.set(Calendar.SECOND, 0);
+
+            Calendar endHour = Calendar.getInstance();
+
+            rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour));
+
+            stats = convertRSListToArray(rsList);
+        } else {
+            //get from monthly usage stats
+            Calendar monthCal = (Calendar) endDate.clone();
+            monthCal.set(Calendar.DATE, 0);
+            monthCal.set(Calendar.HOUR, 0);
+            monthCal.set(Calendar.MINUTE, 0);
+            monthCal.set(Calendar.SECOND, 0);
+
+            stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal));
+        }
+
+        // store the statistics in a temporary map. This is because, we are getting the server name
+        // from the URL and there might be two distinct URL gives same server name.
+        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
+        // Hence, the value should be accumulated value
+        HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>();
+
+        if (stats != null) {
+            for (RequestStatistics stat : stats) {
+                //Proceed only if request count is not zero
+                if (stat.getRequestCount() == 0) {
+                    continue;
+                }
+
+                String serverName = extractServiceNameFromUrl(stat.getKey());
+
+                //find whether the map already has this key; If not, insert a new one
+                RequestStatistics reqStat = tempReqStatMap.get(serverName);
+                if (reqStat == null) {
+                    reqStat = new RequestStatistics(serverName);
+                    tempReqStatMap.put(serverName, reqStat);
+                }
+
+                // Update the service specific statistics
+                reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount());
+                reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount());
+                reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount());
+            }
+        }
+
+        //Convert to array and return it
+        Collection<RequestStatistics> values = tempReqStatMap.values();
+        return values.toArray(new RequestStatistics[values.size()]);
+
+    }
+
+    public CartridgeStatistics[] getCartridgeStatistics(int tenantId, Calendar startDate,
+                                                    Calendar endDate, boolean currentMonth) throws Exception {
+        CartridgeStatistics[] stats;
+        /*if (currentMonth) {
+            //get from daily usage stats
+            List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
+            csList = dao.getDailyCartridgeStats(tenantId, startDate, endDate);
+
+            //next we'll get from the houlry stats to get the stats which are not yet
+            //summarized to the daily stats table
+            Calendar startHour = Calendar.getInstance();
+            startHour.set(Calendar.HOUR, 0);
+            startHour.set(Calendar.MINUTE, 0);
+            startHour.set(Calendar.SECOND, 0);
+
+            Calendar endHour = Calendar.getInstance();
+
+            csList.addAll(dao.getHourlyCartridgeStats(tenantId, startHour, endHour));
+
+            stats = convertCSListToArray(csList);
+        } else {
+            //get from monthly usage stats
+            Calendar monthCal = (Calendar) endDate.clone();
+            monthCal.set(Calendar.DATE, 0);
+            monthCal.set(Calendar.HOUR, 0);
+            monthCal.set(Calendar.MINUTE, 0);
+            monthCal.set(Calendar.SECOND, 0);
+
+            stats = convertCSListToArray(dao.getMonthlyCartridgeStats(tenantId, monthCal));
+        }*/
+        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
+        csList = dao.getHourlyCartridgeStats(tenantId, startDate, endDate);
+        stats = convertCSListToArray(csList);
+
+        //Add a comment explaining following logic later
+        HashMap<String, CartridgeStatistics> tempCartridgeStatMap = new HashMap<String, CartridgeStatistics>();
+
+        if (stats != null) {
+            for (CartridgeStatistics stat : stats) {
+                //Proceed only if request count is not zero
+                if (stat.getCartridgeHours() == 0) {
+                    continue;
+                }
+
+                
+                //find whether the map already has this key; If not, insert a new one
+                CartridgeStatistics cartridgeStat = tempCartridgeStatMap.get(stat.getKey());
+                if (cartridgeStat == null) {
+                    cartridgeStat = new CartridgeStatistics(stat.getKey());
+                    tempCartridgeStatMap.put(stat.getKey(), cartridgeStat);
+                }
+
+                // Update the service specific statistics
+                cartridgeStat.setCartridgeHours(cartridgeStat.getCartridgeHours() + stat.getCartridgeHours());
+                cartridgeStat.setInstanceId(stat.getInstanceId());
+            }
+        }
+
+        //Convert to array and return it
+        Collection<CartridgeStatistics> values = tempCartridgeStatMap.values();
+        return values.toArray(new CartridgeStatistics[values.size()]);
+
+    }
+
+    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
+        //get the domain name
+        TenantManager tenantManger = Util.getRealmService().getTenantManager();
+        String domain = tenantManger.getDomain(tenantId);
+        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);
+
+        //Get the startDate, endDate from yearMonth String
+        Date date = CommonUtil.getDateFromMonthString(yearMonth);
+        Calendar startDate = Calendar.getInstance();
+        startDate.setTime(date);
+        Calendar endDate = (Calendar) startDate.clone();
+        endDate.add(Calendar.MONTH, 1);
+
+        //Calculate whether the yearMonth fits to current month; if the current date is less than
+        // endDate, then we treat it as current month
+        boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0);
+
+        //get the data capacity
+        TenantDataCapacity capacity;
+        try {
+            capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth);
+        } catch (Exception e) {
+            String msg = "Error in getting data capacity from metering service.";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        tenantUsage.setRegistryCapacity(capacity);
+
+        //get the service request statistics
+        RequestStatistics[] reqStats = null;
+        try {
+            reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth);
+        } catch (Exception e) {
+            String msg = "Error in getting request statistics from metering service.";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        tenantUsage.setRequestStatistics(reqStats);
+
+        //Calculate total Request statistics
+        RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL);
+        long totalReq = 0;
+        long totalRes = 0;
+        long totalFault = 0;
+        if(reqStats!=null){
+            for (RequestStatistics stat : reqStats) {
+                totalReq += stat.getRequestCount();
+                totalRes += stat.getResponseCount();
+                totalFault += stat.getFaultCount();
+            }
+            totalReqStat.setRequestCount(totalReq);
+            totalReqStat.setResponseCount(totalRes);
+            totalReqStat.setFaultCount(totalFault);
+        }
+        tenantUsage.setTotalRequestStatistics(totalReqStat);
+
+        //get Bandwidth statistics
+        BandwidthStatistics[][] bwStats = null;
+        try {
+            bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth);
+        } catch (Exception e) {
+            String msg = "Error in getting bandwidth statistics from metering service.";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]);
+        tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]);
+        tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]);
+
+        //get the total bandwidths
+        int index = 0;
+        for (BandwidthStatistics[] bwArray : bwStats) {
+            long incomingBandwidth = 0;
+            long outgoingBandwidth = 0;
+            for (BandwidthStatistics bandwidth : bwArray) {
+                incomingBandwidth += bandwidth.getIncomingBandwidth();
+                outgoingBandwidth += bandwidth.getOutgoingBandwidth();
+            }
+            BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL);
+            total.setIncomingBandwidth(incomingBandwidth);
+            total.setOutgoingBandwidth(outgoingBandwidth);
+            switch (index) {
+                case REG_BANDWIDTH_INDEX:
+                    tenantUsage.setTotalRegistryBandwidth(total);
+                    break;
+                case SVC_BANDWIDTH_INDEX:
+                    tenantUsage.setTotalServiceBandwidth(total);
+                    break;
+                case WEBAPP_BANDWIDTH_INDEX:
+                    tenantUsage.setTotalWebappBandwidth(total);
+                    break;
+            }
+            ++index;
+        }
+
+        // the users count will be calculated only if the yearMonth is the current yearMonth
+        if (isCurrentMonth) {
+            int usersCount = getCurrentUserCount(tenantId);
+            tenantUsage.setNumberOfUsers(usersCount);
+        }
+        // get the API invocation data
+        APIManagerUsageStats[] apiStats = null;
+        try {
+            apiStats = getAPIManagerUsageStats(tenantId, startDate, endDate, isCurrentMonth);
+        } catch (Exception e) {
+            String msg = "Error in getting bandwidth statistics from metering service.";
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        tenantUsage.setApiManagerUsageStats(apiStats);
+
+        //retrieving cartridge hours
+        CartridgeStatistics[] cartridgeStatistics = getCartridgeStatistics(tenantId, startDate, endDate, isCurrentMonth);
+        tenantUsage.setCartridgeStatistics(cartridgeStatistics);
+        long totalCartridgeHours = 0;
+        if(cartridgeStatistics!=null && cartridgeStatistics.length>0){
+            
+            for (CartridgeStatistics cs : cartridgeStatistics){
+                totalCartridgeHours += cs.getCartridgeHours();
+            }
+        }
+
+        CartridgeStatistics totalCS = new CartridgeStatistics();
+        totalCS.setCartridgeHours(totalCartridgeHours);
+
+        tenantUsage.setTotalCartridgeHours(totalCS);
+        return tenantUsage;
+    }
+
+    /**
+     * @param serviceURL
+     * @return service name
+     *         <p/>
+     *         Extract the stratos service part from URL; expecting the URL as
+     *         protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant
+     *         We are interested in "service" part only
+     */
+    private String extractServiceNameFromUrl(String serviceURL) {
+        if (serviceURL == null || serviceURL.equals("")) {
+            //No service URL is given, so return a default value
+            return DEFAULT_SERVICE_NAME;
+        }
+
+        int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part
+        if (startIndex != -1) {
+            // protocol://service.domain:port/tenant-domain/ case
+            startIndex += 3;
+        } else {
+            //service.domain:port/tenant case
+            startIndex = 0;
+        }
+
+        int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "."
+        if (endIndex == -1) {
+            // "." is not there; search for ":"
+            endIndex = serviceURL.indexOf(':', startIndex);
+
+            if (endIndex == -1) {
+                //Still could not find ":", then search for "/"
+                endIndex = serviceURL.indexOf('/', startIndex);
+
+                if (endIndex == -1) {
+                    //Noting is there, so take the whole service URL
+                    endIndex = serviceURL.length();
+                }
+            }
+
+        }
+        return serviceURL.substring(startIndex, endIndex);
+    }
+
+    /**
+     * @return Instance Usages Statics Array that contains data
+     * @throws Exception when back end error occurs
+     */
+    public InstanceUsageStatics[] getInstanceUsages() throws Exception {
+
+        //TODO: implement
+        return null;
+        /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats();
+        if (instanceData == null || instanceData.length == 0) {
+            return null;
+        }
+        InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length];
+        int elementID = 0;
+        for (InstanceUsageStat iu : instanceData) {
+            InstanceUsageStatics iu1 = new InstanceUsageStatics();
+            iu1.setInstanceID(iu.getInstanceId().intValue());
+            iu1.setInstanceURL(iu.getServerURL());
+            iu1.setStartTime(iu.getStartTimestamp());
+            iu1.setStopTime(iu.getStopTimestamp());
+            iu1.setRunning(iu.getIsRunning());
+            returnValue[elementID] = iu1;
+            elementID = elementID + 1;
+        }
+        return returnValue;
+        */
+    }
+
+
+    private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) {
+        BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()];
+        bwsArray = bwsList.toArray(bwsArray);
+        return bwsArray;
+    }
+
+    private APIManagerUsageStats[] convertAPIStatListToArray(List<APIManagerUsageStats> bwsList) {
+        APIManagerUsageStats[] bwsArray = new APIManagerUsageStats[bwsList.size()];
+        bwsArray = bwsList.toArray(bwsArray);
+        return bwsArray;
+    }
+
+    private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) {
+        RequestStatistics[] rsArray = new RequestStatistics[rsList.size()];
+        rsArray = rsList.toArray(rsArray);
+        return rsArray;
+    }
+
+    private CartridgeStatistics[] convertCSListToArray(List<CartridgeStatistics> csList){
+        CartridgeStatistics[] csArray = new CartridgeStatistics[csList.size()];
+        csArray = csList.toArray(csArray);
+        return csArray;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java
new file mode 100644
index 0000000..bd47d8f
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java
@@ -0,0 +1,72 @@
+/*
+ *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.usage.beans;
+
+public class APIManagerUsageStats {
+    private String key;
+    private String serverUrl;
+    private long incomingBandwidth;
+    private long outgoingBandwidth;
+    private long requestCount;
+
+    public long getRequestCount() {
+        return requestCount;
+    }
+
+    public void setRequestCount(long requestCount) {
+        this.requestCount = requestCount;
+    }
+
+
+    public APIManagerUsageStats(String key) {
+        this.key = key;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public long getIncomingBandwidth() {
+        return incomingBandwidth;
+    }
+
+    public void setIncomingBandwidth(long incomingBandwidth) {
+        this.incomingBandwidth = incomingBandwidth;
+    }
+
+    public long getOutgoingBandwidth() {
+        return outgoingBandwidth;
+    }
+
+    public void setOutgoingBandwidth(long outgoingBandwidth) {
+        this.outgoingBandwidth = outgoingBandwidth;
+    }
+
+    public String getServerUrl() {
+        return serverUrl;
+    }
+
+    public void setServerUrl(String serverUrl) {
+        this.serverUrl = serverUrl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java
new file mode 100644
index 0000000..9e62626
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java
@@ -0,0 +1,65 @@
+/*
+ *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.usage.beans;
+
+/**
+ * 
+ */
+public class BandwidthStatistics {
+    private String key;
+    private String serverUrl;
+    private long incomingBandwidth;
+    private long outgoingBandwidth;
+
+    public BandwidthStatistics(String key){
+        this.key = key;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public long getIncomingBandwidth() {
+        return incomingBandwidth;
+    }
+
+    public void setIncomingBandwidth(long incomingBandwidth) {
+        this.incomingBandwidth = incomingBandwidth;
+    }
+
+    public long getOutgoingBandwidth() {
+        return outgoingBandwidth;
+    }
+
+    public void setOutgoingBandwidth(long outgoingBandwidth) {
+        this.outgoingBandwidth = outgoingBandwidth;
+    }
+
+    public String getServerUrl() {
+        return serverUrl;
+    }
+
+    public void setServerUrl(String serverUrl) {
+        this.serverUrl = serverUrl;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java
new file mode 100644
index 0000000..4568519
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java
@@ -0,0 +1,59 @@
+/*
+ *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.usage.beans;
+
+
+public class CartridgeStatistics {
+    
+    private String key;
+    private String instanceId;
+    private long cartridgeHours;
+    
+    public CartridgeStatistics(){
+        //Default constructor
+    }
+
+    public CartridgeStatistics(String key){
+        this.key = key;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public long getCartridgeHours() {
+        return cartridgeHours;
+    }
+
+    public void setCartridgeHours(long cartridgeHours) {
+        this.cartridgeHours = cartridgeHours;
+    }
+
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public void setInstanceId(String instanceId) {
+        this.instanceId = instanceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java
new file mode 100644
index 0000000..b0877ef
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java
@@ -0,0 +1,91 @@
+/*
+ *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.usage.beans;
+
+import java.util.Calendar;
+
+public class InstanceUsageStatics {
+
+    private Calendar startTime;
+    private Calendar stopTime;
+    private String instanceURL;
+    private Integer instanceID;
+    private long usedTimeInSeconds;
+    private boolean running;
+
+    public boolean isRunning() {
+        return running;
+    }
+
+    public void setRunning(boolean running) {
+        this.running = running;
+    }
+
+    public Calendar getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Calendar startTime) {
+        this.startTime = startTime;
+    }
+
+    public Calendar getStopTime() {
+        return stopTime;
+    }
+
+    public void setStopTime(Calendar stopTime) {
+        //Check weather stop time is Default value in database in that case
+        //server should still running so set isRunning as true
+        Calendar fixedDate = Calendar.getInstance();
+        fixedDate.set(2001, 1, 1, 00, 00, 00);
+        if (stopTime.compareTo(fixedDate) == 0) {
+            this.running = true;
+        }
+        this.stopTime = stopTime;
+    }
+
+    public String getInstanceURL() {
+        return instanceURL;
+    }
+
+    public void setInstanceURL(String instanceURL) {
+        this.instanceURL = instanceURL;
+    }
+
+    public Integer getInstanceID() {
+        return instanceID;
+    }
+
+    public void setInstanceID(Integer instanceID) {
+        this.instanceID = instanceID;
+    }
+
+    public long getUsedTimeInSeconds() {
+        long returnValue = (this.stopTime.getTimeInMillis() -
+                this.startTime.getTimeInMillis()) / 1000;
+        if (returnValue < 0) {
+            running = true;
+        }
+        return usedTimeInSeconds;
+    }
+    public void setUsedTimeInSeconds(long value){
+        this.usedTimeInSeconds=value;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java
new file mode 100644
index 0000000..3af8b9d
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java
@@ -0,0 +1,59 @@
+/*
+ *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.usage.beans;
+
+import java.util.Arrays;
+
+public class PaginatedInstanceUsage {
+    private InstanceUsageStatics[] instanceUsages;
+    private int pageNumber;
+    private int numberOfPages;
+
+    public InstanceUsageStatics[] getInstanceUsages() {
+        if(instanceUsages != null) {
+        return Arrays.copyOf(instanceUsages, instanceUsages.length);
+        }
+
+        return null;
+    }
+
+    public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) {
+        if(instanceUsages != null) {
+            this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length);
+        }
+    }
+
+    public int getPageNumber() {
+        return pageNumber;
+    }
+
+    public void setPageNumber(int pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+
+    public int getNumberOfPages() {
+        return numberOfPages;
+    }
+
+    public void setNumberOfPages(int numberOfPages) {
+        this.numberOfPages = numberOfPages;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java
new file mode 100644
index 0000000..e538807
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.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.usage.beans;
+
+import java.util.Arrays;
+
+public class PaginatedTenantUsageInfo {
+    private TenantUsage[] tenantUsages;
+    private int pageNumber;
+    private int numberOfPages;
+    
+    public TenantUsage[] getTenantUsages() {
+        return Arrays.copyOf(tenantUsages, tenantUsages.length);
+    }
+    public void setTenantUsages(TenantUsage[] tenantUsages) {
+        this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length);
+    }
+    public int getPageNumber() {
+        return pageNumber;
+    }
+    public void setPageNumber(int pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+    public int getNumberOfPages() {
+        return numberOfPages;
+    }
+    public void setNumberOfPages(int numberOfPages) {
+        this.numberOfPages = numberOfPages;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java
new file mode 100644
index 0000000..e703578
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java
@@ -0,0 +1,63 @@
+/*
+ *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.usage.beans;
+public class RequestStatistics {
+    private String key;
+    private long requestCount;
+    private long responseCount;
+    private long faultCount;
+
+    public RequestStatistics(String key) {
+        this.key = key;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public long getRequestCount() {
+        return requestCount;
+    }
+
+    public void setRequestCount(long requestCount) {
+        this.requestCount = requestCount;
+    }
+
+    public long getResponseCount() {
+        return responseCount;
+    }
+
+    public void setResponseCount(long responseCount) {
+        this.responseCount = responseCount;
+    }
+
+    public long getFaultCount() {
+        return faultCount;
+    }
+
+    public void setFaultCount(long faultCount) {
+        this.faultCount = faultCount;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java
new file mode 100644
index 0000000..c0f2ea7
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java
@@ -0,0 +1,55 @@
+/*
+ *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.usage.beans;
+
+public class TenantDataCapacity {
+
+    private long registryContentCapacity;
+    private long registryContentHistoryCapacity;
+
+    public TenantDataCapacity() {
+    }
+    
+    /**
+     * @param registryContentCapacity
+     * @param registryContentHistoryCapacity
+     */
+    public TenantDataCapacity(
+            long registryContentCapacity, long registryContentHistoryCapacity) {
+        this.registryContentCapacity = registryContentCapacity;
+        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
+    }
+
+    public long getRegistryContentCapacity() {
+        return registryContentCapacity;
+    }
+
+    public void setRegistryContentCapacity(long registryContentCapacity) {
+        this.registryContentCapacity = registryContentCapacity;
+    }
+
+    public long getRegistryContentHistoryCapacity() {
+        return registryContentHistoryCapacity;
+    }
+
+    public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) {
+        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java
new file mode 100644
index 0000000..8afd9af
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java
@@ -0,0 +1,219 @@
+/*
+ *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.usage.beans;
+
+public class TenantUsage {
+    private int tenantId;
+    private String domain;
+    private int numberOfUsers;
+    private UsageEntry[] usageEntries;
+    private BandwidthStatistics[] registryBandwidthStatistics;
+    private BandwidthStatistics[] serviceBandwidthStatistics;
+    private BandwidthStatistics[] webappBandwidthStatistics;
+    private CartridgeStatistics[] cartridgeStatistics;
+    private RequestStatistics[] requestStatistics;
+    private TenantDataCapacity registryCapacity;
+    private RequestStatistics totalRequestStatistics;
+    private BandwidthStatistics totalRegistryBandwidth;
+    private BandwidthStatistics totalServiceBandwidth;
+    private BandwidthStatistics totalWebappBandwidth;
+    private CartridgeStatistics totalCartridgeHours;
+    private APIManagerUsageStats[] apiManagerUsageStats;
+
+    public APIManagerUsageStats[] getApiManagerUsageStats() {
+        return apiManagerUsageStats;
+    }
+
+    public void setApiManagerUsageStats(APIManagerUsageStats[] apiManagerUsageStats) {
+        this.apiManagerUsageStats = apiManagerUsageStats;
+    }
+
+    public BandwidthStatistics[] getRegistryBandwidthStatistics() {
+        return registryBandwidthStatistics;
+    }
+
+    public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) {
+        this.registryBandwidthStatistics = registryBandwidthStatistics;
+    }
+
+    public BandwidthStatistics[] getServiceBandwidthStatistics() {
+        return serviceBandwidthStatistics;
+    }
+
+    public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) {
+        this.serviceBandwidthStatistics = serviceBandwidthStatistics;
+    }
+
+    public BandwidthStatistics[] getWebappBandwidthStatistics() {
+        return webappBandwidthStatistics;
+    }
+
+    public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) {
+        this.webappBandwidthStatistics = webappBandwidthStatistics;
+    }
+
+    public RequestStatistics getTotalRequestStatistics() {
+        return totalRequestStatistics;
+    }
+
+    public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) {
+        this.totalRequestStatistics = totalRequestStatistics;
+    }
+
+    public BandwidthStatistics getTotalRegistryBandwidth() {
+        return totalRegistryBandwidth;
+    }
+
+    public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) {
+        this.totalRegistryBandwidth = totalRegistryBandwidth;
+    }
+
+    public BandwidthStatistics getTotalServiceBandwidth() {
+        return totalServiceBandwidth;
+    }
+
+    public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) {
+        this.totalServiceBandwidth = totalServiceBandwidth;
+    }
+
+    public BandwidthStatistics getTotalWebappBandwidth() {
+        return totalWebappBandwidth;
+    }
+
+    public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) {
+        this.totalWebappBandwidth = totalWebappBandwidth;
+    }
+
+    public CartridgeStatistics[] getCartridgeStatistics() {
+        return cartridgeStatistics;
+    }
+
+    public void setCartridgeStatistics(CartridgeStatistics[] cartridgeStatistics) {
+        this.cartridgeStatistics = cartridgeStatistics;
+    }
+
+    public CartridgeStatistics getTotalCartridgeHours() {
+        return totalCartridgeHours;
+    }
+
+    public void setTotalCartridgeHours(CartridgeStatistics totalCartridgeHours) {
+        this.totalCartridgeHours = totalCartridgeHours;
+    }
+
+    public TenantUsage() {
+        // empty method required for used in web services
+    }
+
+    public TenantUsage(int tenantId, String domain) {
+        this.tenantId = tenantId;
+        this.domain = domain;
+    }
+
+    public int getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(int tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+    public UsageEntry[] getUsageEntries() {
+        return usageEntries;
+    }
+
+    public void setUsageEntries(UsageEntry[] usageEntries) {
+        this.usageEntries = usageEntries;
+    }
+
+    public RequestStatistics[] getRequestStatistics() {
+        return requestStatistics;
+    }
+
+    public void setRequestStatistics(RequestStatistics[] requestStatistics) {
+        this.requestStatistics = requestStatistics;
+    }
+
+    public TenantDataCapacity getRegistryCapacity() {
+        return registryCapacity;
+    }
+
+    public void setRegistryCapacity(TenantDataCapacity registryCapacity) {
+        this.registryCapacity = registryCapacity;
+    }
+
+    public int getNumberOfUsers() {
+        return numberOfUsers;
+    }
+
+    public void setNumberOfUsers(int numberOfUsers) {
+        this.numberOfUsers = numberOfUsers;
+    }
+
+    public long getRegistryContentCapacity(){
+        long retValue = 0;
+        if (registryCapacity != null) {
+            retValue = registryCapacity.getRegistryContentCapacity();
+        }
+        return retValue;
+    }
+
+    public long getRegistryContentHistoryCapacity(){
+        long retValue = 0;
+        if (registryCapacity != null) {
+            retValue = registryCapacity.getRegistryContentHistoryCapacity();
+        }
+        return retValue;
+    }
+
+    public long getTotalIncomingBandwidth(){
+        long incomingBW =  0;
+        if(totalRegistryBandwidth != null){
+            incomingBW += totalRegistryBandwidth.getIncomingBandwidth();
+        }
+        if(totalServiceBandwidth != null){
+            incomingBW += totalServiceBandwidth.getIncomingBandwidth();
+        }
+        if(totalWebappBandwidth != null){
+            incomingBW += totalWebappBandwidth.getIncomingBandwidth();
+        }
+        return incomingBW;
+    }
+
+    public long getTotalOutgoingBandwidth(){
+        long outgoingBW =  0;
+        if(totalRegistryBandwidth != null){
+            outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth();
+        }
+        if(totalServiceBandwidth != null){
+            outgoingBW += totalServiceBandwidth.getOutgoingBandwidth();
+        }
+        if(totalWebappBandwidth != null){
+            outgoingBW += totalWebappBandwidth.getOutgoingBandwidth();
+        }
+        return outgoingBW;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java
new file mode 100644
index 0000000..04e8be2
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java
@@ -0,0 +1,49 @@
+/*
+ *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.usage.beans;
+
+public class UsageEntry {
+    private String key;
+    private String value;
+
+    public UsageEntry() {
+        // empty constructor to used in web services
+    }
+
+    public UsageEntry(String key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/internal/UsageServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/internal/UsageServiceComponent.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/internal/UsageServiceComponent.java
new file mode 100644
index 0000000..2c3b133
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/internal/UsageServiceComponent.java
@@ -0,0 +1,101 @@
+/*
+ *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.usage.internal;
+
+import org.apache.stratos.usage.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.wso2.carbon.ndatasource.core.DataSourceService;
+
+/**
+ * @scr.component name="org.wso2.carbon.usage" immediate="true"
+ * @scr.reference name="registry.service"
+ * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="1..1"
+ * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
+ * @scr.reference name="user.realmservice.default" 
+ * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1" 
+ * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
+ * @scr.reference name="config.context.service" 
+ * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" 
+ * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
+ * @scr.reference name="datasources.service"
+ * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
+ * cardinality="1..1" policy="dynamic"
+ * bind="setDataSourceService" unbind="unsetDataSourceService"
+ */
+public class UsageServiceComponent {
+    private static Log log = LogFactory.getLog(UsageServiceComponent.class);
+
+
+    protected void activate(ComponentContext context) {
+        try {
+            Util.registerRetrieverServices(context.getBundleContext());
+            log.debug("******* Usage bundle is activated ******* ");    
+        } catch (Exception e) {
+            log.error("******* Error in activating Usage bundle ******* ");
+        }
+    }
+
+    protected void deactivate(ComponentContext context) {
+        log.debug("******* Usage is deactivated ******* ");
+    }
+
+    protected void setRegistryService(RegistryService registryService) {
+        Util.setRegistryService(registryService);
+    }
+
+    protected void unsetRegistryService(RegistryService registryService) {
+        Util.setRegistryService(null);
+    }
+
+    protected void setRealmService(RealmService realmService) {
+        Util.setRealmService(realmService);
+    }
+
+    protected void unsetRealmService(RealmService realmService) {
+        Util.setRealmService(null);
+    }
+    
+    protected void setConfigurationContextService(ConfigurationContextService ccService) {
+        //commented to work with the local transport
+	/*ConfigurationContext serverCtx = ccService.getServerConfigContext();
+        AxisConfiguration serverConfig = serverCtx.getAxisConfiguration();
+        LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig);
+        LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services");
+        LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
+	*/
+        Util.setConfigurationContextService(ccService);
+    }
+
+    protected void unsetConfigurationContextService(ConfigurationContextService ccService) {
+        Util.setConfigurationContextService(null);
+    }
+
+    protected void setDataSourceService(DataSourceService dataSourceService){
+        Util.setDataSourceService(dataSourceService);
+    }
+    
+    protected void unsetDataSourceService(DataSourceService dataSourceService){
+        Util.setDataSourceService(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/services/UsageService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/services/UsageService.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/services/UsageService.java
new file mode 100644
index 0000000..c7714bb
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/services/UsageService.java
@@ -0,0 +1,204 @@
+/*
+ *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.usage.services;
+
+import org.apache.stratos.usage.beans.InstanceUsageStatics;
+import org.apache.stratos.usage.beans.PaginatedInstanceUsage;
+import org.apache.stratos.usage.beans.PaginatedTenantUsageInfo;
+import org.apache.stratos.usage.util.Util;
+import org.apache.stratos.common.util.CommonUtil;
+import org.wso2.carbon.core.AbstractAdmin;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.apache.stratos.usage.beans.TenantUsage;
+import org.wso2.carbon.user.core.tenant.Tenant;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+
+import java.text.ParseException;
+import java.util.*;
+
+public class UsageService extends AbstractAdmin {
+    /**
+     * Return the usage of the current logged in tenant
+     *
+     * @param yearMonth year month
+     * @return the current usage of the tenant
+     * @throws Exception
+     */
+    public TenantUsage retrieveCurrentTenantUsage(String yearMonth) throws Exception {
+        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
+        int tenantId = registry.getTenantId();
+        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
+    }
+
+    /**
+     * Return the all the tenant usages, requires super admin permissions
+     *
+     * @param yearMonth
+     * @return
+     * @throws Exception
+     */
+    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
+        TenantManager tenantManager = Util.getRealmService().getTenantManager();
+        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
+        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
+        for (Tenant tenant : tenants) {
+            if (tenant.isActive()) {
+                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
+                        tenant.getId(), yearMonth);
+                tenantUsages.add(tenantUsage);
+            }
+        }
+        return tenantUsages.toArray(new TenantUsage[tenantUsages.size()]);
+    }
+
+    /**
+     * Return the all the tenant usages paginated, requires super admin permissions
+     *
+     * @param yearMonth
+     * @param pageNumber
+     * @param entriesPerPage
+     * @return PaginatedTenantUsageInfo
+     * @throws Exception
+     */
+    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
+                                                                  int entriesPerPage) throws Exception {
+        TenantManager tenantManager = Util.getRealmService().getTenantManager();
+        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
+        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
+
+        int i = 0;
+        int numberOfPages = 0;
+        for (Tenant tenant : tenants) {
+            if (tenant.isActive()) {
+                if (i % entriesPerPage == 0) {
+                    numberOfPages++;
+                }
+                if (numberOfPages == pageNumber) {
+                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
+                            tenant.getId(), yearMonth);
+                    tenantUsages.add(tenantUsage);
+                }
+                i++;
+            }
+        }
+        PaginatedTenantUsageInfo paginatedTenantInfo = new PaginatedTenantUsageInfo();
+        paginatedTenantInfo.setTenantUsages(
+                tenantUsages.toArray(new TenantUsage[tenantUsages.size()]));
+        paginatedTenantInfo.setNumberOfPages(numberOfPages);
+        paginatedTenantInfo.setPageNumber(pageNumber);
+        return paginatedTenantInfo;
+    }
+
+    /**
+     * Returns usage of a particular tenant, requires super admin permissions
+     *
+     * @param yearMonth
+     * @param tenantId
+     * @return
+     * @throws Exception
+     */
+    public TenantUsage retrieveTenantUsage(String yearMonth, int tenantId) throws Exception {
+        return Util.getTenantUsageRetriever().getTenantUsage(tenantId, yearMonth);
+    }
+
+    public InstanceUsageStatics[] retrieveInstanceUsage() throws Exception {
+        return Util.getTenantUsageRetriever().getInstanceUsages();
+    }
+
+    /**
+     * @param yearMonth      year and month that used to retrieve data
+     * @param pageNumber
+     * @param entriesPerPage number of entries per page
+     * @return PaginatedInstanceUsage object that hold instance data and other parameters
+     * @throws Exception when retrieving Paginated Instance Usage error occurs
+     */
+    public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
+                                                                 int entriesPerPage) throws Exception {
+        InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
+        List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
+        PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
+        int i = 0;
+        int numberOfPages = 0;
+        if (instanceUsages != null && instanceUsages.length > 0) {
+            for (InstanceUsageStatics usage : instanceUsages) {
+                InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
+                if (instance != null) {
+                    if (i % entriesPerPage == 0) {
+                        numberOfPages++;
+                    }
+                }
+            }
+
+            paginatedInstanceUsages.setInstanceUsages(
+                instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
+        } else {
+            paginatedInstanceUsages.setInstanceUsages(null);
+        }
+
+        paginatedInstanceUsages.setNumberOfPages(numberOfPages);
+        paginatedInstanceUsages.setPageNumber(pageNumber);
+        return paginatedInstanceUsages;
+    }
+
+    /**
+     * @param usage     is Instance usage Statics object that holds data
+     * @param yearMonth year and month that need to check with instance usage data
+     * @return instance static if instance usage data match with given year and month, else null
+     */
+    public InstanceUsageStatics getValidUsageEntry(InstanceUsageStatics usage, String yearMonth) {
+        Date date = Calendar.getInstance().getTime();
+        if (yearMonth != null) {
+            try {
+                date = CommonUtil.getDateFromMonthString(yearMonth);
+            } catch (ParseException e) {
+
+            }
+        }
+        Calendar startDate = Calendar.getInstance();
+        startDate.setTime(date);
+        Calendar endDate = (Calendar) startDate.clone();
+        endDate.add(Calendar.MONTH, 1);
+        if (usage.getStartTime().compareTo(startDate) <= 0 && usage.getStopTime().compareTo(endDate) >= 0) {
+            usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
+                    startDate.getTimeInMillis()) / 1000);
+            return usage;
+        }
+        if (usage.getStartTime().compareTo(startDate) > 0 && usage.getStartTime().compareTo(endDate) < 0) {
+            if (usage.getStopTime().compareTo(endDate) < 0) {
+                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
+                        usage.getStartTime().getTimeInMillis()) / 1000);
+                return usage;
+
+            } else if (usage.getStopTime().compareTo(endDate) > 0) {
+                usage.setUsedTimeInSeconds((endDate.getTimeInMillis() -
+                        usage.getStartTime().getTimeInMillis()) / 1000);
+                return usage;
+
+            }
+        }
+        if (usage.getStartTime().compareTo(startDate) < 0 && usage.getStopTime().compareTo(endDate) < 0) {
+            if (usage.getStopTime().compareTo(startDate) > 0) {
+                usage.setUsedTimeInSeconds((usage.getStopTime().getTimeInMillis() -
+                        startDate.getTimeInMillis()) / 1000);
+                return usage;
+            }
+        }
+        return null;
+    }
+}


[05/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
deleted file mode 100644
index d7fce1d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/DataAccessObject.java
+++ /dev/null
@@ -1,358 +0,0 @@
-package org.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.beans.BandwidthStatistics;
-import org.wso2.carbon.usage.beans.RequestStatistics;
-import org.wso2.carbon.usage.beans.TenantDataCapacity;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-public class DataAccessObject {
-    
-    private static Log log = LogFactory.getLog(DataAccessObject.class);
-    private DataSource dataSource;
-    
-    
-    public DataAccessObject(){
-        if(Util.getDataSourceService()!=null){
-            try{
-            this.dataSource = (DataSource)Util.getDataSourceService().
-                                getDataSource(Util.BILLING_DATA_SOURCE_NAME).getDSObject();
-            }catch(Exception e){
-                log.error("Error occurred while obtaining " + Util.BILLING_DATA_SOURCE_NAME +
-                        " datasource from data source service.", e);
-                dataSource=null;
-            }
-        }else{
-            log.error("Cannot obtain data source " + Util.BILLING_DATA_SOURCE_NAME + ". Datasource service is null");
-            dataSource=null;
-        }
-    }
-
-
-    public List<BandwidthStatistics> getHourlyBandwidthStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getDailyBandwidthStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_TYPE");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-                
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) || 
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                    
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) || 
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-                
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-                
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily usage data from the database. ", e);
-            
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Stats of this month will be retrieved
-     * @return A list of BandwidthStatistics objects
-     * @throws Exception
-     */
-    public List<BandwidthStatistics> getMonthlyBandwidthStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("PAYLOAD_DATA");
-                BandwidthStatistics bws = new BandwidthStatistics(key);
-
-                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
-                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-
-                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
-                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
-                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
-                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
-                }else {
-                    //Do nothing
-                }
-
-                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
-
-                bwsList.add(bws);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return bwsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getHourlyRequestStats(int tenantId, Calendar startDate,
-                                                         Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving hourly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param startDate Start date - Stats of this date will be included
-     * @param endDate End date - Stats of this date will be included
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getDailyRequestStats(int tenantId, Calendar startDate,
-                                                        Calendar endDate) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
-            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving daily service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    /**
-     *
-     * @param tenantId Tenant ID
-     * @param month Month - Stats of this month will be retrieved
-     * @return A list of RequestStatistics objects
-     * @throws Exception
-     */
-    public List<RequestStatistics> getMonthlyRequestStats(int tenantId,
-                                                          Calendar month) throws Exception{
-        Connection connection = null;
-        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-
-        try{
-            connection = dataSource.getConnection();
-            String sql = "SELECT * FROM SERVICE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setInt(1, tenantId);
-            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                String key = resultSet.getString("SERVER_NAME");
-                RequestStatistics reqStat = new RequestStatistics(key);
-                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
-                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
-                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
-
-                rsList.add(reqStat);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving monthly service request stats from the database. ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return rsList;
-
-    }
-
-    public TenantDataCapacity getTenantDataCapacity(int tenantId) throws Exception{
-        Connection connection = null;
-        TenantDataCapacity tenantDataCapacity = null;
-
-        try{
-            connection = dataSource.getConnection();
-            String id = ""  + tenantId + "Final";
-            String sql = "SELECT * FROM REGISTRY_USAGE_HOURLY_ANALYTICS WHERE ID = ?";
-            PreparedStatement ps = connection.prepareStatement(sql);
-            ps.setString(1, id);
-            ResultSet resultSet = ps.executeQuery();
-
-            while(resultSet.next()){
-                long currentCapacity = resultSet.getLong("CURRENT_USAGE");
-                long historyCapacity = resultSet.getLong("HISTORY_USAGE");
-
-                tenantDataCapacity = new TenantDataCapacity(currentCapacity, historyCapacity);
-            }
-        }catch(SQLException e){
-            log.error("Error occurred while retrieving registry data usage from . ", e);
-
-        }finally {
-            if(connection!=null){
-                connection.close();
-            }
-        }
-
-        return tenantDataCapacity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/Util.java
deleted file mode 100644
index 6c9ebae..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/java/org/wso2/carbon/usage/util/Util.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.util;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.wso2.carbon.ndatasource.core.DataSourceService;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-
-import javax.sql.DataSource;
-
-/**
- * Util methods for usage.
- */
-public class Util {
-
-    private static final Log log = LogFactory.getLog(Util.class);
-
-    private static RegistryService registryService;
-    private static RealmService realmService;
-    private static TenantUsageRetriever tenantUsageRetriever;
-    private static ConfigurationContextService configurationContextService;
-    private static DataSourceService dataSourceService;
-    public static String BILLING_DATA_SOURCE_NAME="WSO2BillingDS";
-
-    public static synchronized void setRegistryService(RegistryService service) {
-        if (registryService == null) {
-            registryService = service;
-        }
-    }
-    
-    public static void setConfigurationContextService(
-            ConfigurationContextService configurationContextService) {
-        Util.configurationContextService = configurationContextService;
-    }
-    
-    public static ConfigurationContextService getConfigurationContextService(){
-        return configurationContextService;
-    }
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static RegistryService getRegistryService() {
-        return registryService;
-    }
-
-    public static TenantUsageRetriever getTenantUsageRetriever() {
-        return tenantUsageRetriever;
-    }
-
-    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
-        return registryService.getUserRealm(tenantId);
-    }
-
-    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
-        return registryService.getGovernanceSystemRegistry();
-    }
-
-    public static void registerRetrieverServices(BundleContext bundleContext) throws Exception {
-        ConfigurationContextService confCtxSvc = Util.getConfigurationContextService();
-
-        // creating and registering tenant and user usage retrievers
-        tenantUsageRetriever = new TenantUsageRetriever(
-                registryService, confCtxSvc.getServerConfigContext());
-        bundleContext.registerService(
-                TenantUsageRetriever.class.getName(), tenantUsageRetriever, null);
-    }
-
-    public static DataSourceService getDataSourceService() {
-        return dataSourceService;
-    }
-
-    public static void setDataSourceService(DataSourceService dataSourceService) {
-        Util.dataSourceService = dataSourceService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 2d2f81e..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <!--<ManagementPermission>
-            <DisplayName>User-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/userUsage</ResourceId>
-        </ManagementPermission> -->
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Protected</DisplayName>
-            <ResourceId>/permission/protected</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/protected/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Any-Tenant-Usage</DisplayName>
-            <ResourceId>/permission/protected/monitor/anytenantUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 8e82415..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-    <service name="UsageService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.services.UsageService
-        </parameter>
-
-        <operation name="retrieveCurrentTenantUsage">
-            <parameter name="AuthorizationAction" locked="true">/permission/admin/monitor/tenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrievePaginatedTenantUsages">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-        <operation name="retrieveTenantUsage">
-            <parameter name="superTenantService" locked="true">true</parameter>
-            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
-        </operation>
-    </service>
-    <parameter name="adminService" locked="true">true</parameter>
-
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/all_tenant_usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/all_tenant_usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/all_tenant_usage_report.jrxml
deleted file mode 100644
index b9483aa..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/all_tenant_usage_report.jrxml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="all_tenant_usage_report"  pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="yearMonth" class="java.lang.String"/>
-	<field name="tenantName" class="java.lang.String"/>
-	<field name="numberOfUsers" class="java.lang.String"/>
-	<field name="currentDataStorage" class="java.lang.String"/>
-	<field name="regBandwidth" class="java.lang.String"/>
-	<field name="svcBandwidth" class="java.lang.String"/>
-	<field name="svcTotalRequest" class="java.lang.String"/>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="79" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="35" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Transparent" x="0" y="0" width="279" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<text><![CDATA[Tenant Usage Report for the month]]></text>
-			</staticText>
-			<textField>
-				<reportElement mode="Transparent" x="279" y="0" width="276" height="35" backcolor="#9B9999"/>
-				<textElement>
-					<font size="13" isBold="true"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{yearMonth}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band height="61" splitType="Stretch">
-			<staticText>
-				<reportElement mode="Opaque" x="0" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Domain]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="100" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Number of users]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="200" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Storage Usage]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="300" y="29" width="100" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Registry Bandwidth]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="400" y="29" width="73" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Total Service Bandwidht]]></text>
-			</staticText>
-			<staticText>
-				<reportElement mode="Opaque" x="473" y="29" width="82" height="32" backcolor="#C0C0C0"/>
-				<textElement>
-					<font isBold="true"/>
-				</textElement>
-				<text><![CDATA[Service Requests]]></text>
-			</staticText>
-		</band>
-	</columnHeader>
-	<detail>
-		<band height="103" splitType="Stretch">
-			<textField>
-				<reportElement x="0" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantName}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="100" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{numberOfUsers}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="200" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{currentDataStorage}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="300" y="21" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{regBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="400" y="21" width="73" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcBandwidth}]]></textFieldExpression>
-			</textField>
-			<textField>
-				<reportElement x="473" y="21" width="82" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcTotalRequest}]]></textFieldExpression>
-			</textField>
-		</band>
-	</detail>
-	<columnFooter>
-		<band height="45" splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="54" splitType="Stretch">
-			<textField>
-				<reportElement x="455" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
-			</textField>
-			<textField pattern="MMMMM dd, yyyy">
-				<reportElement x="0" y="34" width="100" height="20"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageFooter>
-	<summary>
-		<band height="42" splitType="Stretch"/>
-	</summary>
-</jasperReport>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/usage_report.jrxml b/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/usage_report.jrxml
deleted file mode 100644
index 5b43c2f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.0/src/main/resources/reports/usage_report.jrxml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
-	<property name="ireport.zoom" value="1.0"/>
-	<property name="ireport.x" value="0"/>
-	<property name="ireport.y" value="0"/>
-	<field name="task" class="java.lang.String"/>
-	<field name="usagecol1" class="java.lang.String"/>
-	<field name="usagecol2" class="java.lang.String"/>
-	<field name="usagecol3" class="java.lang.String"/>
-	<field name="usagecol4" class="java.lang.String"/>
-	<field name="usagecol1Value" class="java.lang.String"/>
-	<field name="usagecol2Value" class="java.lang.String"/>
-	<field name="usagecol3Value" class="java.lang.String"/>
-	<field name="usagecol4Value" class="java.lang.String"/>
-	<field name="tenantDomain" class="java.lang.String"/>
-	<group name="usagedatagroup">
-		<groupExpression><![CDATA[$F{task}]]></groupExpression>
-		<groupHeader>
-			<band height="72" splitType="Stretch">
-				<rectangle>
-					<reportElement x="0" y="21" width="555" height="16" backcolor="#D0F5E8"/>
-				</rectangle>
-				<textField>
-					<reportElement x="0" y="22" width="555" height="16"/>
-					<textElement>
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{task}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="38" width="555" height="16" backcolor="#E6F1B6"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="39" width="132" height="17"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="39" width="132" height="15"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="288" y="39" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="38" width="132" height="16"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4}]]></textFieldExpression>
-				</textField>
-				<rectangle>
-					<reportElement x="0" y="55" width="555" height="15" backcolor="#DBE596"/>
-				</rectangle>
-				<textField isBlankWhenNull="true">
-					<reportElement x="0" y="57" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="145" y="55" width="132" height="16"/>
-					<textElement verticalAlignment="Middle">
-						<font size="9"/>
-					</textElement>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="287" y="55" width="132" height="14"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3Value}]]></textFieldExpression>
-				</textField>
-				<textField isBlankWhenNull="true">
-					<reportElement x="423" y="56" width="132" height="15"/>
-					<textElement verticalAlignment="Middle"/>
-					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4Value}]]></textFieldExpression>
-				</textField>
-			</band>
-		</groupHeader>
-		<groupFooter>
-			<band splitType="Stretch"/>
-		</groupFooter>
-	</group>
-	<background>
-		<band splitType="Stretch"/>
-	</background>
-	<title>
-		<band height="17" splitType="Stretch"/>
-	</title>
-	<pageHeader>
-		<band height="19" splitType="Stretch">
-			<textField pattern="dd/MM/yyyy h.mm a">
-				<reportElement x="403" y="0" width="132" height="16"/>
-				<textElement/>
-				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
-			</textField>
-			<staticText>
-				<reportElement x="0" y="1" width="169" height="15"/>
-				<textElement textAlignment="Right">
-					<font size="12" isUnderline="true"/>
-				</textElement>
-				<text><![CDATA[Usage Report For : ]]></text>
-			</staticText>
-			<textField>
-				<reportElement x="169" y="0" width="234" height="16"/>
-				<textElement verticalAlignment="Middle">
-					<font size="12"/>
-				</textElement>
-				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantDomain}]]></textFieldExpression>
-			</textField>
-		</band>
-	</pageHeader>
-	<columnHeader>
-		<band splitType="Stretch"/>
-	</columnHeader>
-	<detail>
-		<band height="5" splitType="Stretch"/>
-	</detail>
-	<columnFooter>
-		<band splitType="Stretch"/>
-	</columnFooter>
-	<pageFooter>
-		<band height="8" splitType="Stretch"/>
-	</pageFooter>
-	<summary>
-		<band height="7" splitType="Stretch"/>
-	</summary>
-</jasperReport>
-

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/pom.xml b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/pom.xml
deleted file mode 100644
index 8b4005a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/pom.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.usage</artifactId>
-    <version>2.1.1</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>add-source</id>
-                        <phase>generate-sources</phase>
-                        <goals>
-                            <goal>add-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                <source>target/generated-code/src</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <ListenerManager-RequiredServices>
-                            org.wso2.carbon.usage.api.TenantUsageRetriever
-                        </ListenerManager-RequiredServices>
-                        <Private-Package>
-                            org.wso2.carbon.usage.internal.*,
-                            org.wso2.carbon.usage.util.*,
-                            org.wso2.carbon.usage.services.*,
-                            org.wso2.carbon.usage.client.*
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.beans.*,
-                            org.wso2.carbon.usage.api.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.rule.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            org.wso2.carbon.stratos.common.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-            
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.mgt</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.agent</artifactId>
-        </dependency>
-         <!--<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId>
-        </dependency>-->
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.ndatasource.core</artifactId>
-            <version>4.1.0</version>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
deleted file mode 100644
index 22037e2..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/api/TenantUsageRetriever.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.api;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.beans.*;
-import org.wso2.carbon.usage.util.DataAccessObject;
-import org.wso2.carbon.usage.util.Util;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.UserStoreException;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.util.*;
-
-public class TenantUsageRetriever {
-    private static final Log log = LogFactory.getLog(TenantUsageRetriever.class);
-    private static final String DEFAULT_SERVICE_NAME = "Stratos";
-    private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS";
-    private static final String TOTAL_LABEL = "Total";
-    public static final int REG_BANDWIDTH_INDEX = 0;
-    public static final int SVC_BANDWIDTH_INDEX = 1;
-    public static final int WEBAPP_BANDWIDTH_INDEX = 2;
-    public static final int API_CALL_STATS=3;
-
-    private RegistryService registryService;
-    private DataAccessObject dao;
-
-    public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext)
-            throws Exception {
-
-        // we are loading the essentials from the constructors in order to restrict the users
-        // to use the usage retrievers.
-        this.registryService = registryService;
-        this.dao = new DataAccessObject();
-    }
-
-
-    public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate,
-                                              boolean currentMonth) throws Exception {
-        TenantDataCapacity dataCapacity = null;
-
-        if(currentMonth){
-            dataCapacity = dao.getTenantDataCapacity(tenantId);
-        } else {
-            //we don't have a way to see the registry usage of last months yet
-        }
-
-        return dataCapacity;
-
-    }
-
-    /**
-     * This returns the number of users in a given tenant
-     * @param tenantId Tenant ID
-     * @return Number of users
-     * @throws RegistryException
-     */
-    public int getCurrentUserCount(int tenantId) throws RegistryException {
-        UserRealm userRealm = registryService.getUserRealm(tenantId);
-        int usersCount;
-        try {
-            String[] users = userRealm.getUserStoreManager().listUsers("*", -1);
-            usersCount = users.length;
-        } catch (UserStoreException e) {
-            String msg = "Error in getting the current users.";
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-        }
-        return usersCount;
-    }
-
-    public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        BandwidthStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
-            bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour));
-            stats = convertBWListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>();
-        HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>();
-
-        if (stats != null) {
-            for (BandwidthStatistics stat : stats) {
-                //Proceed only if incoming bandwidth or outgoing bandwidth is not zero
-                if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) {
-                    continue;
-                }
-
-                //TODO: fix the extractServiceUrl method properly
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String bandwidthName = stat.getKey();
-
-                HashMap<String, BandwidthStatistics> bwMap;
-                if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) {
-                    bwMap = regBwMap;
-                } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) {
-                    bwMap = svcBwMap;
-                } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) ||
-                        bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) {
-                    bwMap = webappBwMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + bandwidthName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                BandwidthStatistics reqStat = bwMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new BandwidthStatistics(serverName);
-                    bwMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setIncomingBandwidth(
-                        reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth());
-                reqStat.setOutgoingBandwidth(
-                        reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth());
-            }
-        }
-
-        //Convert to array and return it
-        BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][];
-        Collection<BandwidthStatistics> values = regBwMap.values();
-        returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = svcBwMap.values();
-        returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-        values = webappBwMap.values();
-        returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]);
-
-        return returnValue;
-    }
-
-
-    public APIManagerUsageStats[] getAPIManagerUsageStats(int tenantId, Calendar startDate,
-                                                          Calendar endDate, boolean currentMonth) throws Exception {
-        //return the bandwidth usage of a user for a given period
-        APIManagerUsageStats[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
-            bwsList = dao.getDailyAPIManagerUsageStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            bwsList.addAll(dao.getHourlyAPIManagerUsageStats(tenantId, startHour, endHour));
-            stats = convertAPIStatListToArray(bwsList);
-
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertAPIStatListToArray(dao.getMonthlyAPIManagerUsageStats(tenantId, monthCal));
-        }
-        HashMap<String, APIManagerUsageStats> statMap = new HashMap<String, APIManagerUsageStats>();
-        if (stats != null) {
-            for (APIManagerUsageStats stat : stats) {
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-                String serverName = extractServiceNameFromUrl(stat.getServerUrl());
-                String statName = stat.getKey();
-
-                HashMap<String, APIManagerUsageStats> statsHashMap;
-                if (statName.equals("API-Call")) {
-                    statsHashMap = statMap;
-                } else {
-                    log.warn("Unable to identify bandwidth name " + statName);
-                    continue;
-                }
-
-                //find whether the map already has this key; If not, insert a new one
-                APIManagerUsageStats reqStat = statsHashMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new APIManagerUsageStats(serverName);
-                    statsHashMap.put(serverName, reqStat);
-                }
-                reqStat.setRequestCount(stat.getRequestCount());
-            }
-        }
-
-        //Convert to array and return it
-        APIManagerUsageStats[] returnValue = new APIManagerUsageStats[0];
-        Collection<APIManagerUsageStats> values = statMap.values();
-        returnValue = values.toArray(new APIManagerUsageStats[values.size()]);
-        return returnValue;
-    }
-
-
-    public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate,
-                                                    Calendar endDate, boolean currentMonth) throws Exception {
-        RequestStatistics[] stats;
-        if (currentMonth) {
-            //get from daily usage stats
-            List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
-            rsList = dao.getDailyRequestStats(tenantId, startDate, endDate);
-
-            //next we'll get from the houlry stats to get the stats which are not yet
-            //summarized to the daily stats table
-            Calendar startHour = Calendar.getInstance();
-            startHour.set(Calendar.HOUR, 0);
-            startHour.set(Calendar.MINUTE, 0);
-            startHour.set(Calendar.SECOND, 0);
-
-            Calendar endHour = Calendar.getInstance();
-
-            rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour));
-
-            stats = convertRSListToArray(rsList);
-        } else {
-            //get from monthly usage stats
-            Calendar monthCal = (Calendar) endDate.clone();
-            monthCal.set(Calendar.DATE, 0);
-            monthCal.set(Calendar.HOUR, 0);
-            monthCal.set(Calendar.MINUTE, 0);
-            monthCal.set(Calendar.SECOND, 0);
-
-            stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal));
-        }
-
-        // store the statistics in a temporary map. This is because, we are getting the server name
-        // from the URL and there might be two distinct URL gives same server name.
-        // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb"
-        // Hence, the value should be accumulated value
-        HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>();
-
-        if (stats != null) {
-            for (RequestStatistics stat : stats) {
-                //Proceed only if request count is not zero
-                if (stat.getRequestCount() == 0) {
-                    continue;
-                }
-
-                String serverName = extractServiceNameFromUrl(stat.getKey());
-
-                //find whether the map already has this key; If not, insert a new one
-                RequestStatistics reqStat = tempReqStatMap.get(serverName);
-                if (reqStat == null) {
-                    reqStat = new RequestStatistics(serverName);
-                    tempReqStatMap.put(serverName, reqStat);
-                }
-
-                // Update the service specific statistics
-                reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount());
-                reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount());
-                reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount());
-            }
-        }
-
-        //Convert to array and return it
-        Collection<RequestStatistics> values = tempReqStatMap.values();
-        return values.toArray(new RequestStatistics[values.size()]);
-
-    }
-
-    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
-        //get the domain name
-        TenantManager tenantManger = Util.getRealmService().getTenantManager();
-        String domain = tenantManger.getDomain(tenantId);
-        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);
-
-        //Get the startDate, endDate from yearMonth String
-        Date date = CommonUtil.getDateFromMonthString(yearMonth);
-        Calendar startDate = Calendar.getInstance();
-        startDate.setTime(date);
-        Calendar endDate = (Calendar) startDate.clone();
-        endDate.add(Calendar.MONTH, 1);
-
-        //Calculate whether the yearMonth fits to current month; if the current date is less than
-        // endDate, then we treat it as current month
-        boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0);
-
-        //get the data capacity
-        TenantDataCapacity capacity;
-        try {
-            capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting data capacity from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryCapacity(capacity);
-
-        //get the service request statistics
-        RequestStatistics[] reqStats = null;
-        try {
-            reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting request statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRequestStatistics(reqStats);
-
-        //Calculate total Request statistics
-        RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL);
-        long totalReq = 0;
-        long totalRes = 0;
-        long totalFault = 0;
-        if(reqStats!=null){
-            for (RequestStatistics stat : reqStats) {
-                totalReq += stat.getRequestCount();
-                totalRes += stat.getResponseCount();
-                totalFault += stat.getFaultCount();
-            }
-            totalReqStat.setRequestCount(totalReq);
-            totalReqStat.setResponseCount(totalRes);
-            totalReqStat.setFaultCount(totalFault);
-        }
-        tenantUsage.setTotalRequestStatistics(totalReqStat);
-
-        //get Bandwidth statistics
-        BandwidthStatistics[][] bwStats = null;
-        try {
-            bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]);
-        tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]);
-        tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]);
-
-        //get the total bandwidths
-        int index = 0;
-        for (BandwidthStatistics[] bwArray : bwStats) {
-            long incomingBandwidth = 0;
-            long outgoingBandwidth = 0;
-            for (BandwidthStatistics bandwidth : bwArray) {
-                incomingBandwidth += bandwidth.getIncomingBandwidth();
-                outgoingBandwidth += bandwidth.getOutgoingBandwidth();
-            }
-            BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL);
-            total.setIncomingBandwidth(incomingBandwidth);
-            total.setOutgoingBandwidth(outgoingBandwidth);
-            switch (index) {
-                case REG_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalRegistryBandwidth(total);
-                    break;
-                case SVC_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalServiceBandwidth(total);
-                    break;
-                case WEBAPP_BANDWIDTH_INDEX:
-                    tenantUsage.setTotalWebappBandwidth(total);
-                    break;
-            }
-            ++index;
-        }
-
-        // the users count will be calculated only if the yearMonth is the current yearMonth
-        if (isCurrentMonth) {
-            int usersCount = getCurrentUserCount(tenantId);
-            tenantUsage.setNumberOfUsers(usersCount);
-        }
-        // get the API invocation data
-        APIManagerUsageStats[] apiStats = null;
-        try {
-            apiStats = getAPIManagerUsageStats(tenantId, startDate, endDate, isCurrentMonth);
-        } catch (Exception e) {
-            String msg = "Error in getting bandwidth statistics from metering service.";
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        tenantUsage.setApiManagerUsageStats(apiStats);
-        return tenantUsage;
-    }
-
-    /**
-     * @param serviceURL
-     * @return service name
-     *         <p/>
-     *         Extract the stratos service part from URL; expecting the URL as
-     *         protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant
-     *         We are interested in "service" part only
-     */
-    private String extractServiceNameFromUrl(String serviceURL) {
-        if (serviceURL == null || serviceURL.equals("")) {
-            //No service URL is given, so return a default value
-            return DEFAULT_SERVICE_NAME;
-        }
-
-        int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part
-        if (startIndex != -1) {
-            // protocol://service.domain:port/tenant-domain/ case
-            startIndex += 3;
-        } else {
-            //service.domain:port/tenant case
-            startIndex = 0;
-        }
-
-        int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "."
-        if (endIndex == -1) {
-            // "." is not there; search for ":"
-            endIndex = serviceURL.indexOf(':', startIndex);
-
-            if (endIndex == -1) {
-                //Still could not find ":", then search for "/"
-                endIndex = serviceURL.indexOf('/', startIndex);
-
-                if (endIndex == -1) {
-                    //Noting is there, so take the whole service URL
-                    endIndex = serviceURL.length();
-                }
-            }
-
-        }
-        return serviceURL.substring(startIndex, endIndex);
-    }
-
-    /**
-     * @return Instance Usages Statics Array that contains data
-     * @throws Exception when back end error occurs
-     */
-    public InstanceUsageStatics[] getInstanceUsages() throws Exception {
-
-        //TODO: implement
-        return null;
-        /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats();
-        if (instanceData == null || instanceData.length == 0) {
-            return null;
-        }
-        InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length];
-        int elementID = 0;
-        for (InstanceUsageStat iu : instanceData) {
-            InstanceUsageStatics iu1 = new InstanceUsageStatics();
-            iu1.setInstanceID(iu.getInstanceId().intValue());
-            iu1.setInstanceURL(iu.getServerURL());
-            iu1.setStartTime(iu.getStartTimestamp());
-            iu1.setStopTime(iu.getStopTimestamp());
-            iu1.setRunning(iu.getIsRunning());
-            returnValue[elementID] = iu1;
-            elementID = elementID + 1;
-        }
-        return returnValue;
-        */
-    }
-
-
-    private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) {
-        BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private APIManagerUsageStats[] convertAPIStatListToArray(List<APIManagerUsageStats> bwsList) {
-        APIManagerUsageStats[] bwsArray = new APIManagerUsageStats[bwsList.size()];
-        bwsArray = bwsList.toArray(bwsArray);
-        return bwsArray;
-    }
-
-    private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) {
-        RequestStatistics[] rsArray = new RequestStatistics[rsList.size()];
-        rsArray = rsList.toArray(rsArray);
-        return rsArray;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
deleted file mode 100644
index 9321011..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/APIManagerUsageStats.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-public class APIManagerUsageStats {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-    private long requestCount;
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-
-    public APIManagerUsageStats(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
deleted file mode 100644
index f236e0f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/BandwidthStatistics.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-/**
- * 
- */
-public class BandwidthStatistics {
-    private String key;
-    private String serverUrl;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-
-    public BandwidthStatistics(String key){
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public String getServerUrl() {
-        return serverUrl;
-    }
-
-    public void setServerUrl(String serverUrl) {
-        this.serverUrl = serverUrl;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
deleted file mode 100644
index 25cb759..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/InstanceUsageStatics.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Calendar;
-
-public class InstanceUsageStatics {
-
-    private Calendar startTime;
-    private Calendar stopTime;
-    private String instanceURL;
-    private Integer instanceID;
-    private long usedTimeInSeconds;
-    private boolean running;
-
-    public boolean isRunning() {
-        return running;
-    }
-
-    public void setRunning(boolean running) {
-        this.running = running;
-    }
-
-    public Calendar getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(Calendar startTime) {
-        this.startTime = startTime;
-    }
-
-    public Calendar getStopTime() {
-        return stopTime;
-    }
-
-    public void setStopTime(Calendar stopTime) {
-        //Check weather stop time is Default value in database in that case
-        //server should still running so set isRunning as true
-        Calendar fixedDate = Calendar.getInstance();
-        fixedDate.set(2001, 1, 1, 00, 00, 00);
-        if (stopTime.compareTo(fixedDate) == 0) {
-            this.running = true;
-        }
-        this.stopTime = stopTime;
-    }
-
-    public String getInstanceURL() {
-        return instanceURL;
-    }
-
-    public void setInstanceURL(String instanceURL) {
-        this.instanceURL = instanceURL;
-    }
-
-    public Integer getInstanceID() {
-        return instanceID;
-    }
-
-    public void setInstanceID(Integer instanceID) {
-        this.instanceID = instanceID;
-    }
-
-    public long getUsedTimeInSeconds() {
-        long returnValue = (this.stopTime.getTimeInMillis() -
-                this.startTime.getTimeInMillis()) / 1000;
-        if (returnValue < 0) {
-            running = true;
-        }
-        return usedTimeInSeconds;
-    }
-    public void setUsedTimeInSeconds(long value){
-        this.usedTimeInSeconds=value;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
deleted file mode 100644
index b7407af..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedInstanceUsage.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedInstanceUsage {
-    private InstanceUsageStatics[] instanceUsages;
-    private int pageNumber;
-    private int numberOfPages;
-
-    public InstanceUsageStatics[] getInstanceUsages() {
-        if(instanceUsages != null) {
-        return Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-
-        return null;
-    }
-
-    public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) {
-        if(instanceUsages != null) {
-            this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length);
-        }
-    }
-
-    public int getPageNumber() {
-        return pageNumber;
-    }
-
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
deleted file mode 100644
index 0a3bd1b..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/PaginatedTenantUsageInfo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.beans;
-
-import java.util.Arrays;
-
-public class PaginatedTenantUsageInfo {
-    private TenantUsage[] tenantUsages;
-    private int pageNumber;
-    private int numberOfPages;
-    
-    public TenantUsage[] getTenantUsages() {
-        return Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public void setTenantUsages(TenantUsage[] tenantUsages) {
-        this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length);
-    }
-    public int getPageNumber() {
-        return pageNumber;
-    }
-    public void setPageNumber(int pageNumber) {
-        this.pageNumber = pageNumber;
-    }
-    public int getNumberOfPages() {
-        return numberOfPages;
-    }
-    public void setNumberOfPages(int numberOfPages) {
-        this.numberOfPages = numberOfPages;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
deleted file mode 100644
index 085b91a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/RequestStatistics.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-public class RequestStatistics {
-    private String key;
-    private long requestCount;
-    private long responseCount;
-    private long faultCount;
-
-    public RequestStatistics(String key) {
-        this.key = key;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
-    public long getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(long requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public long getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(long responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public long getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(long faultCount) {
-        this.faultCount = faultCount;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java b/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
deleted file mode 100644
index 543126d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage/2.1.1/src/main/java/org/wso2/carbon/usage/beans/TenantDataCapacity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.beans;
-
-public class TenantDataCapacity {
-
-    private long registryContentCapacity;
-    private long registryContentHistoryCapacity;
-
-    public TenantDataCapacity() {
-    }
-    
-    /**
-     * @param registryContentCapacity
-     * @param registryContentHistoryCapacity
-     */
-    public TenantDataCapacity(
-            long registryContentCapacity, long registryContentHistoryCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-    public long getRegistryContentCapacity() {
-        return registryContentCapacity;
-    }
-
-    public void setRegistryContentCapacity(long registryContentCapacity) {
-        this.registryContentCapacity = registryContentCapacity;
-    }
-
-    public long getRegistryContentHistoryCapacity() {
-        return registryContentHistoryCapacity;
-    }
-
-    public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) {
-        this.registryContentHistoryCapacity = registryContentHistoryCapacity;
-    }
-
-}


[19/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
deleted file mode 100644
index ba01f0a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/PublisherUtils.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.util;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.Agent;
-import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.DataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.conf.AgentConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
-import org.wso2.carbon.databridge.commons.Event;
-import org.wso2.carbon.databridge.commons.exception.AuthenticationException;
-import org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException;
-import org.wso2.carbon.databridge.commons.exception.TransportException;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.user.api.Tenant;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.NetworkUtils;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.math.BigInteger;
-import java.net.MalformedURLException;
-import java.net.SocketException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * this class provide utility methods to publish usage statistics
- */
-public class PublisherUtils {
-    private static Log log = LogFactory.getLog(PublisherUtils.class);
-    private static final String TRANSPORT = "https";
-    private static ConfigurationContextService configurationContextService;
-    private static Agent agent;
-    private static DataPublisher dataPublisher;
-    private static AsyncDataPublisher asyncDataPublisher;
-    private static String streamId;
-    private static final String usageEventStream = "org.wso2.carbon.usage.agent";
-    private static final String usageEventStreamVersion = "1.0.0";
-    
-    private static final String reqStatEventStream="org.wso2.carbon.service.request.stats";
-    private static final String reqStatEventStreamVersion="1.0.0";
-    private static String reqStatEventStreamId;
-    
-    private static Map<Integer, String> serverUrlMap = new HashMap<Integer, String>();
-
-
-    /**
-     * method to update server name
-     * @param tenantId tenant id
-     * @return server name
-     * @throws UsageException
-     */
-
-    public static String updateServerName(int tenantId) throws UsageException {
-
-        String serverName;
-        String hostName;
-
-        try {
-            hostName = NetworkUtils.getLocalHostname();
-        } catch (SocketException e) {
-            throw new UsageException("Error getting host name for the registry usage event payload",
-                    e);
-        }
-
-        ConfigurationContextService configurationContextService = PublisherUtils.
-                getConfigurationContextService();
-        ConfigurationContext configurationContext;
-        if (configurationContextService != null) {
-            configurationContext = configurationContextService.getServerConfigContext();
-        } else {
-            throw new UsageException("ConfigurationContext is null");
-        }
-//        int port = CarbonUtils.getTransportPort(configurationContext, "https");
-
-        String carbonHttpsPort = System.getProperty("carbon." + TRANSPORT + ".port");
-        if (carbonHttpsPort == null) {
-            carbonHttpsPort = Integer.toString(
-                    CarbonUtils.getTransportPort(configurationContext, TRANSPORT));
-        }
-        String baseServerUrl = TRANSPORT + "://" + hostName + ":" + carbonHttpsPort;
-        String context = configurationContext.getContextRoot();
-
-        String tenantDomain = null;
-        try {
-            Tenant tenant = Util.getRealmService().getTenantManager().getTenant(tenantId);
-            if(tenant!=null){
-                tenantDomain = tenant.getDomain();
-            }
-        } catch (org.wso2.carbon.user.api.UserStoreException e) {
-            throw new UsageException("Failed to get tenant domain", e);
-        }
-
-        if ((tenantDomain != null) &&
-                !(tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME))) {
-            serverName = baseServerUrl + context + "t/" + tenantDomain;
-
-        } else if (context.equals("/")) {
-
-            serverName = baseServerUrl + "";
-        } else {
-            serverName = baseServerUrl + context;
-
-        }
-
-        return serverName;
-    }
-    
-    public static String getServerUrl(int tenantId){
-
-        String serverUrl = serverUrlMap.get(tenantId);
-        if(serverUrl!=null){
-            return serverUrl;
-        }
-
-        if(serverUrl==null){
-            try{
-                serverUrl = updateServerName(tenantId);
-            }catch (UsageException e) {
-                log.error("Could not create the server url for tenant id: " + tenantId, e);
-            }
-        }
-
-        if(serverUrl!=null && !"".equals(serverUrl)){
-            serverUrlMap.put(tenantId, serverUrl);
-        }
-        return serverUrl;
-    }
-
-    public static void defineUsageEventStream() throws Exception {
-
-        createDataPublisher();
-
-        if(dataPublisher == null){
-            return;
-        }
-
-        try {
-
-            streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            log.info("Event stream with stream ID: " + streamId + " found.");
-
-        } catch (NoStreamDefinitionExistException e) {
-
-            log.info("Defining the event stream because it was not found in BAM");
-            try {
-                defineStream();    
-            } catch (Exception ex) {
-                String msg = "An error occurred while defining the even stream for Usage agent. " + e.getMessage();
-                log.warn(msg);
-            }
-
-        }
-
-    }
-    
-    private static void defineStream() throws Exception {
-        streamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + usageEventStream +"'," +
-                        "  'version':'" + usageEventStreamVersion +"'," +
-                        "  'nickName': 'usage.agent'," +
-                        "  'description': 'Tenant usage data'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'Type','type':'STRING'}," +
-                        "          {'name':'Value','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-        
-    }
-    
-    private static void defineRequestStatEventStream() throws Exception{
-        reqStatEventStreamId = dataPublisher.
-                defineStream("{" +
-                        "  'name':'" + reqStatEventStream +"'," +
-                        "  'version':'" + reqStatEventStreamVersion +"'," +
-                        "  'nickName': 'service.request.stats'," +
-                        "  'description': 'Tenants service request statistics'," +
-                        "  'metaData':[" +
-                        "          {'name':'clientType','type':'STRING'}" +
-                        "  ]," +
-                        "  'payloadData':[" +
-                        "          {'name':'ServerName','type':'STRING'}," +
-                        "          {'name':'TenantID','type':'STRING'}," +
-                        "          {'name':'RequestCount','type':'INT'}," +
-                        "          {'name':'ResponseCount','type':'INT'}," +
-                        "          {'name':'FaultCount','type':'INT'}," +
-                        "          {'name':'ResponseTime','type':'LONG'}" +
-                        "  ]" +
-                        "}");
-    }
-
-    public static void createDataPublisher(){
-
-        ServerConfiguration serverConfig =  CarbonUtils.getServerConfiguration();
-        String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
-        String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
-        String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
-        String adminUsername = CommonUtil.getStratosConfig().getAdminUserName();
-        String adminPassword = CommonUtil.getStratosConfig().getAdminPassword();
-
-        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
-        System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
-
-        try {
-            dataPublisher = new DataPublisher(bamServerUrl, adminUsername, adminPassword);
-        } catch (Exception e) {
-            log.warn("Unable to create a data publisher to " + bamServerUrl +
-                    ". Usage Agent will not function properly. " + e.getMessage());
-        }
-
-    }
-
-    /**
-     * Creates an async data publisher using the existing data publisher object
-     */
-    public static void createAsynDataPublisher(){
-        if(dataPublisher==null){
-            createDataPublisher();
-        }
-
-        if(dataPublisher==null){
-            log.warn("Cannot create the async data publisher because the data publisher is null");
-            return;
-        }
-
-        try {
-            asyncDataPublisher = new AsyncDataPublisher(dataPublisher);
-        } catch (Exception e) {
-            log.error("Could not create an async data publisher using the data publisher", e);
-        }
-    }
-
-
-    /**
-     * this method get the event payload, construct the SOAP envelop and call the publish method in
-     * EventBrokerService.
-     *
-     * @param usage BandwidthUsage
-     * @throws UsageException
-     */
-    public static void publish(BandwidthUsage usage) throws UsageException {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for usage data publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(streamId == null){
-            try{
-                streamId = dataPublisher.findStream(usageEventStream, usageEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                                        new Object[]{getServerUrl(usage.getTenantId()),
-                                                    Integer.toString(usage.getTenantId()),
-                                                    usage.getMeasurement(),
-                                                    usage.getValue()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-    
-    public static void publish(SystemStatistics statistics, int tenantId) throws Exception {
-
-        if(dataPublisher==null){
-            log.info("Creating data publisher for service-stats publishing");
-            createDataPublisher();
-
-            //If we cannot create a data publisher we should give up
-            //this means data will not be published
-            if(dataPublisher == null){
-                return;
-            }
-        }
-
-        if(reqStatEventStreamId == null){
-            try{
-                reqStatEventStreamId = dataPublisher.findStream(reqStatEventStream, reqStatEventStreamVersion);
-            }catch (NoStreamDefinitionExistException e){
-                log.info("Defining the event stream because it was not found in BAM");
-                try{
-                    defineRequestStatEventStream();
-                } catch(Exception ex){
-                    String msg = "Error occurred while defining the event stream for publishing usage data. " + ex.getMessage();
-                    log.error(msg);
-                    //We do not want to proceed without an event stream. Therefore we return.
-                    return;
-                }
-            }catch (Exception exc){
-                log.error("Error occurred while searching for stream id. " + exc.getMessage());
-                //We do not want to proceed without an event stream. Therefore we return.
-                return;
-            }
-        }
-
-        try {
-
-            Event usageEvent = new Event(reqStatEventStreamId, System.currentTimeMillis(), new Object[]{"external"}, null,
-                    new Object[]{getServerUrl(tenantId),
-                            Integer.toString(tenantId),
-                            statistics.getCurrentInvocationRequestCount(),
-                            statistics.getCurrentInvocationResponseCount(),
-                            statistics.getCurrentInvocationFaultCount(),
-                            statistics.getCurrentInvocationResponseTime()});
-
-            dataPublisher.publish(usageEvent);
-
-        } catch (Exception e) {
-            log.error("Error occurred while publishing usage event to BAM. " + e.getMessage(), e);
-            throw new UsageException(e.getMessage(), e);
-        }
-
-    }
-
-    /**
-     * method to get configurationContextService
-     * @return configurationContextService
-     */
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return configurationContextService;
-    }
-
-    /**
-     * method to setConfigurationContextService
-     * @param configurationContextService
-     */
-    public static void setConfigurationContextService(ConfigurationContextService configurationContextService) {
-        PublisherUtils.configurationContextService = configurationContextService;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
deleted file mode 100644
index 8bbd800..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/UsageAgentConstants.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-/**
- * this class define constants for UsageAgent component
- */
-public class UsageAgentConstants {
-    public static final String ELEMENT_NAME_DATA = "Data";
-    public static final String ELEMENT_NAME_KEY = "Key";
-    public static final String ELEMENT_NAME_VALUE = "Value";
-
-    public static final String STATISTICS_DATA_NS_URI = "http://wso2.org/ns/2009/09/bam/server/user-defined/data";
-    public static final String STATISTICS_DATA_NS_PREFIX = "svrusrdata";
-
-    // OM element names
-    public static final String STATISTICS_DATA_ELEMENT_NAME_EVENT = "Event";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVICE_STATISTICS_DATA = "ServerUserDefinedData";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_TENANT_ID = "TenantID";
-    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVER_NAME = "ServerName";
-
-    public static final String BAM_SERVER_URL = "BamServerURL";
-    public static final String BAM_SERVER_STAT_SERVICE = "BAMServerUserDefinedDataSubscriberService";
-    public static final String BAM_SERVER_STAT_FILTER = "carbon/bam/data/publishers/bandwidth-stat";
-
-    public static final String TOPIC_SEPARATOR = "/";
-    public static final String EVENT_NAME = "UsageMeteringEvent";
-
-    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER;
-//    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER + TOPIC_SEPARATOR + EVENT_NAME;
-
-
-    public static final String BANDWIDTH_USAGE_SERVICES_CONTEXT = "services";
-    public static final String BANDWIDTH_USAGE_WEBAPPS_CONTEXT = "webapps";
-    public static final String BANDWIDTH_CARBON = "carbon";
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/Util.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
deleted file mode 100644
index f29b261..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/util/Util.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.event.core.exception.EventBrokerException;
-import org.wso2.carbon.event.core.subscription.Subscription;
-import org.wso2.carbon.event.core.util.EventBrokerConstants;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.listeners.RegistryUsageListener;
-import org.wso2.carbon.usage.agent.persist.UsageDataPersistenceManager;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.File;
-
-
-/**
- * this class provide utility methods to set and get RealmService, initializing listeners,
- * initializing PersistenceManager etc
- * Further it provide methods to create statistics event subscription
- */
-
-public class Util {
-    private static final Log log = LogFactory.getLog(Util.class);
-    private static final String USAGE_THROTTLING_AGENT_CONFIG_FILE = "usage-throttling-agent-config.xml";
-    private static RealmService realmService;
-    private static ConfigurationContextService contextService;
-    private static UsageDataPersistenceManager persistenceManager;
-    //private static EventBrokerService eventBrokerService;
-    private static EventBroker eventBrokerService;
-    private static ServerConfigurationService serverConfiguration;
-
-    private static SystemStatisticsUtil systemStatisticsUtil;
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static void initializeAllListeners() throws Exception {
-        RegistryUsageListener.registerRegistryUsagePersistingListener(
-                RegistryContext.getBaseInstance());
-    }
-
-    public static void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.contextService = contextService;
-    }
-
-    public static ConfigurationContextService getConfigurationContextService() {
-        return Util.contextService;
-    }
-
-    /**
-     * this method create a PersistenceManager instance and start a thread for persisting statistics
-     */
-
-    public static void initializePersistenceManager() {
-        File usageAgentConfigFile  = new File(CarbonUtils.getCarbonConfigDirPath() + File.separator +
-                StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + Util.USAGE_THROTTLING_AGENT_CONFIG_FILE);
-        persistenceManager = new UsageDataPersistenceManager(new UsageAgentConfiguration(usageAgentConfigFile));
-        //start a thread for persisting bandwidth Usage statistics
-        if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            persistenceManager.scheduleBandwidthUsageDataRetrievalTask();
-            persistenceManager.scheduleUsageDataPersistenceTask();
-        }
-    }
-
-    public static void addToPersistingControllerQueue(BandwidthUsage usage) {
-        persistenceManager.addToQueue(usage);
-    }
-
-    public static EventBroker getEventBrokerService() {
-        return eventBrokerService;
-    }
-
-    public static void setEventBrokerService(EventBroker eventBrokerService) {
-        Util.eventBrokerService = eventBrokerService;
-    }
-
-    public static ServerConfigurationService getServerConfiguration() {
-        return serverConfiguration;
-    }
-
-    public static void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.serverConfiguration = serverConfiguration;
-    }
-
-    public static SystemStatisticsUtil getSystemStatisticsUtil() {
-        return systemStatisticsUtil;
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil) {
-        Util.systemStatisticsUtil = systemStatisticsUtil;
-    }
-
-    /**
-     * method to create static subscription to BAM
-     *
-     * @throws EventBrokerException, if creating the static subscription to BAM failed.
-     */
-    public static void createStaticEventSubscription() throws EventBrokerException {
-
-        //Get BAM URL from carbon.xml
-        ServerConfigurationService serverConfiguration = getServerConfiguration();
-        if (serverConfiguration == null) {
-            throw new IllegalArgumentException("Invalid server configuration");
-        }
-        String serverURL = serverConfiguration.getFirstProperty(UsageAgentConstants.BAM_SERVER_URL);
-
-        if(log.isDebugEnabled()){
-            log.debug("Bam url = " + serverURL);
-        }
-
-        //Add static subscription only if bam url is set
-        if (serverURL != null) {
-            String serviceURL = serverURL + UsageAgentConstants.BAM_SERVER_STAT_SERVICE;
-
-            EventBroker eventBrokerService = getEventBrokerService();
-            Subscription subscription = new Subscription();
-            // set the subscription end point to the service url
-            subscription.setEventSinkURL(serviceURL);
-            subscription.setTopicName(UsageAgentConstants.BAM_SERVER_STAT_FILTER);
-            subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);
-
-            try {
-                eventBrokerService.subscribe(subscription);
-            } catch (EventBrokerException e) {
-                String msg = "Cannot subscribe to the event broker ";
-                log.error(msg);
-                throw e;
-            }
-        }
-    }
-    
-    public static int getTenantId(String toAddress) throws Exception {
-        int index = toAddress.indexOf("/t/");
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        if(index >= 0){
-            String tenantDomain = toAddress.substring(index+2, toAddress.indexOf("/", index+3));
-            tenantId = getRealmService().getTenantManager().getTenantId(tenantDomain);
-        }
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/component.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 564f65f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Monitor</DisplayName>
-            <ResourceId>/permission/admin/monitor</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>Tenant-Usage</DisplayName>
-            <ResourceId>/permission/admin/monitor/tenantUsage/customUsage</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/module.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/module.xml
deleted file mode 100644
index 23f6025..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
- ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- ~
- ~ WSO2 Inc. 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.
- -->
-<module name="metering" class="org.wso2.carbon.usage.agent.listeners.axis2.RequestMeteringModule">
-   <InFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFlow>
-
-   <InFaultFlow>
-
-       <!--<handler name="InFlowMeteringHandler"
-                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
-           <order phase="OpPhase"/>
-       </handler>-->
-   </InFaultFlow>
-
-    <OutFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-    </OutFlow>
-
-    <OutFaultFlow>
-        <handler name="OutFlowMeteringHandler"
-                 class="org.wso2.carbon.usage.agent.listeners.StatisticsOutHandler">
-            <order phase="StatReporting"/>
-        </handler>
-
-    </OutFaultFlow>
-   <parameter name="adminModule" locked="true">true</parameter>
-</module>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/services.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 720bdb9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- !
- ! Copyright 2006 The Apache Software Foundation.
- !
- ! Licensed 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.
- !-->
-<serviceGroup>
-
-  <service name="CustomMeteringService" scope="transportsession">
-        <transports>
-            <transport>https</transport>
-        </transports>
-        <parameter name="ServiceClass" locked="false">
-            org.wso2.carbon.usage.agent.services.CustomMeteringService
-        </parameter>
-    </service>   
-    <parameter name="adminService" locked="true">true</parameter>
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/usage-throttling-agent-config.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/usage-throttling-agent-config.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/usage-throttling-agent-config.xml
deleted file mode 100644
index 6a222d7..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/resources/META-INF/usage-throttling-agent-config.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<UsageAndThrottlingAgentConfiguration xmlns="http://wso2.com/carbon/multitenancy/usage-throttling-agent/config">
-    <UsageAgent>
-        <UsageDataPersistenceTask>
-            <StartupDelayInMilliSeconds>60000</StartupDelayInMilliSeconds>
-            <NumberOfRecordsPerExecution>100</NumberOfRecordsPerExecution>
-            <ExecutionIntervalInMilliSeconds>100</ExecutionIntervalInMilliSeconds>
-        </UsageDataPersistenceTask>
-    </UsageAgent>
-    <ThrottlingAgent>
-        <ThrottlingInfoCacheUpdaterTask>
-            <StartupDelayInSeconds></StartupDelayInSeconds>
-            <ExecutionIntervalInSeconds></ExecutionIntervalInSeconds>
-        </ThrottlingInfoCacheUpdaterTask>
-    </ThrottlingAgent>
-</UsageAndThrottlingAgentConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/pom.xml
deleted file mode 100644
index dfd46a1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/pom.xml
+++ /dev/null
@@ -1,143 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <version>2.1.1</version>
-    <artifactId>org.wso2.carbon.usage.agent</artifactId>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage Agent</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Private-Package>
-                        	!org.wso2.carbon.usage.agent.api.*,
-                            org.wso2.carbon.usage.agent.*,
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.agent.api.*,
-                            org.wso2.carbon.usage.agent.beans.*,
-                            org.wso2.carbon.usage.agent.util.PublisherUtils,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.stratos.common.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.utils</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.statistics</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.registry.common</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.event.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-	    <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.email.verification</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.server</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.tomcat.ext</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.databridge.agent.thrift</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
deleted file mode 100644
index f8b0b42..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.api;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *   CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists,
- *   to persist and retrieve usage.
- */
-
-public class CustomMeteringAgent {
-    private static final Log log = LogFactory.getLog(CustomMeteringAgent.class);
-    private Registry registry;
-
-    /**
-     * Constructor for the custom metering agent
-     *
-     * @param registry governance registry of super tenant
-     */
-    public CustomMeteringAgent(Registry registry) {
-        this.registry = registry;
-    }
-
-    /**
-     * Get recorded durations
-     * @param measurement  the measurement to get the duration
-     * @return the durations array
-     * @throws UsageException
-     */
-    public String[] getRecordedDurations(String measurement) throws UsageException {
-        String[] durations;
-        String measurementCollectionPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement;
-        try {
-            Resource resource = registry.get(measurementCollectionPath);
-            if (!(resource instanceof Collection)) {
-                String msg =
-                        "The records collection is not a registry collection. path: " +
-                                measurementCollectionPath + ".";
-                log.error(msg);
-                throw new UsageException(msg);
-            }
-            durations = ((Collection) resource).getChildren();
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return durations;
-    }
-
-    /**
-     * Check whether the usage entry exist or not
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return true if usage entry exists
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public boolean isUsageEntryExists(String duration, String measurement)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            if (registry.resourceExists(measurementPath)) {
-                return true;
-            }
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return false;
-    }
-
-    /**
-     * Persist usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public void persistUsage(String duration, String measurement, String value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.newResource();
-            ((ResourceImpl) measurementResource).setVersionableChange(false);
-            // save the measurement value in resource
-            measurementResource.setContent(value);
-            registry.put(measurementPath, measurementResource);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in persisting the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-    }
-
-    /**
-     * Retrieve usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public String retrieveUsage(String duration, String measurement)
-            throws UsageException {
-        String usageValue;
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.get(measurementPath);
-            // save the measurement value in resource
-            byte[] contentBytes = (byte[]) measurementResource.getContent();
-            usageValue = new String(contentBytes);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in retrieving the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return usageValue;
-    }
-
-    /**
-     * Add a long value to the usage, if there were no previous entry, this will
-     * start with value 0
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @return the added measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public long addUsage(String duration, String measurement, long value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        // adding the bandwidth have to be in a transaction
-        boolean transactionSuccess = false;
-        try {
-            registry.beginTransaction();
-            if (isUsageEntryExists(duration, measurement)) {
-                String usageStr = retrieveUsage(duration, measurement);
-                try {
-                    long storedValue = Long.parseLong(usageStr);
-                    value += storedValue;
-                } catch (NumberFormatException e) {
-                    String msg = "Error in parsing the integer string: " + usageStr;
-                    log.error(msg, e);
-                    throw new RegistryException(msg, e);
-                }
-            }
-            String valueStr = Long.toString(value);
-            persistUsage(duration, measurement, valueStr);
-            transactionSuccess = true;
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in invoking the add usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        } finally {
-            try {
-                if (transactionSuccess) {
-                    registry.commitTransaction();
-                } else {
-                    registry.rollbackTransaction();
-                }
-            } catch (RegistryException e) {
-                String msg = "Error in commiting/rollbacking the transaction";
-                log.error(msg, e);
-            }
-        }
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
deleted file mode 100644
index 2448fcc..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/APIManagerRequestStats.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.beans;
-
-public class APIManagerRequestStats {
-    private int requestCount;
-    private int responseCount;
-    private int faultCount;
-    private long responseTime;
-    private int tenantId;
-    private String measurement;
-    private long value;
-
-    public APIManagerRequestStats() {
-        requestCount = 0;
-        responseCount = 0;
-        faultCount = 0;
-        responseTime = 0;
-        measurement = "APICall";
-        value = 0;
-        tenantId = 0;
-    }
-
-    public String getMeasurement() {
-        return measurement;
-    }
-
-    public void setMeasurement(String measurement) {
-        this.measurement = measurement;
-    }
-
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getRequestCount() {
-        return requestCount;
-    }
-
-    public void setRequestCount(int requestCount) {
-        this.requestCount = requestCount;
-    }
-
-    public int getResponseCount() {
-        return responseCount;
-    }
-
-    public void setResponseCount(int responseCount) {
-        this.responseCount = responseCount;
-    }
-
-    public int getFaultCount() {
-        return faultCount;
-    }
-
-    public void setFaultCount(int faultCount) {
-        this.faultCount = faultCount;
-    }
-
-    public long getResponseTime() {
-        return responseTime;
-    }
-
-    public void setResponseTime(long responseTime) {
-        this.responseTime = responseTime;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
deleted file mode 100644
index a792746..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.beans;
-
-/**
- * the bean class for BandwidthUsage with attributes
- * int tenant id,
- * String measurement
- * long value   *
- */
-
-public class BandwidthUsage {
-    private int tenantId;
-    private String measurement;
-    private long value;
-
-
-    public String getMeasurement() {
-        return measurement;
-    }
-
-    public BandwidthUsage(int tenantId, String measurement, long value) {
-        this.tenantId = tenantId;
-        this.measurement = measurement;
-        this.value = value;
-    }
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
deleted file mode 100644
index 7528171..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-public class UsageAgentConfiguration {
-    private static final Log log = LogFactory.getLog(UsageAgentConfiguration.class);
-
-    private static final Integer DEFAULT_NUMBER_OF_RECORDS_PER_RUN = 100;
-    private static final Integer DEFAULT_EXECUTION_INTERVAL_IN_MILLISECONDS = 100;
-    private static final Integer DEFAULT_STARTUP_DELAY_IN_MILLISECONDS = 60000;
-
-    private int usageTasksNumberOfRecordsPerExecution = -1;
-
-    private int usageTasksExecutionIntervalInMilliSeconds = -1;
-
-    private int usageTasksStartupDelayInMilliSeconds = -1;
-
-    public UsageAgentConfiguration(File configFile) {
-        if (configFile.exists()) {
-            try {
-                OMElement usageAndThrottlingAgentConfiguration =
-                        new StAXOMBuilder(new FileInputStream(configFile)).getDocumentElement();
-                if (usageAndThrottlingAgentConfiguration != null) {
-                    OMElement usageAgent = usageAndThrottlingAgentConfiguration.getFirstChildWithName(
-                            new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config", "UsageAgent"));
-                    if (usageAgent != null) {
-                        OMElement usageDataPersistenceTaskConfig = usageAgent.getFirstChildWithName(
-                                new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                        "UsageDataPersistenceTask"));
-                        if (usageDataPersistenceTaskConfig != null) {
-                            OMElement numberOfRecordsPerExecutionEle = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "NumberOfRecordsPerExecution"));
-                            if (numberOfRecordsPerExecutionEle != null && numberOfRecordsPerExecutionEle.getText() != null &&
-                                    numberOfRecordsPerExecutionEle.getText().length() > 0) {
-                                try {
-                                    usageTasksNumberOfRecordsPerExecution = Integer.parseInt(numberOfRecordsPerExecutionEle.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task number of records value.", ne);
-                                }
-                            }
-
-                            OMElement executionIntervalInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "ExecutionIntervalInMilliSeconds"));
-                            if (executionIntervalInMilliSeconds != null && executionIntervalInMilliSeconds.getText() != null &&
-                                    executionIntervalInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksExecutionIntervalInMilliSeconds =
-                                            Integer.parseInt(executionIntervalInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task  execution interval value.", ne);
-                                }
-                            }
-
-                            OMElement startupDelayInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "StartupDelayInMilliSeconds"));
-                            if (startupDelayInMilliSeconds != null && startupDelayInMilliSeconds.getText() != null &&
-                                    startupDelayInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksStartupDelayInMilliSeconds =
-                                            Integer.parseInt(startupDelayInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task startup delay value.", ne);
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } catch (FileNotFoundException e) {
-                log.error("Cannot find " + configFile.getAbsolutePath(), e);
-            } catch (XMLStreamException e) {
-                log.error("Error reading XML stream of file " + configFile.getAbsolutePath(), e);
-            }
-        }
-    }
-
-    public int getUsageTasksNumberOfRecordsPerExecution() {
-        return usageTasksNumberOfRecordsPerExecution;
-    }
-
-    public int getUsageTasksExecutionIntervalInMilliSeconds() {
-        return usageTasksExecutionIntervalInMilliSeconds;
-    }
-
-    public int getUsageTasksStartupDelayInMilliSeconds() {
-        return usageTasksStartupDelayInMilliSeconds;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
deleted file mode 100644
index 023d16f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.exception;
-
-/**
- * UsageException class to handle usage exception
- */
-public class UsageException extends Exception {
-    public UsageException(String msg, Exception e) {
-        super(msg, e);
-    }
-    public UsageException(String msg) {
-        super(msg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
deleted file mode 100644
index 62ae4cf..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.1/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.agent.internal;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.usage.agent.listeners.UsageStatsAxis2ConfigurationContextObserver;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to activate and deactivate the UsageAgentServiceComponent, set and unset
- * Serverconfigurarion, set and unset EventBrokerService.
- *
- * @scr.component name="org.wso2.carbon.usage.agent" immediate="true"
- * @scr.reference name="user.realmservice.default"
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1"
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service"
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="0..1"
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="server.configuration"
- * interface="org.wso2.carbon.base.api.ServerConfigurationService" cardinality="1..1"
- * policy="dynamic" bind="setServerConfiguration" unbind="unsetServerConfiguration"
- * @scr.reference name="eventbroker.service"
- * interface="org.wso2.carbon.event.core.EventBroker" cardinality="1..1"
- * policy="dynamic" bind="setEventBrokerService" unbind="unsetEventBrokerService"
- * @scr.reference name="org.wso2.carbon.statistics.services"
- * interface="org.wso2.carbon.statistics.services.SystemStatisticsUtil"
- * cardinality="0..1" policy="dynamic" bind="setSystemStatisticsUtil" unbind="unsetSystemStatisticsUtil"
- */
-public class UsageAgentServiceComponent {
-    private static Log log = LogFactory.getLog(UsageAgentServiceComponent.class);
-
-    /**
-     * method to activate UsageAgentServiceComponent
-     *
-     * @param context componentContext
-     */
-    protected void activate(ComponentContext context) {
-        try {
-            PrivilegedCarbonContext.startTenantFlow();
-            PrivilegedCarbonContext.getCurrentContext().setTenantId(
-                    MultitenantConstants.SUPER_TENANT_ID);
-            PrivilegedCarbonContext.getCurrentContext().getTenantDomain(true);
-            PrivilegedCarbonContext.getCurrentContext().setUsername(
-                    CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            PrivilegedCarbonContext.getCurrentContext().setUserRealm(
-                    Util.getRealmService().getBootstrapRealm());
-            
-            // initialize listeners
-            // currently we have RegistryUsagePersistingListener only
-            Util.initializeAllListeners();
-
-            //initialize persistenceManager for persisting BandwidthUsage
-            Util.initializePersistenceManager();
-
-            // create statistic event subscription
-            Util.createStaticEventSubscription();
-
-            if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-                //PublisherUtils.defineUsageEventStream();
-
-                UsageStatsAxis2ConfigurationContextObserver statObserver = new UsageStatsAxis2ConfigurationContextObserver();
-                context.getBundleContext().registerService(Axis2ConfigurationContextObserver.class.getName(), statObserver, null);
-                log.info("Observer to register the module for request statistics publishing was registered");
-            }
-
-            // register the request data persistor osgi service so that we can
-            // store service request bandwidths
-            // TODO: Remove this and ServiceDataPersistor after fixing ESB metering
-//            context.getBundleContext().registerService(
-//                    RequestDataPersister.class.getName(), new ServiceDataPersistor(), null);
-
-            log.debug("******* Multitenancy Usage Agent bundle is activated ******* ");
-        } catch (Throwable e) {
-            log.error("******* Failed to activate Multitenancy Usage Agent bundle ****", e);
-        } finally {
-            PrivilegedCarbonContext.endTenantFlow();
-        }
-    }
-
-    /**
-     * method to deactivate bundle
-     *
-     * @param context ComponentContext
-     */
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Multitenancy Metering Usage Agent bundle is deactivated ******* ");
-    }
-
-    /**
-     * method to set RealmService
-     *
-     * @param realmService RealmService
-     */
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    /**
-     * method to unsetRealmService
-     *
-     * @param realmService RealmService
-     */
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-
-    /**
-     * method to set ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(contextService);
-        PublisherUtils.setConfigurationContextService(contextService);
-    }
-
-    /**
-     * method to unset ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    /**
-     * method to set server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(serverConfiguration);
-    }
-
-    /**
-     * method to unset server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void unsetServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(null);
-    }
-
-    /**
-     * method to set EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-
-    protected void setEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(registryEventBrokerService);
-    }
-
-    /**
-     * method to unset EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-    protected void unsetEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(null);
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(systemStatisticsUtil);
-    }
-
-    public static void unsetSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(null);
-    }
-
-}


[25/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/UsageAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/UsageAgentConstants.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/UsageAgentConstants.java
new file mode 100644
index 0000000..94cddc5
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/UsageAgentConstants.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.usage.agent.util;
+
+/**
+ * this class define constants for UsageAgent component
+ */
+public class UsageAgentConstants {
+    public static final String ELEMENT_NAME_DATA = "Data";
+    public static final String ELEMENT_NAME_KEY = "Key";
+    public static final String ELEMENT_NAME_VALUE = "Value";
+
+    public static final String STATISTICS_DATA_NS_URI = "http://wso2.org/ns/2009/09/bam/server/user-defined/data";
+    public static final String STATISTICS_DATA_NS_PREFIX = "svrusrdata";
+
+    // OM element names
+    public static final String STATISTICS_DATA_ELEMENT_NAME_EVENT = "Event";
+    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVICE_STATISTICS_DATA = "ServerUserDefinedData";
+    public static final String STATISTICS_DATA_ELEMENT_NAME_TENANT_ID = "TenantID";
+    public static final String STATISTICS_DATA_ELEMENT_NAME_SERVER_NAME = "ServerName";
+
+    public static final String BAM_SERVER_URL = "BamServerURL";
+    public static final String BAM_SERVER_STAT_SERVICE = "BAMServerUserDefinedDataSubscriberService";
+    public static final String BAM_SERVER_STAT_FILTER = "carbon/bam/data/publishers/bandwidth-stat";
+
+    public static final String TOPIC_SEPARATOR = "/";
+    public static final String EVENT_NAME = "UsageMeteringEvent";
+
+    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER;
+//    public static final String BANDWIDTH_USAGE_TOPIC = BAM_SERVER_STAT_FILTER + TOPIC_SEPARATOR + EVENT_NAME;
+
+
+    public static final String BANDWIDTH_USAGE_SERVICES_CONTEXT = "services";
+    public static final String BANDWIDTH_USAGE_WEBAPPS_CONTEXT = "webapps";
+    public static final String BANDWIDTH_CARBON = "carbon";
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/Util.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/Util.java b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/Util.java
new file mode 100644
index 0000000..0397869
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/Util.java
@@ -0,0 +1,178 @@
+/*
+ *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.usage.agent.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.base.api.ServerConfigurationService;
+import org.wso2.carbon.event.core.EventBroker;
+import org.wso2.carbon.event.core.exception.EventBrokerException;
+import org.wso2.carbon.event.core.subscription.Subscription;
+import org.wso2.carbon.event.core.util.EventBrokerConstants;
+import org.wso2.carbon.registry.core.config.RegistryContext;
+import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.usage.agent.beans.BandwidthUsage;
+import org.apache.stratos.usage.agent.config.UsageAgentConfiguration;
+import org.apache.stratos.usage.agent.listeners.RegistryUsageListener;
+import org.apache.stratos.usage.agent.persist.UsageDataPersistenceManager;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.io.File;
+
+
+/**
+ * this class provide utility methods to set and get RealmService, initializing listeners,
+ * initializing PersistenceManager etc
+ * Further it provide methods to create statistics event subscription
+ */
+
+public class Util {
+    private static final Log log = LogFactory.getLog(Util.class);
+    private static final String USAGE_THROTTLING_AGENT_CONFIG_FILE = "usage-throttling-agent-config.xml";
+    private static RealmService realmService;
+    private static ConfigurationContextService contextService;
+    private static UsageDataPersistenceManager persistenceManager;
+    //private static EventBrokerService eventBrokerService;
+    private static EventBroker eventBrokerService;
+    private static ServerConfigurationService serverConfiguration;
+
+    private static SystemStatisticsUtil systemStatisticsUtil;
+
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+    public static void initializeAllListeners() throws Exception {
+        RegistryUsageListener.registerRegistryUsagePersistingListener(
+                RegistryContext.getBaseInstance());
+    }
+
+    public static void setConfigurationContextService(ConfigurationContextService contextService) {
+        Util.contextService = contextService;
+    }
+
+    public static ConfigurationContextService getConfigurationContextService() {
+        return Util.contextService;
+    }
+
+    /**
+     * this method create a PersistenceManager instance and start a thread for persisting statistics
+     */
+
+    public static void initializePersistenceManager() {
+        File usageAgentConfigFile  = new File(CarbonUtils.getCarbonConfigDirPath() + File.separator +
+                StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator + Util.USAGE_THROTTLING_AGENT_CONFIG_FILE);
+        persistenceManager = new UsageDataPersistenceManager(new UsageAgentConfiguration(usageAgentConfigFile));
+        //start a thread for persisting bandwidth Usage statistics
+        if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
+            persistenceManager.scheduleBandwidthUsageDataRetrievalTask();
+            persistenceManager.scheduleUsageDataPersistenceTask();
+        }
+    }
+
+    public static void addToPersistingControllerQueue(BandwidthUsage usage) {
+        persistenceManager.addToQueue(usage);
+    }
+
+    public static EventBroker getEventBrokerService() {
+        return eventBrokerService;
+    }
+
+    public static void setEventBrokerService(EventBroker eventBrokerService) {
+        Util.eventBrokerService = eventBrokerService;
+    }
+
+    public static ServerConfigurationService getServerConfiguration() {
+        return serverConfiguration;
+    }
+
+    public static void setServerConfiguration(ServerConfigurationService serverConfiguration) {
+        Util.serverConfiguration = serverConfiguration;
+    }
+
+    public static SystemStatisticsUtil getSystemStatisticsUtil() {
+        return systemStatisticsUtil;
+    }
+
+    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil) {
+        Util.systemStatisticsUtil = systemStatisticsUtil;
+    }
+
+    /**
+     * method to create static subscription to BAM
+     *
+     * @throws EventBrokerException, if creating the static subscription to BAM failed.
+     */
+    public static void createStaticEventSubscription() throws EventBrokerException {
+
+        //Get BAM URL from carbon.xml
+        ServerConfigurationService serverConfiguration = getServerConfiguration();
+        if (serverConfiguration == null) {
+            throw new IllegalArgumentException("Invalid server configuration");
+        }
+        String serverURL = serverConfiguration.getFirstProperty(UsageAgentConstants.BAM_SERVER_URL);
+
+        if(log.isDebugEnabled()){
+            log.debug("Bam url = " + serverURL);
+        }
+
+        //Add static subscription only if bam url is set
+        if (serverURL != null) {
+            String serviceURL = serverURL + UsageAgentConstants.BAM_SERVER_STAT_SERVICE;
+
+            EventBroker eventBrokerService = getEventBrokerService();
+            Subscription subscription = new Subscription();
+            // set the subscription end point to the service url
+            subscription.setEventSinkURL(serviceURL);
+            subscription.setTopicName(UsageAgentConstants.BAM_SERVER_STAT_FILTER);
+            subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
+            subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);
+
+            try {
+                eventBrokerService.subscribe(subscription);
+            } catch (EventBrokerException e) {
+                String msg = "Cannot subscribe to the event broker ";
+                log.error(msg);
+                throw e;
+            }
+        }
+    }
+    
+    public static int getTenantId(String toAddress) throws Exception {
+        int index = toAddress.indexOf("/t/");
+        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
+        if(index >= 0){
+            String tenantDomain = toAddress.substring(index+2, toAddress.indexOf("/", index+3));
+            tenantId = getRealmService().getTenantManager().getTenantId(tenantDomain);
+        }
+        return tenantId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..0654318
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/component.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+
+<component xmlns="http://products.wso2.org/carbon">
+    <ManagementPermissions>
+        <ManagementPermission>
+            <DisplayName>Monitor</DisplayName>
+            <ResourceId>/permission/admin/monitor</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Tenant-Usage</DisplayName>
+            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Tenant-Usage</DisplayName>
+            <ResourceId>/permission/admin/monitor/tenantUsage/customUsage</ResourceId>
+        </ManagementPermission>
+    </ManagementPermissions>
+</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/module.xml b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/module.xml
new file mode 100644
index 0000000..1b09002
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/module.xml
@@ -0,0 +1,51 @@
+<!--
+  ~  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.
+  -->
+<module name="metering" class="org.apache.stratos.usage.agent.listeners.axis2.RequestMeteringModule">
+   <InFlow>
+
+       <!--<handler name="InFlowMeteringHandler"
+                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
+           <order phase="OpPhase"/>
+       </handler>-->
+   </InFlow>
+
+   <InFaultFlow>
+
+       <!--<handler name="InFlowMeteringHandler"
+                class="org.wso2.carbon.usage.agent.listeners.StatisticsInHandler">
+           <order phase="OpPhase"/>
+       </handler>-->
+   </InFaultFlow>
+
+    <OutFlow>
+        <handler name="OutFlowMeteringHandler"
+                 class="org.apache.stratos.usage.agent.listeners.StatisticsOutHandler">
+            <order phase="StatReporting"/>
+        </handler>
+    </OutFlow>
+
+    <OutFaultFlow>
+        <handler name="OutFlowMeteringHandler"
+                 class="org.apache.stratos.usage.agent.listeners.StatisticsOutHandler">
+            <order phase="StatReporting"/>
+        </handler>
+
+    </OutFaultFlow>
+   <parameter name="adminModule" locked="true">true</parameter>
+</module>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..a0c68b1
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/services.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+<serviceGroup>
+
+  <service name="CustomMeteringService" scope="transportsession">
+        <transports>
+            <transport>https</transport>
+        </transports>
+        <parameter name="ServiceClass" locked="false">
+            org.apache.stratos.usage.agent.services.CustomMeteringService
+        </parameter>
+    </service>   
+    <parameter name="adminService" locked="true">true</parameter>
+    <parameter name="hiddenService" locked="true">true</parameter>
+</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/usage-throttling-agent-config.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/usage-throttling-agent-config.xml b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/usage-throttling-agent-config.xml
new file mode 100644
index 0000000..ac3084a
--- /dev/null
+++ b/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/usage-throttling-agent-config.xml
@@ -0,0 +1,33 @@
+<!--
+  ~  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.
+  -->
+<UsageAndThrottlingAgentConfiguration xmlns="http://wso2.com/carbon/multitenancy/usage-throttling-agent/config">
+    <UsageAgent>
+        <UsageDataPersistenceTask>
+            <StartupDelayInMilliSeconds>60000</StartupDelayInMilliSeconds>
+            <NumberOfRecordsPerExecution>100</NumberOfRecordsPerExecution>
+            <ExecutionIntervalInMilliSeconds>100</ExecutionIntervalInMilliSeconds>
+        </UsageDataPersistenceTask>
+    </UsageAgent>
+    <ThrottlingAgent>
+        <ThrottlingInfoCacheUpdaterTask>
+            <StartupDelayInSeconds></StartupDelayInSeconds>
+            <ExecutionIntervalInSeconds></ExecutionIntervalInSeconds>
+        </ThrottlingInfoCacheUpdaterTask>
+    </ThrottlingAgent>
+</UsageAndThrottlingAgentConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/pom.xml b/components/org.apache.stratos.usage.summary.helper/pom.xml
new file mode 100644
index 0000000..3cbe53c
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/pom.xml
@@ -0,0 +1,139 @@
+<!--
+# 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.
+  -->
+<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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.stratos</groupId>
+    <version>3.0.0-SNAPSHOT</version>
+    <artifactId>org.apache.stratos.usage.summary.helper</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos Usage Summary Generation Helper</name>
+
+    <build>
+
+        <plugins>
+	    <plugin>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>maven-scr-plugin</artifactId>
+                    <version>1.7.2</version>
+                    <executions>
+                        <execution>
+                            <id>generate-scr-scrdescriptor</id>
+                            <goals>
+                                <goal>scr</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.apache.stratos.usage.summary.*,
+                        </Export-Package>
+                        <Import-Package>
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+		<dependency>
+    	    <groupId>org.apache.hive.wso2</groupId>
+		    <artifactId>hive</artifactId>
+    	    <version>0.8.1.wso2v3</version>
+			<exclusions>
+        		<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-exec</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-shims</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-builtins</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-service</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-serde</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-metastore</artifactId>
+       	 		</exclusion>	
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-cassandra</artifactId>
+       	 		</exclusion>
+				<exclusion>
+          			<groupId>org.apache.hive</groupId>
+          			<artifactId>hive-jdbc</artifactId>
+       	 		</exclusion>
+				<exclusion>
+					<groupId>org.wso2.carbon</groupId>
+                    <artifactId>hive-jdbc-handler</artifactId>
+                </exclusion>
+			</exclusions> 
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.analytics.hive</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.hadoop</groupId>
+            <artifactId>hadoop-core</artifactId>
+            <version>0.20.2</version>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>wso2-nexus</id>
+            <name>WSO2 internal Repository</name>
+            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </releases>
+        </repository>
+    </repositories>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
new file mode 100644
index 0000000..370faed
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
@@ -0,0 +1,58 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the hour range for the next daily summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current daily summarization cycle
+ * from the usage hourly tables.
+ */
+public class DailyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos cartridge stats daily summarization.");
+        try {
+            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsDailyTimestamp();
+            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running daily cartridge stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
+            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
+            setProperty("current_daily_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting date range for daily cartridge stats analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyServiceStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
new file mode 100644
index 0000000..c688713
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
@@ -0,0 +1,58 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the hour range for the next daily summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current daily summarization cycle
+ * from the usage hourly tables.
+ */
+public class DailyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos service stats daily summarization.");
+        try {
+            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsDailyTimestamp();
+            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running daily service stats analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
+            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
+            setProperty("current_daily_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting date range for daily service stats analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailySummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailySummarizerHelper.java
new file mode 100644
index 0000000..2043337
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailySummarizerHelper.java
@@ -0,0 +1,58 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the hour range for the next daily summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current daily summarization cycle
+ * from the usage hourly tables.
+ */
+public class DailySummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos usage daily summarization.");
+        try {
+            String lastDailyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageDailyTimestamp();
+            Long lastDailyTimestampSecs = Timestamp.valueOf(lastDailyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running daily usage analytics from " + lastDailyTimestampStr + " to " + currentTsStr);
+            setProperty("last_daily_ts", lastDailyTimestampSecs.toString());
+            setProperty("current_daily_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting date range for daily usage analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
new file mode 100644
index 0000000..fde59df
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyCartridgeStatsSummarizerHelper.java
@@ -0,0 +1,55 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
+ * This is needed to excluded the already summarized usage stats in the current summarization cycle.
+ */
+public class HourlyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlyCartridgeStatsSummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos cartridge stats hourly summarization.");
+        try {
+            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsHourlyTimestamp();
+            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+
+            log.info("Running hourly cartridge stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting hour range for hourly cartridge stats analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
new file mode 100644
index 0000000..0a13245
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlyServiceStatsSummarizerHelper.java
@@ -0,0 +1,55 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
+ * This is needed to excluded the already summarized usage stats in the current summarization cycle.
+ */
+public class HourlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlyServiceStatsSummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos service stats hourly summarization.");
+        try {
+            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsHourlyTimestamp();
+            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+
+            log.info("Running hourly service stats analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting hour range for hourly service stats analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlySummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlySummarizerHelper.java
new file mode 100644
index 0000000..f41fe9f
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/HourlySummarizerHelper.java
@@ -0,0 +1,55 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the timestamp of the last hourly summarization cycle in hive config.
+ * This is needed to excluded the already summarized usage stats in the current summarization cycle.
+ */
+public class HourlySummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos usage hourly summarization.");
+        try {
+            String lastHourlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageHourlyTimestamp();
+            Long lastHourlyTimestamp = Timestamp.valueOf(lastHourlyTimestampStr).getTime();
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+
+            log.info("Running hourly usage analytics from " + lastHourlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_hourly_ts", lastHourlyTimestamp.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting hour range for hourly usage analysis. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
new file mode 100644
index 0000000..30e2ad4
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyCartridgeStatsSummarizerHelper.java
@@ -0,0 +1,60 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the date range for the next monthly summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current monthly summarization cycle
+ * from the usage hourly tables.
+ */
+public class MonthlyCartridgeStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos cartridge stats monthly summarization.");
+        try {
+            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastCartridgeStatsMonthlyTimestamp();
+            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running monthly cartridge stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
+            setProperty("current_monthly_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting month range for monthly cartridge stats analytics. ", e);
+        }
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
new file mode 100644
index 0000000..8c81a83
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlyServiceStatsSummarizerHelper.java
@@ -0,0 +1,60 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the date range for the next monthly summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current monthly summarization cycle
+ * from the usage hourly tables.
+ */
+public class MonthlyServiceStatsSummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos service stats monthly summarization.");
+        try {
+            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastUsageMonthlyTimestamp();
+            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
+            setProperty("current_monthly_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting month range for monthly service stats analytics. ", e);
+        }
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlySummarizerHelper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlySummarizerHelper.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlySummarizerHelper.java
new file mode 100644
index 0000000..b35fbb7
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/MonthlySummarizerHelper.java
@@ -0,0 +1,60 @@
+/*
+ *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.usage.summary.helper;
+
+import org.apache.stratos.usage.summary.helper.util.DataAccessObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.analytics.hive.extension.AbstractHiveAnalyzer;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to set the date range for the next monthly summarization cycle in the hive config.
+ * This is important to select the data slice corresponding the current monthly summarization cycle
+ * from the usage hourly tables.
+ */
+public class MonthlySummarizerHelper extends AbstractHiveAnalyzer {
+
+    private static Log log = LogFactory.getLog(HourlySummarizerHelper.class);
+
+    public void execute() {
+        log.info("Running custom analyzer for Stratos usage monthly summarization.");
+        try {
+            String lastMonthlyTimestampStr = DataAccessObject.getInstance().getAndUpdateLastServiceStatsMonthlyTimestamp();
+            Long lastMonthlyTimestampSecs = Timestamp.valueOf(lastMonthlyTimestampStr).getTime() / 1000;
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            String currentTsStr = formatter.format(new Date().getTime());
+            Long currentTsSecs = Timestamp.valueOf(currentTsStr).getTime() / 1000;
+
+            log.info("Running monthly service stats analytics from " + lastMonthlyTimestampStr + " to " + currentTsStr);
+            setProperty("last_monthly_ts", lastMonthlyTimestampSecs.toString());
+            setProperty("current_monthly_ts", currentTsSecs.toString());
+        } catch (Exception e) {
+            log.error("An error occurred while setting month range for monthly service stats analysis. ", e);
+        }
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
new file mode 100644
index 0000000..28bd055
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/internal/UsageSummaryHelperServiceComponent.java
@@ -0,0 +1,84 @@
+/*
+ *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.usage.summary.helper.internal;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.analytics.hive.service.HiveExecutorService;
+import org.wso2.carbon.ndatasource.core.DataSourceService;
+import org.apache.stratos.usage.summary.helper.util.DataHolder;
+
+import javax.sql.DataSource;
+
+/**
+ *
+ * @scr.component name="org.wso2.carbon.usage.summary" immediate="true"
+ * @scr.reference name="hive.executor.service"
+ * interface="org.wso2.carbon.analytics.hive.service.HiveExecutorService" cardinality="1..1"
+ * policy="dynamic" bind="setHiveExecutorService" unbind="unsetHiveExecutorService"
+ * @scr.reference name="datasources.service"
+ * interface="org.wso2.carbon.ndatasource.core.DataSourceService"
+ * cardinality="1..1" policy="dynamic"
+ * bind="setDataSourceService" unbind="unsetDataSourceService"
+ */
+public class UsageSummaryHelperServiceComponent {
+    
+    private static Log log = LogFactory.getLog(UsageSummaryHelperServiceComponent.class);
+
+    protected void activate(ComponentContext context){
+
+        log.info("Stratos usage summary helper bundle started");
+        /*try{
+
+        }catch (Throwable t){
+            log.error("Error occurred while activating the usage summary helper bundle..", t);
+        }*/
+    }
+
+    protected void deactivate(){
+        log.debug("Usage summary helper bundle was deactivated..");
+    }
+
+    protected void setHiveExecutorService(HiveExecutorService executorService){
+        //DataHolder.setExecutorService(executorService);
+    }
+
+    protected void unsetHiveExecutorService(HiveExecutorService executorService){
+        //DataHolder.setExecutorService(null);
+    }
+    
+    protected void setDataSourceService(DataSourceService dataSourceService){
+        DataHolder.setDataSourceService(dataSourceService);
+        try {
+            DataHolder.setDataSource((DataSource)dataSourceService.getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject());
+            log.info("Data source set to data holder");
+        } catch (Exception e) {
+            log.error("Error occurred while retrieving the data source: " + DataHolder.BILLING_DATA_SOURCE_NAME, e); //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+
+    protected void unsetDataSourceService(DataSourceService dataSourceService){
+        DataHolder.setDataSourceService(null);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataAccessObject.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataAccessObject.java
new file mode 100644
index 0000000..3af9706
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataAccessObject.java
@@ -0,0 +1,399 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.usage.summary.helper.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper class to retrieve relevant timestamps from relational database tables.
+ */
+public class DataAccessObject {
+
+    private static Log log = LogFactory.getLog(DataAccessObject.class);
+
+    private static DataSource dataSource = null;
+
+    private static DataAccessObject usageDataAccessObj = null;
+
+    private DataAccessObject() {
+    }
+
+    public static DataAccessObject getInstance() throws Exception {
+        if (usageDataAccessObj == null) {
+            usageDataAccessObj = new DataAccessObject();
+        }
+
+        if (usageDataAccessObj.dataSource == null) {
+            if (DataHolder.getDataSource() != null) {
+                try {
+                    dataSource = DataHolder.getDataSource();
+                    //dataSource = (DataSource) DataHolder.getDataSourceService().
+                    //       getDataSource(DataHolder.BILLING_DATA_SOURCE_NAME).getDSObject();
+                } catch (Exception e) {
+                    log.error("Error occurred while obtaining " + DataHolder.BILLING_DATA_SOURCE_NAME +
+                              " datasource from data source service.", e);
+                    throw new Exception(e);
+                }
+            } else {
+                log.error("Cannot obtain data source " + DataHolder.BILLING_DATA_SOURCE_NAME +
+                          ". Datasource service is null");
+                throw new Exception("Datasource service not available");
+            }
+
+        }
+
+        return usageDataAccessObj;
+    }
+
+    public String getAndUpdateLastUsageHourlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM USAGE_LAST_HOURLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO USAGE_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastUsageDailyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM USAGE_LAST_DAILY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO USAGE_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastUsageMonthlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM USAGE_LAST_MONTHLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO USAGE_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastServiceStatsHourlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_HOURLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO SERVICE_STATS_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last hourly timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastServiceStatsDailyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_DAILY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO SERVICE_STATS_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last daily timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastServiceStatsMonthlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM SERVICE_STATS_LAST_MONTHLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO SERVICE_STATS_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last monthly timestamp. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastCartridgeStatsHourlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_HOURLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_HOURLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last hourly timestamp for cartridge stats. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastCartridgeStatsDailyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_DAILY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_DAILY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last daily timestamp for cartridge stats. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+    public String getAndUpdateLastCartridgeStatsMonthlyTimestamp() throws SQLException {
+
+        Timestamp lastSummaryTs = null;
+        Connection connection = null;
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT TIMESTMP FROM CARTRIDGE_STATS_LAST_MONTHLY_TS WHERE ID='LatestTS'";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ResultSet resultSet = ps.executeQuery();
+            if (resultSet.next()) {
+                lastSummaryTs = resultSet.getTimestamp("TIMESTMP");
+            } else {
+                lastSummaryTs = new Timestamp(0);
+            }
+
+            DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+            Timestamp currentTs = Timestamp.valueOf(formatter.format(new Date()));
+
+            String currentSql = "INSERT INTO CARTRIDGE_STATS_LAST_MONTHLY_TS (ID, TIMESTMP) VALUES('LatestTS',?) ON DUPLICATE KEY UPDATE TIMESTMP=?";
+            PreparedStatement ps1 = connection.prepareStatement(currentSql);
+            ps1.setTimestamp(1, currentTs);
+            ps1.setTimestamp(2, currentTs);
+            ps1.execute();
+
+        } catch (SQLException e) {
+            log.error("Error occurred while trying to get and update the last monthly timestamp for cartridge stats. ", e);
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return lastSummaryTs.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataHolder.java b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataHolder.java
new file mode 100644
index 0000000..f4889a6
--- /dev/null
+++ b/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/util/DataHolder.java
@@ -0,0 +1,50 @@
+/*
+*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+*  WSO2 Inc. 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.usage.summary.helper.util;
+
+import org.wso2.carbon.ndatasource.core.DataSourceService;
+
+import javax.sql.DataSource;
+
+public class DataHolder {
+
+    private static DataSourceService dataSourceService;
+
+    private static DataSource dataSource;
+
+    public static final String BILLING_DATA_SOURCE_NAME = "WSO2BillingDS";
+    //public static final String BILLING_DATA_SOURCE_NAME = "WSO2USAGE_DS";
+
+
+    public static DataSource getDataSource() {
+        return dataSource;
+    }
+
+    public static void setDataSource(DataSource dataSource) {
+        DataHolder.dataSource = dataSource;
+    }
+
+    public static DataSourceService getDataSourceService() {
+        return dataSourceService;
+    }
+
+    public static void setDataSourceService(DataSourceService dataSourceService) {
+        DataHolder.dataSourceService = dataSourceService;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage.ui/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage.ui/pom.xml b/components/org.apache.stratos.usage.ui/pom.xml
new file mode 100644
index 0000000..3cd0ec8
--- /dev/null
+++ b/components/org.apache.stratos.usage.ui/pom.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+# 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.
+  -->
+<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/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-components-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+	<relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.usage.ui</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Usage - User Interface</name>
+
+    <build>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.wso2.carbon.usage.ui.*,
+                        </Export-Package>
+                        <Import-Package>
+			    org.wso2.carbon.usage.stub.*; version="${carbon.platform.package.import.version.range}",
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,                            
+                            org.apache.lucene.*,
+                            *;resolution:=optional
+                        </Import-Package>
+                        <Carbon-Component>UIBundle</Carbon-Component>
+                    </instructions>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+        </dependency>
+	    <dependency>
+            <groupId>commons-codec.wso2</groupId>
+            <artifactId>commons-codec</artifactId>
+	    <version>1.4.0.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
+	    <version>${carbon.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.equinox</groupId>
+            <artifactId>javax.servlet</artifactId>
+	    <version>3.0.0.v201112011016</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+            <artifactId>axiom</artifactId>
+	    <version>1.2.11.wso2v2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.ui</artifactId>
+	    <version>${carbon.platform.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>2.1.2</version>
+        </dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.usage.stub</artifactId>
+		<version>4.1.3</version>
+        </dependency>
+    </dependencies>
+
+</project>


[16/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
deleted file mode 100644
index 2286516..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsageListener.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.RegistryUsagePersister;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- */
-public class RegistryUsageListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsageListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-        //persisting to registry content addition
-        RegistryUsagePersister.storeAddContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        //RegistryUsagePersister.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        //RegistryUsagePersister.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //If metering is disabled, we do not need to register the handler
-        if(!"true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-            return;
-        }
-
-        HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsageListener handler = new RegistryUsageListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE, Filter.DELETE};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-    }
-
-    //===========================================================================================
-    public void delete(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getRegistry().get(path.getCompletePath());
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size = 0;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else if (contentObj instanceof String[]) {
-            // of type collection
-            for (String str : (String[]) contentObj) {
-                size += str.length();
-            }
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        RegistryUsagePersister.storeDeleteContent(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
deleted file mode 100644
index 0e7e75a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/RegistryUsagePersistingListener.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.config.RegistryContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.jdbc.handlers.Handler;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerLifecycleManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.HandlerManager;
-import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.Filter;
-import org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher;
-import org.wso2.carbon.registry.core.session.CurrentSession;
-import org.wso2.carbon.registry.core.utils.RegistryUtils;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.usage.agent.persist.BandwidthPersistor;
-import org.wso2.carbon.usage.agent.util.MonitoredReader;
-import org.wso2.carbon.usage.agent.util.MonitoredWriter;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Handler that intercept the registry calls
- * Currently this handler is not registered because there is a similar handler RegistryUsageHandler
- * After examining properly this class will be deleted.
- */
-public class RegistryUsagePersistingListener extends Handler {
-
-    private static final Log log = LogFactory.getLog(RegistryUsagePersistingListener.class);
-
-    public void put(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-
-        // called only once per request
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        ResourcePath path = context.getResourcePath();
-        Resource resource = context.getResource();
-        ((ResourceImpl) resource).setPath(path.getCompletePath());
-        if (resource instanceof CollectionImpl) {
-            return;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-
-
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        //we will pass through, so that normal registry operation will put the resource
-    }
-
-    public void importResource(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-//        ResourcePath resourcePath = context.getResourcePath();
-        String sourceURL = context.getSourceURL();
-     
-
-        // the import resource logic
-        URL url;
-        try {
-            if (sourceURL != null && sourceURL.toLowerCase().startsWith("file:")) {
-                String msg = "The source URL must not be file in the server's local file system";
-                throw new RegistryException(msg);
-            }
-            url = new URL(sourceURL);
-        } catch (MalformedURLException e) {
-            String msg = "Given source URL " + sourceURL + "is not valid.";
-            throw new RegistryException(msg, e);
-        }
-
-        try {
-            URLConnection uc = url.openConnection();
-            InputStream in = uc.getInputStream();
-            byte[] inByteArr = RegistryUtils.getByteArray(in);
-            int size = inByteArr.length;
-
-            // persisting bandwidth
-            BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-        } catch (IOException e) {
-
-            String msg = "Could not read from the given URL: " + sourceURL;
-            throw new RegistryException(msg, e);
-        }
-    }
-
-    public Resource get(RequestContext context) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return null;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return null;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return null;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-
-        // get the resource
-        Resource resource = context.getResource();
-        if (resource == null) {
-            ResourcePath resourcePath = context.getResourcePath();
-            Registry registry = context.getRegistry();
-            if (registry.resourceExists(resourcePath.getPath())) {
-                resource = registry.get(resourcePath.getPath());
-                context.setResource(resource);
-                context.setProcessingComplete(true); // nothing else to do.
-            }
-        }
-        if (resource == null) {
-            return null;
-        }
-        if (resource instanceof CollectionImpl) {
-            return resource;
-        }
-        Object contentObj = resource.getContent();
-        if (contentObj == null) {
-            return resource;
-        }
-        int size;
-        if (contentObj instanceof String) {
-            size = ((String) contentObj).length();
-        } else if (contentObj instanceof byte[]) {
-            size = ((byte[]) contentObj).length;
-        } else {
-            String msg = "Unsupported type for the content.";
-            log.error(msg);
-            throw new RegistryException(msg);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-        return resource;
-    }
-
-    public void dump(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        long size = requestContext.getBytesWritten();
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-
-        if (size == 0) {
-            //Still not dumped
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Writer writer = requestContext.getDumpingWriter();
-            // we wrap the writer with the monitored writer
-            MonitoredWriter monitoredWriter = new MonitoredWriter(writer);
-            registry.dump(path, monitoredWriter);
-            size = monitoredWriter.getTotalWritten();
-            requestContext.setProcessingComplete(true);
-        }
-
-        // persisting bandwidth
-        BandwidthPersistor.storeOutgoingBandwidth(tenantId, size);
-
-    }
-
-    public void restore(RequestContext requestContext) throws RegistryException {
-        if (CurrentSession.getCallerTenantId() == MultitenantConstants.SUPER_TENANT_ID ||
-                CurrentSession.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) {
-            // no limitations for the super tenant
-            return;
-        }
-        if (CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(CurrentSession.getUser()) ||
-                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(CurrentSession.getUser())) {
-            // skipping tracking for anonymous and system user
-            return;
-        }
-        // called only once per request..
-        if (CurrentSession.getAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR)
-                != null) {
-            return;
-        }
-        CurrentSession.setAttribute(StratosConstants.REGISTRY_USAGE_PERSISTED_SESSION_ATTR, true);
-
-        // pre triggering
-        int tenantId = CurrentSession.getTenantId();
-        long size = requestContext.getBytesRead();
-
-        if (size == 0) {
-            //not restored yet
-            Registry registry = requestContext.getRegistry();
-            String path = requestContext.getResourcePath().getPath();
-            Reader reader = requestContext.getDumpingReader();
-            // we wrap the reader with the monitored reader
-            MonitoredReader monitoredReader = new MonitoredReader(reader);
-            registry.restore(path, monitoredReader);
-            size = monitoredReader.getTotalRead();
-            requestContext.setProcessingComplete(true);
-        }
-        // persisting bandwidth
-        BandwidthPersistor.storeIncomingBandwidth(tenantId, size);
-
-    }
-
-    public static void registerRegistryUsagePersistingListener(RegistryContext registryContext)
-            throws RegistryException {
-
-        //This was commented out because there is a similar class RegistryUsageListener
-        //After examiming properly this class will be deleted
-        /*HandlerManager handlerManager = registryContext.getHandlerManager();
-        RegistryUsagePersistingListener handler = new RegistryUsagePersistingListener();
-        URLMatcher anyUrlMatcher = new URLMatcher();
-        anyUrlMatcher.setPattern(".*");
-        String[] applyingFilters = new String[]{
-                Filter.PUT, Filter.IMPORT, Filter.GET, Filter.DUMP, Filter.RESTORE,};
-
-        handlerManager.addHandlerWithPriority(applyingFilters, anyUrlMatcher, handler,
-                HandlerLifecycleManager.DEFAULT_REPORTING_HANDLER_PHASE);
-        */
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
deleted file mode 100644
index cd4d2d9..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsInHandler.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-public class StatisticsInHandler extends AbstractHandler{
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-            return InvocationResponse.CONTINUE;
-        }
-
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-                tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
deleted file mode 100644
index 9e21058..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/StatisticsOutHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.core.util.SystemFilter;
-import org.wso2.carbon.statistics.services.util.SystemStatistics;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-
-public class StatisticsOutHandler extends AbstractHandler{
-
-    private static Log log = LogFactory.getLog(StatisticsOutHandler.class);
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-
-
-        AxisService axisService =  messageContext.getAxisService();
-        if(axisService== null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
-                axisService.isClientSide()){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-
-        if(Util.getSystemStatisticsUtil()==null){
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return InvocationResponse.CONTINUE;
-        }
-        SystemStatistics systemStatistics = Util.getSystemStatisticsUtil().getSystemStatistics(messageContext);
-        
-        int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-        tenantId = CarbonContext.getCurrentContext().getTenantId();
-
-        if(tenantId == MultitenantConstants.INVALID_TENANT_ID ||
-            tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-
-            PrivilegedCarbonContext.destroyCurrentContext();
-            return Handler.InvocationResponse.CONTINUE;
-        }
-
-        try {
-            PublisherUtils.publish(systemStatistics, tenantId);
-        } catch (Exception e) {
-            //Logging the complete stacktrace in debug mode
-            if(log.isDebugEnabled()){
-                log.debug(e);
-            }
-
-            log.error("Error occurred while publishing request statistics. Full stacktrace available in debug logs. " + e.getMessage());
-        }
-
-        PrivilegedCarbonContext.destroyCurrentContext();
-        return InvocationResponse.CONTINUE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
deleted file mode 100644
index 3c30ed3..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/UsageStatsAxis2ConfigurationContextObserver.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.wso2.carbon.usage.agent.listeners;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver;
-
-
-public class UsageStatsAxis2ConfigurationContextObserver extends AbstractAxis2ConfigurationContextObserver {
-
-    private static final Log log = LogFactory.getLog(UsageStatsAxis2ConfigurationContextObserver.class);
-
-    @Override
-    public void createdConfigurationContext(ConfigurationContext configContext) {
-
-        AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
-        int tenantId = PrivilegedCarbonContext.getCurrentContext().getTenantId(false);
-        try {
-            axisConfiguration.engageModule("metering");
-        } catch (AxisFault axisFault) {
-            log.error("Could not engage metering module for tenant: " + tenantId, axisFault);
-        }
-
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
deleted file mode 100644
index 0eab461..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.usage.agent.util.Util;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * this class is used to obtain tenant id from MeteredServletRequest or MessageContext
- */
-
-public class RequestMeteringHandler extends AbstractHandler {
-    private static final Log log = LogFactory.getLog(RequestMeteringHandler.class);
-
-    /**
-     * this method  invoke  MeteredServletRequest and return a InvocationResponse
-     * @param messageContext  MessageContext
-     * @return InvocationResponse
-     * @throws AxisFault
-     */
-
-    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
-        if (log.isDebugEnabled()) {
-            log.debug("Staring metering handler invocation. Incoming message: " +
-                    messageContext.getEnvelope().toString());
-        }
-        AxisService service = messageContext.getAxisService();
-        Parameter param = service.getParameter("adminService");
-
-        Object obj = messageContext.getProperty("transport.http.servletRequest");
-        if (obj == null) {
-            // TODO: check for cause of the error.
-            log.debug("Servlet request is null. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-        if (!(obj instanceof MeteredServletRequest)) {
-            log.debug("HttpServletRequest is not of type MeteredServletRequest. Skip monitoring.");
-            return InvocationResponse.CONTINUE;
-        }
-
-        MeteredServletRequest servletRequest = (MeteredServletRequest) obj;
-
-        if (param != null && "true".equals(param.getValue())) {
-            servletRequest.setAttribute(StratosConstants.ADMIN_SERVICE_SERVLET_ATTR, "true");
-            return InvocationResponse.CONTINUE;
-        }
-        servletRequest.setAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR, service.getName());
-
-        int tenantId = getTenantId(servletRequest);
-        servletRequest.setAttribute(StratosConstants.TENANT_ID_SERVLET_ATTR, tenantId);
-
-        return InvocationResponse.CONTINUE;
-    }
-
-    /**
-     * method to get tenant id from MeteredServletRequest
-     * @param servletRequest MeteredServletRequest
-     * @return tenant id
-     */
-
-    private int getTenantId(MeteredServletRequest servletRequest) {
-        String address = servletRequest.getRequestURI();
-        String servicesPrefix = "/services/t/";
-        if (address != null && address.contains(servicesPrefix)) {
-            int domainNameStartIndex =
-                    address.indexOf(servicesPrefix) + servicesPrefix.length();
-            int domainNameEndIndex = address.indexOf('/', domainNameStartIndex);
-            String domainName = address.substring(domainNameStartIndex,
-                    domainNameEndIndex == -1 ? address.length() : domainNameEndIndex);
-
-            // return tenant id if domain name is not null
-            if (domainName != null) {
-                try {
-                    return Util.getRealmService().getTenantManager().getTenantId(domainName);
-                } catch (org.wso2.carbon.user.api.UserStoreException e) {
-                    log.error("An error occurred while obtaining the tenant id.", e);
-                }
-            }
-        }
-
-        // return 0 if the domain name is null
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
deleted file mode 100644
index f45b8b5..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/listeners/axis2/RequestMeteringModule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.listeners.axis2;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisDescription;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.modules.Module;
-import org.apache.neethi.Assertion;
-import org.apache.neethi.Policy;
-
-public class RequestMeteringModule implements Module {
-
-    public void init(ConfigurationContext configurationContext, AxisModule axisModule)
-            throws AxisFault {
-    }
-
-    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public boolean canSupportAssertion(Assertion assertion) {
-        return true;
-    }
-
-    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
-    }
-
-    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
deleted file mode 100644
index e52384d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthPersistor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class BandwidthPersistor {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
deleted file mode 100644
index 7824fe8..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.core.init.CarbonServerManager;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.stratos.common.util.StratosConfiguration;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsContainer;
-import org.wso2.carbon.tomcat.ext.transport.statistics.TransportStatisticsEntry;
-import org.wso2.carbon.usage.agent.util.UsageAgentConstants;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.util.Queue;
-
-public class BandwidthUsageDataRetrievalTask implements Runnable {
-    private static final Log log = LogFactory.getLog(BandwidthUsageDataRetrievalTask.class);
-
-    private Queue<TransportStatisticsEntry> transportStats;
-    private UsageAgentConfiguration configuration;
-
-    //This will be decided based on whether a BAM Server URL is provided or not
-    private boolean isBamAvailable=false;
-
-    public BandwidthUsageDataRetrievalTask(UsageAgentConfiguration configuration) {
-        transportStats = TransportStatisticsContainer.getTransportStatistics();
-        this.configuration = configuration;
-
-        //Checking for the BAM Server URL
-        String bamServerUrl = ServerConfiguration.getInstance().getFirstProperty("BamServerURL");
-        if(bamServerUrl != null){
-            this.isBamAvailable = true;
-        }
-    }
-
-    public void run() {
-        /*if (log.isDebugEnabled()) {
-            log.debug("Retrieving Service and Web App bandwidth usage statistics.");
-        }*/
-
-        if (!transportStats.isEmpty()) {
-            for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !transportStats.isEmpty(); i++) {
-                TransportStatisticsEntry entry = transportStats.remove();
-                try {
-                    if(!isBamAvailable){
-                        return;
-                    }
-
-                    int tenantId = getTenantID(entry.getTenantName());
-                    //if the tenant does not exist, no need and no way of updating the usage data
-                    //therefore ignore it
-                    if(tenantId<0){
-                        return;
-                    }
-                    if (inferMeasurement(entry).equals(UsageConstants.SERVICE_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.SERVICE_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    } else if (inferMeasurement(entry).equals(UsageConstants.WEBAPP_BANDWIDTH)) {
-                        if (entry.getRequestSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_INCOMING_BW, entry.getRequestSize()));
-                        }
-                        if (entry.getResponseSize() > 0) {
-                            Util.addToPersistingControllerQueue(new BandwidthUsage(getTenantID(entry.getTenantName()), UsageConstants.WEBAPP_OUTGOING_BW, entry.getResponseSize()));
-                        }
-                    }
-                } catch (UserStoreException e) {
-                    log.error("Error persisting bandwidth usage statistics.", e);
-                }
-
-            }
-        }
-    }
-
-
-    private String inferMeasurement(TransportStatisticsEntry entry) {
-        if (entry.getContext() != null) {
-            if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_SERVICES_CONTEXT)) {
-                return UsageConstants.SERVICE_BANDWIDTH;
-            } else if (entry.getContext().equals(UsageAgentConstants.BANDWIDTH_USAGE_WEBAPPS_CONTEXT)) {
-                return UsageConstants.WEBAPP_BANDWIDTH;
-            }
-        }
-
-        return UsageAgentConstants.BANDWIDTH_CARBON;
-    }
-
-    private int getTenantID(String tenantDomain) throws UserStoreException {
-        return Util.getRealmService().getTenantManager().getTenantId(tenantDomain);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
deleted file mode 100644
index 0bd7ab1..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/RegistryUsagePersister.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.lang.System;
-
-/**
- * this class is used to store incoming and outgoing bandwidth
- */
-
-public class RegistryUsagePersister {
-
-    /**
-     * method to store incoming bandwidth
-     * @param tenantId tenant id
-     * @param size value of the incoming bandwidth
-     */
-
-    public static void storeIncomingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_INCOMING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    //=============================================================
-
-    public static void storeAddContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-In", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-    public static void storeDeleteContent(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, "ContentBandwidth-Out", size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-   //=============================================================
-    /**
-     * method to store outgoingBandwidth
-     * @param tenantId tenant id
-     * @param size value of the outgoing bandwidth
-     */
-    public static void storeOutgoingBandwidth(int tenantId, long size) {
-        if ((MultitenantConstants.SUPER_TENANT_ID!=tenantId) && (size > 0)) {
-            BandwidthUsage usage = new BandwidthUsage(
-                    tenantId, UsageConstants.REGISTRY_OUTGOING_BW, size);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
deleted file mode 100644
index 9b0902c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/ServiceDataPersistor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.core.transports.metering.MeteredServletRequest;
-import org.wso2.carbon.core.transports.metering.MeteredServletResponse;
-import org.wso2.carbon.core.transports.metering.RequestDataPersister;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to persist service data
- */
-public class ServiceDataPersistor implements RequestDataPersister {
-    private static final Log log = LogFactory.getLog(ServiceDataPersistor.class);
-
-    /**
-     * this method get tenant id, inDataSize and outDataSize from the wrappedRequest, construct a
-     * BandwidthUsage object and add it to PersistingControllerQueue
-     * @param wrappedRequest  MeteredServletRequest
-     * @param wrappedResponse MeteredServletResponse
-     */
-    public void persist(MeteredServletRequest wrappedRequest, MeteredServletResponse wrappedResponse) {
-        if ("true".equals(wrappedRequest.getAttribute(StratosConstants.SERVICE_NAME_SERVLET_ATTR))) {
-            return;
-        }
-
-        Integer tenantId = (Integer) wrappedRequest.getAttribute(
-                StratosConstants.TENANT_ID_SERVLET_ATTR);
-        if (tenantId == null || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
-            return;
-        }
-        long inDataSize = wrappedRequest.getReadSize();
-        long outDataSize = wrappedResponse.getWrittenSize();
-
-        if(log.isTraceEnabled()){
-            log.trace("Persisting service bandwidth usage for tenant " + tenantId + " in size: " + inDataSize + " out size: " + outDataSize);
-        }
-        // add the job to queue
-        if (inDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_INCOMING_BW, inDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-        if (outDataSize > 0) {
-            BandwidthUsage usage = new BandwidthUsage(tenantId,
-                    UsageConstants.SERVICE_OUTGOING_BW, outDataSize);
-            Util.addToPersistingControllerQueue(usage);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
deleted file mode 100644
index 5cf4491..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceManager.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-
-import java.util.Queue;
-import java.util.concurrent.*;
-
-public class UsageDataPersistenceManager {
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceManager.class);
-
-    // queue to store Bandwidth usage statistics.
-    // usage of  LinkedBlockingQueue ensures operations on the queue to wait for the queue to be non
-    // empty when retrieving and wait for space when storing element.
-    private Queue<BandwidthUsage> persistenceJobs = new LinkedBlockingQueue<BandwidthUsage>();
-
-    private final ScheduledExecutorService scheduler;
-
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceManager(UsageAgentConfiguration configuration) {
-        scheduler = Executors.newScheduledThreadPool(2, new UsageDataPersistenceThreadFactory());
-        this.configuration = configuration;
-    }
-
-    /**
-     * this method add bandwidth usage entries to the jobQueue
-     *
-     * @param usage Bandwidth usage
-     */
-
-    public void addToQueue(BandwidthUsage usage) {
-        persistenceJobs.add(usage);
-    }
-
-    public void scheduleUsageDataPersistenceTask() {
-        //we will schedule the usage data persistence task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new UsageDataPersistenceTask(persistenceJobs, configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Usage data persistence task was scheduled");
-        }else{
-            log.debug("Usage data persistence task is disabled");
-        }
-    }
-
-
-    public void scheduleBandwidthUsageDataRetrievalTask() {
-        //we will schedule the usage data retrieval task only if interval is not -1
-        if(configuration.getUsageTasksExecutionIntervalInMilliSeconds()>0){
-            scheduler.scheduleWithFixedDelay(new BandwidthUsageDataRetrievalTask(configuration),
-                    configuration.getUsageTasksStartupDelayInMilliSeconds(),
-                    configuration.getUsageTasksExecutionIntervalInMilliSeconds(),
-                    TimeUnit.MILLISECONDS);
-            log.debug("Bandwidth Usage data retrieval task was scheduled");
-        }else {
-            log.debug("Bandwidth Usage data retrieval task was disabled");
-        }
-    }
-
-    class UsageDataPersistenceThreadFactory implements ThreadFactory {
-        private int counter = 0;
-
-        public Thread newThread(Runnable r) {
-            return new Thread(r, "UsageDataPersistenceThread-" + counter++);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
deleted file mode 100644
index 64f3b0a..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/persist/UsageDataPersistenceTask.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.persist;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.base.MultitenantConstants;
-import org.wso2.carbon.usage.agent.beans.BandwidthUsage;
-import org.wso2.carbon.usage.agent.config.UsageAgentConfiguration;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Queue;
-
-public class UsageDataPersistenceTask implements Runnable {
-
-    private static final Log log = LogFactory.getLog(UsageDataPersistenceTask.class);
-
-    private Queue<BandwidthUsage> usagePersistenceJobs;
-    private UsageAgentConfiguration configuration;
-
-    public UsageDataPersistenceTask(Queue<BandwidthUsage> jobs, UsageAgentConfiguration configuration) {
-        usagePersistenceJobs = jobs;
-        this.configuration = configuration;
-    }
-
-    public void run() {
-        if (!usagePersistenceJobs.isEmpty()) {
-            if (log.isDebugEnabled()) {
-                log.debug("Persisting Service and Web App bandwidth usage statistics");
-            }
-            try {
-                persistUsage(usagePersistenceJobs);
-            } catch (UsageException e) {
-                log.error("Error when persisting usage statistics.", e);
-            }
-        }
-    }
-
-    /**
-     * this method create a Summarizer object for each tenant and call accumulate() method to
-     * accumulate usage statistics
-     *
-     * @param jobQueue usage data persistence jobs
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     *
-     */
-
-    public void persistUsage(Queue<BandwidthUsage> jobQueue) throws UsageException {
-
-        // create a map to hold summarizer objects against tenant id
-        HashMap<Integer, Summarizer> summarizerMap = new HashMap<Integer, Summarizer>();
-
-        // if the jobQueue is not empty
-        for (int i = 0; i < configuration.getUsageTasksNumberOfRecordsPerExecution() && !jobQueue.isEmpty(); i++) {
-
-            // get the first element from the queue, which is a BandwidthUsage object
-            BandwidthUsage usage = jobQueue.poll();
-
-            // get the tenant id
-            int tenantId = usage.getTenantId();
-
-            //get the Summarizer object corresponds to the tenant id
-            Summarizer summarizer = summarizerMap.get(tenantId);
-
-            // when tenant invoke service for the first time, no corresponding summarizer object in
-            // the map
-            if (summarizer == null) {
-                //create a Summarizer object and put to the summarizerMap
-                summarizer = new Summarizer();
-                summarizerMap.put(tenantId, summarizer);
-            }
-
-            //  now accumulate usage
-            summarizer.accumulate(usage);
-        }
-
-        //Finished accumulating. Now publish the events
-
-        // get the collection view of values in summarizerMap
-        Collection<Summarizer> summarizers = summarizerMap.values();
-
-        // for each summarizer object call the publish method
-        for (Summarizer summarizer : summarizers) {
-            summarizer.publish();
-        }
-    }
-
-    /**
-     * inner class Summarizer
-     * this class is used to accumulate and publish usage statistics.
-     * for each tenant this keeps a map to store BandwidthUsage values
-     */
-    private static class Summarizer {
-        private HashMap<String, BandwidthUsage> usageMap;
-
-        public Summarizer() {
-            usageMap = new HashMap<String, BandwidthUsage>();
-        }
-
-        /**
-         * the method to accumulate usage data
-         *
-         * @param usage BandwidthUsage
-         */
-
-        public void accumulate(BandwidthUsage usage) {
-            // get the measurement name of usage entry
-            String key = usage.getMeasurement();
-
-            // get the existing value of measurement
-            BandwidthUsage existingUsage = usageMap.get(key);
-
-            // if this measurement is metered earlier add the new value to the existing value
-            if (existingUsage != null) {
-                existingUsage.setValue(existingUsage.getValue() + usage.getValue());
-            } else {
-                // if this measurement is not metered previously we need to add it to the usageMap
-                usageMap.put(key, usage);
-            }
-        }
-
-        /**
-         * this method reads usage items from the usageMap and call publish method to publish to
-         * the BAM
-         *
-         * @throws UsageException
-         */
-
-        public void publish() throws UsageException {
-
-            // get the collection view of values in usageMap
-            Collection<BandwidthUsage> usages = usageMap.values();
-
-            for (BandwidthUsage usage : usages) {
-                try {
-                    // publish the usage entry if it is not the super-tenant
-                    if(MultitenantConstants.SUPER_TENANT_ID != usage.getTenantId()){
-                        PublisherUtils.publish(usage);
-                    }
-                } catch (UsageException e) {
-                    log.error("Error in publishing bandwidth usage data", e);
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
deleted file mode 100644
index 23e684d..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/services/CustomMeteringService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.services;
-
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.usage.agent.api.CustomMeteringAgent;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *      CustomMeteringService class defines methods to get recorded duration, to check whether
- *      usage entries exists, persist usage, retrieve usage and add usage.
- */
-public class CustomMeteringService extends AbstractAdmin {
-
-    /**
-     * method to get recorded durations
-     * @param measurement  the measurement name
-     * @return  duration array
-     * @throws Exception
-     */
-
-    public String[] getRecordedDurations(String measurement) throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).getRecordedDurations(measurement);
-    }
-
-    /**
-     * method to check whether usage entry exists or not
-     * @param duration  duration
-     * @param measurement measurement name
-     * @return true if usage entry exist
-     * @throws Exception
-     */
-    public boolean isUsageEntryExists( String duration, String measurement)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).isUsageEntryExists(duration,
-                measurement);
-    }
-
-    /**
-     * method to persist usage
-     * @param duration
-     * @param measurement measurement name
-     * @param value   value of measurement
-     * @throws Exception
-     */
-    public void persistUsage( String duration, String measurement, String value)
-            throws Exception {
-        new CustomMeteringAgent(getGovernanceRegistry()).persistUsage(duration, measurement, value);
-    }
-
-    /**
-     * method to retrieve usage
-     * @param duration
-     * @param measurement measurement name
-     * @return usage value
-     * @throws UsageException
-     */
-
-    public String retrieveUsage( String duration, String measurement)
-            throws UsageException {
-        return new CustomMeteringAgent(getGovernanceRegistry())
-                .retrieveUsage(duration, measurement);
-    }
-
-    /**
-     * method to add usage entries
-     * @param userName user name
-     * @param duration duration of the measurement
-     * @param measurement measurement name
-     * @param value usage value
-     * @return usage value
-     * @throws Exception
-     */
-    public long addUsage(String userName, String duration, String measurement, long value)
-            throws Exception {
-        return new CustomMeteringAgent(getGovernanceRegistry()).addUsage(duration, measurement,
-                value);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
deleted file mode 100644
index 821ed82..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredReader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-/**
- * this class is used to wrap the Reader object
- */
-public class MonitoredReader extends Reader {
-    Reader reader;
-    long totalRead;
-
-    public MonitoredReader(Reader reader) {
-        this.reader = reader;
-        totalRead = 0;
-    }
-
-    public int read(char cbuf[], int off, int len) throws IOException {
-        int read = reader.read(cbuf, off, len);
-        totalRead += read;
-        return read;
-    }
-
-    public void close() throws IOException {
-        reader.close();
-    }
-
-    public long getTotalRead() {
-        return totalRead;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
deleted file mode 100644
index 856fd18..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.2/src/main/java/org/wso2/carbon/usage/agent/util/MonitoredWriter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.util;
-
-import java.io.IOException;
-import java.io.Writer;
-
-
-/**
- * this class is used to wrap Writer object
- */
-public class MonitoredWriter extends Writer {
-    Writer writer;
-    long totalWritten;
-
-    public MonitoredWriter(Writer writer) {
-        this.writer = writer;
-        totalWritten = 0;
-    }
-
-    public void write(char cbuf[], int off, int len) throws IOException {
-        totalWritten += (len - off);
-        writer.write(cbuf, off, len);
-    }
-
-    public void flush() throws IOException {
-        writer.flush();
-    }
-
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    public long getTotalWritten() {
-        return totalWritten;
-    }
-}


[21/27] aplying 0001-Refactor-usage-module-to-apache-stratos.patch

Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/DataAccessObject.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/DataAccessObject.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/DataAccessObject.java
new file mode 100644
index 0000000..b3120cf
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/DataAccessObject.java
@@ -0,0 +1,642 @@
+/*
+ *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.usage.util;
+
+
+import org.apache.stratos.usage.beans.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.constants.UsageConstants;
+
+import javax.sql.DataSource;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+public class DataAccessObject {
+
+    private static Log log = LogFactory.getLog(DataAccessObject.class);
+    private DataSource dataSource;
+
+
+    public DataAccessObject(){
+        if(Util.getDataSourceService()!=null){
+            try{
+                this.dataSource = (DataSource)Util.getDataSourceService().
+                        getDataSource(Util.BILLING_DATA_SOURCE_NAME).getDSObject();
+            }catch(Exception e){
+                log.error("Error occurred while obtaining " + Util.BILLING_DATA_SOURCE_NAME +
+                        " datasource from data source service.", e);
+                dataSource=null;
+            }
+        }else{
+            log.error("Cannot obtain data source " + Util.BILLING_DATA_SOURCE_NAME + ". Datasource service is null");
+            dataSource=null;
+        }
+    }
+
+
+    public List<BandwidthStatistics> getHourlyBandwidthStats(int tenantId, Calendar startDate,
+                                                             Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("PAYLOAD_TYPE");
+                BandwidthStatistics bws = new BandwidthStatistics(key);
+
+                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
+                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+
+                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
+                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+                }else {
+                    //Do nothing
+                }
+
+                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
+
+                bwsList.add(bws);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return bwsList;
+
+    }
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate End date - Stats of this date will be included
+     * @return A list of BandwidthStatistics objects
+     * @throws Exception
+     */
+    public List<BandwidthStatistics> getDailyBandwidthStats(int tenantId, Calendar startDate,
+                                                            Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("PAYLOAD_TYPE");
+                BandwidthStatistics bws = new BandwidthStatistics(key);
+
+                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
+                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+
+                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
+                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+                }else {
+                    //Do nothing
+                }
+
+                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
+
+                bwsList.add(bws);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving daily usage data from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return bwsList;
+
+    }
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param month Stats of this month will be retrieved
+     * @return A list of BandwidthStatistics objects
+     * @throws Exception
+     */
+    public List<BandwidthStatistics> getMonthlyBandwidthStats(int tenantId,
+                                                              Calendar month) throws Exception{
+        Connection connection = null;
+        List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("PAYLOAD_DATA");
+                BandwidthStatistics bws = new BandwidthStatistics(key);
+
+                if(UsageConstants.SERVICE_INCOMING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_INCOMING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_INCOMING_BW.equals(key)){
+                    bws.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+
+                }else if(UsageConstants.SERVICE_OUTGOING_BW.equals(key) ||
+                        UsageConstants.WEBAPP_OUTGOING_BW.equals(key) ||
+                        UsageConstants.REGISTRY_OUTGOING_BW.equals(key)){
+                    bws.setOutgoingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+                }else {
+                    //Do nothing
+                }
+
+                bws.setServerUrl(resultSet.getString("SERVER_NAME"));
+
+                bwsList.add(bws);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return bwsList;
+
+    }
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate End date - Stats of this date will be included
+     * @return A list of RequestStatistics objects
+     * @throws Exception
+     */
+    public List<RequestStatistics> getHourlyRequestStats(int tenantId, Calendar startDate,
+                                                         Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM SERVICE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("SERVER_NAME");
+                RequestStatistics reqStat = new RequestStatistics(key);
+                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
+                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
+                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
+
+                rsList.add(reqStat);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving hourly service request stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return rsList;
+
+    }
+
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate End date - Stats of this date will be included
+     * @return A list of RequestStatistics objects
+     * @throws Exception
+     */
+    public List<RequestStatistics> getDailyRequestStats(int tenantId, Calendar startDate,
+                                                        Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM SERVICE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("SERVER_NAME");
+                RequestStatistics reqStat = new RequestStatistics(key);
+                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
+                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
+                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
+
+                rsList.add(reqStat);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving daily service request stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return rsList;
+
+    }
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param month Month - Stats of this month will be retrieved
+     * @return A list of RequestStatistics objects
+     * @throws Exception
+     */
+    public List<RequestStatistics> getMonthlyRequestStats(int tenantId,
+                                                          Calendar month) throws Exception{
+        Connection connection = null;
+        List<RequestStatistics> rsList = new ArrayList<RequestStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM SERVICE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                String key = resultSet.getString("SERVER_NAME");
+                RequestStatistics reqStat = new RequestStatistics(key);
+                reqStat.setRequestCount(resultSet.getInt("REQUEST_COUNT"));
+                reqStat.setResponseCount(resultSet.getInt("RESPONSE_COUNT"));
+                reqStat.setFaultCount(resultSet.getInt("FAULT_COUNT"));
+
+                rsList.add(reqStat);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving monthly service request stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return rsList;
+
+    }
+
+    public TenantDataCapacity getTenantDataCapacity(int tenantId) throws Exception{
+        Connection connection = null;
+        TenantDataCapacity tenantDataCapacity = null;
+
+        try{
+            connection = dataSource.getConnection();
+            String id = ""  + tenantId + "Final";
+            String sql = "SELECT * FROM REGISTRY_USAGE_HOURLY_ANALYTICS WHERE ID = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setString(1, id);
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                long currentCapacity = resultSet.getLong("CURRENT_USAGE");
+                long historyCapacity = resultSet.getLong("HISTORY_USAGE");
+
+                tenantDataCapacity = new TenantDataCapacity(currentCapacity, historyCapacity);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving registry data usage from . ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return tenantDataCapacity;
+    }
+
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate End date - Stats of this date will be included
+     * @return A list of CartridgeStatistics objects
+     * @throws Exception
+     */
+    public List<CartridgeStatistics> getHourlyCartridgeStats(int tenantId, Calendar startDate,
+                                                         Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+
+            String sql = "SELECT * FROM CARTRIDGE_STATS_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setString(1, String.valueOf(tenantId));
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                CartridgeStatistics cs = new CartridgeStatistics();
+                cs.setInstanceId(resultSet.getString("IMAGE_ID"));
+                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
+                cs.setKey(resultSet.getString("CARTRIDGE_TYPE") + " - " + resultSet.getString("NODE_ID"));
+
+                csList.add(cs);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving hourly cartridge stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return csList;
+
+    }
+
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate End date - Stats of this date will be included
+     * @return A list of RequestStatistics objects
+     * @throws Exception
+     */
+    public List<CartridgeStatistics> getDailyCartridgeStats(int tenantId, Calendar startDate,
+                                                        Calendar endDate) throws Exception{
+        Connection connection = null;
+        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            //TODO: Implement the SQL logic
+            String sql = "SELECT * FROM CARTRIDGE_STATS_DAILY_ANALYTICS WHERE TENANT_ID = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setString(1, String.valueOf(tenantId));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                CartridgeStatistics cs = new CartridgeStatistics();
+                cs.setInstanceId(resultSet.getString("IMAGE_ID"));
+                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
+                cs.setKey(resultSet.getString("CARTRIDGE_TYPE") + " - " + resultSet.getString("NODE_ID"));
+
+                csList.add(cs);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving daily cartridge stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return csList;
+
+    }
+
+    /**
+     *
+     * @param tenantId Tenant ID
+     * @param month Month - Stats of this month will be retrieved
+     * @return A list of RequestStatistics objects
+     * @throws Exception
+     */
+    public List<CartridgeStatistics> getMonthlyCartridgeStats(int tenantId,
+                                                          Calendar month) throws Exception{
+        Connection connection = null;
+        List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>();
+
+        try{
+            connection = dataSource.getConnection();
+            //TODO: Implement SQL logic
+            String sql = "SELECT * FROM CARTRIDGE_STATS_MONTHLY_ANALYTICS WHERE TENANT_ID = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setString(1, String.valueOf(tenantId));
+            ResultSet resultSet = ps.executeQuery();
+
+            while(resultSet.next()){
+                CartridgeStatistics cs = new CartridgeStatistics();
+                cs.setInstanceId(resultSet.getString("NODE_ID"));
+                cs.setCartridgeHours(resultSet.getInt("DURATION_HOURS"));
+                cs.setKey(resultSet.getString("IMAGE_ID"));
+
+                csList.add(cs);
+            }
+        }catch(SQLException e){
+            log.error("Error occurred while retrieving monthly cartridge stats from the database. ", e);
+
+        }finally {
+            if(connection!=null){
+                connection.close();
+            }
+        }
+
+        return csList;
+
+    }
+
+    /**
+     * @param tenantId  Tenant Id of associated tenant
+     * @param startDate Start Date start time stamp of hour
+     * @param endDate   End date end time stamp of hour
+     * @return APIManagerUsageStats objects
+     * @throws Exception
+     */
+    public List<APIManagerUsageStats> getHourlyAPIManagerUsageStats(int tenantId, Calendar startDate,
+                                                                    Calendar endDate) throws Exception {
+        Connection connection = null;
+        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_HOURLY_ANALYTICS WHERE TENANT_ID = ? AND HOUR_FACT >= ? AND HOUR_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while (resultSet.next()) {
+                String key = resultSet.getString("PAYLOAD_TYPE");
+                APIManagerUsageStats stats = new APIManagerUsageStats(key);
+
+                if (UsageConstants.API_CALL_COUNT.equals(key)) {
+                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+
+                } else {
+                    //Do nothing
+                }
+
+                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
+                bwsList.add(stats);
+            }
+        } catch (SQLException e) {
+            log.error("Error occurred while retrieving hourly usage data from the database. ", e);
+
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return bwsList;
+
+    }
+
+    /**
+     * @param tenantId  Tenant ID
+     * @param startDate Start date - Stats of this date will be included
+     * @param endDate   End date - Stats of this date will be included
+     * @return A list of APIManagerUsageStats objects
+     * @throws Exception
+     */
+    public List<APIManagerUsageStats> getDailyAPIManagerUsageStats(int tenantId, Calendar startDate,
+                                                                   Calendar endDate) throws Exception {
+        Connection connection = null;
+        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_DAILY_ANALYTICS WHERE TENANT_ID = ? AND DAY_FACT >= ? AND DAY_FACT <= ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(startDate.getTimeInMillis()));
+            ps.setTimestamp(3, new Timestamp(endDate.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while (resultSet.next()) {
+                String key = resultSet.getString("PAYLOAD_TYPE");
+                APIManagerUsageStats stats = new APIManagerUsageStats(key);
+
+                if ("API-Call".equals(key)) {
+                    stats.setRequestCount(resultSet.getLong("PAYLOAD_VALUE"));
+                } else {
+                    //Do nothing
+                }
+
+                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
+                bwsList.add(stats);
+            }
+        } catch (SQLException e) {
+            log.error("Error occurred while retrieving daily usage data from the database. ", e);
+
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+        return bwsList;
+    }
+
+    /**
+     * @param tenantId Tenant ID
+     * @param month    Stats of this month will be retrieved
+     * @return A list of APIManagerUsageStats objects
+     * @throws Exception
+     */
+    public List<APIManagerUsageStats> getMonthlyAPIManagerUsageStats(int tenantId,
+                                                                     Calendar month) throws Exception {
+        Connection connection = null;
+        List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>();
+
+        try {
+            connection = dataSource.getConnection();
+            String sql = "SELECT * FROM USAGE_MONTHLY_ANALYTICS WHERE TENANT_ID = ? AND MONTH_FACT = ?";
+            PreparedStatement ps = connection.prepareStatement(sql);
+            ps.setInt(1, tenantId);
+            ps.setTimestamp(2, new Timestamp(month.getTimeInMillis()));
+            ResultSet resultSet = ps.executeQuery();
+
+            while (resultSet.next()) {
+                String key = resultSet.getString("PAYLOAD_DATA");
+                APIManagerUsageStats stats = new APIManagerUsageStats(key);
+
+                if (UsageConstants.API_CALL_COUNT.equals(key)) {
+                    stats.setIncomingBandwidth(resultSet.getLong("PAYLOAD_VALUE"));
+
+                } else {
+                    //Do nothing
+                }
+
+                stats.setServerUrl(resultSet.getString("SERVER_NAME"));
+                bwsList.add(stats);
+            }
+        } catch (SQLException e) {
+            log.error("Error occurred while retrieving monthly usage data from the database. ", e);
+
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+        }
+
+        return bwsList;
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/Util.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/Util.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/Util.java
new file mode 100644
index 0000000..6015a50
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/Util.java
@@ -0,0 +1,108 @@
+/*
+ *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.usage.util;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleContext;
+import org.wso2.carbon.ndatasource.core.DataSourceService;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.apache.stratos.usage.api.TenantUsageRetriever;
+
+import javax.sql.DataSource;
+
+/**
+ * Util methods for usage.
+ */
+public class Util {
+
+    private static final Log log = LogFactory.getLog(Util.class);
+
+    private static RegistryService registryService;
+    private static RealmService realmService;
+    private static TenantUsageRetriever tenantUsageRetriever;
+    private static ConfigurationContextService configurationContextService;
+    private static DataSourceService dataSourceService;
+    public static String BILLING_DATA_SOURCE_NAME="WSO2BillingDS";
+
+    public static synchronized void setRegistryService(RegistryService service) {
+        if (registryService == null) {
+            registryService = service;
+        }
+    }
+    
+    public static void setConfigurationContextService(
+            ConfigurationContextService configurationContextService) {
+        Util.configurationContextService = configurationContextService;
+    }
+    
+    public static ConfigurationContextService getConfigurationContextService(){
+        return configurationContextService;
+    }
+
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+    public static RegistryService getRegistryService() {
+        return registryService;
+    }
+
+    public static TenantUsageRetriever getTenantUsageRetriever() {
+        return tenantUsageRetriever;
+    }
+
+    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
+        return registryService.getUserRealm(tenantId);
+    }
+
+    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
+        return registryService.getGovernanceSystemRegistry();
+    }
+
+    public static void registerRetrieverServices(BundleContext bundleContext) throws Exception {
+        ConfigurationContextService confCtxSvc = Util.getConfigurationContextService();
+
+        // creating and registering tenant and user usage retrievers
+        tenantUsageRetriever = new TenantUsageRetriever(
+                registryService, confCtxSvc.getServerConfigContext());
+        bundleContext.registerService(
+                TenantUsageRetriever.class.getName(), tenantUsageRetriever, null);
+    }
+
+    public static DataSourceService getDataSourceService() {
+        return dataSourceService;
+    }
+
+    public static void setDataSourceService(DataSourceService dataSourceService) {
+        Util.dataSourceService = dataSourceService;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.usage/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..ae323a6
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/resources/META-INF/component.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+
+<component xmlns="http://products.wso2.org/carbon">
+    <ManagementPermissions>
+        <ManagementPermission>
+            <DisplayName>Monitor</DisplayName>
+            <ResourceId>/permission/admin/monitor</ResourceId>
+        </ManagementPermission>
+        <!--<ManagementPermission>
+            <DisplayName>User-Usage</DisplayName>
+            <ResourceId>/permission/admin/monitor/userUsage</ResourceId>
+        </ManagementPermission> -->
+        <ManagementPermission>
+            <DisplayName>Tenant-Usage</DisplayName>
+            <ResourceId>/permission/admin/monitor/tenantUsage</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Protected</DisplayName>
+            <ResourceId>/permission/protected</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Monitor</DisplayName>
+            <ResourceId>/permission/protected/monitor</ResourceId>
+        </ManagementPermission>
+        <ManagementPermission>
+            <DisplayName>Any-Tenant-Usage</DisplayName>
+            <ResourceId>/permission/protected/monitor/anytenantUsage</ResourceId>
+        </ManagementPermission>
+    </ManagementPermissions>
+</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.usage/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..bd16f6d
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/resources/META-INF/services.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  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.
+  -->
+<serviceGroup>
+
+    <service name="UsageService" scope="transportsession">
+        <transports>
+            <transport>https</transport>
+        </transports>
+        <parameter name="ServiceClass" locked="false">
+            org.apache.stratos.usage.services.UsageService
+        </parameter>
+
+        <operation name="retrieveCurrentTenantUsage">
+            <parameter name="AuthorizationAction" locked="true">/permission/admin/monitor/tenantUsage</parameter>
+        </operation>
+        <operation name="retrieveTenantUsages">
+            <parameter name="superTenantService" locked="true">true</parameter>
+            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
+        </operation>
+        <operation name="retrievePaginatedTenantUsages">
+            <parameter name="superTenantService" locked="true">true</parameter>
+            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
+        </operation>
+        <operation name="retrieveTenantUsage">
+            <parameter name="superTenantService" locked="true">true</parameter>
+            <parameter name="AuthorizationAction" locked="true">/permission/protected/monitor/anytenantUsage</parameter>
+        </operation>
+    </service>
+    <parameter name="adminService" locked="true">true</parameter>
+
+    <parameter name="hiddenService" locked="true">true</parameter>
+</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/resources/reports/all_tenant_usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/resources/reports/all_tenant_usage_report.jrxml b/components/org.apache.stratos.usage/src/main/resources/reports/all_tenant_usage_report.jrxml
new file mode 100644
index 0000000..b9483aa
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/resources/reports/all_tenant_usage_report.jrxml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="all_tenant_usage_report"  pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
+	<property name="ireport.zoom" value="1.0"/>
+	<property name="ireport.x" value="0"/>
+	<property name="ireport.y" value="0"/>
+	<field name="yearMonth" class="java.lang.String"/>
+	<field name="tenantName" class="java.lang.String"/>
+	<field name="numberOfUsers" class="java.lang.String"/>
+	<field name="currentDataStorage" class="java.lang.String"/>
+	<field name="regBandwidth" class="java.lang.String"/>
+	<field name="svcBandwidth" class="java.lang.String"/>
+	<field name="svcTotalRequest" class="java.lang.String"/>
+	<background>
+		<band splitType="Stretch"/>
+	</background>
+	<title>
+		<band height="79" splitType="Stretch"/>
+	</title>
+	<pageHeader>
+		<band height="35" splitType="Stretch">
+			<staticText>
+				<reportElement mode="Transparent" x="0" y="0" width="279" height="35" backcolor="#9B9999"/>
+				<textElement>
+					<font size="13" isBold="true"/>
+				</textElement>
+				<text><![CDATA[Tenant Usage Report for the month]]></text>
+			</staticText>
+			<textField>
+				<reportElement mode="Transparent" x="279" y="0" width="276" height="35" backcolor="#9B9999"/>
+				<textElement>
+					<font size="13" isBold="true"/>
+				</textElement>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{yearMonth}]]></textFieldExpression>
+			</textField>
+		</band>
+	</pageHeader>
+	<columnHeader>
+		<band height="61" splitType="Stretch">
+			<staticText>
+				<reportElement mode="Opaque" x="0" y="29" width="100" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Domain]]></text>
+			</staticText>
+			<staticText>
+				<reportElement mode="Opaque" x="100" y="29" width="100" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Number of users]]></text>
+			</staticText>
+			<staticText>
+				<reportElement mode="Opaque" x="200" y="29" width="100" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Storage Usage]]></text>
+			</staticText>
+			<staticText>
+				<reportElement mode="Opaque" x="300" y="29" width="100" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Total Registry Bandwidth]]></text>
+			</staticText>
+			<staticText>
+				<reportElement mode="Opaque" x="400" y="29" width="73" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Total Service Bandwidht]]></text>
+			</staticText>
+			<staticText>
+				<reportElement mode="Opaque" x="473" y="29" width="82" height="32" backcolor="#C0C0C0"/>
+				<textElement>
+					<font isBold="true"/>
+				</textElement>
+				<text><![CDATA[Service Requests]]></text>
+			</staticText>
+		</band>
+	</columnHeader>
+	<detail>
+		<band height="103" splitType="Stretch">
+			<textField>
+				<reportElement x="0" y="21" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantName}]]></textFieldExpression>
+			</textField>
+			<textField>
+				<reportElement x="100" y="21" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{numberOfUsers}]]></textFieldExpression>
+			</textField>
+			<textField>
+				<reportElement x="200" y="21" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{currentDataStorage}]]></textFieldExpression>
+			</textField>
+			<textField>
+				<reportElement x="300" y="21" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{regBandwidth}]]></textFieldExpression>
+			</textField>
+			<textField>
+				<reportElement x="400" y="21" width="73" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcBandwidth}]]></textFieldExpression>
+			</textField>
+			<textField>
+				<reportElement x="473" y="21" width="82" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{svcTotalRequest}]]></textFieldExpression>
+			</textField>
+		</band>
+	</detail>
+	<columnFooter>
+		<band height="45" splitType="Stretch"/>
+	</columnFooter>
+	<pageFooter>
+		<band height="54" splitType="Stretch">
+			<textField>
+				<reportElement x="455" y="34" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
+			</textField>
+			<textField pattern="MMMMM dd, yyyy">
+				<reportElement x="0" y="34" width="100" height="20"/>
+				<textElement/>
+				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
+			</textField>
+		</band>
+	</pageFooter>
+	<summary>
+		<band height="42" splitType="Stretch"/>
+	</summary>
+</jasperReport>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/org.apache.stratos.usage/src/main/resources/reports/usage_report.jrxml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.usage/src/main/resources/reports/usage_report.jrxml b/components/org.apache.stratos.usage/src/main/resources/reports/usage_report.jrxml
new file mode 100644
index 0000000..5b43c2f
--- /dev/null
+++ b/components/org.apache.stratos.usage/src/main/resources/reports/usage_report.jrxml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
+	<property name="ireport.zoom" value="1.0"/>
+	<property name="ireport.x" value="0"/>
+	<property name="ireport.y" value="0"/>
+	<field name="task" class="java.lang.String"/>
+	<field name="usagecol1" class="java.lang.String"/>
+	<field name="usagecol2" class="java.lang.String"/>
+	<field name="usagecol3" class="java.lang.String"/>
+	<field name="usagecol4" class="java.lang.String"/>
+	<field name="usagecol1Value" class="java.lang.String"/>
+	<field name="usagecol2Value" class="java.lang.String"/>
+	<field name="usagecol3Value" class="java.lang.String"/>
+	<field name="usagecol4Value" class="java.lang.String"/>
+	<field name="tenantDomain" class="java.lang.String"/>
+	<group name="usagedatagroup">
+		<groupExpression><![CDATA[$F{task}]]></groupExpression>
+		<groupHeader>
+			<band height="72" splitType="Stretch">
+				<rectangle>
+					<reportElement x="0" y="21" width="555" height="16" backcolor="#D0F5E8"/>
+				</rectangle>
+				<textField>
+					<reportElement x="0" y="22" width="555" height="16"/>
+					<textElement>
+						<font size="9"/>
+					</textElement>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{task}]]></textFieldExpression>
+				</textField>
+				<rectangle>
+					<reportElement x="0" y="38" width="555" height="16" backcolor="#E6F1B6"/>
+				</rectangle>
+				<textField isBlankWhenNull="true">
+					<reportElement x="0" y="39" width="132" height="17"/>
+					<textElement verticalAlignment="Middle">
+						<font size="9"/>
+					</textElement>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="145" y="39" width="132" height="15"/>
+					<textElement verticalAlignment="Middle">
+						<font size="9"/>
+					</textElement>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="288" y="39" width="132" height="16"/>
+					<textElement verticalAlignment="Middle">
+						<font size="9"/>
+					</textElement>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="423" y="38" width="132" height="16"/>
+					<textElement verticalAlignment="Middle"/>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4}]]></textFieldExpression>
+				</textField>
+				<rectangle>
+					<reportElement x="0" y="55" width="555" height="15" backcolor="#DBE596"/>
+				</rectangle>
+				<textField isBlankWhenNull="true">
+					<reportElement x="0" y="57" width="132" height="14"/>
+					<textElement verticalAlignment="Middle"/>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol1Value}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="145" y="55" width="132" height="16"/>
+					<textElement verticalAlignment="Middle">
+						<font size="9"/>
+					</textElement>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol2Value}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="287" y="55" width="132" height="14"/>
+					<textElement verticalAlignment="Middle"/>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol3Value}]]></textFieldExpression>
+				</textField>
+				<textField isBlankWhenNull="true">
+					<reportElement x="423" y="56" width="132" height="15"/>
+					<textElement verticalAlignment="Middle"/>
+					<textFieldExpression class="java.lang.String"><![CDATA[$F{usagecol4Value}]]></textFieldExpression>
+				</textField>
+			</band>
+		</groupHeader>
+		<groupFooter>
+			<band splitType="Stretch"/>
+		</groupFooter>
+	</group>
+	<background>
+		<band splitType="Stretch"/>
+	</background>
+	<title>
+		<band height="17" splitType="Stretch"/>
+	</title>
+	<pageHeader>
+		<band height="19" splitType="Stretch">
+			<textField pattern="dd/MM/yyyy h.mm a">
+				<reportElement x="403" y="0" width="132" height="16"/>
+				<textElement/>
+				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
+			</textField>
+			<staticText>
+				<reportElement x="0" y="1" width="169" height="15"/>
+				<textElement textAlignment="Right">
+					<font size="12" isUnderline="true"/>
+				</textElement>
+				<text><![CDATA[Usage Report For : ]]></text>
+			</staticText>
+			<textField>
+				<reportElement x="169" y="0" width="234" height="16"/>
+				<textElement verticalAlignment="Middle">
+					<font size="12"/>
+				</textElement>
+				<textFieldExpression class="java.lang.String"><![CDATA[$F{tenantDomain}]]></textFieldExpression>
+			</textField>
+		</band>
+	</pageHeader>
+	<columnHeader>
+		<band splitType="Stretch"/>
+	</columnHeader>
+	<detail>
+		<band height="5" splitType="Stretch"/>
+	</detail>
+	<columnFooter>
+		<band splitType="Stretch"/>
+	</columnFooter>
+	<pageFooter>
+		<band height="8" splitType="Stretch"/>
+	</pageFooter>
+	<summary>
+		<band height="7" splitType="Stretch"/>
+	</summary>
+</jasperReport>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/pom.xml b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/pom.xml
deleted file mode 100644
index 599b25c..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/pom.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<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/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>usage-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <version>2.1.0</version>
-    <artifactId>org.wso2.carbon.usage.agent</artifactId>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Usage Agent</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <Private-Package>
-                        	!org.wso2.carbon.usage.agent.api.*,
-                            org.wso2.carbon.usage.agent.*,
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.usage.agent.api.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.stratos.common.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.axis2.wso2</groupId>
-            <artifactId>axis2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.utils</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.statistics</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.registry.common</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.event.core</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-	    <groupId>org.wso2.carbon</groupId>
-	    <artifactId>org.wso2.carbon.email.verification</artifactId>
-            <version>${carbon.platform.version}</version>
-	</dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.server</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.tomcat.ext</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-	<dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.databridge.agent.thrift</artifactId>
-            <version>${carbon.platform.version}</version>
-        </dependency>
-
-    </dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
deleted file mode 100644
index f8b0b42..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/api/CustomMeteringAgent.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.api;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.registry.core.*;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.stratos.common.constants.UsageConstants;
-import org.wso2.carbon.usage.agent.exception.UsageException;
-
-/**
- *   CustomMeteringAgent is used to get recorded duration, to check whether usage entry exists,
- *   to persist and retrieve usage.
- */
-
-public class CustomMeteringAgent {
-    private static final Log log = LogFactory.getLog(CustomMeteringAgent.class);
-    private Registry registry;
-
-    /**
-     * Constructor for the custom metering agent
-     *
-     * @param registry governance registry of super tenant
-     */
-    public CustomMeteringAgent(Registry registry) {
-        this.registry = registry;
-    }
-
-    /**
-     * Get recorded durations
-     * @param measurement  the measurement to get the duration
-     * @return the durations array
-     * @throws UsageException
-     */
-    public String[] getRecordedDurations(String measurement) throws UsageException {
-        String[] durations;
-        String measurementCollectionPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement;
-        try {
-            Resource resource = registry.get(measurementCollectionPath);
-            if (!(resource instanceof Collection)) {
-                String msg =
-                        "The records collection is not a registry collection. path: " +
-                                measurementCollectionPath + ".";
-                log.error(msg);
-                throw new UsageException(msg);
-            }
-            durations = ((Collection) resource).getChildren();
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return durations;
-    }
-
-    /**
-     * Check whether the usage entry exist or not
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return true if usage entry exists
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public boolean isUsageEntryExists(String duration, String measurement)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            if (registry.resourceExists(measurementPath)) {
-                return true;
-            }
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in checking the usage entry exists. measurement: " + measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return false;
-    }
-
-    /**
-     * Persist usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public void persistUsage(String duration, String measurement, String value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.newResource();
-            ((ResourceImpl) measurementResource).setVersionableChange(false);
-            // save the measurement value in resource
-            measurementResource.setContent(value);
-            registry.put(measurementPath, measurementResource);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in persisting the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-    }
-
-    /**
-     * Retrieve usage of a user
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @return measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public String retrieveUsage(String duration, String measurement)
-            throws UsageException {
-        String usageValue;
-        Resource measurementResource;
-        String measurementPath =
-                UsageConstants.CUSTOM_METERING_PATH + RegistryConstants.PATH_SEPARATOR +
-                        measurement +
-                        RegistryConstants.PATH_SEPARATOR + duration;
-        try {
-            measurementResource = registry.get(measurementPath);
-            // save the measurement value in resource
-            byte[] contentBytes = (byte[]) measurementResource.getContent();
-            usageValue = new String(contentBytes);
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in retrieving the usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        }
-        return usageValue;
-    }
-
-    /**
-     * Add a long value to the usage, if there were no previous entry, this will
-     * start with value 0
-     *
-     * @param duration    the duration (e.g. year month), null for any duration
-     * @param measurement measurement key
-     * @param value       measurement value
-     * @return the added measurement value
-     * @throws org.wso2.carbon.usage.agent.exception.UsageException
-     */
-    public long addUsage(String duration, String measurement, long value)
-            throws UsageException {
-        if (duration == null) {
-            duration = UsageConstants.ANY_DURATION;
-        }
-        // adding the bandwidth have to be in a transaction
-        boolean transactionSuccess = false;
-        try {
-            registry.beginTransaction();
-            if (isUsageEntryExists(duration, measurement)) {
-                String usageStr = retrieveUsage(duration, measurement);
-                try {
-                    long storedValue = Long.parseLong(usageStr);
-                    value += storedValue;
-                } catch (NumberFormatException e) {
-                    String msg = "Error in parsing the integer string: " + usageStr;
-                    log.error(msg, e);
-                    throw new RegistryException(msg, e);
-                }
-            }
-            String valueStr = Long.toString(value);
-            persistUsage(duration, measurement, valueStr);
-            transactionSuccess = true;
-        } catch (RegistryException e) {
-            String msg =
-                    "Error in invoking the add usage. measurement: " +
-                            measurement + ".";
-            log.error(msg, e);
-            throw new UsageException(msg, e);
-        } finally {
-            try {
-                if (transactionSuccess) {
-                    registry.commitTransaction();
-                } else {
-                    registry.rollbackTransaction();
-                }
-            } catch (RegistryException e) {
-                String msg = "Error in commiting/rollbacking the transaction";
-                log.error(msg, e);
-            }
-        }
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
deleted file mode 100644
index a792746..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/beans/BandwidthUsage.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.usage.agent.beans;
-
-/**
- * the bean class for BandwidthUsage with attributes
- * int tenant id,
- * String measurement
- * long value   *
- */
-
-public class BandwidthUsage {
-    private int tenantId;
-    private String measurement;
-    private long value;
-
-
-    public String getMeasurement() {
-        return measurement;
-    }
-
-    public BandwidthUsage(int tenantId, String measurement, long value) {
-        this.tenantId = tenantId;
-        this.measurement = measurement;
-        this.value = value;
-    }
-
-    public long getValue() {
-        return value;
-    }
-
-    public void setValue(long value) {
-        this.value = value;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getTenantId() {
-        return tenantId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
deleted file mode 100644
index 7528171..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/config/UsageAgentConfiguration.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.config;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-public class UsageAgentConfiguration {
-    private static final Log log = LogFactory.getLog(UsageAgentConfiguration.class);
-
-    private static final Integer DEFAULT_NUMBER_OF_RECORDS_PER_RUN = 100;
-    private static final Integer DEFAULT_EXECUTION_INTERVAL_IN_MILLISECONDS = 100;
-    private static final Integer DEFAULT_STARTUP_DELAY_IN_MILLISECONDS = 60000;
-
-    private int usageTasksNumberOfRecordsPerExecution = -1;
-
-    private int usageTasksExecutionIntervalInMilliSeconds = -1;
-
-    private int usageTasksStartupDelayInMilliSeconds = -1;
-
-    public UsageAgentConfiguration(File configFile) {
-        if (configFile.exists()) {
-            try {
-                OMElement usageAndThrottlingAgentConfiguration =
-                        new StAXOMBuilder(new FileInputStream(configFile)).getDocumentElement();
-                if (usageAndThrottlingAgentConfiguration != null) {
-                    OMElement usageAgent = usageAndThrottlingAgentConfiguration.getFirstChildWithName(
-                            new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config", "UsageAgent"));
-                    if (usageAgent != null) {
-                        OMElement usageDataPersistenceTaskConfig = usageAgent.getFirstChildWithName(
-                                new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                        "UsageDataPersistenceTask"));
-                        if (usageDataPersistenceTaskConfig != null) {
-                            OMElement numberOfRecordsPerExecutionEle = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "NumberOfRecordsPerExecution"));
-                            if (numberOfRecordsPerExecutionEle != null && numberOfRecordsPerExecutionEle.getText() != null &&
-                                    numberOfRecordsPerExecutionEle.getText().length() > 0) {
-                                try {
-                                    usageTasksNumberOfRecordsPerExecution = Integer.parseInt(numberOfRecordsPerExecutionEle.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task number of records value.", ne);
-                                }
-                            }
-
-                            OMElement executionIntervalInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "ExecutionIntervalInMilliSeconds"));
-                            if (executionIntervalInMilliSeconds != null && executionIntervalInMilliSeconds.getText() != null &&
-                                    executionIntervalInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksExecutionIntervalInMilliSeconds =
-                                            Integer.parseInt(executionIntervalInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task  execution interval value.", ne);
-                                }
-                            }
-
-                            OMElement startupDelayInMilliSeconds = usageDataPersistenceTaskConfig.getFirstChildWithName(
-                                    new QName("http://wso2.com/carbon/multitenancy/usage-throttling-agent/config",
-                                            "StartupDelayInMilliSeconds"));
-                            if (startupDelayInMilliSeconds != null && startupDelayInMilliSeconds.getText() != null &&
-                                    startupDelayInMilliSeconds.getText().length() > 0) {
-                                try {
-                                    usageTasksStartupDelayInMilliSeconds =
-                                            Integer.parseInt(startupDelayInMilliSeconds.getText());
-                                } catch (NumberFormatException ne) {
-                                    log.error("Error while parsing usage persistence task startup delay value.", ne);
-                                }
-                            }
-                        }
-                    }
-                }
-
-            } catch (FileNotFoundException e) {
-                log.error("Cannot find " + configFile.getAbsolutePath(), e);
-            } catch (XMLStreamException e) {
-                log.error("Error reading XML stream of file " + configFile.getAbsolutePath(), e);
-            }
-        }
-    }
-
-    public int getUsageTasksNumberOfRecordsPerExecution() {
-        return usageTasksNumberOfRecordsPerExecution;
-    }
-
-    public int getUsageTasksExecutionIntervalInMilliSeconds() {
-        return usageTasksExecutionIntervalInMilliSeconds;
-    }
-
-    public int getUsageTasksStartupDelayInMilliSeconds() {
-        return usageTasksStartupDelayInMilliSeconds;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
deleted file mode 100644
index 023d16f..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/exception/UsageException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.usage.agent.exception;
-
-/**
- * UsageException class to handle usage exception
- */
-public class UsageException extends Exception {
-    public UsageException(String msg, Exception e) {
-        super(msg, e);
-    }
-    public UsageException(String msg) {
-        super(msg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/df3475cc/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java b/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
deleted file mode 100644
index 62ae4cf..0000000
--- a/components/stratos/usage/org.wso2.carbon.usage.agent/2.1.0/src/main/java/org/wso2/carbon/usage/agent/internal/UsageAgentServiceComponent.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- *  Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- *  WSO2 Inc. 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.wso2.carbon.usage.agent.internal;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.CarbonConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.base.api.ServerConfigurationService;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.event.core.EventBroker;
-import org.wso2.carbon.statistics.services.SystemStatisticsUtil;
-import org.wso2.carbon.usage.agent.listeners.UsageStatsAxis2ConfigurationContextObserver;
-import org.wso2.carbon.usage.agent.util.PublisherUtils;
-import org.wso2.carbon.usage.agent.util.Util;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
-import org.wso2.carbon.utils.ConfigurationContextService;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * this class is used to activate and deactivate the UsageAgentServiceComponent, set and unset
- * Serverconfigurarion, set and unset EventBrokerService.
- *
- * @scr.component name="org.wso2.carbon.usage.agent" immediate="true"
- * @scr.reference name="user.realmservice.default"
- * interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1"
- * policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
- * @scr.reference name="config.context.service"
- * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="0..1"
- * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
- * @scr.reference name="server.configuration"
- * interface="org.wso2.carbon.base.api.ServerConfigurationService" cardinality="1..1"
- * policy="dynamic" bind="setServerConfiguration" unbind="unsetServerConfiguration"
- * @scr.reference name="eventbroker.service"
- * interface="org.wso2.carbon.event.core.EventBroker" cardinality="1..1"
- * policy="dynamic" bind="setEventBrokerService" unbind="unsetEventBrokerService"
- * @scr.reference name="org.wso2.carbon.statistics.services"
- * interface="org.wso2.carbon.statistics.services.SystemStatisticsUtil"
- * cardinality="0..1" policy="dynamic" bind="setSystemStatisticsUtil" unbind="unsetSystemStatisticsUtil"
- */
-public class UsageAgentServiceComponent {
-    private static Log log = LogFactory.getLog(UsageAgentServiceComponent.class);
-
-    /**
-     * method to activate UsageAgentServiceComponent
-     *
-     * @param context componentContext
-     */
-    protected void activate(ComponentContext context) {
-        try {
-            PrivilegedCarbonContext.startTenantFlow();
-            PrivilegedCarbonContext.getCurrentContext().setTenantId(
-                    MultitenantConstants.SUPER_TENANT_ID);
-            PrivilegedCarbonContext.getCurrentContext().getTenantDomain(true);
-            PrivilegedCarbonContext.getCurrentContext().setUsername(
-                    CarbonConstants.REGISTRY_SYSTEM_USERNAME);
-            PrivilegedCarbonContext.getCurrentContext().setUserRealm(
-                    Util.getRealmService().getBootstrapRealm());
-            
-            // initialize listeners
-            // currently we have RegistryUsagePersistingListener only
-            Util.initializeAllListeners();
-
-            //initialize persistenceManager for persisting BandwidthUsage
-            Util.initializePersistenceManager();
-
-            // create statistic event subscription
-            Util.createStaticEventSubscription();
-
-            if("true".equals(ServerConfiguration.getInstance().getFirstProperty("EnableMetering"))){
-                //PublisherUtils.defineUsageEventStream();
-
-                UsageStatsAxis2ConfigurationContextObserver statObserver = new UsageStatsAxis2ConfigurationContextObserver();
-                context.getBundleContext().registerService(Axis2ConfigurationContextObserver.class.getName(), statObserver, null);
-                log.info("Observer to register the module for request statistics publishing was registered");
-            }
-
-            // register the request data persistor osgi service so that we can
-            // store service request bandwidths
-            // TODO: Remove this and ServiceDataPersistor after fixing ESB metering
-//            context.getBundleContext().registerService(
-//                    RequestDataPersister.class.getName(), new ServiceDataPersistor(), null);
-
-            log.debug("******* Multitenancy Usage Agent bundle is activated ******* ");
-        } catch (Throwable e) {
-            log.error("******* Failed to activate Multitenancy Usage Agent bundle ****", e);
-        } finally {
-            PrivilegedCarbonContext.endTenantFlow();
-        }
-    }
-
-    /**
-     * method to deactivate bundle
-     *
-     * @param context ComponentContext
-     */
-    protected void deactivate(ComponentContext context) {
-        log.debug("******* Multitenancy Metering Usage Agent bundle is deactivated ******* ");
-    }
-
-    /**
-     * method to set RealmService
-     *
-     * @param realmService RealmService
-     */
-    protected void setRealmService(RealmService realmService) {
-        Util.setRealmService(realmService);
-    }
-
-    /**
-     * method to unsetRealmService
-     *
-     * @param realmService RealmService
-     */
-
-    protected void unsetRealmService(RealmService realmService) {
-        Util.setRealmService(null);
-    }
-
-    /**
-     * method to set ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void setConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(contextService);
-        PublisherUtils.setConfigurationContextService(contextService);
-    }
-
-    /**
-     * method to unset ConfigurationContextService
-     *
-     * @param contextService ConfigurationContextService
-     */
-    protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
-        Util.setConfigurationContextService(null);
-    }
-
-    /**
-     * method to set server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void setServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(serverConfiguration);
-    }
-
-    /**
-     * method to unset server configurations
-     *
-     * @param serverConfiguration ServerConfiguration
-     */
-    protected void unsetServerConfiguration(ServerConfigurationService serverConfiguration) {
-        Util.setServerConfiguration(null);
-    }
-
-    /**
-     * method to set EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-
-    protected void setEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(registryEventBrokerService);
-    }
-
-    /**
-     * method to unset EventBrokerService
-     *
-     * @param registryEventBrokerService EventBroker
-     */
-    protected void unsetEventBrokerService(EventBroker registryEventBrokerService) {
-        Util.setEventBrokerService(null);
-    }
-
-    public static void setSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(systemStatisticsUtil);
-    }
-
-    public static void unsetSystemStatisticsUtil(SystemStatisticsUtil systemStatisticsUtil){
-        Util.setSystemStatisticsUtil(null);
-    }
-
-}