Package alluxio.conf
Class Configuration
- java.lang.Object
-
- alluxio.conf.Configuration
-
public final class Configuration extends java.lang.Object
Global configuration properties of Alluxio. This class works like a dictionary and serves each Alluxio configuration property as a key-value pair.
Alluxio configuration properties are loaded into this class in the following order with decreasing priority:
- Java system properties;
- Environment variables via
alluxio-env.sh
or from OS settings; - Site specific properties via
alluxio-site.properties
file;
The default properties are defined in the
PropertyKey
class in the codebase. Alluxio users can override values of these default properties by creatingalluxio-site.properties
and putting it under javaCLASSPATH
when running Alluxio (e.g., ${ALLUXIO_HOME}/conf/)This class defines many convenient static methods which delegate to an internal
InstancedConfiguration
. To use this global configuration in a method that takesAlluxioConfiguration
as an argument, passglobal()
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InstancedConfiguration
copyGlobal()
static AlluxioProperties
copyProperties()
Create and return a copy of all properties.static java.lang.Object
get(PropertyKey key)
Gets the value for the given key in theProperties
; if this key is not found, a RuntimeException is thrown.static java.lang.Object
get(PropertyKey key, ConfigurationValueOptions options)
Gets the value for the given key in theProperties
; if this key is not found, a RuntimeException is thrown.static boolean
getBoolean(PropertyKey key)
Gets the boolean representation of the value for the given key.static long
getBytes(PropertyKey key)
Gets the bytes of the value for the given key.static <T> java.lang.Class<T>
getClass(PropertyKey key)
Gets the value for the given key as a class.static InstancedConfiguration
getClusterConf(alluxio.grpc.GetConfigurationPResponse response, AlluxioConfiguration conf, alluxio.grpc.Scope scope)
Loads the cluster level configuration from the get configuration response, filters out the configuration for certain scope, and merges it with the existing configuration.static java.util.List<alluxio.grpc.ConfigProperty>
getConfiguration(alluxio.grpc.Scope scope)
Gets all configuration properties filtered by the specified scope.static double
getDouble(PropertyKey key)
Gets the double representation of the value for the given key.static java.time.Duration
getDuration(PropertyKey key)
Gets the time of the key as a duration.static <T extends java.lang.Enum<T>>
TgetEnum(PropertyKey key, java.lang.Class<T> enumType)
Gets the value for the given key as an enum value.static int
getInt(PropertyKey key)
Gets the integer representation of the value for the given key.static java.util.List<java.lang.String>
getList(PropertyKey key)
Gets the value for the given key as a list.static long
getLong(PropertyKey key)
Gets the long integer representation of the value for the given key.static long
getMs(PropertyKey key)
Gets the time of key in millisecond unit.static java.util.Map<java.lang.String,java.lang.Object>
getNestedProperties(PropertyKey prefixKey)
Gets a set of properties that share a given common prefix key as a map.static java.lang.Object
getOrDefault(PropertyKey key, java.lang.String defaultValue, ConfigurationValueOptions options)
static <T> T
getOrDefault(PropertyKey key, T defaultValue)
static PathConfiguration
getPathConf(alluxio.grpc.GetConfigurationPResponse response, AlluxioConfiguration clusterConf)
Loads the path level configuration from the get configuration response.static Source
getSource(PropertyKey key)
static java.lang.String
getString(PropertyKey key)
Gets the String value for the given key.static AlluxioConfiguration
global()
static java.lang.String
hash()
static boolean
isSet(PropertyKey key)
Checks if the configuration contains a value for the given key.static boolean
isSetByUser(PropertyKey key)
Checks if the configuration contains a value for the given key that is set by a user.static java.util.Set<PropertyKey>
keySet()
static void
loadClusterDefaults(java.net.InetSocketAddress address, alluxio.grpc.Scope scope)
Loads cluster default values for workers from the meta master if it's not loaded yet.static alluxio.grpc.GetConfigurationPResponse
loadConfiguration(java.net.InetSocketAddress address, AlluxioConfiguration conf, boolean ignoreClusterConf, boolean ignorePathConf)
Loads configuration from meta master in one RPC.static void
merge(java.util.Map<?,?> properties, Source source)
Merges the current configuration properties with new properties.static InstancedConfiguration
modifiableGlobal()
static void
reloadProperties()
Reloads site properties from disk.static void
set(PropertyKey key, java.lang.Object value)
Sets the value for the appropriate key in theProperties
.static void
set(PropertyKey key, java.lang.Object value, Source source)
Sets the value for the appropriate key in theProperties
by source.static java.util.Map<java.lang.String,java.lang.Object>
toMap()
static java.util.Map<java.lang.String,java.lang.Object>
toMap(ConfigurationValueOptions opts)
static void
unset(PropertyKey key)
Unsets the value for the appropriate key in theProperties
.
-
-
-
Method Detail
-
copyProperties
public static AlluxioProperties copyProperties()
Create and return a copy of all properties.- Returns:
- a copy of properties
-
merge
public static void merge(java.util.Map<?,?> properties, Source source)
Merges the current configuration properties with new properties. If a property exists both in the new and current configuration, the one from the new configuration wins if its priority is higher or equal than the existing one.- Parameters:
properties
- the sourceProperties
to be mergedsource
- the source of the the properties (e.g., system property, default and etc)
-
set
public static void set(PropertyKey key, java.lang.Object value)
Sets the value for the appropriate key in theProperties
.- Parameters:
key
- the key to setvalue
- the value for the key
-
set
public static void set(PropertyKey key, java.lang.Object value, Source source)
Sets the value for the appropriate key in theProperties
by source.- Parameters:
key
- the key to setvalue
- the value for the keysource
- the source of the the properties (e.g., system property, default and etc)
-
unset
public static void unset(PropertyKey key)
Unsets the value for the appropriate key in theProperties
.- Parameters:
key
- the key to unset
-
get
public static java.lang.Object get(PropertyKey key)
Gets the value for the given key in theProperties
; if this key is not found, a RuntimeException is thrown.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key
-
get
public static java.lang.Object get(PropertyKey key, ConfigurationValueOptions options)
Gets the value for the given key in theProperties
; if this key is not found, a RuntimeException is thrown.- Parameters:
key
- the key to get the value foroptions
- options for getting configuration value- Returns:
- the value for the given key
-
getOrDefault
public static <T> T getOrDefault(PropertyKey key, T defaultValue)
- Type Parameters:
T
- the type of default value- Parameters:
key
- the key to get the value fordefaultValue
- the value to return if no value is set for the specified key- Returns:
- the value
-
getOrDefault
public static java.lang.Object getOrDefault(PropertyKey key, java.lang.String defaultValue, ConfigurationValueOptions options)
- Parameters:
key
- the key to get the value fordefaultValue
- the value to return if no value is set for the specified keyoptions
- options for getting configuration value- Returns:
- the value
-
isSet
public static boolean isSet(PropertyKey key)
Checks if the configuration contains a value for the given key.- Parameters:
key
- the key to check- Returns:
- true if there is value for the key, false otherwise
-
isSetByUser
public static boolean isSetByUser(PropertyKey key)
Checks if the configuration contains a value for the given key that is set by a user.- Parameters:
key
- the key to check- Returns:
- true if there is value for the key by a user, false otherwise
-
keySet
public static java.util.Set<PropertyKey> keySet()
- Returns:
- the keys configured by the configuration
-
getString
public static java.lang.String getString(PropertyKey key)
Gets the String value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as an
String
-
getInt
public static int getInt(PropertyKey key)
Gets the integer representation of the value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as an
int
-
getDouble
public static double getDouble(PropertyKey key)
Gets the double representation of the value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as a
double
-
getLong
public static long getLong(PropertyKey key)
Gets the long integer representation of the value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as a
long
-
getBoolean
public static boolean getBoolean(PropertyKey key)
Gets the boolean representation of the value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as a
boolean
-
getList
public static java.util.List<java.lang.String> getList(PropertyKey key)
Gets the value for the given key as a list.- Parameters:
key
- the key to get the value for- Returns:
- the list of values for the given key
-
getEnum
public static <T extends java.lang.Enum<T>> T getEnum(PropertyKey key, java.lang.Class<T> enumType)
Gets the value for the given key as an enum value.- Type Parameters:
T
- the type of the enum- Parameters:
key
- the key to get the value forenumType
- the type of the enum- Returns:
- the value for the given key as an enum value
-
getBytes
public static long getBytes(PropertyKey key)
Gets the bytes of the value for the given key.- Parameters:
key
- the key to get the value for- Returns:
- the bytes of the value for the given key
-
getMs
public static long getMs(PropertyKey key)
Gets the time of key in millisecond unit.- Parameters:
key
- the key to get the value for- Returns:
- the time of key in millisecond unit
-
getDuration
public static java.time.Duration getDuration(PropertyKey key)
Gets the time of the key as a duration.- Parameters:
key
- the key to get the value for- Returns:
- the value of the key represented as a duration
-
getClass
public static <T> java.lang.Class<T> getClass(PropertyKey key)
Gets the value for the given key as a class.- Type Parameters:
T
- the type of the class- Parameters:
key
- the key to get the value for- Returns:
- the value for the given key as a class
-
getNestedProperties
public static java.util.Map<java.lang.String,java.lang.Object> getNestedProperties(PropertyKey prefixKey)
Gets a set of properties that share a given common prefix key as a map. E.g., if A.B=V1 and A.C=V2, calling this method with prefixKey=A returns a map of {B=V1, C=V2}, where B and C are also valid properties. If no property shares the prefix, an empty map is returned.- Parameters:
prefixKey
- the prefix key- Returns:
- a map from nested properties aggregated by the prefix
-
getSource
public static Source getSource(PropertyKey key)
- Parameters:
key
- the property key- Returns:
- the source for the given key
-
toMap
public static java.util.Map<java.lang.String,java.lang.Object> toMap()
- Returns:
- a map from all configuration property names to their values; values may potentially be null
-
toMap
public static java.util.Map<java.lang.String,java.lang.Object> toMap(ConfigurationValueOptions opts)
- Parameters:
opts
- options for formatting the configuration values- Returns:
- a map from all configuration property names to their values; values may potentially be null
-
global
public static AlluxioConfiguration global()
- Returns:
- the global configuration through
AlluxioConfiguration
API, which is a read-only API
-
modifiableGlobal
public static InstancedConfiguration modifiableGlobal()
- Returns:
- the global configuration instance that is modifiable
-
copyGlobal
public static InstancedConfiguration copyGlobal()
- Returns:
- a copy of
InstancedConfiguration
object based on the global configuration
-
getConfiguration
public static java.util.List<alluxio.grpc.ConfigProperty> getConfiguration(alluxio.grpc.Scope scope)
Gets all configuration properties filtered by the specified scope.- Parameters:
scope
- the scope to filter by- Returns:
- the properties
-
loadClusterDefaults
public static void loadClusterDefaults(java.net.InetSocketAddress address, alluxio.grpc.Scope scope) throws AlluxioStatusException
Loads cluster default values for workers from the meta master if it's not loaded yet.- Parameters:
address
- the master addressscope
- the property scope- Throws:
AlluxioStatusException
-
loadConfiguration
public static alluxio.grpc.GetConfigurationPResponse loadConfiguration(java.net.InetSocketAddress address, AlluxioConfiguration conf, boolean ignoreClusterConf, boolean ignorePathConf) throws AlluxioStatusException
Loads configuration from meta master in one RPC.- Parameters:
address
- the meta master addressconf
- the existing configurationignoreClusterConf
- do not load cluster configuration related informationignorePathConf
- do not load path configuration related information- Returns:
- the RPC response
- Throws:
AlluxioStatusException
-
getClusterConf
public static InstancedConfiguration getClusterConf(alluxio.grpc.GetConfigurationPResponse response, AlluxioConfiguration conf, alluxio.grpc.Scope scope)
Loads the cluster level configuration from the get configuration response, filters out the configuration for certain scope, and merges it with the existing configuration.- Parameters:
response
- the get configuration RPC responseconf
- the existing configurationscope
- the target scope- Returns:
- the merged configuration
-
getPathConf
public static PathConfiguration getPathConf(alluxio.grpc.GetConfigurationPResponse response, AlluxioConfiguration clusterConf)
Loads the path level configuration from the get configuration response. Only client scope properties will be loaded.- Parameters:
response
- the get configuration RPC responseclusterConf
- cluster level configuration- Returns:
- the loaded path level configuration
-
hash
public static java.lang.String hash()
- Returns:
- hash of properties
-
reloadProperties
public static void reloadProperties()
Reloads site properties from disk.
-
-