HDFS-16323. DatanodeHttpServer doesn't require handler state map while retrieving filter handlers (#3659)

(cherry picked from commit 646c470e5d)
This commit is contained in:
Viraj Jasani 2021-11-17 18:47:09 +05:30 committed by Chao Sun
parent 5314f2e7a3
commit 1e6e8a19ab
1 changed files with 2 additions and 6 deletions

View File

@ -64,7 +64,6 @@ import java.nio.channels.ServerSocketChannel;
import java.security.GeneralSecurityException;
import java.util.Enumeration;
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_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 {
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
// set them to the minimum possible
private static final int HTTP_SELECTOR_THREADS = 1;
@ -281,11 +278,10 @@ public class DatanodeHttpServer implements Closeable {
try {
Method initializeState = classes[i].getDeclaredMethod("initializeState",
Configuration.class);
Constructor constructor =
Constructor<?> constructor =
classes[i].getDeclaredConstructor(initializeState.getReturnType());
handlers[i] = (ChannelHandler) constructor.newInstance(
HANDLER_STATE.getOrDefault(classes[i],
initializeState.invoke(null, configuration)));
initializeState.invoke(null, configuration));
} catch (NoSuchMethodException | InvocationTargetException
| IllegalAccessException | InstantiationException
| IllegalArgumentException e) {