http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js deleted file mode 100644 index 894c7ad..0000000 --- a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/js/usage-report.js +++ /dev/null @@ -1,69 +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. - * -*/ - -function createXmlHttpRequest() { - var request; - - // Lets try using ActiveX to instantiate the XMLHttpRequest - // object - try { - request = new ActiveXObject("Microsoft.XMLHTTP"); - } catch(ex1) { - try { - request = new ActiveXObject("Msxml2.XMLHTTP"); - } catch(ex2) { - request = null; - } - } - - // If the previous didn't work, lets check if the browser natively support XMLHttpRequest - if (!request && typeof XMLHttpRequest != "undefined") { - //The browser does, so lets instantiate the object - request = new XMLHttpRequest(); - } - function removeCarriageReturns(string) { - return string.replace(/\n/g, ""); - } - - return request; -} -function getUsageReportData() { - - var xmlHttpReq = createXmlHttpRequest(); - - // Make sure the XMLHttpRequest object was instantiated - if (xmlHttpReq) { - // This is a synchronous POST, hence UI blocking. - xmlHttpReq.open("GET", "usage_report.jsp", false); - xmlHttpReq.send(null); - - if (xmlHttpReq.status == 200) { - return removeCarriageReturns(xmlHttpReq.responseText); - } - - return false; - } - - return false; -} -function removeCarriageReturns(string) { - return string.replace(/\n/g, ""); -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp deleted file mode 100644 index 6e763be..0000000 --- a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/tenant_usage.jsp +++ /dev/null @@ -1,475 +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. - --%> -<%@ page import="org.apache.stratos.usage.stub.beans.xsd.BandwidthStatistics" %> -<%@ page import="org.apache.stratos.usage.stub.beans.xsd.RequestStatistics" %> -<%@ page import="org.apache.stratos.usage.ui.report.UsageReport" %> -<%@ page import="org.apache.stratos.usage.stub.beans.xsd.TenantUsage" %> -<%@ page import="java.util.List" %> -<%@ page import="org.apache.stratos.usage.ui.utils.UsageUtil" %> -<%@ page import="org.apache.stratos.usage.stub.beans.xsd.CartridgeStatistics" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> - -<carbon:jsi18n - resourceBundle="org.apache.stratos.usage.ui.i18n.JSResources" - request="<%=request%>"/> - - -<fmt:bundle basename="org.apache.stratos.usage.ui.i18n.Resources"> -<carbon:breadcrumb - label="tenant.menu" - resourceBundle="org.apache.stratos.usage.ui.i18n.Resources" - topPage="true" - request="<%=request%>"/> -<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/> -<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script> -<script type="text/javascript" src="../registry_common/js/registry_common.js"></script> -<script type="text/javascript" src="../ajax/js/prototype.js"></script> -<script type="text/javascript" src="js/register_config.js"></script> -<script type="text/javascript" src="js/usage-report.js"></script> -<% - - TenantUsage usage = UsageUtil.retrieveCurrentTenantUsage(request, config, session); - int numberOfUsers = usage.getNumberOfUsers(); - String yearMonth = request.getParameter("year-month"); - session.setAttribute("year-month", yearMonth); - - - if (yearMonth == null) { - // get the current year month - yearMonth = UsageUtil.getCurrentYearMonth(); - } - String username = (String) request.getSession().getAttribute("logged-user"); - String tenantName = usage.getDomain(); - int tenantId = usage.getTenantId(); - String currentYearMonth = UsageUtil.getCurrentYearMonth(); -%> - -<% - - UsageReport usageReport = new UsageReport(config, session, request); - List<String> reportDataArray = usageReport.getUsageReportData(); - request.getSession().setAttribute("usage_data", reportDataArray); -%> - -<div id="middle"> - -<h2><fmt:message key="tenant.usage.report"/> for the Month - <%=yearMonth%> (Tenant: <%=tenantName%> - )</h2> - -<%--<div id="report_ui"> - <carbon:report - component="org.wso2.carbon.usage" - template="usage_report" - pdfReport="true" - htmlReport="true" - excelReport="true" - reportDataSession="usage_data" - /> -</div>--%> -<div id="workArea"> - -<form id="usageForm" action="tenant_usage.jsp" method="post"> - -<table class="styledLeft"> -<thead> -<tr> - <th> - <fmt:message key="report.duration"/> - </th> -</tr> -</thead> -<tbody> -<tr> -<td class="nopadding"> -<table class="normal-nopadding" cellspacing="0"> -<tbody> -<tr> - <td><fmt:message key="year.month"/></td> - <td colspan="3"> - <select onchange="this.form.submit()" name="year-month" id="year-month" style="width:200px"> - <% - for (String ym : UsageUtil.getYearMonths()) { - String selectedStr = ""; - if (ym.equals(yearMonth)) { - selectedStr = "selected=\"true\" "; - } - %> - <option <%=selectedStr%> value="<%=ym%>"><%=ym%> - </option> - <% - } - %> - </select> - </td> -</tr> -<% - if (currentYearMonth.equals(yearMonth)) { -%> -<tr> - <td colspan="4" class="middle-header"><fmt:message key="users"/></td> -</tr> -<tr> - <td><fmt:message key="number.of.users"/></td> - <td colspan="3"> - <input readonly="1" type="text" name="userCount" id="userCount" style="width:200px" - value="<%=numberOfUsers%>"/> - </td> -</tr> - -<tr> - <td colspan="4" class="middle-header"><fmt:message key="storage.usage"/></td> -</tr> - -<tr> - <td><fmt:message key="data.storage.name"/></td> - <td><fmt:message key="current.data.storage"/></td> - <td><fmt:message key="history.data.storage"/></td> - <td><fmt:message key="total.data.storage"/></td> -</tr> -<% - String totalDataStorage = UsageUtil.getTotalDataStorage(usage); - String currentDataStorage = UsageUtil.getCurrentDataStorage(usage); - String historyDataStorage = UsageUtil.getHistoryDataStorage(usage); -%> -<tr> - <td><fmt:message key="registry.content.storage.name"/></td> - <td colspan="1"> - <input readonly="1" type="text" name="currentData" id="currentData" style="width:200px" - value="<%=currentDataStorage%>"/> - </td> - <td colspan="1"> - <input readonly="1" type="text" name="historyData" id="historyData" style="width:200px" - value="<%=historyDataStorage%>"/> - </td> - <td colspan="1"> - <input readonly="1" type="text" name="totalData" id="totalData" style="width:200px" - value="<%=totalDataStorage%>"/> - </td> -</tr> -<% - } -%> - -<tr> - <td colspan="4" class="middle-header"><fmt:message key="api.usage"/></td> -</tr> -<tr> - <td><fmt:message key="server.name"/></td> - <td><fmt:message key="number.of.api.calls"/></td> -</tr> -<% - String apiCallCount = UsageUtil.getAPIUsage(usage); -%> - -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totalAPICalls" id="APICalls" - style="width:200px" value="<%=apiCallCount%>"/> - </td> -</tr> - -<%--<tr> - <td colspan="4" class="middle-header"><fmt:message key="registry.bandwidth.usage"/></td> -</tr> -<tr> - <td><fmt:message key="server.name"/></td> - <td><fmt:message key="incoming.bandwidth"/></td> - <td><fmt:message key="outgoing.bandwidth"/></td> - <td><fmt:message key="total.bandwidth"/></td> -</tr> -<% - String totRegInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalRegistryBandwidth()); - String totRegOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalRegistryBandwidth()); - String totRegBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalRegistryBandwidth()); - BandwidthStatistics[] regBWStats = usage.getRegistryBandwidthStatistics(); - if (regBWStats != null && regBWStats.length > 0 && regBWStats[0] != null) { - for (BandwidthStatistics stat : regBWStats) { - String regInBandwidth = UsageUtil.getIncomingBandwidth(stat); - String regOutBandwidth = UsageUtil.getOutgoingBandwidth(stat); - String regBandwidth = UsageUtil.getTotalBandwidth(stat); -%> -<tr> - <td><%=stat.getKey()%> - </td> - <td> - <input readonly="1" type="text" name="registryIncomingBW" id="registryIncomingBW" - style="width:200px" value="<%=regInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="registryOutgoingBW" id="registryOutgoingBW" - style="width:200px" value="<%=regOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="registryTotalBW" id="registryTotalBW" - style="width:200px" value="<%=regBandwidth%>"/> - </td> -</tr> -<% - } - } -%> -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totRegistryIncomingBW" id="totRegistryIncomingBW" - style="width:200px" value="<%=totRegInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totRegistryOutgoingBW" id="totRegistryOutgoingBW" - style="width:200px" value="<%=totRegOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totRegistryTotalBW" id="totRegistryTotalBW" - style="width:200px" value="<%=totRegBandwidth%>"/> - </td> -</tr> ---%> - -<tr> - <td colspan="4" class="middle-header"><fmt:message key="service.bandwidth.usage"/></td> -</tr> -<tr> - <td><fmt:message key="server.name"/></td> - <td><fmt:message key="incoming.bandwidth"/></td> - <td><fmt:message key="outgoing.bandwidth"/></td> - <td><fmt:message key="total.bandwidth"/></td> -</tr> -<% - String totSvcInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalServiceBandwidth()); - String totSvcOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalServiceBandwidth()); - String totSvcBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalServiceBandwidth()); - BandwidthStatistics[] svcBWStats = usage.getServiceBandwidthStatistics(); - if (svcBWStats != null && svcBWStats.length > 0 && svcBWStats[0] != null) { - for (BandwidthStatistics stat : svcBWStats) { - String svcInBandwidth = UsageUtil.getIncomingBandwidth(stat); - String svcOutBandwidth = UsageUtil.getOutgoingBandwidth(stat); - String svcBandwidth = UsageUtil.getTotalBandwidth(stat); -%> -<tr> - <td><%=stat.getKey()%> - </td> - <td> - <input readonly="1" type="text" name="serviceIncomingBW" id="serviceIncomingBW" - style="width:200px" value="<%=svcInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="serviceOutgoingBW" id="serviceOutgoingBW" - style="width:200px" value="<%=svcOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="serviceTotalBW" id="serviceTotalBW" - style="width:200px" value="<%=svcBandwidth%>"/> - </td> -</tr> -<% - } - } -%> -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totServiceIncomingBW" id="totServiceIncomingBW" - style="width:200px" value="<%=totSvcInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totServiceOutgoingBW" id="totServiceOutgoingBW" - style="width:200px" value="<%=totSvcOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totServiceTotalBW" id="totServiceTotalBW" - style="width:200px" value="<%=totSvcBandwidth%>"/> - </td> -</tr> - - -<tr> - <td colspan="4" class="middle-header"><fmt:message key="webapp.bandwidth.usage"/></td> -</tr> -<tr> - <td><fmt:message key="server.name"/></td> - <td><fmt:message key="incoming.bandwidth"/></td> - <td><fmt:message key="outgoing.bandwidth"/></td> - <td><fmt:message key="total.bandwidth"/></td> -</tr> -<% - String totWebappInBandwidth = UsageUtil.getIncomingBandwidth(usage.getTotalWebappBandwidth()); - String totWebappOutBandwidth = UsageUtil.getOutgoingBandwidth(usage.getTotalWebappBandwidth()); - String totWebappBandwidth = UsageUtil.getTotalBandwidth(usage.getTotalWebappBandwidth()); - BandwidthStatistics[] webappBWStats = usage.getWebappBandwidthStatistics(); - if (webappBWStats != null && webappBWStats.length > 0 && webappBWStats[0] != null) { - for (BandwidthStatistics stat : webappBWStats) { - String webappInBandwidth = UsageUtil.getIncomingBandwidth(stat); - String webappOutBandwidth = UsageUtil.getOutgoingBandwidth(stat); - String webappBandwidth = UsageUtil.getTotalBandwidth(stat); -%> -<tr> - <td><%=stat.getKey()%> - </td> - <td> - <input readonly="1" type="text" name="webappIncomingBW" id="webappIncomingBW" - style="width:200px" value="<%=webappInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="webappOutgoingBW" id="webappOutgoingBW" - style="width:200px" value="<%=webappOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="webappTotalBW" id="webappTotalBW" style="width:200px" - value="<%=webappBandwidth%>"/> - </td> -</tr> -<% - } - } -%> -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totWebappIncomingBW" id="totWebappIncomingBW" - style="width:200px" value="<%=totWebappInBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totWebappOutgoingBW" id="totWebappOutgoingBW" - style="width:200px" value="<%=totWebappOutBandwidth%>"/> - </td> - <td> - <input readonly="1" type="text" name="totWebappTotalBW" id="totWebappTotalBW" - style="width:200px" value="<%=totWebappBandwidth%>"/> - </td> -</tr> - - -<tr> - <td colspan="4" class="middle-header"><fmt:message key="service.usage.stat"/></td> -</tr> -<tr> - <td><fmt:message key="server.name"/></td> - <td><fmt:message key="service.usage.request"/></td> - <td><fmt:message key="service.usage.response"/></td> - <td><fmt:message key="service.usage.fault"/></td> -</tr> -<% - long totSvcReqCount = usage.getTotalRequestStatistics().getRequestCount(); - long totSvcRespCount = usage.getTotalRequestStatistics().getResponseCount(); - long totSvcFaultCount = usage.getTotalRequestStatistics().getFaultCount(); - RequestStatistics[] svcStats = usage.getRequestStatistics(); - if (svcStats != null && svcStats.length > 0 && svcStats[0] != null) { - for (RequestStatistics stat : svcStats) { - long svcReqCount = stat.getRequestCount(); - long svcResCount = stat.getResponseCount(); - long svcFaultCount = stat.getFaultCount(); -%> -<tr> - <td><%=stat.getKey()%> - </td> - <td> - <input readonly="1" type="text" name="serviceRequestCount" id="serviceRequestCount" - style="width:200px" value="<%=svcReqCount%>"/> - </td> - <td> - <input readonly="1" type="text" name="serviceResponseCount" id="serviceResponseCount" - style="width:200px" value="<%=svcResCount%>"/> - </td> - <td> - <input readonly="1" type="text" name="serviceFaultCount" id="serviceFaultCount" - style="width:200px" value="<%=svcFaultCount%>"/> - </td> -</tr> -<% - } - } -%> -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totServiceRequestCount" id="totServiceRequestCount" - style="width:200px" value="<%=totSvcReqCount%>"/> - </td> - <td> - <input readonly="1" type="text" name="totServiceResponseCount" id="totServiceResponseCount" - style="width:200px" value="<%=totSvcRespCount%>"/> - </td> - <td> - <input readonly="1" type="text" name="totServiceFaultCount" id="totServiceFaultCount" - style="width:200px" value="<%=totSvcFaultCount%>"/> - </td> -</tr> - -<!--cartridge stats--> -<tr> - <td colspan="4" class="middle-header"><fmt:message key="cartridge.stat"/></td> -</tr> -<tr> - <td><fmt:message key="cartridge.type"/></td> - <td><fmt:message key="image.id"/></td> - <td><fmt:message key="cartridge.hours"/></td> - <%--<td><fmt:message key="service.usage.fault"/></td>--%> -</tr> -<% - long totalHours = usage.getTotalCartridgeHours().getCartridgeHours(); - CartridgeStatistics[] cs = usage.getCartridgeStatistics(); - if(cs!=null && cs.length>0 && cs[0] != null) { - for(CartridgeStatistics stat: cs) { - -%> -<tr> - <td><%=stat.getKey()%> - </td> - <td> - <input readonly="1" type="text" name="imageId" id="imageId" - style="width:200px" value="<%=stat.getInstanceId()%>"/> - </td> - <td> - <input readonly="1" type="text" name="cartridgeHours" id="cartridgeHours" - style="width:200px" value="<%=stat.getCartridgeHours()%>"/> - </td> - -</tr> -<% - } - } -%> -<tr> - <td><fmt:message key="all.server.name"/></td> - <td> - <input readonly="1" type="text" name="totalImageIds" id="totalImageIds" - style="width:200px" value=""/> - </td> - <td> - <input readonly="1" type="text" name="totalCartridgeHours" id="totalCartridgeHours" - style="width:200px" value="<%=totalHours%>"/> - </td> - -</tr> - -</tbody> -</table> -</td> -</tr> -</tbody> -</table> -</form> -<br/> -</div> -</div> -</fmt:bundle> - http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp b/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp deleted file mode 100644 index 8caed5c..0000000 --- a/components/org.apache.stratos.usage.ui/src/main/resources/web/tenant-usage/usage_report.jsp +++ /dev/null @@ -1,29 +0,0 @@ -<%@ page import="org.apache.stratos.usage.ui.report.UsageReport" %> -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<carbon:jsi18n -resourceBundle="org.apache.stratos.usage.ui.i18n.JSResources" -request="<%=request%>" /> -<% - - UsageReport usageReport = new UsageReport(config, session, request); - String[] reportDataArray = usageReport.getUsageReportData(); - request.getSession().setAttribute("usage_data", reportDataArray); -%> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/pom.xml b/components/org.apache.stratos.usage/pom.xml deleted file mode 100644 index db5715e..0000000 --- a/components/org.apache.stratos.usage/pom.xml +++ /dev/null @@ -1,146 +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> -<!-- <relativePath>../pom.xml</relativePath>--> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.usage</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Usage</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>target/generated-code/src</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <ListenerManager-RequiredServices> - org.apache.stratos.usage.api.TenantUsageRetriever - </ListenerManager-RequiredServices> - <Private-Package> - org.apache.stratos.usage.internal.*, - org.apache.stratos.usage.util.*, - org.apache.stratos.usage.services.*, - org.apache.stratos.usage.client.* - </Private-Package> - <Export-Package> - org.apache.stratos.usage.beans.*, - org.apache.stratos.usage.api.*, - </Export-Package> - <Import-Package> - org.wso2.carbon.rule.*, - org.wso2.carbon.registry.core.*;version=1.0.1, - org.wso2.carbon.registry.resource.*, - org.apache.stratos.common.*, - !javax.xml.namespace, - javax.xml.namespace; version=0.0.0, - javax.servlet;version="${imp.pkg.version.javax.servlet}", - javax.servlet.http;version="${imp.pkg.version.javax.servlet}", - org.apache.axiom.*; version="${axiom.osgi.version.range}", - *;resolution:=optional - </Import-Package> - </instructions> - </configuration> - </plugin> - - </plugins> - </build> - - <dependencies> - - <dependency> - <groupId>org.apache.axis2.wso2</groupId> - <artifactId>axis2</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.user.core</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.user.mgt</artifactId> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.usage.agent</artifactId> - <version>${project.version}</version> - </dependency> - <!--<dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.usage.meteringqueryds.stub</artifactId> - </dependency>--> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.ndatasource.core</artifactId> - <version>4.2.0</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java deleted file mode 100644 index 8bb190c..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/api/TenantUsageRetriever.java +++ /dev/null @@ -1,607 +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.api; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.stratos.usage.beans.*; -import org.apache.stratos.usage.util.Util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.common.constants.UsageConstants; -import org.apache.stratos.common.util.CommonUtil; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.apache.stratos.usage.util.DataAccessObject; -import org.wso2.carbon.user.core.UserRealm; -import org.wso2.carbon.user.core.UserStoreException; -import org.wso2.carbon.user.core.tenant.TenantManager; - -import java.util.*; - -public class TenantUsageRetriever { - private static final Log log = LogFactory.getLog(TenantUsageRetriever.class); - private static final String DEFAULT_SERVICE_NAME = "Stratos"; - private static final String METERING_ENDPOINT = "local://services/MeteringQueryDS"; - private static final String TOTAL_LABEL = "Total"; - public static final int REG_BANDWIDTH_INDEX = 0; - public static final int SVC_BANDWIDTH_INDEX = 1; - public static final int WEBAPP_BANDWIDTH_INDEX = 2; - public static final int API_CALL_STATS=3; - - private RegistryService registryService; - private DataAccessObject dao; - - public TenantUsageRetriever(RegistryService registryService, ConfigurationContext configContext) - throws Exception { - - // we are loading the essentials from the constructors in order to restrict the users - // to use the usage retrievers. - this.registryService = registryService; - this.dao = new DataAccessObject(); - } - - - public TenantDataCapacity getDataCapacity(int tenantId, Calendar startDate, Calendar endDate, - boolean currentMonth) throws Exception { - TenantDataCapacity dataCapacity = null; - - if(currentMonth){ - dataCapacity = dao.getTenantDataCapacity(tenantId); - } else { - //we don't have a way to see the registry usage of last months yet - } - - return dataCapacity; - - } - - /** - * This returns the number of users in a given tenant - * @param tenantId Tenant ID - * @return Number of users - * @throws RegistryException - */ - public int getCurrentUserCount(int tenantId) throws RegistryException { - UserRealm userRealm = registryService.getUserRealm(tenantId); - int usersCount; - try { - String[] users = userRealm.getUserStoreManager().listUsers("*", -1); - usersCount = users.length; - } catch (UserStoreException e) { - String msg = "Error in getting the current users."; - log.error(msg, e); - throw new RegistryException(msg, e); - } - return usersCount; - } - - public BandwidthStatistics[][] getBandwidthStatistics(int tenantId, Calendar startDate, - Calendar endDate, boolean currentMonth) throws Exception { - //return the bandwidth usage of a user for a given period - BandwidthStatistics[] stats; - if (currentMonth) { - //get from daily usage stats - List<BandwidthStatistics> bwsList = new ArrayList<BandwidthStatistics>(); - bwsList = dao.getDailyBandwidthStats(tenantId, startDate, endDate); - - //next we'll get from the houlry stats to get the stats which are not yet - //summarized to the daily stats table - Calendar startHour = Calendar.getInstance(); - startHour.set(Calendar.HOUR, 0); - startHour.set(Calendar.MINUTE, 0); - startHour.set(Calendar.SECOND, 0); - - Calendar endHour = Calendar.getInstance(); - - bwsList.addAll(dao.getHourlyBandwidthStats(tenantId, startHour, endHour)); - stats = convertBWListToArray(bwsList); - - } else { - //get from monthly usage stats - Calendar monthCal = (Calendar) endDate.clone(); - monthCal.set(Calendar.DATE, 0); - monthCal.set(Calendar.HOUR, 0); - monthCal.set(Calendar.MINUTE, 0); - monthCal.set(Calendar.SECOND, 0); - - stats = convertBWListToArray(dao.getMonthlyBandwidthStats(tenantId, monthCal)); - } - - // store the statistics in a temporary map. This is because, we are getting the server name - // from the URL and there might be two distinct URL gives same server name. - // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb" - // Hence, the value should be accumulated value - HashMap<String, BandwidthStatistics> regBwMap = new HashMap<String, BandwidthStatistics>(); - HashMap<String, BandwidthStatistics> svcBwMap = new HashMap<String, BandwidthStatistics>(); - HashMap<String, BandwidthStatistics> webappBwMap = new HashMap<String, BandwidthStatistics>(); - - if (stats != null) { - for (BandwidthStatistics stat : stats) { - //Proceed only if incoming bandwidth or outgoing bandwidth is not zero - if (stat.getIncomingBandwidth() == 0 && stat.getOutgoingBandwidth() == 0) { - continue; - } - - //TODO: fix the extractServiceUrl method properly - String serverName = extractServiceNameFromUrl(stat.getServerUrl()); - String bandwidthName = stat.getKey(); - - HashMap<String, BandwidthStatistics> bwMap; - if (bandwidthName.equals(UsageConstants.REGISTRY_INCOMING_BW) || - bandwidthName.equals(UsageConstants.REGISTRY_OUTGOING_BW)) { - bwMap = regBwMap; - } else if (bandwidthName.equals(UsageConstants.SERVICE_INCOMING_BW) || - bandwidthName.equals(UsageConstants.SERVICE_OUTGOING_BW)) { - bwMap = svcBwMap; - } else if (bandwidthName.equals(UsageConstants.WEBAPP_INCOMING_BW) || - bandwidthName.equals(UsageConstants.WEBAPP_OUTGOING_BW)) { - bwMap = webappBwMap; - } else { - log.warn("Unable to identify bandwidth name " + bandwidthName); - continue; - } - - //find whether the map already has this key; If not, insert a new one - BandwidthStatistics reqStat = bwMap.get(serverName); - if (reqStat == null) { - reqStat = new BandwidthStatistics(serverName); - bwMap.put(serverName, reqStat); - } - - // Update the service specific statistics - reqStat.setIncomingBandwidth( - reqStat.getIncomingBandwidth() + stat.getIncomingBandwidth()); - reqStat.setOutgoingBandwidth( - reqStat.getOutgoingBandwidth() + stat.getOutgoingBandwidth()); - } - } - - //Convert to array and return it - BandwidthStatistics[][] returnValue = new BandwidthStatistics[3][]; - Collection<BandwidthStatistics> values = regBwMap.values(); - returnValue[REG_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]); - values = svcBwMap.values(); - returnValue[SVC_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]); - values = webappBwMap.values(); - returnValue[WEBAPP_BANDWIDTH_INDEX] = values.toArray(new BandwidthStatistics[values.size()]); - - return returnValue; - } - - - public APIManagerUsageStats[] getAPIManagerUsageStats(int tenantId, Calendar startDate, - Calendar endDate, boolean currentMonth) throws Exception { - //return the bandwidth usage of a user for a given period - APIManagerUsageStats[] stats; - if (currentMonth) { - //get from daily usage stats - List<APIManagerUsageStats> bwsList = new ArrayList<APIManagerUsageStats>(); - bwsList = dao.getDailyAPIManagerUsageStats(tenantId, startDate, endDate); - - //next we'll get from the houlry stats to get the stats which are not yet - //summarized to the daily stats table - Calendar startHour = Calendar.getInstance(); - startHour.set(Calendar.HOUR, 0); - startHour.set(Calendar.MINUTE, 0); - startHour.set(Calendar.SECOND, 0); - - Calendar endHour = Calendar.getInstance(); - - bwsList.addAll(dao.getHourlyAPIManagerUsageStats(tenantId, startHour, endHour)); - stats = convertAPIStatListToArray(bwsList); - - } else { - //get from monthly usage stats - Calendar monthCal = (Calendar) endDate.clone(); - monthCal.set(Calendar.DATE, 0); - monthCal.set(Calendar.HOUR, 0); - monthCal.set(Calendar.MINUTE, 0); - monthCal.set(Calendar.SECOND, 0); - - stats = convertAPIStatListToArray(dao.getMonthlyAPIManagerUsageStats(tenantId, monthCal)); - } - HashMap<String, APIManagerUsageStats> statMap = new HashMap<String, APIManagerUsageStats>(); - if (stats != null) { - for (APIManagerUsageStats stat : stats) { - if (stat.getRequestCount() == 0) { - continue; - } - String serverName = extractServiceNameFromUrl(stat.getServerUrl()); - String statName = stat.getKey(); - - HashMap<String, APIManagerUsageStats> statsHashMap; - if (statName.equals("API-Call")) { - statsHashMap = statMap; - } else { - log.warn("Unable to identify bandwidth name " + statName); - continue; - } - - //find whether the map already has this key; If not, insert a new one - APIManagerUsageStats reqStat = statsHashMap.get(serverName); - if (reqStat == null) { - reqStat = new APIManagerUsageStats(serverName); - statsHashMap.put(serverName, reqStat); - } - reqStat.setRequestCount(stat.getRequestCount()); - } - } - - //Convert to array and return it - APIManagerUsageStats[] returnValue = new APIManagerUsageStats[0]; - Collection<APIManagerUsageStats> values = statMap.values(); - returnValue = values.toArray(new APIManagerUsageStats[values.size()]); - return returnValue; - } - - - public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate, - Calendar endDate, boolean currentMonth) throws Exception { - RequestStatistics[] stats; - if (currentMonth) { - //get from daily usage stats - List<RequestStatistics> rsList = new ArrayList<RequestStatistics>(); - rsList = dao.getDailyRequestStats(tenantId, startDate, endDate); - - //next we'll get from the houlry stats to get the stats which are not yet - //summarized to the daily stats table - Calendar startHour = Calendar.getInstance(); - startHour.set(Calendar.HOUR, 0); - startHour.set(Calendar.MINUTE, 0); - startHour.set(Calendar.SECOND, 0); - - Calendar endHour = Calendar.getInstance(); - - rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour)); - - stats = convertRSListToArray(rsList); - } else { - //get from monthly usage stats - Calendar monthCal = (Calendar) endDate.clone(); - monthCal.set(Calendar.DATE, 0); - monthCal.set(Calendar.HOUR, 0); - monthCal.set(Calendar.MINUTE, 0); - monthCal.set(Calendar.SECOND, 0); - - stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal)); - } - - // store the statistics in a temporary map. This is because, we are getting the server name - // from the URL and there might be two distinct URL gives same server name. - // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb" - // Hence, the value should be accumulated value - HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>(); - - if (stats != null) { - for (RequestStatistics stat : stats) { - //Proceed only if request count is not zero - if (stat.getRequestCount() == 0) { - continue; - } - - String serverName = extractServiceNameFromUrl(stat.getKey()); - - //find whether the map already has this key; If not, insert a new one - RequestStatistics reqStat = tempReqStatMap.get(serverName); - if (reqStat == null) { - reqStat = new RequestStatistics(serverName); - tempReqStatMap.put(serverName, reqStat); - } - - // Update the service specific statistics - reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount()); - reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount()); - reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount()); - } - } - - //Convert to array and return it - Collection<RequestStatistics> values = tempReqStatMap.values(); - return values.toArray(new RequestStatistics[values.size()]); - - } - - public CartridgeStatistics[] getCartridgeStatistics(int tenantId, Calendar startDate, - Calendar endDate, boolean currentMonth) throws Exception { - CartridgeStatistics[] stats; - /*if (currentMonth) { - //get from daily usage stats - List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>(); - csList = dao.getDailyCartridgeStats(tenantId, startDate, endDate); - - //next we'll get from the houlry stats to get the stats which are not yet - //summarized to the daily stats table - Calendar startHour = Calendar.getInstance(); - startHour.set(Calendar.HOUR, 0); - startHour.set(Calendar.MINUTE, 0); - startHour.set(Calendar.SECOND, 0); - - Calendar endHour = Calendar.getInstance(); - - csList.addAll(dao.getHourlyCartridgeStats(tenantId, startHour, endHour)); - - stats = convertCSListToArray(csList); - } else { - //get from monthly usage stats - Calendar monthCal = (Calendar) endDate.clone(); - monthCal.set(Calendar.DATE, 0); - monthCal.set(Calendar.HOUR, 0); - monthCal.set(Calendar.MINUTE, 0); - monthCal.set(Calendar.SECOND, 0); - - stats = convertCSListToArray(dao.getMonthlyCartridgeStats(tenantId, monthCal)); - }*/ - List<CartridgeStatistics> csList = new ArrayList<CartridgeStatistics>(); - csList = dao.getHourlyCartridgeStats(tenantId, startDate, endDate); - stats = convertCSListToArray(csList); - - //Add a comment explaining following logic later - HashMap<String, CartridgeStatistics> tempCartridgeStatMap = new HashMap<String, CartridgeStatistics>(); - - if (stats != null) { - for (CartridgeStatistics stat : stats) { - //Proceed only if request count is not zero - if (stat.getCartridgeHours() == 0) { - continue; - } - - - //find whether the map already has this key; If not, insert a new one - CartridgeStatistics cartridgeStat = tempCartridgeStatMap.get(stat.getKey()); - if (cartridgeStat == null) { - cartridgeStat = new CartridgeStatistics(stat.getKey()); - tempCartridgeStatMap.put(stat.getKey(), cartridgeStat); - } - - // Update the service specific statistics - cartridgeStat.setCartridgeHours(cartridgeStat.getCartridgeHours() + stat.getCartridgeHours()); - cartridgeStat.setInstanceId(stat.getInstanceId()); - } - } - - //Convert to array and return it - Collection<CartridgeStatistics> values = tempCartridgeStatMap.values(); - return values.toArray(new CartridgeStatistics[values.size()]); - - } - - public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception { - //get the domain name - TenantManager tenantManger = Util.getRealmService().getTenantManager(); - String domain = tenantManger.getDomain(tenantId); - TenantUsage tenantUsage = new TenantUsage(tenantId, domain); - - //Get the startDate, endDate from yearMonth String - Date date = CommonUtil.getDateFromMonthString(yearMonth); - Calendar startDate = Calendar.getInstance(); - startDate.setTime(date); - Calendar endDate = (Calendar) startDate.clone(); - endDate.add(Calendar.MONTH, 1); - - //Calculate whether the yearMonth fits to current month; if the current date is less than - // endDate, then we treat it as current month - boolean isCurrentMonth = (Calendar.getInstance().compareTo(endDate) <= 0); - - //get the data capacity - TenantDataCapacity capacity; - try { - capacity = getDataCapacity(tenantId, startDate, endDate, isCurrentMonth); - } catch (Exception e) { - String msg = "Error in getting data capacity from metering service."; - log.error(msg, e); - throw new Exception(msg, e); - } - tenantUsage.setRegistryCapacity(capacity); - - //get the service request statistics - RequestStatistics[] reqStats = null; - try { - reqStats = getRequestStatistics(tenantId, startDate, endDate, isCurrentMonth); - } catch (Exception e) { - String msg = "Error in getting request statistics from metering service."; - log.error(msg, e); - throw new Exception(msg, e); - } - tenantUsage.setRequestStatistics(reqStats); - - //Calculate total Request statistics - RequestStatistics totalReqStat = new RequestStatistics(TOTAL_LABEL); - long totalReq = 0; - long totalRes = 0; - long totalFault = 0; - if(reqStats!=null){ - for (RequestStatistics stat : reqStats) { - totalReq += stat.getRequestCount(); - totalRes += stat.getResponseCount(); - totalFault += stat.getFaultCount(); - } - totalReqStat.setRequestCount(totalReq); - totalReqStat.setResponseCount(totalRes); - totalReqStat.setFaultCount(totalFault); - } - tenantUsage.setTotalRequestStatistics(totalReqStat); - - //get Bandwidth statistics - BandwidthStatistics[][] bwStats = null; - try { - bwStats = getBandwidthStatistics(tenantId, startDate, endDate, isCurrentMonth); - } catch (Exception e) { - String msg = "Error in getting bandwidth statistics from metering service."; - log.error(msg, e); - throw new Exception(msg, e); - } - tenantUsage.setRegistryBandwidthStatistics(bwStats[REG_BANDWIDTH_INDEX]); - tenantUsage.setServiceBandwidthStatistics(bwStats[SVC_BANDWIDTH_INDEX]); - tenantUsage.setWebappBandwidthStatistics(bwStats[WEBAPP_BANDWIDTH_INDEX]); - - //get the total bandwidths - int index = 0; - for (BandwidthStatistics[] bwArray : bwStats) { - long incomingBandwidth = 0; - long outgoingBandwidth = 0; - for (BandwidthStatistics bandwidth : bwArray) { - incomingBandwidth += bandwidth.getIncomingBandwidth(); - outgoingBandwidth += bandwidth.getOutgoingBandwidth(); - } - BandwidthStatistics total = new BandwidthStatistics(TOTAL_LABEL); - total.setIncomingBandwidth(incomingBandwidth); - total.setOutgoingBandwidth(outgoingBandwidth); - switch (index) { - case REG_BANDWIDTH_INDEX: - tenantUsage.setTotalRegistryBandwidth(total); - break; - case SVC_BANDWIDTH_INDEX: - tenantUsage.setTotalServiceBandwidth(total); - break; - case WEBAPP_BANDWIDTH_INDEX: - tenantUsage.setTotalWebappBandwidth(total); - break; - } - ++index; - } - - // the users count will be calculated only if the yearMonth is the current yearMonth - if (isCurrentMonth) { - int usersCount = getCurrentUserCount(tenantId); - tenantUsage.setNumberOfUsers(usersCount); - } - // get the API invocation data - APIManagerUsageStats[] apiStats = null; - try { - apiStats = getAPIManagerUsageStats(tenantId, startDate, endDate, isCurrentMonth); - } catch (Exception e) { - String msg = "Error in getting bandwidth statistics from metering service."; - log.error(msg, e); - throw new Exception(msg, e); - } - tenantUsage.setApiManagerUsageStats(apiStats); - - //retrieving cartridge hours - CartridgeStatistics[] cartridgeStatistics = getCartridgeStatistics(tenantId, startDate, endDate, isCurrentMonth); - tenantUsage.setCartridgeStatistics(cartridgeStatistics); - long totalCartridgeHours = 0; - if(cartridgeStatistics!=null && cartridgeStatistics.length>0){ - - for (CartridgeStatistics cs : cartridgeStatistics){ - totalCartridgeHours += cs.getCartridgeHours(); - } - } - - CartridgeStatistics totalCS = new CartridgeStatistics(); - totalCS.setCartridgeHours(totalCartridgeHours); - - tenantUsage.setTotalCartridgeHours(totalCS); - return tenantUsage; - } - - /** - * @param serviceURL - * @return service name - * <p/> - * Extract the stratos service part from URL; expecting the URL as - * protocol://service.domain:port/tenant-domain/ or service.domain:port/tenant - * We are interested in "service" part only - */ - private String extractServiceNameFromUrl(String serviceURL) { - if (serviceURL == null || serviceURL.equals("")) { - //No service URL is given, so return a default value - return DEFAULT_SERVICE_NAME; - } - - int startIndex = serviceURL.indexOf("://"); //exclude protocol:// part - if (startIndex != -1) { - // protocol://service.domain:port/tenant-domain/ case - startIndex += 3; - } else { - //service.domain:port/tenant case - startIndex = 0; - } - - int endIndex = serviceURL.indexOf('.', startIndex); //take upto first "." - if (endIndex == -1) { - // "." is not there; search for ":" - endIndex = serviceURL.indexOf(':', startIndex); - - if (endIndex == -1) { - //Still could not find ":", then search for "/" - endIndex = serviceURL.indexOf('/', startIndex); - - if (endIndex == -1) { - //Noting is there, so take the whole service URL - endIndex = serviceURL.length(); - } - } - - } - return serviceURL.substring(startIndex, endIndex); - } - - /** - * @return Instance Usages Statics Array that contains data - * @throws Exception when back end error occurs - */ - public InstanceUsageStatics[] getInstanceUsages() throws Exception { - - //TODO: implement - return null; - /*InstanceUsageStat[] instanceData = meteringStub.getInstanceUsageStats(); - if (instanceData == null || instanceData.length == 0) { - return null; - } - InstanceUsageStatics[] returnValue = new InstanceUsageStatics[instanceData.length]; - int elementID = 0; - for (InstanceUsageStat iu : instanceData) { - InstanceUsageStatics iu1 = new InstanceUsageStatics(); - iu1.setInstanceID(iu.getInstanceId().intValue()); - iu1.setInstanceURL(iu.getServerURL()); - iu1.setStartTime(iu.getStartTimestamp()); - iu1.setStopTime(iu.getStopTimestamp()); - iu1.setRunning(iu.getIsRunning()); - returnValue[elementID] = iu1; - elementID = elementID + 1; - } - return returnValue; - */ - } - - - private BandwidthStatistics[] convertBWListToArray(List<BandwidthStatistics> bwsList) { - BandwidthStatistics[] bwsArray = new BandwidthStatistics[bwsList.size()]; - bwsArray = bwsList.toArray(bwsArray); - return bwsArray; - } - - private APIManagerUsageStats[] convertAPIStatListToArray(List<APIManagerUsageStats> bwsList) { - APIManagerUsageStats[] bwsArray = new APIManagerUsageStats[bwsList.size()]; - bwsArray = bwsList.toArray(bwsArray); - return bwsArray; - } - - private RequestStatistics[] convertRSListToArray(List<RequestStatistics> rsList) { - RequestStatistics[] rsArray = new RequestStatistics[rsList.size()]; - rsArray = rsList.toArray(rsArray); - return rsArray; - } - - private CartridgeStatistics[] convertCSListToArray(List<CartridgeStatistics> csList){ - CartridgeStatistics[] csArray = new CartridgeStatistics[csList.size()]; - csArray = csList.toArray(csArray); - return csArray; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.java deleted file mode 100644 index bd47d8f..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/APIManagerUsageStats.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.beans; - -public class APIManagerUsageStats { - private String key; - private String serverUrl; - private long incomingBandwidth; - private long outgoingBandwidth; - private long requestCount; - - public long getRequestCount() { - return requestCount; - } - - public void setRequestCount(long requestCount) { - this.requestCount = requestCount; - } - - - public APIManagerUsageStats(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public long getIncomingBandwidth() { - return incomingBandwidth; - } - - public void setIncomingBandwidth(long incomingBandwidth) { - this.incomingBandwidth = incomingBandwidth; - } - - public long getOutgoingBandwidth() { - return outgoingBandwidth; - } - - public void setOutgoingBandwidth(long outgoingBandwidth) { - this.outgoingBandwidth = outgoingBandwidth; - } - - public String getServerUrl() { - return serverUrl; - } - - public void setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java deleted file mode 100644 index 9e62626..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/BandwidthStatistics.java +++ /dev/null @@ -1,65 +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.beans; - -/** - * - */ -public class BandwidthStatistics { - private String key; - private String serverUrl; - private long incomingBandwidth; - private long outgoingBandwidth; - - public BandwidthStatistics(String key){ - this.key = key; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public long getIncomingBandwidth() { - return incomingBandwidth; - } - - public void setIncomingBandwidth(long incomingBandwidth) { - this.incomingBandwidth = incomingBandwidth; - } - - public long getOutgoingBandwidth() { - return outgoingBandwidth; - } - - public void setOutgoingBandwidth(long outgoingBandwidth) { - this.outgoingBandwidth = outgoingBandwidth; - } - - public String getServerUrl() { - return serverUrl; - } - - public void setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java deleted file mode 100644 index 4568519..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/CartridgeStatistics.java +++ /dev/null @@ -1,59 +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.beans; - - -public class CartridgeStatistics { - - private String key; - private String instanceId; - private long cartridgeHours; - - public CartridgeStatistics(){ - //Default constructor - } - - public CartridgeStatistics(String key){ - this.key = key; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public long getCartridgeHours() { - return cartridgeHours; - } - - public void setCartridgeHours(long cartridgeHours) { - this.cartridgeHours = cartridgeHours; - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.java deleted file mode 100644 index b0877ef..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/InstanceUsageStatics.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.beans; - -import java.util.Calendar; - -public class InstanceUsageStatics { - - private Calendar startTime; - private Calendar stopTime; - private String instanceURL; - private Integer instanceID; - private long usedTimeInSeconds; - private boolean running; - - public boolean isRunning() { - return running; - } - - public void setRunning(boolean running) { - this.running = running; - } - - public Calendar getStartTime() { - return startTime; - } - - public void setStartTime(Calendar startTime) { - this.startTime = startTime; - } - - public Calendar getStopTime() { - return stopTime; - } - - public void setStopTime(Calendar stopTime) { - //Check weather stop time is Default value in database in that case - //server should still running so set isRunning as true - Calendar fixedDate = Calendar.getInstance(); - fixedDate.set(2001, 1, 1, 00, 00, 00); - if (stopTime.compareTo(fixedDate) == 0) { - this.running = true; - } - this.stopTime = stopTime; - } - - public String getInstanceURL() { - return instanceURL; - } - - public void setInstanceURL(String instanceURL) { - this.instanceURL = instanceURL; - } - - public Integer getInstanceID() { - return instanceID; - } - - public void setInstanceID(Integer instanceID) { - this.instanceID = instanceID; - } - - public long getUsedTimeInSeconds() { - long returnValue = (this.stopTime.getTimeInMillis() - - this.startTime.getTimeInMillis()) / 1000; - if (returnValue < 0) { - running = true; - } - return usedTimeInSeconds; - } - public void setUsedTimeInSeconds(long value){ - this.usedTimeInSeconds=value; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java deleted file mode 100644 index 3af8b9d..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedInstanceUsage.java +++ /dev/null @@ -1,59 +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.beans; - -import java.util.Arrays; - -public class PaginatedInstanceUsage { - private InstanceUsageStatics[] instanceUsages; - private int pageNumber; - private int numberOfPages; - - public InstanceUsageStatics[] getInstanceUsages() { - if(instanceUsages != null) { - return Arrays.copyOf(instanceUsages, instanceUsages.length); - } - - return null; - } - - public void setInstanceUsages(InstanceUsageStatics[] instanceUsages) { - if(instanceUsages != null) { - this.instanceUsages = Arrays.copyOf(instanceUsages, instanceUsages.length); - } - } - - public int getPageNumber() { - return pageNumber; - } - - public void setPageNumber(int pageNumber) { - this.pageNumber = pageNumber; - } - - public int getNumberOfPages() { - return numberOfPages; - } - - public void setNumberOfPages(int numberOfPages) { - this.numberOfPages = numberOfPages; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java deleted file mode 100644 index e538807..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/PaginatedTenantUsageInfo.java +++ /dev/null @@ -1,47 +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.beans; - -import java.util.Arrays; - -public class PaginatedTenantUsageInfo { - private TenantUsage[] tenantUsages; - private int pageNumber; - private int numberOfPages; - - public TenantUsage[] getTenantUsages() { - return Arrays.copyOf(tenantUsages, tenantUsages.length); - } - public void setTenantUsages(TenantUsage[] tenantUsages) { - this.tenantUsages = Arrays.copyOf(tenantUsages, tenantUsages.length); - } - public int getPageNumber() { - return pageNumber; - } - public void setPageNumber(int pageNumber) { - this.pageNumber = pageNumber; - } - public int getNumberOfPages() { - return numberOfPages; - } - public void setNumberOfPages(int numberOfPages) { - this.numberOfPages = numberOfPages; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java deleted file mode 100644 index e703578..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/RequestStatistics.java +++ /dev/null @@ -1,63 +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.beans; -public class RequestStatistics { - private String key; - private long requestCount; - private long responseCount; - private long faultCount; - - public RequestStatistics(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public long getRequestCount() { - return requestCount; - } - - public void setRequestCount(long requestCount) { - this.requestCount = requestCount; - } - - public long getResponseCount() { - return responseCount; - } - - public void setResponseCount(long responseCount) { - this.responseCount = responseCount; - } - - public long getFaultCount() { - return faultCount; - } - - public void setFaultCount(long faultCount) { - this.faultCount = faultCount; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java deleted file mode 100644 index c0f2ea7..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantDataCapacity.java +++ /dev/null @@ -1,55 +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.beans; - -public class TenantDataCapacity { - - private long registryContentCapacity; - private long registryContentHistoryCapacity; - - public TenantDataCapacity() { - } - - /** - * @param registryContentCapacity - * @param registryContentHistoryCapacity - */ - public TenantDataCapacity( - long registryContentCapacity, long registryContentHistoryCapacity) { - this.registryContentCapacity = registryContentCapacity; - this.registryContentHistoryCapacity = registryContentHistoryCapacity; - } - - public long getRegistryContentCapacity() { - return registryContentCapacity; - } - - public void setRegistryContentCapacity(long registryContentCapacity) { - this.registryContentCapacity = registryContentCapacity; - } - - public long getRegistryContentHistoryCapacity() { - return registryContentHistoryCapacity; - } - - public void setRegistryContentHistoryCapacity(long registryContentHistoryCapacity) { - this.registryContentHistoryCapacity = registryContentHistoryCapacity; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java deleted file mode 100644 index 8afd9af..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/TenantUsage.java +++ /dev/null @@ -1,219 +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.beans; - -public class TenantUsage { - private int tenantId; - private String domain; - private int numberOfUsers; - private UsageEntry[] usageEntries; - private BandwidthStatistics[] registryBandwidthStatistics; - private BandwidthStatistics[] serviceBandwidthStatistics; - private BandwidthStatistics[] webappBandwidthStatistics; - private CartridgeStatistics[] cartridgeStatistics; - private RequestStatistics[] requestStatistics; - private TenantDataCapacity registryCapacity; - private RequestStatistics totalRequestStatistics; - private BandwidthStatistics totalRegistryBandwidth; - private BandwidthStatistics totalServiceBandwidth; - private BandwidthStatistics totalWebappBandwidth; - private CartridgeStatistics totalCartridgeHours; - private APIManagerUsageStats[] apiManagerUsageStats; - - public APIManagerUsageStats[] getApiManagerUsageStats() { - return apiManagerUsageStats; - } - - public void setApiManagerUsageStats(APIManagerUsageStats[] apiManagerUsageStats) { - this.apiManagerUsageStats = apiManagerUsageStats; - } - - public BandwidthStatistics[] getRegistryBandwidthStatistics() { - return registryBandwidthStatistics; - } - - public void setRegistryBandwidthStatistics(BandwidthStatistics[] registryBandwidthStatistics) { - this.registryBandwidthStatistics = registryBandwidthStatistics; - } - - public BandwidthStatistics[] getServiceBandwidthStatistics() { - return serviceBandwidthStatistics; - } - - public void setServiceBandwidthStatistics(BandwidthStatistics[] serviceBandwidthStatistics) { - this.serviceBandwidthStatistics = serviceBandwidthStatistics; - } - - public BandwidthStatistics[] getWebappBandwidthStatistics() { - return webappBandwidthStatistics; - } - - public void setWebappBandwidthStatistics(BandwidthStatistics[] webappBandwidthStatistics) { - this.webappBandwidthStatistics = webappBandwidthStatistics; - } - - public RequestStatistics getTotalRequestStatistics() { - return totalRequestStatistics; - } - - public void setTotalRequestStatistics(RequestStatistics totalRequestStatistics) { - this.totalRequestStatistics = totalRequestStatistics; - } - - public BandwidthStatistics getTotalRegistryBandwidth() { - return totalRegistryBandwidth; - } - - public void setTotalRegistryBandwidth(BandwidthStatistics totalRegistryBandwidth) { - this.totalRegistryBandwidth = totalRegistryBandwidth; - } - - public BandwidthStatistics getTotalServiceBandwidth() { - return totalServiceBandwidth; - } - - public void setTotalServiceBandwidth(BandwidthStatistics totalServiceBandwidth) { - this.totalServiceBandwidth = totalServiceBandwidth; - } - - public BandwidthStatistics getTotalWebappBandwidth() { - return totalWebappBandwidth; - } - - public void setTotalWebappBandwidth(BandwidthStatistics totalWebappBandwidth) { - this.totalWebappBandwidth = totalWebappBandwidth; - } - - public CartridgeStatistics[] getCartridgeStatistics() { - return cartridgeStatistics; - } - - public void setCartridgeStatistics(CartridgeStatistics[] cartridgeStatistics) { - this.cartridgeStatistics = cartridgeStatistics; - } - - public CartridgeStatistics getTotalCartridgeHours() { - return totalCartridgeHours; - } - - public void setTotalCartridgeHours(CartridgeStatistics totalCartridgeHours) { - this.totalCartridgeHours = totalCartridgeHours; - } - - public TenantUsage() { - // empty method required for used in web services - } - - public TenantUsage(int tenantId, String domain) { - this.tenantId = tenantId; - this.domain = domain; - } - - public int getTenantId() { - return tenantId; - } - - public void setTenantId(int tenantId) { - this.tenantId = tenantId; - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public UsageEntry[] getUsageEntries() { - return usageEntries; - } - - public void setUsageEntries(UsageEntry[] usageEntries) { - this.usageEntries = usageEntries; - } - - public RequestStatistics[] getRequestStatistics() { - return requestStatistics; - } - - public void setRequestStatistics(RequestStatistics[] requestStatistics) { - this.requestStatistics = requestStatistics; - } - - public TenantDataCapacity getRegistryCapacity() { - return registryCapacity; - } - - public void setRegistryCapacity(TenantDataCapacity registryCapacity) { - this.registryCapacity = registryCapacity; - } - - public int getNumberOfUsers() { - return numberOfUsers; - } - - public void setNumberOfUsers(int numberOfUsers) { - this.numberOfUsers = numberOfUsers; - } - - public long getRegistryContentCapacity(){ - long retValue = 0; - if (registryCapacity != null) { - retValue = registryCapacity.getRegistryContentCapacity(); - } - return retValue; - } - - public long getRegistryContentHistoryCapacity(){ - long retValue = 0; - if (registryCapacity != null) { - retValue = registryCapacity.getRegistryContentHistoryCapacity(); - } - return retValue; - } - - public long getTotalIncomingBandwidth(){ - long incomingBW = 0; - if(totalRegistryBandwidth != null){ - incomingBW += totalRegistryBandwidth.getIncomingBandwidth(); - } - if(totalServiceBandwidth != null){ - incomingBW += totalServiceBandwidth.getIncomingBandwidth(); - } - if(totalWebappBandwidth != null){ - incomingBW += totalWebappBandwidth.getIncomingBandwidth(); - } - return incomingBW; - } - - public long getTotalOutgoingBandwidth(){ - long outgoingBW = 0; - if(totalRegistryBandwidth != null){ - outgoingBW += totalRegistryBandwidth.getOutgoingBandwidth(); - } - if(totalServiceBandwidth != null){ - outgoingBW += totalServiceBandwidth.getOutgoingBandwidth(); - } - if(totalWebappBandwidth != null){ - outgoingBW += totalWebappBandwidth.getOutgoingBandwidth(); - } - return outgoingBW; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java b/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java deleted file mode 100644 index 04e8be2..0000000 --- a/components/org.apache.stratos.usage/src/main/java/org/apache/stratos/usage/beans/UsageEntry.java +++ /dev/null @@ -1,49 +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.beans; - -public class UsageEntry { - private String key; - private String value; - - public UsageEntry() { - // empty constructor to used in web services - } - - public UsageEntry(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -}
