日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hadoop jetty的应用

發(fā)布時間:2025/3/21 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hadoop jetty的应用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

? 在hadoop中很多地方都用到了servlet,并且使用jetty作為servlet的容器來提供http的服務,其主要是通過org.apache.hadoop.http.HttpServer類實現(xiàn)的,HttpServer類是對Jetty的簡單封裝,通過調用HttpServer類的addServlet方法增加可以實現(xiàn)增加servlet到jetty的功能:

1 2 3 4 5 ??public?void?addServlet(String?name,?String?pathSpec, ??????Class<??extends?HttpServlet>?clazz)?{?????//名稱,url訪問路徑,處理類 ????addInternalServlet(name,?pathSpec,?clazz,?false); ????addFilterPathMapping(pathSpec,?webAppContext); ??}

默認在HttpServer的構造函數中,會調用addDefaultServlets添加需要增加的servlets:

1 2 3 4 5 6 7 8 9 10 11 ?public?HttpServer(String?name,?String?bindAddress,?int?port, ??????boolean?findPort,?Configuration?conf,?AccessControlList?adminsAcl, ??????Connector?connector,?String[]?pathSpecs)?throws?IOException?{ .... ????webAppContext?=?new?WebAppContext(); ????webAppContext.setDisplayName(name); ????webAppContext.setContextPath(?"/"); ????webAppContext.setWar(appDir?+?"/"?+?name); .... ???addDefaultServlets(); ....

啟動addDefaultServlets定義了默認加載的servlet:

1 2 3 4 5 6 7 8 ??protected?void?addDefaultServlets()?{ ????//?set?up?default?servlets ????addServlet("stacks"?,?"/stacks"?,?StackServlet.class); ????addServlet("logLevel",?"/logLevel",?LogLevel.Servlet.class); ????addServlet("metrics",?"/metrics",?MetricsServlet.class); ????addServlet("jmx",?"/jmx",?JMXJsonServlet.class); ????addServlet("conf",?"/conf",?ConfServlet.class); ??}

hadoop在多個地方都用到了HttpServer這個類:

比如在org.apache.hadoop.hdfs.server.datanode.DataNode類中:

1 DataNode的構造函數--->startDataNode-->initDataXceiver+startInfoServer

其中startInfoServer就是調用HttpServer類啟動jetty的:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 private?HttpServer?infoServer?=?null; ... private?void?startInfoServer(Configuration?conf)?throws?IOException?{ ??//?create?a?servlet?to?serve?full-file?content ??InetSocketAddress?infoSocAddr?=?DataNode.getInfoAddr(conf); ??String?infoHost?=?infoSocAddr.getHostName(); ??int?tmpInfoPort?=?infoSocAddr.getPort(); ??this.infoServer?=?(secureResources?==?null) ???????new?HttpServer("datanode",?infoHost,?tmpInfoPort,?tmpInfoPort?==?0, ?????????conf,?new?AccessControlList(conf.get(DFS_ADMIN,?"?"))) ?????:?new?HttpServer("datanode",?infoHost,?tmpInfoPort,?tmpInfoPort?==?0, ?????????conf,?new?AccessControlList(conf.get(DFS_ADMIN,?"?")), ?????????secureResources.getListener()); ??LOG.info("Opened?info?server?at?"?+?infoHost?+?":"?+?tmpInfoPort); ..... ??this.infoServer.addInternalServlet(null,?"/streamFile/*",?StreamFile.class);?//添加datanode專屬的servlet ??this.infoServer.addInternalServlet(null,?"/getFileChecksum/*", ??????FileChecksumServlets.GetServlet.class); ??this.infoServer.setAttribute("datanode",?this); ??this.infoServer.setAttribute(JspHelper.CURRENT_CONF,?conf); ??this.infoServer.addServlet(null,?"/blockScannerReport", ?????????????????????????????DataBlockScanner.Servlet.class); ??if?(WebHdfsFileSystem.isEnabled(conf,?LOG))?{ ????infoServer.addJerseyResourcePackage(DatanodeWebHdfsMethods.class ????????.getPackage().getName()?+?";"?+?Param.class.getPackage().getName(), ????????WebHdfsFileSystem.PATH_PREFIX?+?"/*"); ??} ??this.infoServer.start(); }

小結如下:

1)HttpServer是對Jetty的簡單封裝

2)hadoop各個組件都會用到HttpServer,datanode/namenode,resourcemanager等

其主要功能有:Hadoop的內部狀態(tài)顯示,運行和管理

3)HttpServer的addDefaultServlets方法定義了通用的幾個servlet(比如更改日志級別的servlet),在每個類中又會定義屬于自己的servlet



本文轉自菜菜光 51CTO博客,原文鏈接:http://blog.51cto.com/caiguangguang/1592799,如需轉載請自行聯(lián)系原作者

總結

以上是生活随笔為你收集整理的hadoop jetty的应用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。