Package org.apache.accumulo.core.conf
Class AccumuloConfiguration
- java.lang.Object
-
- org.apache.accumulo.core.conf.AccumuloConfiguration
-
- Direct Known Subclasses:
ConfigurationCopy
,DefaultConfiguration
,ObservableConfiguration
,SiteConfiguration
public abstract class AccumuloConfiguration extends Object implements Iterable<Map.Entry<String,String>>
A configuration object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AccumuloConfiguration.MatchFilter
A filter that accepts properties whose keys are an exact match.static class
AccumuloConfiguration.PrefixFilter
A filter that accepts properties whose keys begin with a prefix.static interface
AccumuloConfiguration.PropertyFilter
Deprecated.since 1.7.0; usePredicate
instead.
-
Constructor Summary
Constructors Constructor Description AccumuloConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
get(String property)
Gets a property value from this configuration.abstract String
get(Property property)
Gets a property value from this configuration.Map<String,String>
getAllPropertiesWithPrefix(Property property)
Gets all properties under the given prefix in this configuration.boolean
getBoolean(Property property)
Gets a property of typePropertyType.BOOLEAN
, interpreting the value properly (usingBoolean.parseBoolean()
).int
getCount(Property property)
Gets a property of typePropertyType.COUNT
, interpreting the value properly (as an integer).static DefaultConfiguration
getDefaultConfiguration()
Gets the default configuration.double
getFraction(String str)
Interprets a string specifying a fraction.double
getFraction(Property property)
Gets a property of typePropertyType.FRACTION
, interpreting the value properly.int
getMaxFilesPerTablet()
Gets the maximum number of files per tablet from this configuration.static long
getMemoryInBytes(String str)
Interprets a string specifying a memory size.long
getMemoryInBytes(Property property)
Gets a property of typePropertyType.MEMORY
, interpreting the value properly.String
getPath(Property property)
Gets a property of typePropertyType.PATH
, interpreting the value properly, replacing supported environment variables.int[]
getPort(Property property)
Gets a property of typePropertyType.PORT
, interpreting the value properly (as an integer within the range of non-privileged ports).abstract void
getProperties(Map<String,String> props, com.google.common.base.Predicate<String> filter)
Returns property key/value pairs in this configuration.static AccumuloConfiguration
getTableConfiguration(Connector conn, String tableId)
Gets the configuration specific to a table.static long
getTimeInMillis(String str)
Interprets a string specifying a time duration.long
getTimeInMillis(Property property)
Gets a property of typePropertyType.TIMEDURATION
, interpreting the value properly.long
getUpdateCount()
Each time configuration changes, this counter should increase.<T> T
instantiateClassProperty(Property property, Class<T> base, T defaultInstance)
Creates a new instance of a class specified in a configuration property.void
invalidateCache()
Invalidates theZooCache
used for storage and quick retrieval of properties for this configuration.Iterator<Map.Entry<String,String>>
iterator()
Returns an iterator over property key/value pairs in this configuration.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
get
public String get(String property)
Gets a property value from this configuration.Note: this is inefficient, but convenient on occasion. For retrieving multiple properties, use
getProperties(Map, Predicate)
with a custom filter.- Parameters:
property
- property to get- Returns:
- property value
-
get
public abstract String get(Property property)
Gets a property value from this configuration.- Parameters:
property
- property to get- Returns:
- property value
-
getProperties
public abstract void getProperties(Map<String,String> props, com.google.common.base.Predicate<String> filter)
Returns property key/value pairs in this configuration. The pairs include those defined in this configuration which pass the given filter, and those supplied from the parent configuration which are not included from here.- Parameters:
props
- properties object to populatefilter
- filter for accepting properties from this configuration
-
iterator
public Iterator<Map.Entry<String,String>> iterator()
Returns an iterator over property key/value pairs in this configuration. Some implementations may elect to omit properties.
-
getUpdateCount
public long getUpdateCount()
Each time configuration changes, this counter should increase. Anything that caches information that is derived from configuration can use this method to know when to update.
-
getAllPropertiesWithPrefix
public Map<String,String> getAllPropertiesWithPrefix(Property property)
Gets all properties under the given prefix in this configuration.- Parameters:
property
- prefix property, must be of type PropertyType.PREFIX- Returns:
- a map of property keys to values
- Throws:
IllegalArgumentException
- if property is not a prefix
-
getMemoryInBytes
public long getMemoryInBytes(Property property)
Gets a property of typePropertyType.MEMORY
, interpreting the value properly.- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
getMemoryInBytes(String)
-
getMemoryInBytes
public static long getMemoryInBytes(String str)
Interprets a string specifying a memory size. A memory size is specified as a long integer followed by an optional B (bytes), K (KB), M (MB), or G (GB).- Parameters:
str
- string value- Returns:
- interpreted memory size
-
getTimeInMillis
public long getTimeInMillis(Property property)
Gets a property of typePropertyType.TIMEDURATION
, interpreting the value properly.- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
getTimeInMillis(String)
-
getTimeInMillis
public static long getTimeInMillis(String str)
Interprets a string specifying a time duration. A time duration is specified as a long integer followed by an optional d (days), h (hours), m (minutes), s (seconds), or ms (milliseconds). A value without a unit is interpreted as seconds.- Parameters:
str
- string value- Returns:
- interpreted time duration in milliseconds
-
getBoolean
public boolean getBoolean(Property property)
Gets a property of typePropertyType.BOOLEAN
, interpreting the value properly (usingBoolean.parseBoolean()
).- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type
-
getFraction
public double getFraction(Property property)
Gets a property of typePropertyType.FRACTION
, interpreting the value properly.- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
getFraction(String)
-
getFraction
public double getFraction(String str)
Interprets a string specifying a fraction. A fraction is specified as a double. An optional % at the end signifies a percentage.- Parameters:
str
- string value- Returns:
- interpreted fraction as a decimal value
-
getPort
public int[] getPort(Property property)
Gets a property of typePropertyType.PORT
, interpreting the value properly (as an integer within the range of non-privileged ports).- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
getTimeInMillis(String)
-
getCount
public int getCount(Property property)
Gets a property of typePropertyType.COUNT
, interpreting the value properly (as an integer).- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
getTimeInMillis(String)
-
getPath
public String getPath(Property property)
Gets a property of typePropertyType.PATH
, interpreting the value properly, replacing supported environment variables.- Parameters:
property
- property to get- Returns:
- property value
- Throws:
IllegalArgumentException
- if the property is of the wrong type- See Also:
Constants.PATH_PROPERTY_ENV_VARS
-
getDefaultConfiguration
public static DefaultConfiguration getDefaultConfiguration()
Gets the default configuration.- Returns:
- default configuration
- See Also:
DefaultConfiguration.getInstance()
-
getTableConfiguration
public static AccumuloConfiguration getTableConfiguration(Connector conn, String tableId) throws TableNotFoundException, AccumuloException
Gets the configuration specific to a table.- Parameters:
conn
- connector (used to find table name)tableId
- table ID- Returns:
- configuration containing table properties
- Throws:
TableNotFoundException
- if the table is not foundAccumuloException
- if there is a problem communicating to Accumulo
-
getMaxFilesPerTablet
public int getMaxFilesPerTablet()
Gets the maximum number of files per tablet from this configuration.- Returns:
- maximum number of files per tablet
- See Also:
Property.TABLE_FILE_MAX
,Property.TSERV_SCAN_MAX_OPENFILES
-
invalidateCache
public void invalidateCache()
Invalidates theZooCache
used for storage and quick retrieval of properties for this configuration.
-
instantiateClassProperty
public <T> T instantiateClassProperty(Property property, Class<T> base, T defaultInstance)
Creates a new instance of a class specified in a configuration property.- Parameters:
property
- property specifying class namebase
- base class of typedefaultInstance
- instance to use if creation fails- Returns:
- new class instance, or default instance if creation failed
- See Also:
AccumuloVFSClassLoader
-
-