Repository: stratos Updated Branches: refs/heads/master 07c19f667 -> 50e1bf056
http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/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 deleted file mode 100644 index 2c3b133..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/internal/UsageServiceComponent.java +++ /dev/null @@ -1,101 +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.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/stratos/blob/ee5e9639/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 deleted file mode 100644 index c7714bb..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/services/UsageService.java +++ /dev/null @@ -1,204 +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.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; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/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 deleted file mode 100644 index b3120cf..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/DataAccessObject.java +++ /dev/null @@ -1,642 +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.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/stratos/blob/ee5e9639/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 deleted file mode 100644 index 6015a50..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/util/Util.java +++ /dev/null @@ -1,108 +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.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/stratos/blob/ee5e9639/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 deleted file mode 100644 index ae323a6..0000000 --- a/components/org.apache.stratos.usage/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,48 +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>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/stratos/blob/ee5e9639/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 deleted file mode 100644 index bd16f6d..0000000 --- a/components/org.apache.stratos.usage/src/main/resources/META-INF/services.xml +++ /dev/null @@ -1,49 +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="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/stratos/blob/ee5e9639/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 deleted file mode 100644 index 215abe4..0000000 --- a/components/org.apache.stratos.usage/src/main/resources/reports/all_tenant_usage_report.jrxml +++ /dev/null @@ -1,157 +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. - --> - -<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/stratos/blob/ee5e9639/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 deleted file mode 100644 index 7b13904..0000000 --- a/components/org.apache.stratos.usage/src/main/resources/reports/usage_report.jrxml +++ /dev/null @@ -1,155 +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. - --> - -<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> -
