Package org.apache.stratos.usage.beans

Examples of org.apache.stratos.usage.beans.TenantUsage


        String userName = dataContext.getUserName();
        String yearMonth = Util.getCurrentMonthString(Calendar.getInstance());
        TenantUsageRetriever tenantUsageRetriever = Util.getTenantUsageRetriever();
       
        try {
            TenantUsage usage = tenantUsageRetriever.getTenantUsage(tenantId, yearMonth);
           
            //Bandwidth usages
            long tenantIncomingBandwidth = usage.getTotalIncomingBandwidth();
            long tenantOutgoingBandwidth = usage.getTotalOutgoingBandwidth();
            dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_INCOMING_BANDWIDTH,
                    tenantIncomingBandwidth);
            dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_OUTGOING_BANDWIDTH,
                    tenantOutgoingBandwidth);
           
            //Registry space capacity
            long currentTenantCapacity = usage.getRegistryContentCapacity();
            long historyTenantCapacity = usage.getRegistryContentHistoryCapacity();
            dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_CAPACITY,
                    currentTenantCapacity);
            dataContext.addDataLong(ThrottlingDataEntryConstants.TENANT_HISTORY_CAPACITY,
                    historyTenantCapacity);
            //Assigning registry bandwidths
            BandwidthStatistics totalRgistryBW=usage.getTotalRegistryBandwidth();
            dataContext.addDataLong(ThrottlingDataEntryConstants.REGISTRY_INCOMING_BANDWIDTH,
                    totalRgistryBW.getIncomingBandwidth());
            dataContext.addDataLong(ThrottlingDataEntryConstants.REGISTRY_OUTGOING_BANDWIDTH,
                    totalRgistryBW.getOutgoingBandwidth());

            //Assigning service bandwidths
            BandwidthStatistics serviceBWStatistic=usage.getTotalServiceBandwidth();
            dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_INCOMING_BANDWIDTH,
                    serviceBWStatistic.getIncomingBandwidth());
            dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_OUTGOING_BANDWIDTH,
                    serviceBWStatistic.getOutgoingBandwidth());
           
            //Assigning webapp bandwidths
            BandwidthStatistics webappBWStatistic = usage.getTotalWebappBandwidth();
            dataContext.addDataLong(ThrottlingDataEntryConstants.WEBAPP_INCOMING_BANDWIDTH,
                    webappBWStatistic.getIncomingBandwidth());
            dataContext.addDataLong(ThrottlingDataEntryConstants.WEBAPP_OUTGOING_BANDWIDTH,
                    webappBWStatistic.getOutgoingBandwidth());
           
            //Assigning service requests and response
            RequestStatistics requestStat = usage.getTotalRequestStatistics();
            dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_REQUEST_COUNT,
                    requestStat.getRequestCount());
            dataContext.addDataLong(ThrottlingDataEntryConstants.SERVICE_RESPONSE_COUNT,
                    requestStat.getResponseCount());
           
            //Get number of users
            int usersCount = usage.getNumberOfUsers();
            dataContext.addDataInt(ThrottlingDataEntryConstants.USERS_COUNT, usersCount);

        } catch (Exception e) {
            String msg = "Error in retrieving Usage information. " + "tenant id: " + tenantId
                    + ", user name: " + userName + ".";
View Full Code Here


        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()]);
View Full Code Here

            if (tenant.isActive()) {
                if (i % entriesPerPage == 0) {
                    numberOfPages++;
                }
                if (numberOfPages == pageNumber) {
                    TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
                            tenant.getId(), yearMonth);
                    tenantUsages.add(tenantUsage);
                }
                i++;
            }
View Full Code Here

TOP

Related Classes of org.apache.stratos.usage.beans.TenantUsage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.