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 + ".";