Package org.switchyard.metadata.qos

Examples of org.switchyard.metadata.qos.Throttling


        }
        return result;
    }
   
    private void addThrottling(TryDefinition route) {
        Throttling throttling = _reference.getServiceMetadata().getThrottling();
        long timePeriodMS = throttling != null ? throttling.getTimePeriod() : Throttling.DEFAULT_TIME_PERIOD;
        route.filter(THROTTLE_CHECK)
            .throttle(header(Throttling.MAX_REQUESTS)).timePeriodMillis(timePeriodMS)
            // throttle needs a child process, so we'll just remove the header
            // using an empty process definition causes some of the interceptors
            // to blow chunks, specifically audit interceptors
View Full Code Here


        // bus route.
        if (!exchange.getPhase().equals(ExchangePhase.IN)) {
            return;
        }

        Throttling throttling = _reference.getServiceMetadata().getThrottling();
        if (throttling != null && throttling.getMaxRequests() > 0) {
            exchange.getMessage().getContext().setProperty(
                    Throttling.MAX_REQUESTS, throttling.getMaxRequests())
                    .addLabels(BehaviorLabel.TRANSIENT.label());
        }
        _producer.send("direct:" + exchange.getConsumer().getName(), camelEx.getExchange());
       
    }
View Full Code Here

        Registrant registrant = new MockRegistrant();
        List<Policy> required = new LinkedList<Policy>();
        required.add(TransactionPolicy.SUSPENDS_TRANSACTION);
        List<Policy> provided = new LinkedList<Policy>();
        provided.add(TransactionPolicy.PROPAGATES_TRANSACTION);
        Throttling throttling = new Throttling();
       
        // add them to service metadata
        ServiceMetadata metadata = ServiceMetadataBuilder.create()
            .providedPolicies(provided)
            .requiredPolicies(required)
View Full Code Here

        Assert.assertEquals(provided.get(0), metadata.getProvidedPolicies().get(0));
    }
   
    @Test
    public void testUpdate() {
        Throttling throttling1 = new Throttling().setMaxRequests(50);
        ServiceMetadata metadata = ServiceMetadataBuilder.create()
                .throttling(throttling1)
                .build();
       
        Assert.assertEquals(50, metadata.getThrottling().getMaxRequests());
       
        Throttling throttling2 = new Throttling().setMaxRequests(150);
        ServiceMetadataBuilder.update(metadata).throttling(throttling2);
        Assert.assertEquals(150, metadata.getThrottling().getMaxRequests());
    }
View Full Code Here

        final Service service = new MockService(name, new InOnlyService(), sink);
        final ServiceReference reference = new ServiceReferenceImpl(name, new InOnlyService(), null, null);
        final ExchangeDispatcher dispatch = _provider.createDispatcher(reference);
       
        // Set throttling to 1 per second
        Throttling throttle = new Throttling().setMaxRequests(1);
        ServiceMetadataBuilder.update(reference.getServiceMetadata()).throttling(throttle);
               
        final int NUM_SENDS = 5;
        for (int i = 0; i < NUM_SENDS; i++) {
            new Thread(new Runnable() {
View Full Code Here

        QName name = new QName("testThrottleTimePeriod");
        final ExchangeSink sink = new ExchangeSink();
        final Service service = new MockService(name, new InOnlyService(), sink);
        final ServiceReference reference = new ServiceReferenceImpl(name, new InOnlyService(), null, null);
        // Set throttling to 1 per minute (60000 ms)
        Throttling throttle = new Throttling().setMaxRequests(1).setTimePeriod(60 * 1000);
        ServiceMetadataBuilder.update(reference.getServiceMetadata()).throttling(throttle);
       
        final ExchangeDispatcher dispatch = _provider.createDispatcher(reference);
               
        final int NUM_SENDS = 5;
View Full Code Here

        final ThrottlingModel throttling = extensions.getThrottling();
        if (throttling == null) {
            return null;
        }
        final Long timePeriod = throttling.getTimePeriod();
        final Throttling retVal = new Throttling();
        retVal.setMaxRequests(throttling.getMaxRequests());
        if (timePeriod != null) {
            retVal.setTimePeriod(timePeriod);
        }
        return retVal;
    }
View Full Code Here

TOP

Related Classes of org.switchyard.metadata.qos.Throttling

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.