com.yahoo.container.handler.ThreadpoolConfig Maven / Gradle / Ivy
/**
* This file is generated from a config definition file.
* ------------ D O N O T E D I T ! ------------
*/
package com.yahoo.container.handler;
import java.util.*;
import java.io.File;
import java.nio.file.Path;
import com.yahoo.config.*;
/**
* This class represents the root node of threadpool
*
* Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
*/
public final class ThreadpoolConfig extends ConfigInstance {
public final static String CONFIG_DEF_MD5 = "1d16fda178819a683ce0672446d90269";
public final static String CONFIG_DEF_NAME = "threadpool";
public final static String CONFIG_DEF_NAMESPACE = "container.handler";
public final static String CONFIG_DEF_VERSION = "";
public final static String[] CONFIG_DEF_SCHEMA = {
"namespace=container.handler",
"maxthreads int default=500",
"maxThreadExecutionTimeSeconds int default=190"
};
public static String getDefMd5() { return CONFIG_DEF_MD5; }
public static String getDefName() { return CONFIG_DEF_NAME; }
public static String getDefNamespace() { return CONFIG_DEF_NAMESPACE; }
public static String getDefVersion() { return CONFIG_DEF_VERSION; }
public interface Producer extends ConfigInstance.Producer {
void getConfig(Builder builder);
}
public static class Builder implements ConfigInstance.Builder {
private Set __uninitialized = new HashSet();
private Integer maxthreads = null;
private Integer maxThreadExecutionTimeSeconds = null;
public Builder() { }
public Builder(ThreadpoolConfig config) {
maxthreads(config.maxthreads());
maxThreadExecutionTimeSeconds(config.maxThreadExecutionTimeSeconds());
}
private Builder override(Builder __superior) {
if (__superior.maxthreads != null)
maxthreads(__superior.maxthreads);
if (__superior.maxThreadExecutionTimeSeconds != null)
maxThreadExecutionTimeSeconds(__superior.maxThreadExecutionTimeSeconds);
return this;
}
public Builder maxthreads(int __value) {
maxthreads = __value;
return this;
}
private Builder maxthreads(String __value) {
return maxthreads(Integer.valueOf(__value));
}
public Builder maxThreadExecutionTimeSeconds(int __value) {
maxThreadExecutionTimeSeconds = __value;
return this;
}
private Builder maxThreadExecutionTimeSeconds(String __value) {
return maxThreadExecutionTimeSeconds(Integer.valueOf(__value));
}
@java.lang.Override
public final boolean dispatchGetConfig(ConfigInstance.Producer producer) {
if (producer instanceof Producer) {
((Producer)producer).getConfig(this);
return true;
}
return false;
}
@java.lang.Override
public final String getDefMd5() { return CONFIG_DEF_MD5; }
@java.lang.Override
public final String getDefName() { return CONFIG_DEF_NAME; }
@java.lang.Override
public final String getDefNamespace() { return CONFIG_DEF_NAMESPACE; }
public ThreadpoolConfig build() {
return new ThreadpoolConfig(this);
}
}
private final IntegerNode maxthreads;
// The max time the container tolerates having no threads available before it shuts down to
// get out of a bad state. This should be set a bit higher than the expected max execution
// time of each request when in a state of overload, i.e about "worst case execution time*2"
private final IntegerNode maxThreadExecutionTimeSeconds;
public ThreadpoolConfig(Builder builder) {
this(builder, true);
}
private ThreadpoolConfig(Builder builder, boolean throwIfUninitialized) {
if (throwIfUninitialized && ! builder.__uninitialized.isEmpty())
throw new IllegalArgumentException("The following builder parameters for " +
"threadpool must be initialized: " + builder.__uninitialized);
maxthreads = (builder.maxthreads == null) ?
new IntegerNode(500) : new IntegerNode(builder.maxthreads);
maxThreadExecutionTimeSeconds = (builder.maxThreadExecutionTimeSeconds == null) ?
new IntegerNode(190) : new IntegerNode(builder.maxThreadExecutionTimeSeconds);
}
/**
* @return threadpool.maxthreads
*/
public int maxthreads() {
return maxthreads.value();
}
/**
* @return threadpool.maxThreadExecutionTimeSeconds
*/
public int maxThreadExecutionTimeSeconds() {
return maxThreadExecutionTimeSeconds.value();
}
private ChangesRequiringRestart getChangesRequiringRestart(ThreadpoolConfig newConfig) {
ChangesRequiringRestart changes = new ChangesRequiringRestart("threadpool");
return changes;
}
private static boolean containsFieldsFlaggedWithRestart() {
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy