Examples of SystemMeteringAgent


Examples of org.wso2.carbon.usage.agent.api.SystemMeteringAgent

    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
        return registryService.getGovernanceSystemRegistry();
    }

    public static SystemMeteringAgent getSystemMeteringAgent() throws RegistryException {
        return new SystemMeteringAgent(getSuperTenantGovernanceSystemRegistry());
    }
View Full Code Here

Examples of org.wso2.carbon.usage.agent.api.SystemMeteringAgent

    private static final Log log = LogFactory.getLog(Alpha1.class);

    public void migrate() throws Exception {
        // changes to the data model for the statics.
        TenantManager tenantManager = Util.getRealmService().getTenantManager();
        SystemMeteringAgent meteringAgent = Util.getSystemMeteringAgent();

        //get super tenant governance registry
        UserRegistry superTenantGovernanceRegistry = Util.getSuperTenantGovernanceSystemRegistry();
        if (!superTenantGovernanceRegistry.resourceExists(OLD_BANDWIDTH_USE_STORE_PATH)) {
            return;
        }

        Tenant[] tenants = tenantManager.getAllTenants();
        // uses only the current year month 2010-july
        String yearMonth = CommonUtil.getCurrentMonthString();
        for (Tenant tenant : tenants) {
            int tenantId = tenant.getId();
            long incomingBw = getOldIncomingRegistryBandwidth(yearMonth, tenantId);
            long outgoingBw = getOldOutgoingRegistryBandwidth(yearMonth, tenantId);

            if (incomingBw != 0) {
                meteringAgent.persistUsage(tenantId, yearMonth,
                        UsageConstants.REGISTRY_INCOMING_BW, incomingBw + "");
            }
            if (outgoingBw != 0) {
                meteringAgent.persistUsage(tenantId, yearMonth,
                        UsageConstants.REGISTRY_OUTGOING_BW, outgoingBw + "");
            }
            log.info("Migrating registry bandwidth data to the new data model. tenant id: " +
                    tenantId + ".");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.