Examples of Endpoint


Examples of org.apache.synapse.endpoints.Endpoint

        System.out.println("Testing dynamic endpoint lookup...");

        // Phase 1
        System.out.println("Testing basic registry lookup functionality...");
        MessageContext synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep1 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep1);
        assertTrue(ep1.isInitialized());
        assertEquals(1, registry.getHitCount());
        assertEquals("http://test.url", ((AddressEndpoint) ep1).getDefinition().getAddress());

        // Phase 2
        System.out.println("Testing basic endpoint caching...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep2 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep2);
        assertEquals(1, registry.getHitCount());
        assertTrue(ep1 == ep2);

        // Phase 3
        System.out.println("Testing advanced endpoint caching...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        System.out.println("Waiting for the cache to expire...");
        Thread.sleep(8500L);
        Endpoint ep3 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep3);
        assertEquals(1, registry.getHitCount());
        assertTrue(ep1 == ep3);

        // Phase 4
        System.out.println("Testing endpoint reloading...");
        registry.updateResource(KEY_DYNAMIC_ENDPOINT_1, TestUtils.createOMElement(DYNAMIC_ENDPOINT_2));
        System.out.println("Waiting for the cache to expire...");
        Thread.sleep(8500L);
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep4 = synCtx.getEndpoint(KEY_DYNAMIC_ENDPOINT_1);
        assertNotNull(ep4);
        assertTrue(ep4.isInitialized());
        assertEquals(2, registry.getHitCount());
        assertEquals("http://test2.url", ((AddressEndpoint) ep4).getDefinition().getAddress());
        assertTrue(ep1 != ep4);
        assertTrue(!ep1.isInitialized());

        // Phase 5
        System.out.println("Testing for non-existing endpoints...");
        synCtx = TestUtils.createSynapseMessageContext("<empty/>", config);
        Endpoint ep5 = synCtx.getEndpoint("non-existing-endpoint");
        assertNull(ep5);

        System.out.println("Dynamic endpoint lookup tests were successful...");
    }
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

        }

        this.totalWeight = totalWeight;

        for (int i = 0; i < endpoints.size(); i++) {
            Endpoint e = endpoints.get(i);
            if (e instanceof PropertyInclude) {
                PropertyInclude include = (PropertyInclude) e;

                MediatorProperty weight = include.getProperty(
                        LB_WEIGHTED_RRLC_WEIGHT);
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

    public Endpoint getEndpoint(String key) {
        Object o = localEntries.get(key);
        if (o != null && o instanceof Endpoint) {
            return (Endpoint) o;
        } else {
            Endpoint e = getConfiguration().getEndpoint(key);
            synchronized (e) {
                if (!e.isInitialized()) {
                    e.init(synEnv);
                }
            }
            localEntries.put(key, e);
            return e;
        }
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

        LoadbalanceAlgorithm algo = endpoint.getAlgorithm();

        String []firstTwoRoundsResults = new String[34];
        for (int i = 0; i < 34; i++) {
            Endpoint epr = algo.getNextEndpoint(messageContext, null);
            if (epr instanceof AddressEndpoint) {
                firstTwoRoundsResults[i] =
                        ((AddressEndpoint)epr).getProperty(
                                WeightedRRLCAlgorithm.LB_WEIGHTED_RRLC_WEIGHT).getValue();
            }
        }

        for (int i = 0; i < 34; i++) {
            assertEquals(firstTwoRoundsExpected[i], firstTwoRoundsResults[i]);
        }

        String []secondTwoRoundsExpected = {
                "6", "6", "6", "6", "5", "5", "5", "5", "5", "5", "5", "3", "3", "3", "3", "2", "2",
                "2", "2", "1", "1", "6", "6", "6", "6", "5", "5", "5", "5", "5", "5", "5", "3", "3"};
        String []secondTwoRoundsResults = new String[34];
        for (int i = 0; i < 34; i++) {
            Endpoint epr = algo.getNextEndpoint(messageContext, null);
            if (epr instanceof AddressEndpoint) {
                secondTwoRoundsResults[i] =
                        ((AddressEndpoint)epr).getProperty(
                                WeightedRRLCAlgorithm.LB_WEIGHTED_RRLC_WEIGHT).getValue();
            }
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

            if (entry.getValue() instanceof SequenceMediator) {
                SequenceMediator seq = (SequenceMediator) entry.getValue();
                seq.setDynamic(true);
                seq.setRegistryKey(entry.getKey());
            } else if (entry.getValue() instanceof Endpoint) {
                Endpoint ep = (Endpoint) entry.getValue();
            }

        } else {
            // if the type of the object is known to have a mapper, create the
            // resultant Object using the known mapper, and cache this Object
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

        }

        Map<String, Endpoint> map = childEndpoints.get(root);
        assert endpointNames != null;
        for (String endpointName : endpointNames) {
            Endpoint endpoint = null;
            if (map != null) {
                endpoint = map.get(endpointName);
                if (endpoint == null || endpoints.contains(endpoint)) {
                    map = childEndpoints.get(endpointName);
                    if (map != null) {
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

            log.debug("For session with id " + id + " : expiry time interval : " + expireTimeWindow);
        }

        long expiryTime = System.currentTimeMillis() + expireTimeWindow;

        Endpoint rootEndpoint = endpoints.get(0);

        SessionInformation information = new SessionInformation(id,
                endpoints, expiryTime);

        if (isClustered) {
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

                    " : expiry time interval : " + expireTimeWindow);
        }

        long expiryTime = System.currentTimeMillis() + expireTimeWindow;

        Endpoint rootEndpoint = endpoints.get(0);

        SessionInformation information = new SessionInformation(id,
                currentMember, expiryTime);

        if (isClustered) {
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

     * @param algorithmContext The context in which holds run time states related to the algorithm
     * @return endpoint to send the next message
     */
    public Endpoint getNextEndpoint(MessageContext synCtx, AlgorithmContext algorithmContext) {

        Endpoint nextEndpoint;
        int attempts = 0;
        synchronized (algorithmContext) {
            int currentEPR = algorithmContext.getCurrentEndpointIndex();
            do {
                // two successive clients could get the same endpoint if not synchronized.
                nextEndpoint = (Endpoint) endpoints.get(currentEPR);

                if (currentEPR == endpoints.size() - 1) {
                    currentEPR = 0;
                } else {
                    currentEPR++;
                }
                algorithmContext.setCurrentEndpointIndex(currentEPR);

                attempts++;
                if (attempts > endpoints.size()) {
                    return null;
                }

            } while (!nextEndpoint.readyToSend());
        }

        return nextEndpoint;
    }
View Full Code Here

Examples of org.apache.synapse.endpoints.Endpoint

        processAuditStatus(sm,elem);

        OMElement epElement = elem.getFirstChildWithName(ENDPOINT_Q);
        if (epElement != null) {
            // create the endpoint and set it in the send mediator
            Endpoint endpoint = EndpointFactory.getEndpointFromElement(epElement, true, properties);
            if (endpoint != null) {
                sm.setEndpoint(endpoint);
            }
        }
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.