Examples of ThreadPoolProfile


Examples of org.apache.camel.spi.ThreadPoolProfile

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // create and register thread pool profile
                ThreadPoolProfile profile = new ThreadPoolProfile("MyThreadPool");
                profile.setPoolSize(8);
                profile.setMaxPoolSize(8);
                profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
                context.getExecutorServiceManager().registerThreadPoolProfile(profile);
               
                for (int i = 0; i < NUM_AGGREGATORS; ++i) {
                    from("direct:start" + i)
                        // aggregate timeout after 3th seconds
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

    }

    public void testBigProfile() throws Exception {
        CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");

        ThreadPoolProfile profile = context.getExecutorServiceManager().getThreadPoolProfile("big");
        assertEquals(50, profile.getPoolSize().intValue());
        assertEquals(100, profile.getMaxPoolSize().intValue());
        assertEquals(ThreadPoolRejectedPolicy.DiscardOldest, profile.getRejectedPolicy());
        assertEquals(null, profile.getKeepAliveTime());
        assertEquals(null, profile.getMaxQueueSize());

        // create a thread pool from big
        ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyBig", "big");
        ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
        assertEquals(50, tp.getCorePoolSize());
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

    }

    public void testLowProfile() throws Exception {
        CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");

        ThreadPoolProfile profile = context.getExecutorServiceManager().getThreadPoolProfile("low");
        assertEquals(1, profile.getPoolSize().intValue());
        assertEquals(5, profile.getMaxPoolSize().intValue());
        assertEquals(null, profile.getKeepAliveTime());
        assertEquals(null, profile.getMaxQueueSize());
        assertEquals(null, profile.getRejectedPolicy());

        // create a thread pool from low
        ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyLow", "low");
        ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
        assertEquals(1, tp.getCorePoolSize());
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

        int queueSize = -1;
        if (maxQueueSize != null) {
            queueSize = CamelContextHelper.parseInteger(getCamelContext(), maxQueueSize);
        }

        ThreadPoolProfile profile = new ThreadPoolProfileBuilder(getId())
                .poolSize(size)
                .maxPoolSize(max)
                .keepAliveTime(keepAlive, timeUnit)
                .maxQueueSize(queueSize)
                .rejectedPolicy(rejectedPolicy)
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

        // lookup and use custom profiles from the registry
        Map<String, ThreadPoolProfile> profiles = context.getRegistry().lookupByType(ThreadPoolProfile.class);
        if (profiles != null && !profiles.isEmpty()) {
            for (Entry<String, ThreadPoolProfile> entry : profiles.entrySet()) {
                ThreadPoolProfile profile = entry.getValue();
                // do not add if already added, for instance a tracer that is also an InterceptStrategy class
                if (profile.isDefaultProfile()) {
                    LOG.info("Using custom default ThreadPoolProfile with id: " + entry.getKey() + " and implementation: " + profile);
                    context.getExecutorServiceManager().setDefaultThreadPoolProfile(profile);
                    defaultIds.add(entry.getKey());
                } else {
                    context.getExecutorServiceManager().registerThreadPoolProfile(profile);
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

     * @param context    the camel context
     * @return           the profile
     * @throws Exception is thrown if error creating the profile
     */
    private ThreadPoolProfile asThreadPoolProfile(CamelContext context, ThreadPoolProfileDefinition definition) throws Exception {
        ThreadPoolProfile answer = new ThreadPoolProfile();
        answer.setId(definition.getId());
        answer.setDefaultProfile(definition.getDefaultProfile());
        answer.setPoolSize(CamelContextHelper.parseInteger(context, definition.getPoolSize()));
        answer.setMaxPoolSize(CamelContextHelper.parseInteger(context, definition.getMaxPoolSize()));
        answer.setKeepAliveTime(CamelContextHelper.parseLong(context, definition.getKeepAliveTime()));
        answer.setMaxQueueSize(CamelContextHelper.parseInteger(context, definition.getMaxQueueSize()));
        answer.setRejectedPolicy(definition.getRejectedPolicy());
        answer.setTimeUnit(definition.getTimeUnit());
        return answer;
    }
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

    private ThreadPoolProfile builtIndefaultProfile;

    public DefaultExecutorServiceManager(CamelContext camelContext) {
        this.camelContext = camelContext;

        builtIndefaultProfile = new ThreadPoolProfile(defaultThreadPoolProfileId);
        builtIndefaultProfile.setDefaultProfile(true);
        builtIndefaultProfile.setPoolSize(10);
        builtIndefaultProfile.setMaxPoolSize(20);
        builtIndefaultProfile.setKeepAliveTime(60L);
        builtIndefaultProfile.setTimeUnit(TimeUnit.SECONDS);
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

        return newScheduledThreadPool(source, name, getDefaultThreadPoolProfile());
    }

    @Override
    public ExecutorService newThreadPool(Object source, String name, String profileId) {
        ThreadPoolProfile profile = getThreadPoolProfile(profileId);
        if (profile != null) {
            return newThreadPool(source, name, profile);
        } else {
            // no profile with that id
            return null;
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

    @Override
    public ExecutorService newThreadPool(Object source, String name, ThreadPoolProfile profile) {
        String sanitizedName = URISupport.sanitizeUri(name);
        ObjectHelper.notNull(profile, "ThreadPoolProfile");

        ThreadPoolProfile defaultProfile = getDefaultThreadPoolProfile();
        profile.addDefaults(defaultProfile);

        ThreadFactory threadFactory = createThreadFactory(sanitizedName, true);
        ExecutorService executorService = threadPoolFactory.newThreadPool(profile, threadFactory);
        onThreadPoolCreated(executorService, source, profile.getId());
View Full Code Here

Examples of org.apache.camel.spi.ThreadPoolProfile

        return executorService;
    }

    @Override
    public ExecutorService newThreadPool(Object source, String name, int poolSize, int maxPoolSize) {
        ThreadPoolProfile profile = new ThreadPoolProfile(name);
        profile.setPoolSize(poolSize);
        profile.setMaxPoolSize(maxPoolSize);
        return  newThreadPool(source, name, profile);
    }
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.