http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/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
deleted file mode 100644
index 8174c07..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/BandwidthUsageDataRetrievalTask.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index f56d9b9..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/RegistryUsagePersister.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index c7e7fb7..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/ServiceDataPersistor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 5c27e20..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceManager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 59b5a7e..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/persist/UsageDataPersistenceTask.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index dcb6c12..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/services/CustomMeteringService.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index e61d9b9..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredReader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 307a2e4..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/MonitoredWriter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 607b30b..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/PublisherUtils.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/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
deleted file mode 100644
index 94cddc5..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/UsageAgentConstants.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 0397869..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/java/org/apache/stratos/usage/agent/util/Util.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 0654318..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 1b09002..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one
-  ~  or more contributor license agreements.  See the NOTICE file
-  ~  distributed with this work for additional information
-  ~  regarding copyright ownership.  The ASF licenses this file
-  ~  to you under the Apache License, Version 2.0 (the
-  ~  "License"); you may not use this file except in compliance
-  ~  with the License.  You may obtain a copy of the License at
-
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing,
-  ~  software distributed under the License is distributed on an
-  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~  KIND, either express or implied.  See the License for the
-  ~  specific language governing permissions and limitations
-  ~  under the License.
-  -->
-<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/stratos/blob/ee5e9639/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
deleted file mode 100644
index a0c68b1..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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/stratos/blob/ee5e9639/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
deleted file mode 100644
index ac3084a..0000000
--- 
a/components/org.apache.stratos.usage.agent/src/main/resources/META-INF/usage-throttling-agent-config.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one
-  ~  or more contributor license agreements.  See the NOTICE file
-  ~  distributed with this work for additional information
-  ~  regarding copyright ownership.  The ASF licenses this file
-  ~  to you under the Apache License, Version 2.0 (the
-  ~  "License"); you may not use this file except in compliance
-  ~  with the License.  You may obtain a copy of the License at
-
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing,
-  ~  software distributed under the License is distributed on an
-  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~  KIND, either express or implied.  See the License for the
-  ~  specific language governing permissions and limitations
-  ~  under the License.
-  -->
-<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/stratos/blob/ee5e9639/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
deleted file mode 100644
index e634728..0000000
--- a/components/org.apache.stratos.usage.summary.helper/pom.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-<!--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#  http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-  -->
-<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>4.0.0-SNAPSHOT</version>
-</parent>
-
-       <modelVersion>4.0.0</modelVersion>
-       <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.2.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.apache.hadoop</groupId>
-                       <artifactId>hadoop-core</artifactId>
-                       <version>0.20.2</version>
-               </dependency>
-       </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/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
deleted file mode 100644
index 370faed..0000000
--- 
a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyCartridgeStatsSummarizerHelper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index c688713..0000000
--- 
a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailyServiceStatsSummarizerHelper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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/stratos/blob/ee5e9639/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
deleted file mode 100644
index 2043337..0000000
--- 
a/components/org.apache.stratos.usage.summary.helper/src/main/java/org/apache/stratos/usage/summary/helper/DailySummarizerHelper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-
-package org.apache.stratos.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);
-        }
-    }
-}

Reply via email to