Examples of ThrottleConfiguration


Examples of org.wso2.throttle.ThrottleConfiguration

                    //loads the ThrottleContext
                    ThrottleContext context =
                            throttle.getThrottleContext(ThrottleConstants.DOMAIN_BASED_THROTTLE_KEY);
                    if (context != null) {
                        //Loads the ThrottleConfiguration
                        ThrottleConfiguration config = context.getThrottleConfiguration();
                        if (config != null) {
                            //check for configuration for this caller
                            callerId = config.getConfigurationKeyOfCaller(domain);
                            if (callerId != null) {
                                // If this is a clustered env.
                                if (isClusteringEnable) {
                                    context.setConfigurationContext(cc);
                                    context.setThrottleId(throttleId);
                                }
                                AccessInformation infor =
                                        accessRateController.canAccess(context, callerId,
                                                ThrottleConstants.DOMAIN_BASE);

                                //check for the permission for access
                                if (!infor.isAccessAllowed()) {

                                    //In the case of both of concurrency throttling and
                                    //rate based throttling have enabled ,
                                    //if the access rate less than maximum concurrent access ,
                                    //then it is possible to occur death situation.To avoid that reset,
                                    //if the access has denied by rate based throttling
                                    if (cac != null) {
                                        cac.incrementAndGet();
                                        // set back if this is a clustered env
                                        if (isClusteringEnable) {
                                            cc.setProperty(key, cac);
                                            //replicate the current state of ConcurrentAccessController
                                            try {
                                                if (debugOn) {
                                                    log.debug("Going to replicates the " +
                                                            "states of the ConcurrentAccessController" +
                                                            " with key : " + key);
                                                }
                                                Replicator.replicate(cc, new String[]{key});
                                            } catch (ClusteringFault clusteringFault) {
                                                log.error("Error during replicating states ",
                                                        clusteringFault);
                                            }
                                        }
                                    }
                                    throw new AxisFault(" Access deny for a " +
                                            "caller with Domain " + domain + " " +
                                            " : Reason : " + infor.getFaultReason());
                                }
                            } else {
                                if (debugOn) {
                                    log.debug("Could not find the Throttle Context for domain-Based " +
                                            "Throttling for domain name " + domain + " Throttling for this " +
                                            "domain name may not be configured from policy");
                                }
                            }
                        }
                    }
                } else {
                    if (debugOn) {
                        log.debug("Could not find the domain of the caller - IP-based throttling may occur");
                    }
                }

                //IP based throttling - Only if there is no configuration for caller domain name

                if (callerId == null) {
                    String ip = (String) messageContext.getProperty(MessageContext.REMOTE_ADDR);
                    if (ip != null) {
                        // loads IP based throttle context
                        ThrottleContext context =
                                throttle.getThrottleContext(ThrottleConstants.IP_BASED_THROTTLE_KEY);
                        if (context != null) {
                            //Loads the ThrottleConfiguration
                            ThrottleConfiguration config = context.getThrottleConfiguration();
                            if (config != null) {
                                // check for configuration for this ip
                                callerId = config.getConfigurationKeyOfCaller(ip);
                                if (callerId != null) {
                                    // for clustered env.
                                    if (isClusteringEnable) {
                                        context.setConfigurationContext(cc);
                                        context.setThrottleId(throttleId);
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.