Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.LoadbalanceEndpoint


                out.addChild(new SendMediator());
                mainSeq.addChild(in);
                mainSeq.addChild(out);

                SendMediator send = new SendMediator();
                LoadbalanceEndpoint lb = new LoadbalanceEndpoint();

                FilterMediator filterMediator = new FilterMediator();
                in.addChild(filterMediator);
                SynapseXPath xpath = new SynapseXPath("get-property('To')");
                filterMediator.setSource(xpath);
                filterMediator.setRegex(Pattern.compile("/carbon"));

                PropertyMediator httpSCProperty = new PropertyMediator();
                httpSCProperty.setName("HTTP_SC");
                httpSCProperty.setScope("axis2");
                httpSCProperty.setValue("302");

                PropertyMediator locationHeader = new PropertyMediator();
                locationHeader.setName("Location");
                locationHeader.setScope("transport");
                locationHeader.setValue(getMasterHttpsEndpoint(PortSelector.normalEndpointList));

                PropertyMediator responseProperty = new PropertyMediator();
                responseProperty.setName(SynapseConstants.RESPONSE);
                responseProperty.setValue("true");

                HeaderMediator headerMediator = new HeaderMediator();
                headerMediator.setQName(new QName("To"));
                headerMediator.setAction(1);

                SendMediator sendMediator = new SendMediator();
                DropMediator dropMediator = new DropMediator();

                filterMediator.addChild(locationHeader);
                filterMediator.addChild(httpSCProperty);
                filterMediator.addChild(responseProperty);
                filterMediator.addChild(headerMediator);
                filterMediator.addChild(sendMediator);
                filterMediator.addChild(dropMediator);

                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()));
                }
                send.setEndpoint(lb);
                //in.addChild(send);
                synCfg.addSequence(mainSeq.getName(), mainSeq);
                if(!"set".equals(System.getProperty("lb.disable"))){
View Full Code Here


        initEndpoint(endpoint2, null);

        synapseConfig.addEndpoint(endpoint1.getName(), endpoint1);
        synapseConfig.addEndpoint(endpoint2.getName(), endpoint2);

        LoadbalanceEndpoint lb = new LoadbalanceEndpoint();
        lb.setName("lb");
        lb.setDefinition(new EndpointDefinition());

        IndirectEndpoint child1 = new IndirectEndpoint();
        child1.setKey(endpoint1.getName());
        IndirectEndpoint child2 = new IndirectEndpoint();
        child2.setKey(endpoint2.getName());
        Endpoint child3 = createEndpoint("baz");

        List<Endpoint> children = new ArrayList<Endpoint>();
        children.add(child1);
        children.add(child2);
        children.add(child3);
        lb.setChildren(children);

        synapseConfig.addEndpoint(lb.getName(), lb);
        assertDependency(ConfigurationObject.TYPE_ENDPOINT, child1.getKey(), lb.getName());
        assertDependency(ConfigurationObject.TYPE_ENDPOINT, child2.getKey(), lb.getName());
        assertNoDependency(ConfigurationObject.TYPE_ENDPOINT, child3.getName());
    }
View Full Code Here

        SendMediator send2 = (SendMediator) factory.createMediator(config2);

        assertTrue("Top level endpoint should be a load balance endpoint.",
                send2.getEndpoint() instanceof LoadbalanceEndpoint);

        LoadbalanceEndpoint endpoint = (LoadbalanceEndpoint) send2.getEndpoint();
        List addresses = endpoint.getEndpoints();
        assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);

        assertTrue("Leaf level endpoints should be address endpoints",
                addresses.get(0) instanceof AddressEndpoint);
        assertTrue("Leaf level endpoints should be address endpoints",
View Full Code Here

        SendMediator send2 = (SendMediator) factory.createMediator(config2);

        assertTrue("Top level endpoint should be a load balance endpoint.",
                send2.getEndpoint() instanceof LoadbalanceEndpoint);

        LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) send2.getEndpoint();

        List children = loadbalanceEndpoint.getEndpoints();
        assertEquals("Top level endpoint should have 2 child endpoints.", children.size(), 2);

        assertTrue("First child should be a address endpoint",
                children.get(0) instanceof AddressEndpoint);
View Full Code Here

        loadbalanceElement = epConfig.getFirstChildWithName
                (new QName(Constants.SYNAPSE_NAMESPACE, "loadbalance"));

        if(loadbalanceElement != null) {

            LoadbalanceEndpoint loadbalanceEndpoint = new LoadbalanceEndpoint();

            // set endpoint name
            OMAttribute name = epConfig.getAttribute(new QName(
                    org.apache.synapse.config.xml.Constants.NULL_NAMESPACE, "name"));

            if (name != null) {
                loadbalanceEndpoint.setName(name.getAttributeValue());
            }

            // set endpoints
            ArrayList endpoints = getEndpoints(loadbalanceElement, loadbalanceEndpoint);
            loadbalanceEndpoint.setEndpoints(endpoints);

            // set load balance algorithm
            LoadbalanceAlgorithm algorithm = LoadbalanceAlgorithmFactory.
                    createLoadbalanceAlgorithm(loadbalanceElement, endpoints);
            loadbalanceEndpoint.setAlgorithm(algorithm);

            // set if failover is turned off
            String failover = loadbalanceElement.getAttributeValue(new QName("failover"));
            if (failover != null && failover.equalsIgnoreCase("false")) {
                loadbalanceEndpoint.setFailover(false);
            }

            return loadbalanceEndpoint;
        }
