Examples of Throttler


Examples of com.splout.db.dnode.Fetcher.Throttler

public class TestFetcher {

  @Test
  public void testThrottling() throws InterruptedException {
    double bytesPerSec = 1000;
    Throttler throttler = new Throttler(bytesPerSec);
    long startTime = System.currentTimeMillis();
   
    int bytesConsumed = 0;
   
    for(int i = 0; i < 10; i++) {
      int bytes = (int)(Math.random() * 1000);
      bytesConsumed += bytes;
      throttler.incrementAndThrottle(bytes)
    }
   
    long endTime = System.currentTimeMillis();
    double secs = (endTime - startTime) / (double)1000;
    double avgBytesPerSec = bytesConsumed / secs;
View Full Code Here

Examples of org.apache.camel.processor.Throttler

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = routeContext.createProcessor(this);
        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = routeContext.createProcessor(this);
        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

        Expression maxRequestsExpression = createMaxRequestsPerPeriodExpression(routeContext);
        if (maxRequestsExpression == null) {
            throw new IllegalArgumentException("MaxRequestsPerPeriod expression must be provided on " + this);
        }

        Throttler answer = new Throttler(childProcessor, maxRequestsExpression, period, scheduled);

        if (getAsyncDelayed() != null) {
            answer.setAsyncDelayed(getAsyncDelayed());
        }
       
        if (getCallerRunsWhenRejected() == null) {
            // should be true by default
            answer.setCallerRunsWhenRejected(true);
        } else {
            answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
        }
        return answer;
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

            if (scheduled == null) {
                scheduled = routeContext.getCamelContext().getExecutorServiceStrategy().newScheduledThreadPool(this, "Throttle");
            }
        }

        Throttler answer = new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis, scheduled);
        if (getAsyncDelayed() != null) {
            answer.setAsyncDelayed(getAsyncDelayed());
        }
        if (getCallerRunsWhenRejected() != null) {
            answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
        }
        return answer;
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

            }
        }

        // should be default 1000 millis
        long period = getTimePeriodMillis() != null ? getTimePeriodMillis() : 1000L;
        Throttler answer = new Throttler(childProcessor, getMaximumRequestsPerPeriod(), period, scheduled);
        if (getAsyncDelayed() != null) {
            answer.setAsyncDelayed(getAsyncDelayed());
        }
        if (getCallerRunsWhenRejected() == null) {
            // should be true by default
            answer.setCallerRunsWhenRejected(true);
        } else {
            answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
        }
        return answer;
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = routeContext.createProcessor(this);
        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = this.createChildProcessor(routeContext, true);
        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = routeContext.createProcessor(this);
        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
    }
View Full Code Here

Examples of org.apache.camel.processor.Throttler

        Expression maxRequestsExpression = createMaxRequestsPerPeriodExpression(routeContext);
        if (maxRequestsExpression == null) {
            throw new IllegalArgumentException("MaxRequestsPerPeriod expression must be provided on " + this);
        }

        Throttler answer = new Throttler(routeContext.getCamelContext(), childProcessor, maxRequestsExpression, period, threadPool, shutdownThreadPool);

        if (getAsyncDelayed() != null) {
            answer.setAsyncDelayed(getAsyncDelayed());
        }
       
        if (getCallerRunsWhenRejected() == null) {
            // should be true by default
            answer.setCallerRunsWhenRejected(true);
        } else {
            answer.setCallerRunsWhenRejected(getCallerRunsWhenRejected());
        }
        return answer;
    }
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.