public class TaskEnvRouter
extends java.lang.Object
TaskEnvRouter which handles forwarding environment variables from two sources:
"TASKCFG_<TASKTYPE>_"
and/or "TASKCFG_ALL_", and returns appropriate Maps for task types based on that environment.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TASKCFG_GLOBAL_ENV_PREFIX |
| Constructor and Description |
|---|
TaskEnvRouter()
Creates a new config router which uses the current system environment for its configuration.
|
TaskEnvRouter(java.util.Map<java.lang.String,java.lang.String> envConfig)
Creates a new config router which uses the provided environment variables, which should have
TASKCFG_*
prefixes. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.String> |
getConfig(java.lang.String podType)
Returns the config to be injected into tasks with the provided
podType. |
TaskEnvRouter |
setAllPodsEnv(java.lang.String key,
java.lang.String value)
Adds a custom environment value to be included in all pods.
|
TaskEnvRouter |
setPodEnv(java.lang.String podType,
java.lang.String key,
java.lang.String value)
Adds a custom environment variable to be only included in the specified pod type.
|
java.lang.String |
toString() |
public static final java.lang.String TASKCFG_GLOBAL_ENV_PREFIX
public TaskEnvRouter()
System.getenv()public TaskEnvRouter(java.util.Map<java.lang.String,java.lang.String> envConfig)
TASKCFG_*
prefixes.public TaskEnvRouter setAllPodsEnv(java.lang.String key, java.lang.String value)
TASKCFG_ALL_* or TASKCFG_<POD_TYPE>_* envvars, and by any per-pod types added via
setPodEnv(String, String, String).public TaskEnvRouter setPodEnv(java.lang.String podType, java.lang.String key, java.lang.String value)
TASKCFG_ALL_* or TASKCFG_<POD_TYPE>_* envvars. This takes precedence
over values specified via setAllPodsEnv(String, String) for pods with this type.public java.util.Map<java.lang.String,java.lang.String> getConfig(java.lang.String podType)
podType.
For example, given a task with type "index", this would match scheduler environment variables starting with
"TASKCFG_ALL_" and "TASKCFG_INDEX_" (with those prefixes removed), as well as any appropriate envvars which were
passed in via the Java API (with no modification). The prior takes priority over the latter.podType - the pod type to be matched againstpodType, or an empty map otherwisepublic java.lang.String toString()
toString in class java.lang.Object