MAPREDUCE-3038. job history server not starting because conf() missing HsController (Jeffrey Naisbitt via mahadev) - merging r1172875 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1172879 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mahadev Konar 2011-09-19 22:53:46 +00:00
parent ec1a930822
commit 34797aac75
2 changed files with 24 additions and 14 deletions

View File

@ -1325,6 +1325,9 @@ Release 0.23.0 - Unreleased
MAPREDUCE-3042. Fixed default ResourceTracker address. (Chris Riccomini
via acmurthy)
MAPREDUCE-3038. job history server not starting because conf() missing
HsController (Jeffrey Naisbitt via mahadev)
Release 0.22.0 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -25,6 +25,8 @@ import com.google.common.collect.Maps;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.NoSuchMethodException;
import java.lang.SecurityException;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@ -88,11 +90,13 @@ class Router {
private Dest addController(WebApp.HTTP httpMethod, String path,
Class<? extends Controller> cls,
String action, List<String> names) {
for (Method method : cls.getDeclaredMethods()) {
if (method.getName().equals(action) &&
method.getParameterTypes().length == 0 &&
Modifier.isPublic(method.getModifiers())) {
// TODO: deal with parameters using the names
try {
// Look for the method in all public methods declared in the class
// or inherited by the class.
// Note: this does not distinguish methods with the same signature
// but different return types.
// TODO: We may want to deal with methods that take parameters in the future
Method method = cls.getMethod(action, null);
Dest dest = routes.get(path);
if (dest == null) {
method.setAccessible(true); // avoid any runtime checks
@ -102,9 +106,12 @@ class Router {
}
dest.methods.add(httpMethod);
return dest;
}
}
} catch (NoSuchMethodException nsme) {
throw new WebAppException(action + "() not found in " + cls);
} catch (SecurityException se) {
throw new WebAppException("Security exception thrown for " + action +
"() in " + cls);
}
}
private void addDefaultView(Dest dest) {