public class SystemConfiguration
extends java.lang.Object
1) Load in the DEFAULT_PROPERTY_FILE, if found on the classpath. (Currently 'pirk.properties')
2) Load in any properties files in the LOCAL_PROPERTIES_DIR. The filenames must end with '.properties'
3) Load in properties from the QUERIER_PROPERTIES_FILE and RESPONDER_PROPERTIES_FILE
Constructor and Description |
---|
SystemConfiguration() |
Modifier and Type | Method and Description |
---|---|
static void |
appendProperty(java.lang.String propertyName,
java.lang.String value)
Appends a property via a comma separated list
|
static boolean |
getBooleanProperty(java.lang.String propertyName,
boolean defaultValue)
Gets the specified property as a
boolean , or the default value if the property isn't defined. |
static int |
getIntProperty(java.lang.String propertyName,
int defaultValue)
Gets the specified property as an
int , or the default value if the property isn't found. |
static long |
getLongProperty(java.lang.String propertyName,
long defaultValue)
Gets the specified property as an
long , or the default value if the property isn't found. |
static java.util.Properties |
getProperties()
Return the Properties object maintained by this class.
|
static java.lang.String |
getProperty(java.lang.String propertyName)
Gets the specified property; returns
null if the property isn't found. |
static java.lang.String |
getProperty(java.lang.String propertyName,
java.lang.String defaultValue)
Gets the specified property as a
String , or the default value if the property isn't found. |
static boolean |
hasProperty(java.lang.String propertyName)
Returns true iff the given property name is defined.
|
static void |
initialize() |
static boolean |
isSetTrue(java.lang.String propertyName)
Returns
true iff the specified boolean property value is "true". |
static void |
loadProperties(java.io.InputStream stream)
Load the properties in the Properties object and then trim any whitespace
|
static void |
loadPropsFromDir(java.lang.String dirName)
Loads the properties from local properties file in the specified directory.
|
static void |
loadPropsFromFile(java.io.File file)
Loads the properties from the specified file.
|
static void |
loadPropsFromFile(org.apache.hadoop.fs.Path filePath,
org.apache.hadoop.fs.FileSystem fs)
Loads the properties from the specified file in hdfs
|
static void |
loadPropsFromFile(java.lang.String filename,
org.apache.hadoop.fs.FileSystem fs)
Loads the properties from the specified file in hdfs
|
static void |
loadPropsFromHDFSDir(java.lang.String dirName,
org.apache.hadoop.fs.FileSystem fs)
Loads the properties from local properties file in the specified directory in hdfs.
|
static void |
loadPropsFromResource(java.lang.String name)
Loads the properties from the specified resource on the current classloader.
|
static void |
setProperty(java.lang.String propertyName,
java.lang.String value)
Sets the property to the given value.
|
public static void initialize()
public static java.util.Properties getProperties()
public static java.lang.String getProperty(java.lang.String propertyName)
null
if the property isn't found.propertyName
- The name of the requested property.null
if the property cannot be found.public static java.lang.String getProperty(java.lang.String propertyName, java.lang.String defaultValue)
String
, or the default value if the property isn't found.propertyName
- The name of the requested string property value.defaultValue
- The value to return if the property is undefined.public static int getIntProperty(java.lang.String propertyName, int defaultValue)
int
, or the default value if the property isn't found.propertyName
- The name of the requested int property value.defaultValue
- The value to return if the property is undefined.java.lang.NumberFormatException
- If the property does not contain a parsable int
value.public static long getLongProperty(java.lang.String propertyName, long defaultValue)
long
, or the default value if the property isn't found.propertyName
- The name of the requested long property value.defaultValue
- The value to return if the property is undefined.java.lang.NumberFormatException
- If the property does not contain a parsable long
value.public static boolean getBooleanProperty(java.lang.String propertyName, boolean defaultValue)
boolean
, or the default value if the property isn't defined.propertyName
- The name of the requested boolean property value.defaultValue
- The value to return if the property is undefined.true
if the property is defined and has the value "true", otherwise defaultValue
.public static boolean isSetTrue(java.lang.String propertyName)
true
iff the specified boolean property value is "true".
If the property is not found, or it's value is not "true" then the method will return false
.
propertyName
- The name of the requested boolean property value.true
if the property is defined and has the value "true", otherwise false
.public static void setProperty(java.lang.String propertyName, java.lang.String value)
Any previous values stored at the same property name are replaced.
propertyName
- The name of the property to set.value
- The property value.public static boolean hasProperty(java.lang.String propertyName)
propertyName
- The property name to test.true
if the property is found in the configuration, or false
otherwise.public static void appendProperty(java.lang.String propertyName, java.lang.String value)
If the property does not exist, it adds it.
propertyName
- The property whose value is to be appended with the given value.value
- The value to be stored, or appended to the current value.public static void loadPropsFromDir(java.lang.String dirName)
All files ending in '.properties' will be loaded. The new properties are added to the current system configuration.
dirName
- The directory to search for the new properties files.public static void loadPropsFromHDFSDir(java.lang.String dirName, org.apache.hadoop.fs.FileSystem fs) throws java.io.FileNotFoundException, java.io.IOException
All files ending in '.properties' will be loaded. The new properties are added to the current system configuration.
dirName
- The directory to search for the new properties files.java.io.IOException
java.io.FileNotFoundException
public static void loadPropsFromFile(java.io.File file)
The new properties are added to the current system configuration.
file
- The properties file containing the system properties to add.public static void loadPropsFromFile(java.lang.String filename, org.apache.hadoop.fs.FileSystem fs) throws java.io.IOException
The new properties are added to the current system configuration.
file
- The properties file containing the system properties to add.java.io.IOException
public static void loadPropsFromFile(org.apache.hadoop.fs.Path filePath, org.apache.hadoop.fs.FileSystem fs) throws java.io.IOException
The new properties are added to the current system configuration.
file
- The properties file containing the system properties to add.java.io.IOException
public static void loadPropsFromResource(java.lang.String name)
The new properties are added to the current system configuration.
name
- The name of the resource defining the properties.public static void loadProperties(java.io.InputStream stream) throws java.io.IOException
Properties.load does not do this automatically
java.io.IOException