-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEZ-4347: Add some diagnostic endpoints to TezAM's WebUIService
- Loading branch information
1 parent
f62bf12
commit 47be7fa
Showing
17 changed files
with
421 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
tez-common/src/main/java/org/apache/tez/common/web/AbstractServletToControllerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.tez.common.web; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.Enumeration; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.apache.hadoop.yarn.webapp.Controller; | ||
|
||
/** | ||
* AbstractServletToControllerAdapter is a common ancestor for classes | ||
* that wish to adapt servlets to yarn webapp controllers. | ||
* The adapter is responsible for: | ||
* 1. creating a servlet instance | ||
* 2. creating a dummy ServletConfig | ||
* 3. delegating calls to the servlet instance's doGet method | ||
*/ | ||
public abstract class AbstractServletToControllerAdapter extends Controller { | ||
private AtomicBoolean initialized = new AtomicBoolean(false); | ||
protected HttpServlet servlet; | ||
|
||
@Override | ||
public void index() { | ||
if (initialized.compareAndSet(false, true)) { | ||
initServlet(); | ||
} | ||
try { | ||
/* | ||
* This reflection workaround is needed because HttpServlet.doGet is protected | ||
* (even if subclasses have it public). | ||
*/ | ||
Method doGetMethod = | ||
this.servlet.getClass().getMethod("doGet", HttpServletRequest.class, HttpServletResponse.class); | ||
doGetMethod.setAccessible(true); | ||
doGetMethod.invoke(this.servlet, request(), response()); | ||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | ||
| SecurityException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Creates a dummy servlet config which is suitable for initializing a servlet instance. | ||
* @param servletName | ||
* @return a ServletConfig instance initialized with a ServletContext | ||
*/ | ||
private ServletConfig getDummyServletConfig(String servletName) { | ||
return new ServletConfig() { | ||
|
||
@Override | ||
public String getServletName() { | ||
return servletName; | ||
} | ||
|
||
@Override | ||
public ServletContext getServletContext() { | ||
return request().getServletContext(); | ||
} | ||
|
||
@Override | ||
public Enumeration<String> getInitParameterNames() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getInitParameter(String name) { | ||
return null; | ||
} | ||
}; | ||
} | ||
|
||
private void initServlet() { | ||
try { | ||
servlet.init(getDummyServletConfig(this.servlet.getClass().getSimpleName())); | ||
} catch (ServletException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
tez-common/src/main/java/org/apache/tez/common/web/ServletToControllerAdapters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.tez.common.web; | ||
|
||
import javax.servlet.ServletException; | ||
|
||
import org.apache.hadoop.conf.ConfServlet; | ||
import org.apache.hadoop.http.HttpServer2.StackServlet; | ||
import org.apache.hadoop.jmx.JMXJsonServlet; | ||
|
||
public class ServletToControllerAdapters { | ||
public static class JMXJsonServletController extends AbstractServletToControllerAdapter { | ||
public JMXJsonServletController() throws ServletException { | ||
this.servlet = new JMXJsonServlet(); | ||
} | ||
} | ||
|
||
public static class ConfServletController extends AbstractServletToControllerAdapter { | ||
public ConfServletController() throws ServletException { | ||
this.servlet = new ConfServlet(); | ||
} | ||
} | ||
|
||
public static class StackServletController extends AbstractServletToControllerAdapter { | ||
public StackServletController() throws ServletException { | ||
this.servlet = new StackServlet(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tez-common/src/main/java/org/apache/tez/common/web/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@Private | ||
package org.apache.tez.common.web; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience.Private; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.