Package org.apache.hadoop.util
Class ReflectionUtils
java.lang.Object
org.apache.hadoop.util.ReflectionUtils
General reflection utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloneWritableInto(Writable dst, Writable src) Deprecated.static <T> Tcopy(Configuration conf, T src, T dst) Make a copy of the writable object using serialization to a buffer.static <T> Class<T>getClass(T o) Return the correctly-typedClassof the given object.getDeclaredFieldsIncludingInherited(Class<?> clazz) Gets all the declared fields of a class including fields declared in superclasses.getDeclaredMethodsIncludingInherited(Class<?> clazz) Gets all the declared methods of a class including methods declared in superclasses.static voidlogThreadInfo(org.apache.commons.logging.Log log, String title, long minInterval) Deprecated.to be removed with 3.4.0.static voidlogThreadInfo(org.slf4j.Logger log, String title, long minInterval) Log the current thread stacks at INFO level.static <T> TnewInstance(Class<T> theClass, Configuration conf) Create an object for the given class and initialize it from confstatic <T> TnewInstance(Class<T> theClass, Configuration conf, Class<?>[] argTypes, Object... values) Create an object for the given class and initialize it from confstatic voidprintThreadInfo(PrintStream stream, String title) Print all of the thread's information and stack traces.static voidsetConf(Object theObject, Configuration conf) Check and set 'configuration' if necessary.static voidsetContentionTracing(boolean val)
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
setConf
Check and set 'configuration' if necessary.- Parameters:
theObject- object for which to set configurationconf- Configuration
-
newInstance
Create an object for the given class and initialize it from conf- Type Parameters:
T- Generics Type T.- Parameters:
theClass- class of which an object is createdconf- Configuration- Returns:
- a new object
-
newInstance
public static <T> T newInstance(Class<T> theClass, Configuration conf, Class<?>[] argTypes, Object... values) Create an object for the given class and initialize it from conf- Type Parameters:
T- Generics Type.- Parameters:
theClass- class of which an object is createdconf- ConfigurationargTypes- the types of the argumentsvalues- the values of the arguments- Returns:
- a new object
-
setContentionTracing
public static void setContentionTracing(boolean val) -
printThreadInfo
Print all of the thread's information and stack traces.- Parameters:
stream- the stream totitle- a string title for the stack trace
-
logThreadInfo
@Deprecated public static void logThreadInfo(org.apache.commons.logging.Log log, String title, long minInterval) Deprecated.to be removed with 3.4.0. UselogThreadInfo(Logger, String, long)instead.Log the current thread stacks at INFO level.- Parameters:
log- the logger that logs the stack tracetitle- a descriptive title for the call stacksminInterval- the minimum time from the last
-
logThreadInfo
Log the current thread stacks at INFO level.- Parameters:
log- the logger that logs the stack tracetitle- a descriptive title for the call stacksminInterval- the minimum time from the last
-
getClass
Return the correctly-typedClassof the given object.- Type Parameters:
T- Generics Type T.- Parameters:
o- object whose correctly-typedClassis to be obtained- Returns:
- the correctly typed
Classof the given object.
-
copy
Make a copy of the writable object using serialization to a buffer.- Type Parameters:
T- Generics Type.- Parameters:
src- the object to copy fromdst- the object to copy into, which is destroyedconf- configuration.- Returns:
- dst param (the copy)
- Throws:
IOException- raised on errors performing I/O.
-
cloneWritableInto
Deprecated.- Throws:
IOException
-
getDeclaredFieldsIncludingInherited
Gets all the declared fields of a class including fields declared in superclasses.- Parameters:
clazz- clazz- Returns:
- field List
-
getDeclaredMethodsIncludingInherited
Gets all the declared methods of a class including methods declared in superclasses.- Parameters:
clazz- clazz.- Returns:
- Method List.
-