-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathhiveserver2.jsp
257 lines (243 loc) · 8.39 KB
/
hiveserver2.jsp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<%--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
--%>
<%@ page contentType="text/html;charset=UTF-8"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hive.conf.HiveConf"
import="org.apache.hadoop.hive.conf.HiveConf.ConfVars"
import="org.apache.hive.common.util.HiveVersionInfo"
import="org.apache.hive.http.HttpServer"
import="org.apache.hive.service.cli.operation.Operation"
import="org.apache.hive.service.cli.operation.SQLOperation"
import="org.apache.hadoop.hive.ql.QueryInfo"
import="org.apache.hive.service.cli.session.SessionManager"
import="org.apache.hive.service.cli.session.HiveSession"
import="javax.servlet.ServletContext"
import="java.util.Collection"
import="java.util.Date"
import="java.util.List"
import="jodd.util.HtmlEncoder"
%>
<%
ServletContext ctx = getServletContext();
Configuration conf = (Configuration)ctx.getAttribute("hive.conf");
long startcode = conf.getLong("startcode", System.currentTimeMillis());
SessionManager sessionManager =
(SessionManager)ctx.getAttribute("hive.sm");
String remoteUser = request.getRemoteUser();
%>
<!--[if IE]>
<!DOCTYPE html>
<![endif]-->
<?xml version="1.0" encoding="UTF-8" ?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HiveServer2</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="/static/css/hive.css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-fixed-top navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/hiveserver2.jsp"><img src="/static/hive_logo.jpeg" alt="Hive Logo"/></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="/logs/">Local logs</a></li>
<li><a href="/jmx">Metrics Dump</a></li>
<li><a href="/conf">Hive Configuration</a></li>
<li><a href="/stacks">Stack Trace</a></li>
<li><a href="/llap.html">Llap Daemons</a></li>
<li><a href="/logconf.jsp">Configure logging</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<div class="row inner_header">
<div class="page-header">
<h1>HiveServer2</h1>
</div>
</div>
<div class="row">
<%
if (sessionManager != null) {
long currentTime = System.currentTimeMillis();
%>
<section>
<h2>Active Sessions</h2>
<table class="table table-striped">
<tr>
<th>User Name</th>
<th>IP Address</th>
<th>Operation Count</th>
<th>Active Time (s)</th>
<th>Idle Time (s)</th>
</tr>
<%
Collection<HiveSession> hiveSessions = sessionManager.getSessions();
int sessionCount = 0;
for (HiveSession hiveSession: hiveSessions) {
// Permission check
if (!HttpServer.hasAccess(remoteUser, hiveSession.getUserName(), ctx, request)) {
continue;
}
sessionCount++;
%>
<tr>
<td><%= hiveSession.getUserName() %></td>
<td><%= hiveSession.getIpAddress() %></td>
<td><%= hiveSession.getOpenOperationCount() %></td>
<td><%= (currentTime - hiveSession.getCreationTime())/1000 %></td>
<td><%= (currentTime - hiveSession.getLastAccessTime())/1000 %></td>
</tr>
<%
}
%>
<tr>
<td colspan="5">Total number of sessions: <%= sessionCount %></td>
</tr>
</table>
</section>
<section>
<h2>Open Queries</h2>
<table class="table table-striped">
<tr>
<th>User Name</th>
<th>Query</th>
<th>Execution Engine</th>
<th>State</th>
<th>Opened Timestamp</th>
<th>Opened (s)</th>
<th>Latency (s)</th>
<th>Drilldown Link</th>
</tr>
<%
int queries = 0;
Collection<QueryInfo> operations = sessionManager.getOperationManager().getLiveQueryInfos();
for (QueryInfo operation : operations) {
if (!HttpServer.hasAccess(remoteUser, operation.getUserName(), ctx, request)) {
continue;
}
queries++;
%>
<tr>
<td><%= operation.getUserName() %></td>
<td><%= HtmlEncoder.strict(operation.getQueryDisplay() == null ? "Unknown" : operation.getQueryDisplay().getQueryString()) %></td>
<td><%= operation.getExecutionEngine() %>
<td><%= operation.getState() %></td>
<td><%= new Date(operation.getBeginTime()) %></td>
<td><%= operation.getElapsedTime()/1000 %></td>
<td><%= operation.getRuntime() == null ? "Not finished" : operation.getRuntime()/1000 %></td>
<% String link = "/query_page.html?operationId=" + operation.getOperationId(); %>
<td> <a href= <%= link %>>Drilldown</a> </td>
</tr>
<%
}
%>
<tr>
<td colspan="8">Total number of queries: <%= queries %></td>
</tr>
</table>
</section>
<section>
<h2>Last Max <%= conf.get(ConfVars.HIVE_SERVER2_WEBUI_MAX_HISTORIC_QUERIES.varname) %> Closed Queries</h2>
<table class="table table-striped">
<tr>
<th>User Name</th>
<th>Query</th>
<th>Execution Engine</th>
<th>State</th>
<th>Opened (s)</th>
<th>Closed Timestamp</th>
<th>Latency (s)</th>
<th>Drilldown Link</th>
</tr>
<%
queries = 0;
operations = sessionManager.getOperationManager().getHistoricalQueryInfos();
for (QueryInfo operation : operations) {
if (!HttpServer.hasAccess(remoteUser, operation.getUserName(), ctx, request)) {
continue;
}
queries++;
%>
<tr>
<td><%= operation.getUserName() %></td>
<td><%= HtmlEncoder.strict(operation.getQueryDisplay() == null ? "Unknown" : operation.getQueryDisplay().getQueryString()) %></td>
<td><%= operation.getExecutionEngine() %>
<td><%= operation.getState() %></td>
<td><%= operation.getElapsedTime()/1000 %></td>
<td><%= operation.getEndTime() == null ? "In Progress" : new Date(operation.getEndTime()) %></td>
<td><%= operation.getRuntime() == null ? "n/a" : operation.getRuntime()/1000 %></td>
<% String link = "/query_page.html?operationId=" + operation.getOperationId(); %>
<td> <a href= <%= link %>>Drilldown</a> </td>
</tr>
<%
}
%>
<tr>
<td colspan="8">Total number of queries: <%= queries %></td>
</tr>
</table>
</section>
<%
}
%>
<section>
<h2>Software Attributes</h2>
<table class="table table-striped">
<tr>
<th>Attribute Name</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td>Hive Version</td>
<td><%= HiveVersionInfo.getVersion() %>, r<%= HiveVersionInfo.getRevision() %></td>
<td>Hive version and revision</td>
</tr>
<tr>
<td>Hive Compiled</td>
<td><%= HiveVersionInfo.getDate() %>, <%= HiveVersionInfo.getUser() %></td>
<td>When Hive was compiled and by whom</td>
</tr>
<tr>
<td>HiveServer2 Start Time</td>
<td><%= new Date(startcode) %></td>
<td>Date stamp of when this HiveServer2 was started</td>
</tr>
</table>
</section>
</div>
</div>
</body>
</html>