HDFS-16323. DatanodeHttpServer doesn't require handler state map while retrieving filter handlers (#3659)
(cherry picked from commit 646c470e5d
)
This commit is contained in:
parent
e1267608ec
commit
4e77f772fc
|
@ -64,7 +64,6 @@ import java.nio.channels.ServerSocketChannel;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ADMIN;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ADMIN;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_HTTPS_ADDRESS_DEFAULT;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_HTTPS_ADDRESS_DEFAULT;
|
||||||
|
@ -77,8 +76,6 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_HTTP_INTERNAL_PR
|
||||||
*/
|
*/
|
||||||
public class DatanodeHttpServer implements Closeable {
|
public class DatanodeHttpServer implements Closeable {
|
||||||
static final Logger LOG = LoggerFactory.getLogger(DatanodeHttpServer.class);
|
static final Logger LOG = LoggerFactory.getLogger(DatanodeHttpServer.class);
|
||||||
private static final ConcurrentHashMap<Class<?>, Object> HANDLER_STATE
|
|
||||||
= new ConcurrentHashMap<Class<?>, Object>() {};
|
|
||||||
// HttpServer threads are only used for the web UI and basic servlets, so
|
// HttpServer threads are only used for the web UI and basic servlets, so
|
||||||
// set them to the minimum possible
|
// set them to the minimum possible
|
||||||
private static final int HTTP_SELECTOR_THREADS = 1;
|
private static final int HTTP_SELECTOR_THREADS = 1;
|
||||||
|
@ -281,11 +278,10 @@ public class DatanodeHttpServer implements Closeable {
|
||||||
try {
|
try {
|
||||||
Method initializeState = classes[i].getDeclaredMethod("initializeState",
|
Method initializeState = classes[i].getDeclaredMethod("initializeState",
|
||||||
Configuration.class);
|
Configuration.class);
|
||||||
Constructor constructor =
|
Constructor<?> constructor =
|
||||||
classes[i].getDeclaredConstructor(initializeState.getReturnType());
|
classes[i].getDeclaredConstructor(initializeState.getReturnType());
|
||||||
handlers[i] = (ChannelHandler) constructor.newInstance(
|
handlers[i] = (ChannelHandler) constructor.newInstance(
|
||||||
HANDLER_STATE.getOrDefault(classes[i],
|
initializeState.invoke(null, configuration));
|
||||||
initializeState.invoke(null, configuration)));
|
|
||||||
} catch (NoSuchMethodException | InvocationTargetException
|
} catch (NoSuchMethodException | InvocationTargetException
|
||||||
| IllegalAccessException | InstantiationException
|
| IllegalAccessException | InstantiationException
|
||||||
| IllegalArgumentException e) {
|
| IllegalArgumentException e) {
|
||||||
|
|
Loading…
Reference in New Issue