Package org.apache.synapse.endpoints.algorithms

Examples of org.apache.synapse.endpoints.algorithms.RoundRobin


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

    public static LoadbalanceAlgorithm createLoadbalanceAlgorithm(OMElement loadbalanceElement, List endpoints) {

        //default algorithm is round robin
        LoadbalanceAlgorithm algorithm = new RoundRobin(endpoints);

        OMAttribute policyAttribute = loadbalanceElement.getAttribute(new QName(null,
                XMLConfigConstants.LOADBALANCE_POLICY));
        OMAttribute algoAttribute = loadbalanceElement.getAttribute(new QName(null,
                XMLConfigConstants.LOADBALANCE_ALGORITHM));

        if (policyAttribute != null && algoAttribute != null) {
            String msg = "You cannot specify both the 'policy' & 'algorithm' in the configuration. " +
                         "It is sufficient to provide only the 'algorithm'.";
            log.fatal(msg); // We cannot continue execution. Hence it is logged at fatal level
            throw new SynapseException(msg);
        }

        if (algoAttribute != null) {
            String algorithmStr = algoAttribute.getAttributeValue().trim();
            try {
                algorithm = (LoadbalanceAlgorithm) Class.forName(algorithmStr).newInstance();
                algorithm.setEndpoints(endpoints);
            } catch (Exception e) {
                String msg = "Cannot instantiate LoadbalanceAlgorithm implementation class " +
                             algorithmStr;
                log.fatal(msg, e); // We cannot continue execution. Hence it is logged at fatal level
                throw new SynapseException(msg, e);
View Full Code Here


        if(algoAttribute != null) {
            algorithmName = algoAttribute.getAttributeValue();
        }

        if(algorithmName.equalsIgnoreCase("roundRobin")) {
                algorithm = new RoundRobin(endpoints);
        }

        return algorithm;
    }
View Full Code Here

                AnonymousListMediator elseMediator = new AnonymousListMediator();
                filterMediator.setElseMediator(elseMediator);
                elseMediator.addChild(new LogMediator());
                elseMediator.addChild(send);
                /* if there are ncew endpoints we are removing the current sequence */
                RoundRobin algorithm = new RoundRobin(childEndpoints);
                lb.setAlgorithm(algorithm);
                /* adding all the endpoints started since the current main sequence is removing */
                if(!"set".equals(System.getProperty("lb.disable"))){
                    lb.setMembers(new ArrayList<Member>(addedEndpointList.values()));
                }
View Full Code Here

        if(algoAttribute != null) {
            algorithmName = algoAttribute.getAttributeValue();
        }

        if(algorithmName.equalsIgnoreCase("roundRobin")) {
                algorithm = new RoundRobin(endpoints);
        }

        return algorithm;
    }
View Full Code Here

        if(algoAttribute != null) {
            algorithmName = algoAttribute.getAttributeValue();
        }

        if(algorithmName.equalsIgnoreCase("roundRobin")) {
                algorithm = new RoundRobin(endpoints);
        }

        return algorithm;
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.endpoints.algorithms.RoundRobin

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.