View Full Code Here

        }

        fac = OMAbstractFactory.getOMFactory();
        OMElement endpointElement = fac.createOMElement("endpoint", Constants.SYNAPSE_OMNAMESPACE);

        LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) endpoint;

        String name = loadbalanceEndpoint.getName();
        if (name != null) {
            endpointElement.addAttribute("name", name, null);
        }

        OMElement loadbalanceElement = fac.createOMElement("loadbalance", Constants.SYNAPSE_OMNAMESPACE);
        endpointElement.addChild(loadbalanceElement);

        LoadbalanceAlgorithm algorithm = loadbalanceEndpoint.getAlgorithm();
        String algorithmName = "roundRobin";
        if (algorithm instanceof RoundRobin) {
             algorithmName = "roundRobin";
        }
        loadbalanceElement.addAttribute
                (org.apache.synapse.config.xml.Constants.ALGORITHM_NAME, algorithmName, null);

        // set if failover is turned off in the endpoint
        if (!loadbalanceEndpoint.isFailover()) {
            loadbalanceElement.addAttribute("failover", "false", null);
        }

        List endpoints = loadbalanceEndpoint.getEndpoints();
        for (int i = 0; i < endpoints.size(); i++) {
            Endpoint childEndpoint = (Endpoint) endpoints.get(i);
            EndpointSerializer serializer = EndpointAbstractSerializer.
                    getEndpointSerializer(childEndpoint);
            OMElement aeElement = serializer.serializeEndpoint(childEndpoint);
View Full Code Here

        }

        fac = OMAbstractFactory.getOMFactory();
        OMElement endpointElement = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE);

        LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) endpoint;

        String name = loadbalanceEndpoint.getName();
        if (name != null) {
            endpointElement.addAttribute("name", name, null);
        }

        OMElement loadbalanceElement = fac.createOMElement("loadbalance", SynapseConstants.SYNAPSE_OMNAMESPACE);
        endpointElement.addChild(loadbalanceElement);

        LoadbalanceAlgorithm algorithm = loadbalanceEndpoint.getAlgorithm();
        String algorithmName = "roundRobin";
        if (algorithm instanceof RoundRobin) {
             algorithmName = "roundRobin";
        }
        loadbalanceElement.addAttribute
                (org.apache.synapse.config.xml.XMLConfigConstants.ALGORITHM_NAME, algorithmName, null);

        // set if failover is turned off in the endpoint
        if (!loadbalanceEndpoint.isFailover()) {
            loadbalanceElement.addAttribute("failover", "false", null);
        }

        List endpoints = loadbalanceEndpoint.getEndpoints();
        for (int i = 0; i < endpoints.size(); i++) {
            Endpoint childEndpoint = (Endpoint) endpoints.get(i);
            EndpointSerializer serializer = EndpointAbstractSerializer.
                    getEndpointSerializer(childEndpoint);
            OMElement aeElement = serializer.serializeEndpoint(childEndpoint);
View Full Code Here

        loadbalanceElement = epConfig.getFirstChildWithName
                (new QName(SynapseConstants.SYNAPSE_NAMESPACE, "loadbalance"));

        if(loadbalanceElement != null) {

            LoadbalanceEndpoint loadbalanceEndpoint = new LoadbalanceEndpoint();

            // set endpoint name
            OMAttribute name = epConfig.getAttribute(new QName(
                    org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "name"));

            if (name != null) {
                loadbalanceEndpoint.setName(name.getAttributeValue());
            }

            // set endpoints
            ArrayList endpoints = getEndpoints(loadbalanceElement, loadbalanceEndpoint);
            loadbalanceEndpoint.setEndpoints(endpoints);

            // set load balance algorithm
            LoadbalanceAlgorithm algorithm = LoadbalanceAlgorithmFactory.
                    createLoadbalanceAlgorithm(loadbalanceElement, endpoints);
            loadbalanceEndpoint.setAlgorithm(algorithm);

            // set if failover is turned off
            String failover = loadbalanceElement.getAttributeValue(new QName("failover"));
            if (failover != null && failover.equalsIgnoreCase("false")) {
                loadbalanceEndpoint.setFailover(false);
            }

            return loadbalanceEndpoint;
        }
View Full Code Here

        SendMediator send2 = (SendMediator) factory.createMediator(config2);

        assertTrue("Top level endpoint should be a load balance endpoint.",
                send2.getEndpoint() instanceof LoadbalanceEndpoint);

        LoadbalanceEndpoint endpoint = (LoadbalanceEndpoint) send2.getEndpoint();
        List addresses = endpoint.getEndpoints();
        assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);

        assertTrue("Leaf level endpoints should be address endpoints",
                addresses.get(0) instanceof AddressEndpoint);
        assertTrue("Leaf level endpoints should be address endpoints",
View Full Code Here

        SendMediator send2 = (SendMediator) factory.createMediator(config2);

        assertTrue("Top level endpoint should be a load balance endpoint.",
                send2.getEndpoint() instanceof LoadbalanceEndpoint);

        LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) send2.getEndpoint();

        List children = loadbalanceEndpoint.getEndpoints();
        assertEquals("Top level endpoint should have 2 child endpoints.", children.size(), 2);

        assertTrue("First child should be a address endpoint",
                children.get(0) instanceof AddressEndpoint);
View Full Code Here

TOP

Related Classes of org.apache.synapse.endpoints.LoadbalanceEndpoint

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.