YARN-8091. Revisit checkUserAccessToQueue RM REST API. (wangda)
[hadoop.git] / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-server / hadoop-yarn-server-router / src / test / java / org / apache / hadoop / yarn / server / router / webapp / PassThroughRESTRequestInterceptor.java
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.hadoop.yarn.server.router.webapp;
20
21 import java.io.IOException;
22 import java.util.Set;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26 import javax.ws.rs.core.Response;
27
28 import org.apache.hadoop.security.authorize.AuthorizationException;
29 import org.apache.hadoop.yarn.exceptions.YarnException;
30 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ActivitiesInfo;
31 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppActivitiesInfo;
32 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptsInfo;
33 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo;
34 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppPriority;
35 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppQueue;
36 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppState;
37 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppTimeoutInfo;
38 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppTimeoutsInfo;
39 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationStatisticsInfo;
40 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo;
41 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppsInfo;
42 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterInfo;
43 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterMetricsInfo;
44 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.DelegationToken;
45 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo;
46 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo;
47 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeLabelsInfo;
48 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsEntryList;
49 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeToLabelsInfo;
50 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo;
51 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.RMQueueAclInfo;
52 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationDeleteRequestInfo;
53 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationSubmissionRequestInfo;
54 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationUpdateRequestInfo;
55 import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInfo;
56 import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
57 import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
58 import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
59
60 /**
61 * Mock intercepter that does not do anything other than forwarding it to the
62 * next intercepter in the chain.
63 */
64 public class PassThroughRESTRequestInterceptor
65 extends AbstractRESTRequestInterceptor {
66
67 @Override
68 public AppAttemptsInfo getAppAttempts(HttpServletRequest hsr, String appId) {
69 return getNextInterceptor().getAppAttempts(hsr, appId);
70 }
71
72 @Override
73 public RMQueueAclInfo checkUserAccessToQueue(String queue, String username,
74 String queueAclType, HttpServletRequest hsr)
75 throws AuthorizationException {
76 return getNextInterceptor().checkUserAccessToQueue(queue, username,
77 queueAclType, hsr);
78 }
79
80 @Override
81 public AppAttemptInfo getAppAttempt(HttpServletRequest req,
82 HttpServletResponse res, String appId, String appAttemptId) {
83 return getNextInterceptor().getAppAttempt(req, res, appId, appAttemptId);
84 }
85
86 @Override
87 public ContainersInfo getContainers(HttpServletRequest req,
88 HttpServletResponse res, String appId, String appAttemptId) {
89 return getNextInterceptor().getContainers(req, res, appId, appAttemptId);
90 }
91
92 @Override
93 public ContainerInfo getContainer(HttpServletRequest req,
94 HttpServletResponse res, String appId, String appAttemptId,
95 String containerId) {
96 return getNextInterceptor().getContainer(req, res, appId, appAttemptId,
97 containerId);
98 }
99
100 @Override
101 public ClusterInfo get() {
102 return getNextInterceptor().get();
103 }
104
105 @Override
106 public ClusterInfo getClusterInfo() {
107 return getNextInterceptor().getClusterInfo();
108 }
109
110 @Override
111 public ClusterMetricsInfo getClusterMetricsInfo() {
112 return getNextInterceptor().getClusterMetricsInfo();
113 }
114
115 @Override
116 public SchedulerTypeInfo getSchedulerInfo() {
117 return getNextInterceptor().getSchedulerInfo();
118 }
119
120 @Override
121 public String dumpSchedulerLogs(String time, HttpServletRequest hsr)
122 throws IOException {
123 return getNextInterceptor().dumpSchedulerLogs(time, hsr);
124 }
125
126 @Override
127 public NodesInfo getNodes(String states) {
128 return getNextInterceptor().getNodes(states);
129 }
130
131 @Override
132 public NodeInfo getNode(String nodeId) {
133 return getNextInterceptor().getNode(nodeId);
134 }
135
136 @Override
137 public AppsInfo getApps(HttpServletRequest hsr, String stateQuery,
138 Set<String> statesQuery, String finalStatusQuery, String userQuery,
139 String queueQuery, String count, String startedBegin, String startedEnd,
140 String finishBegin, String finishEnd, Set<String> applicationTypes,
141 Set<String> applicationTags, Set<String> unselectedFields) {
142 return getNextInterceptor().getApps(hsr, stateQuery, statesQuery,
143 finalStatusQuery, userQuery, queueQuery, count, startedBegin,
144 startedEnd, finishBegin, finishEnd, applicationTypes, applicationTags,
145 unselectedFields);
146 }
147
148 @Override
149 public ActivitiesInfo getActivities(HttpServletRequest hsr, String nodeId) {
150 return getNextInterceptor().getActivities(hsr, nodeId);
151 }
152
153 @Override
154 public AppActivitiesInfo getAppActivities(HttpServletRequest hsr,
155 String appId, String time) {
156 return getNextInterceptor().getAppActivities(hsr, appId, time);
157 }
158
159 @Override
160 public ApplicationStatisticsInfo getAppStatistics(HttpServletRequest hsr,
161 Set<String> stateQueries, Set<String> typeQueries) {
162 return getNextInterceptor().getAppStatistics(hsr, stateQueries,
163 typeQueries);
164 }
165
166 @Override
167 public AppInfo getApp(HttpServletRequest hsr, String appId,
168 Set<String> unselectedFields) {
169 return getNextInterceptor().getApp(hsr, appId, unselectedFields);
170 }
171
172 @Override
173 public AppState getAppState(HttpServletRequest hsr, String appId)
174 throws AuthorizationException {
175 return getNextInterceptor().getAppState(hsr, appId);
176 }
177
178 @Override
179 public Response updateAppState(AppState targetState, HttpServletRequest hsr,
180 String appId) throws AuthorizationException, YarnException,
181 InterruptedException, IOException {
182 return getNextInterceptor().updateAppState(targetState, hsr, appId);
183 }
184
185 @Override
186 public NodeToLabelsInfo getNodeToLabels(HttpServletRequest hsr)
187 throws IOException {
188 return getNextInterceptor().getNodeToLabels(hsr);
189 }
190
191 @Override
192 public LabelsToNodesInfo getLabelsToNodes(Set<String> labels)
193 throws IOException {
194 return getNextInterceptor().getLabelsToNodes(labels);
195 }
196
197 @Override
198 public Response replaceLabelsOnNodes(NodeToLabelsEntryList newNodeToLabels,
199 HttpServletRequest hsr) throws Exception {
200 return getNextInterceptor().replaceLabelsOnNodes(newNodeToLabels, hsr);
201 }
202
203 @Override
204 public Response replaceLabelsOnNode(Set<String> newNodeLabelsName,
205 HttpServletRequest hsr, String nodeId) throws Exception {
206 return getNextInterceptor().replaceLabelsOnNode(newNodeLabelsName, hsr,
207 nodeId);
208 }
209
210 @Override
211 public NodeLabelsInfo getClusterNodeLabels(HttpServletRequest hsr)
212 throws IOException {
213 return getNextInterceptor().getClusterNodeLabels(hsr);
214 }
215
216 @Override
217 public Response addToClusterNodeLabels(NodeLabelsInfo newNodeLabels,
218 HttpServletRequest hsr) throws Exception {
219 return getNextInterceptor().addToClusterNodeLabels(newNodeLabels, hsr);
220 }
221
222 @Override
223 public Response removeFromCluserNodeLabels(Set<String> oldNodeLabels,
224 HttpServletRequest hsr) throws Exception {
225 return getNextInterceptor().removeFromCluserNodeLabels(oldNodeLabels, hsr);
226 }
227
228 @Override
229 public NodeLabelsInfo getLabelsOnNode(HttpServletRequest hsr, String nodeId)
230 throws IOException {
231 return getNextInterceptor().getLabelsOnNode(hsr, nodeId);
232 }
233
234 @Override
235 public AppPriority getAppPriority(HttpServletRequest hsr, String appId)
236 throws AuthorizationException {
237 return getNextInterceptor().getAppPriority(hsr, appId);
238 }
239
240 @Override
241 public Response updateApplicationPriority(AppPriority targetPriority,
242 HttpServletRequest hsr, String appId) throws AuthorizationException,
243 YarnException, InterruptedException, IOException {
244 return getNextInterceptor().updateApplicationPriority(targetPriority, hsr,
245 appId);
246 }
247
248 @Override
249 public AppQueue getAppQueue(HttpServletRequest hsr, String appId)
250 throws AuthorizationException {
251 return getNextInterceptor().getAppQueue(hsr, appId);
252 }
253
254 @Override
255 public Response updateAppQueue(AppQueue targetQueue, HttpServletRequest hsr,
256 String appId) throws AuthorizationException, YarnException,
257 InterruptedException, IOException {
258 return getNextInterceptor().updateAppQueue(targetQueue, hsr, appId);
259 }
260
261 @Override
262 public Response createNewApplication(HttpServletRequest hsr)
263 throws AuthorizationException, IOException, InterruptedException {
264 return getNextInterceptor().createNewApplication(hsr);
265 }
266
267 @Override
268 public Response submitApplication(ApplicationSubmissionContextInfo newApp,
269 HttpServletRequest hsr)
270 throws AuthorizationException, IOException, InterruptedException {
271 return getNextInterceptor().submitApplication(newApp, hsr);
272 }
273
274 @Override
275 public Response postDelegationToken(DelegationToken tokenData,
276 HttpServletRequest hsr) throws AuthorizationException, IOException,
277 InterruptedException, Exception {
278 return getNextInterceptor().postDelegationToken(tokenData, hsr);
279 }
280
281 @Override
282 public Response postDelegationTokenExpiration(HttpServletRequest hsr)
283 throws AuthorizationException, IOException, Exception {
284 return getNextInterceptor().postDelegationTokenExpiration(hsr);
285 }
286
287 @Override
288 public Response cancelDelegationToken(HttpServletRequest hsr)
289 throws AuthorizationException, IOException, InterruptedException,
290 Exception {
291 return getNextInterceptor().cancelDelegationToken(hsr);
292 }
293
294 @Override
295 public Response createNewReservation(HttpServletRequest hsr)
296 throws AuthorizationException, IOException, InterruptedException {
297 return getNextInterceptor().createNewReservation(hsr);
298 }
299
300 @Override
301 public Response submitReservation(ReservationSubmissionRequestInfo resContext,
302 HttpServletRequest hsr)
303 throws AuthorizationException, IOException, InterruptedException {
304 return getNextInterceptor().submitReservation(resContext, hsr);
305 }
306
307 @Override
308 public Response updateReservation(ReservationUpdateRequestInfo resContext,
309 HttpServletRequest hsr)
310 throws AuthorizationException, IOException, InterruptedException {
311 return getNextInterceptor().updateReservation(resContext, hsr);
312 }
313
314 @Override
315 public Response deleteReservation(ReservationDeleteRequestInfo resContext,
316 HttpServletRequest hsr)
317 throws AuthorizationException, IOException, InterruptedException {
318 return getNextInterceptor().deleteReservation(resContext, hsr);
319 }
320
321 @Override
322 public Response listReservation(String queue, String reservationId,
323 long startTime, long endTime, boolean includeResourceAllocations,
324 HttpServletRequest hsr) throws Exception {
325 return getNextInterceptor().listReservation(queue, reservationId, startTime,
326 endTime, includeResourceAllocations, hsr);
327 }
328
329 @Override
330 public AppTimeoutInfo getAppTimeout(HttpServletRequest hsr, String appId,
331 String type) throws AuthorizationException {
332 return getNextInterceptor().getAppTimeout(hsr, appId, type);
333 }
334
335 @Override
336 public AppTimeoutsInfo getAppTimeouts(HttpServletRequest hsr, String appId)
337 throws AuthorizationException {
338 return getNextInterceptor().getAppTimeouts(hsr, appId);
339 }
340
341 @Override
342 public Response updateApplicationTimeout(AppTimeoutInfo appTimeout,
343 HttpServletRequest hsr, String appId) throws AuthorizationException,
344 YarnException, InterruptedException, IOException {
345 return getNextInterceptor().updateApplicationTimeout(appTimeout, hsr,
346 appId);
347 }
348 }