Package org.apache.accumulo.core.conf
Class ConfigurationTypeHelper
- java.lang.Object
-
- org.apache.accumulo.core.conf.ConfigurationTypeHelper
-
public class ConfigurationTypeHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description ConfigurationTypeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
getClassInstance(String context, String clazzName, Class<T> base)
Loads a class in the given classloader context.static <T> T
getClassInstance(String context, String clazzName, Class<T> base, T defaultInstance)
Loads a class in the given classloader context, suppressing any exceptions, and optionally providing a default instance to use.static long
getFixedMemoryAsBytes(String str)
Interprets a string specifying bytes.static double
getFraction(String str)
Interprets a string specifying a fraction.static long
getMemoryAsBytes(String str)
Interprets a string specifying a Memory type which is specified as a long integer followed by an optional B (bytes), K (KB), M (MB), G (GB) or % (percentage).static int
getNumThreads(String threads)
Get the number of threads from string property.static long
getTimeInMillis(String str)
Interprets a string specifying a time duration.
-
-
-
Method Detail
-
getFixedMemoryAsBytes
public static long getFixedMemoryAsBytes(String str)
Interprets a string specifying bytes. A bytes type 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 in bytes
-
getMemoryAsBytes
public static long getMemoryAsBytes(String str)
Interprets a string specifying a Memory type which is specified as a long integer followed by an optional B (bytes), K (KB), M (MB), G (GB) or % (percentage).- Parameters:
str
- String value- Returns:
- interpreted memory size in bytes
-
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
-
getFraction
public static 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
-
getClassInstance
public static <T> T getClassInstance(String context, String clazzName, Class<T> base, T defaultInstance)
Loads a class in the given classloader context, suppressing any exceptions, and optionally providing a default instance to use.- Parameters:
context
- the per-table context, can be nullclazzName
- the name of the class to loadbase
- the type of the classdefaultInstance
- a default instance if the class cannot be loaded- Returns:
- a new instance of the class, or the defaultInstance
-
getClassInstance
public static <T> T getClassInstance(String context, String clazzName, Class<T> base) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
Loads a class in the given classloader context.- Parameters:
context
- the per-table context, can be nullclazzName
- the name of the class to loadbase
- the type of the class- Returns:
- a new instance of the class
- Throws:
ClassNotFoundException
IOException
InstantiationException
IllegalAccessException
-
getNumThreads
public static int getNumThreads(String threads)
Get the number of threads from string property. If the value ends with C, then it will be multiplied by the number of cores.
-
-