@@ -0,0 +1,2978 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.%0Apackage com.yahoo.vespa.model.container;%0A%0Aimport com.yahoo.container.bundle.BundleInstantiationSpecification;%0Aimport com.yahoo.container.handler.ThreadPoolProvider;%0Aimport com.yahoo.container.handler.ThreadpoolConfig;%0Aimport com.yahoo.osgi.provider.model.ComponentModel;%0Aimport com.yahoo.vespa.model.container.component.SimpleComponent;%0A%0Aimport java.time.Duration;%0A%0A/**%0A * Component definition for a %7B@link java.util.concurrent.Executor%7D using %7B@link ThreadPoolProvider%7D.%0A *%0A * @author bjorncs%0A */%0Apublic class ThreadPoolExecutorComponent extends SimpleComponent implements ThreadpoolConfig.Producer %7B%0A%0A    private final String name;%0A    private final Integer maxPoolSize;%0A    private final Integer corePoolSize;%0A    private final Duration keepAliveTime;%0A    private final Integer queueSize;%0A    private final Duration maxThreadExecutionTime;%0A%0A    private ThreadPoolExecutorComponent(Builder builder) %7B%0A        super(new ComponentModel(%0A                BundleInstantiationSpecification.getFromStrings(%0A                        %22threadpool-provider@%22 + builder.name,%0A                        ThreadPoolProvider.class.getName(),%0A                        null)));%0A        this.name = builder.name;%0A        this.maxPoolSize = builder.maxPoolSize;%0A        this.corePoolSize = builder.corePoolSize;%0A        this.keepAliveTime = builder.keepAliveTime;%0A        this.queueSize = builder.queueSize;%0A        this.maxThreadExecutionTime = builder.maxThreadExecutionTime;%0A    %7D%0A%0A    @Override%0A    public void getConfig(ThreadpoolConfig.Builder builder) %7B%0A        builder.name(this.name);%0A        if (maxPoolSize != null) builder.maxthreads(maxPoolSize);%0A        if (corePoolSize != null) builder.corePoolSize(corePoolSize);%0A        if (keepAliveTime != null) builder.keepAliveTime(keepAliveTime.toMillis() / 1000D);%0A        if (queueSize != null) builder.queueSize(queueSize);%0A        if (maxThreadExecutionTime != null) builder.maxThreadExecutionTimeSeconds((int)maxThreadExecutionTime.toMillis() / 1000);%0A    %7D%0A%0A    public static class Builder %7B%0A%0A        private final String name;%0A        private Integer maxPoolSize;%0A        private Integer corePoolSize;%0A        private Duration keepAliveTime;%0A        private Integer queueSize;%0A        private Duration maxThreadExecutionTime;%0A%0A        public Builder(String name) %7B this.name = name; %7D%0A%0A        Builder maxPoolSize(int size) %7B this.maxPoolSize = size; return this; %7D%0A        Builder corePoolSize(int size) %7B this.corePoolSize = size; return this; %7D%0A        Builder keepAliveTime(Duration time) %7B this.keepAliveTime = time; return this; %7D%0A        Builder queueSize(int size) %7B this.queueSize = size; return this; %7D%0A        Builder maxThreadExecutionTime(Duration time) %7B this.maxThreadExecutionTime = time; return this; %7D%0A%0A        ThreadPoolExecutorComponent build() %7B return new ThreadPoolExecutorComponent(this); %7D%0A%0A    %7D%0A%7D%0A

Add component definition for ThreadPoolProvider with custom config