关注 spark技术分享,
撸spark源码 玩spark最佳实践

ApiRootResource — /api/v1 URI Handler

ApiRootResource — /api/v1 URI Handler

ApiRootResource is the ApiRequestContext for the /v1 URI path.

ApiRootResource uses @Path("/v1") annotation at the class level. It is a partial URI path template relative to the base URI of the server on which the resource is deployed, the context root of the application, and the URL pattern to which the JAX-RS runtime responds.

Tip
Learn more about @Path annotation in The @Path Annotation and URI Path Templates.

ApiRootResource registers the /api/* context handler (with the REST resources and providers in org.apache.spark.status.api.v1 package).

With the @Path("/v1") annotation and after registering the /api/* context handler, ApiRootResource serves HTTP requests for paths under the /api/v1 URI paths for SparkUI and HistoryServer.

ApiRootResource gives the metrics of a Spark application in JSON format (using JAX-RS API).

Table 1. ApiRootResource’s Paths
Path HTTP Method Description

applications

Delegates to the ApplicationListResource resource class

applications/{appId}

Delegates to the OneApplicationResource resource class

version

GET

Creates a VersionInfo with the current version of Spark

Creating /api/* Context Handler — getServletHandler Method

getServletHandler creates a Jetty ServletContextHandler for /api context path.

Note
The Jetty ServletContextHandler created does not support HTTP sessions as REST API is stateless.

getServletHandler creates a Jetty ServletHolder with the resources and providers in org.apache.spark.status.api.v1 package. It then registers the ServletHolder to serve /* context path (under the ServletContextHandler for /api).

getServletHandler requests UIRootFromServletContext to setUiRoot with the ServletContextHandler and the input UIRoot.

Note
getServletHandler is used when SparkUI and HistoryServer are requested to initialize.
赞(0) 打赏
未经允许不得转载:spark技术分享 » ApiRootResource — /api/v1 URI Handler
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