Examples of ThrottlePolicy


Examples of org.wso2.carbon.throttle.ThrottlePolicy

        }
        //get the axis service
        AxisService service = this.getAxisService(serviceName);

        //object to be returned
        ThrottlePolicy currentConfig = new ThrottlePolicy();

        //Set whether module is currently engaged or not
        AxisModule module = service.getAxisConfiguration()
                .getModule(ThrottleComponentConstants.THROTTLE_MODULE);
        currentConfig.setEngaged(service.isEngaged(module));

        XmlPrimtiveAssertion assertion = this.getThrottlePolicy(service
                .getPolicySubject().getAttachedPolicyComponents());

        return preparePolicyConfigs(assertion, currentConfig);
View Full Code Here

Examples of org.wso2.carbon.throttle.ThrottlePolicy

        if (log.isDebugEnabled()) {
            log.debug("Extracting current global policy configurations");
        }

        //object to be returned
        ThrottlePolicy currentConfig = new ThrottlePolicy();

        //Set whether module is currently engaged or not
        AxisModule module = this.axisConfig
                .getModule(ThrottleComponentConstants.THROTTLE_MODULE);

        Parameter param = module.getParameter(GLOBALLY_ENGAGED_PARAM_NAME);
        if (param != null) {
            String globallyEngaged = (String) param.getValue();
            if (globallyEngaged != null && globallyEngaged.length() != 0) {
                currentConfig.setEngaged(Boolean.parseBoolean(globallyEngaged.trim()));
            }
        }

        XmlPrimtiveAssertion assertion = this.getThrottlePolicy(module
                .getPolicySubject().getAttachedPolicyComponents());
View Full Code Here

Examples of org.wso2.carbon.throttle.ThrottlePolicy

                    + ", in service : " + serviceName);
            throw new ThrottleComponentException("noSuchOperation", new String[]{serviceName});
        }

        //object to be returned
        ThrottlePolicy currentConfig = new ThrottlePolicy();

        //Set whether module is currently engaged or not
        AxisModule module = service.getAxisConfiguration()
                .getModule(ThrottleComponentConstants.THROTTLE_MODULE);
        currentConfig.setEngaged((operation.isEngaged(module) || service.isEngaged(module)));

        XmlPrimtiveAssertion assertion = null;
        if (service.isEngaged(module)) {
            assertion = this.getThrottlePolicy(service
                    .getPolicySubject().getAttachedPolicyComponents());
View Full Code Here

Examples of org.wso2.carbon.throttle.ThrottlePolicy

            Policy policy = PolicyEngine.getPolicy(policyOM);
            List<Policy> list = new ArrayList<Policy>();
            list.add(policy);
            XmlPrimtiveAssertion assertion = this.getThrottlePolicy(list);

            return preparePolicyConfigs(assertion, new ThrottlePolicy());
        } catch (Exception e) {
            throw new ThrottleComponentException("Invalid policy XML ", e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.throttle.ThrottlePolicy

        ArrayList<InternalData> internalConfigs = new ArrayList<InternalData>();
        Policy throttlePolicy;

        if (assertion == null) {
            //if no policy exists, just return an empty config
            return new ThrottlePolicy();
        } else {
            throttlePolicy = PolicyEngine.getPolicy(assertion.getValue());
        }

        //Fill data into the ThrottlePolicy object by going through existing policy
View Full Code Here

Examples of org.wso2.carbon.throttle.stub.types.ThrottlePolicy

                for (int p = 0; p < list.size(); p++) {
                    data[p] = list.get(p);
                }

                //Create a ThrottlePolicy object to be sent
                ThrottlePolicy policy = new ThrottlePolicy();
                policy.setEngaged(true);
                policy.setInternalConfigs(data);
                if (request.getParameter("maxAccess") != null &&
                        !request.getParameter("maxAccess").equals("")) {
                    policy.setMaxConcurrentAccesses(Integer.parseInt(request.getParameter("maxAccess")));
                }
                if (global) {
                    stub.globallyEngageThrottling(policy);
                } else if (operationLevel) {
                    engagedAtHigherLevel = stub.engageThrottlingForOperation(policy, service, operation);
View Full Code Here

Examples of org.wso2.carbon.throttle.stub.types.ThrottlePolicy


    public ThrottlePolicy getExistingConfigs(HttpServletRequest request,
                                             boolean global, boolean operationLevel) throws AxisFault {

        ThrottlePolicy policy = null;
        try {
            String service = request.getParameter("serviceName");
            String operation = request.getParameter("opName");
            String loadDef = request.getParameter("loadDefault");

            ThrottlePolicy defThrottlePolicy= getDefaultThrottlePolicy();
            if (loadDef != null && loadDef.equals("true")) {
                //Set a default policy
                defThrottlePolicy.setEngaged(true);
                policy = defThrottlePolicy;
            } else {
                if (global) {
                    policy = stub.getGlobalPolicyConfigs();
                } else if (operationLevel) {
View Full Code Here

Examples of org.wso2.carbon.throttle.stub.types.ThrottlePolicy

    public String throttlePolicyToString(ThrottlePolicy throttlePolicy) throws RemoteException, ThrottleComponentExceptionException {
        return stub.throttlePolicyToString(throttlePolicy);
    }

    private ThrottlePolicy getDefaultThrottlePolicy() {
        ThrottlePolicy defThrottlePolicy = new ThrottlePolicy();
        InternalData[] defData = new InternalData[2];
        defThrottlePolicy.setInternalConfigs(defData);
        defData[0] = new InternalData();
        defData[0].setRange("other");
        defData[0].setRangeType("IP");
        defData[0].setAccessLevel(2);
View Full Code Here

Examples of org.wso2.carbon.throttle.stub.types.ThrottlePolicy

            proxyServiceAdminStub.addProxy(proxyData);

            log.info("Proxy service added");


            ThrottlePolicy throttlePolicy = new ThrottlePolicy();

            InternalData[] internalDatas = new InternalData[1];

            InternalData data = new InternalData();

            data.setMaxRequestCount(6);
            data.setProhibitTimePeriod(10000);
            data.setRange("other");
            data.setAccessLevel(0);
            data.setRangeType("IP");
            data.setUnitTime(10000);

            internalDatas[0] = data;

            throttlePolicy.setInternalConfigs(internalDatas);
            throttleAdminServiceStub.enableThrottling("StockQuoteProxyTest", throttlePolicy);


            for (int i = 0; i <= 7; i++) {
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.