This project has retired. For details please refer to its
Attic page.
Examples xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.chukwa.hicc.rest;
19
20 import java.net.InetAddress;
21 import java.net.URI;
22 import java.net.URISyntaxException;
23 import java.net.UnknownHostException;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.apache.hadoop.chukwa.hicc.bean.Chart;
28 import org.apache.hadoop.chukwa.hicc.bean.Dashboard;
29 import org.apache.hadoop.chukwa.hicc.bean.Series;
30 import org.apache.hadoop.chukwa.hicc.bean.SeriesMetaData;
31 import org.apache.hadoop.chukwa.hicc.bean.Widget;
32
33 @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="MS_SHOULD_BE_FINAL")
34 public class Examples {
35
36 public static Chart SYSTEM_LOAD_AVERAGE;
37 public static Chart CPU_UTILIZATION;
38 public static Chart MEMORY_UTILIZATION;
39 public static Chart DISK_UTILIZATION;
40 public static Chart NETWORK_UTILIZATION;
41 public static Chart SWAP_UTILIZATION;
42 public static Chart NAMENODE_MEMORY;
43 public static Chart HDFS_USAGE;
44 public static Chart RESOURCE_MANAGER_MEMORY;
45 public static Chart NODE_MANAGER_HEALTH;
46 public static Chart HDFS_HA;
47 public static Chart HDFS_LOAD;
48 public static Chart NAMENODE_RPC_LATENCY;
49 public static Chart DATANODES;
50 public static Chart HBASE_MASTER_MEMORY;
51
52
53 public static Widget SYSTEM_LOAD_AVERAGE_WIDGET;
54 public static Widget WELCOME_PAGE_WIDGET;
55 public static Widget TRIAL_DOWNLOAD_WIDGET;
56 public static Widget CLUSTER_RUNNING_WIDGET;
57 public static Widget USER_WORKING_WIDGET;
58 public static Widget APP_RUNNING_WIDGET;
59 public static Widget TRIAL_ABANDON_RATE_WIDGET;
60 public static Widget CLUSTERS_HEALTH_WIDGET;
61 public static Widget TOP_ACTIVE_CLUSTERS_WIDGET;
62 public static Widget TOP_APP_WIDGET;
63 public static Widget APP_USAGE_WIDGET;
64 public static Widget QUICK_LINKS_WIDGET;
65 public static Widget LOG_SEARCH_WIDGET;
66 public static Widget YARN_APP_WIDGET;
67 public static Widget HDFS_WIDGET;
68 public static Widget HBASE_TABLE_WIDGET;
69 public static Widget TOP_USER_WIDGET;
70 public static Widget HDFS_HA_STATE_WIDGET;
71 public static Widget HDFS_LOAD_WIDGET;
72 public static Widget HDFS_NAMENODE_LATENCY_WIDGET;
73 public static Widget DATANODES_HEALTH_WIDGET;
74 public static Widget NODE_MANAGERS_HEALTH_WIDGET;
75 public static Widget HDFS_REMAINING_WIDGET;
76 public static Widget NAMENODE_MEMORY_WIDGET;
77 public static Widget RESOURCE_MANAGER_MEMORY_WIDGET;
78 public static Widget HBASE_MASTER_MOMORY_WIDGET;
79 public static Widget CPU_UTILIZATION_WIDGET;
80 public static Widget MEMORY_UTILIZATION_WIDGET;
81 public static Widget SWAP_UTILIZATION_WIDGET;
82 public static Widget DISK_UTILIZATION_WIDGET;
83 public static Widget NETWORK_UTILIZATION_WIDGET;
84 public static Widget CPU_HEAPMAP_WIDGET;
85 public static Widget HDFS_UI_WIDGET;
86 public static Widget HBASE_MASTER_UI_WIDGET;
87 public static List<Widget> WIDGET_LIST;
88
89 public static Dashboard DEFAULT_DASHBOARD;
90 public static Dashboard USER_DASHBOARD;
91 public static Dashboard SYSTEM_DASHBOARD;
92
93
94
95 public static Series CPU_METRICS;
96
97
98 public static List<SeriesMetaData> CPU_SERIES_METADATA;
99 public static List<SeriesMetaData> HDFS_USAGE_SERIES_METADATA;
100
101 static {
102 try {
103 final String hostname = InetAddress.getLocalHost().getHostName().toLowerCase();
104 final String[] metrics = { "SystemMetrics.LoadAverage.1" };
105 SYSTEM_LOAD_AVERAGE = Chart.createChart("1", "System Load Average", metrics, hostname, "");
106 final String[] cpuMetrics = { "SystemMetrics.cpu.combined", "SystemMetrics.cpu.sys", "SystemMetrics.cpu.user" };
107 CPU_UTILIZATION = Chart.createChart("2", "CPU Utilization", cpuMetrics, hostname, "percent");
108 final String[] memMetrics = { "SystemMetrics.memory.FreePercent", "SystemMetrics.memory.UsedPercent"};
109 MEMORY_UTILIZATION = Chart.createChart("3", "Memory Utilization", memMetrics, hostname, "percent");
110 final String[] diskMetrics = { "SystemMetrics.disk.ReadBytes", "SystemMetrics.disk.WriteBytes" };
111 DISK_UTILIZATION = Chart.createChart("4", "Disk Utilization", diskMetrics, hostname, "bytes-decimal");
112 final String[] netMetrics = { "SystemMetrics.network.TxBytes", "SystemMetrics.network.RxBytes" };
113 NETWORK_UTILIZATION = Chart.createChart("5", "Network Utilization", netMetrics, hostname, "bytes");
114 final String[] swapMetrics = { "SystemMetrics.swap.Total", "SystemMetrics.swap.Used", "SystemMetrics.swap.Free" };
115 SWAP_UTILIZATION = Chart.createChart("6", "Swap Utilization", swapMetrics, hostname, "bytes-decimal");
116
117
118 StringBuilder namenode = new StringBuilder();
119 namenode.append(hostname);
120 namenode.append(":NameNode");
121 final String[] namenodeHeap = { "HadoopMetrics.jvm.JvmMetrics.MemHeapUsedM", "HadoopMetrics.jvm.JvmMetrics.MemHeapMaxM" };
122 NAMENODE_MEMORY = Chart.createCircle("7", "Namenode Memory", namenodeHeap, namenode.toString(), "%", "up");
123
124
125 final String[] hdfsUsage = { "HadoopMetrics.dfs.FSNamesystem.CapacityRemainingGB", "HadoopMetrics.dfs.FSNamesystem.CapacityTotalGB" };
126 HDFS_USAGE = Chart.createCircle("8", "HDFS Remaining", hdfsUsage, hostname, "%", "down");
127
128
129 StringBuilder rmnode = new StringBuilder();
130 rmnode.append(hostname);
131 rmnode.append(":ResourceManager");
132 final String[] rmHeap = { "HadoopMetrics.jvm.JvmMetrics.MemHeapUsedM", "HadoopMetrics.jvm.JvmMetrics.MemHeapMaxM" };
133 RESOURCE_MANAGER_MEMORY = Chart.createCircle("9", "Resource Manager Memory", rmHeap, rmnode.toString(), "%", "up");
134
135
136 final String[] nmh = { "HadoopMetrics.yarn.ClusterMetrics.NumActiveNMs", "HadoopMetrics.yarn.ClusterMetrics.NumLostNMs" };
137 NODE_MANAGER_HEALTH = Chart.createTile("10", "Node Managers Health", "Node Managers", "Active/Lost", nmh, hostname, "glyphicon-th");
138
139
140 final String[] ha = { "HadoopMetrics.dfs.FSNamesystem.HAState" };
141 HDFS_HA = Chart.createTile("11", "HDFS High Availability State", "HDFS High Availability", "", ha, hostname, "glyphicon-random");
142
143
144 final String[] hdfsLoad = { "HadoopMetrics.dfs.FSNamesystem.TotalLoad" };
145 HDFS_LOAD = Chart.createTile("12", "HDFS Load Average", "HDFS Load", "", hdfsLoad, hostname, "glyphicon-signal");
146
147
148 final String[] nnLatency = { "HadoopMetrics.rpc.rpc.RpcProcessingTimeAvgTime" };
149 NAMENODE_RPC_LATENCY = Chart.createTile("13", "NameNode Latency", "NameNode RPC Latency", "Milliseconds", nnLatency, hostname, "glyphicon-tasks");
150
151
152 final String[] dnHealth = { "HadoopMetrics.dfs.FSNamesystem.StaleDataNodes" };
153 DATANODES = Chart.createTile("14", "Datanodes Health", "Datanodes", "Dead", dnHealth, hostname, "glyphicon-hdd");
154
155
156 StringBuilder hbaseMaster = new StringBuilder();
157 hbaseMaster.append(hostname);
158 hbaseMaster.append(":Master");
159 final String[] hbm = { "HBaseMetrics.jvm.JvmMetrics.MemHeapUsedM", "HBaseMetrics.jvm.JvmMetrics.MemHeapMaxM" };
160 HBASE_MASTER_MEMORY = Chart.createCircle("15", "HBase Master Memory", hbm, hbaseMaster.toString(), "%", "up");
161
162 CPU_SERIES_METADATA = CPU_UTILIZATION.getSeries();
163 HDFS_USAGE_SERIES_METADATA = HDFS_USAGE.getSeries();
164
165
166
167
168
169
170
171
172 Widget widget = new Widget();
173 widget.setTitle("System Load Average");
174 widget.setSrc(new URI("/hicc/v1/chart/draw/1"));
175 widget.setCol(1);
176 widget.setRow(1);
177 widget.setSize_x(2);
178 widget.setSize_y(1);
179 SYSTEM_LOAD_AVERAGE_WIDGET = widget;
180
181
182 Dashboard dashboard = new Dashboard();
183
184 widget = new Widget();
185 widget.setTitle("Welcome Page");
186 widget.setSrc(new URI("/hicc/welcome.html"));
187 widget.setCol(1);
188 widget.setRow(1);
189 widget.setSize_x(12);
190 widget.setSize_y(7);
191 WELCOME_PAGE_WIDGET = widget;
192 dashboard.add(WELCOME_PAGE_WIDGET);
193 DEFAULT_DASHBOARD = dashboard;
194
195 widget = new Widget();
196 widget.setTitle("Trial Downloading");
197 widget.setSrc(new URI("/hicc/home/downloads.html"));
198 widget.setCol(1);
199 widget.setRow(1);
200 widget.setSize_x(2);
201 widget.setSize_y(1);
202 TRIAL_DOWNLOAD_WIDGET = widget;
203
204 widget = new Widget();
205 widget.setTitle("Cluster Running");
206 widget.setSrc(new URI("/hicc/home/clusters.html"));
207 widget.setCol(3);
208 widget.setRow(1);
209 widget.setSize_x(2);
210 widget.setSize_y(1);
211 CLUSTER_RUNNING_WIDGET = widget;
212
213 widget = new Widget();
214 widget.setTitle("Users Working");
215 widget.setSrc(new URI("/hicc/home/users.html"));
216 widget.setCol(5);
217 widget.setRow(1);
218 widget.setSize_x(2);
219 widget.setSize_y(1);
220 USER_WORKING_WIDGET = widget;
221
222 widget = new Widget();
223 widget.setTitle("Applications Running");
224 widget.setSrc(new URI("/hicc/home/apps.html"));
225 widget.setCol(7);
226 widget.setRow(1);
227 widget.setSize_x(2);
228 widget.setSize_y(1);
229 APP_RUNNING_WIDGET = widget;
230
231 widget = new Widget();
232 widget.setTitle("Trial Abandon Rate");
233 widget.setSrc(new URI("/hicc/v1/circles/draw/11"));
234 widget.setCol(1);
235 widget.setRow(2);
236 widget.setSize_x(2);
237 widget.setSize_y(2);
238 TRIAL_ABANDON_RATE_WIDGET = widget;
239
240 widget = new Widget();
241 widget.setTitle("Clusters Health");
242 widget.setSrc(new URI("/hicc/v1/circles/draw/12"));
243 widget.setCol(3);
244 widget.setRow(2);
245 widget.setSize_x(2);
246 widget.setSize_y(2);
247 CLUSTERS_HEALTH_WIDGET = widget;
248
249 widget = new Widget();
250 widget.setTitle("Top Active Clusters");
251 widget.setSrc(new URI("/hicc/clusters/"));
252 widget.setCol(5);
253 widget.setRow(2);
254 widget.setSize_x(2);
255 widget.setSize_y(2);
256 TOP_ACTIVE_CLUSTERS_WIDGET = widget;
257
258 widget = new Widget();
259 widget.setTitle("Top Applications");
260 widget.setSrc(new URI("/hicc/apps/"));
261 widget.setCol(7);
262 widget.setRow(2);
263 widget.setSize_x(2);
264 widget.setSize_y(2);
265 TOP_APP_WIDGET = widget;
266
267 widget = new Widget();
268 widget.setTitle("Applications Usage");
269 widget.setSrc(new URI("/hicc/apps/apps-usage.html"));
270 widget.setCol(7);
271 widget.setRow(2);
272 widget.setSize_x(2);
273 widget.setSize_y(2);
274 APP_USAGE_WIDGET = widget;
275
276
277 dashboard = new Dashboard();
278
279 widget = new Widget();
280 widget.setTitle("Quick Links");
281 widget.setSrc(new URI("/hicc/v1/dashboard/quicklinks"));
282 widget.setCol(1);
283 widget.setRow(1);
284 widget.setSize_x(12);
285 widget.setSize_y(7);
286 QUICK_LINKS_WIDGET = widget;
287 dashboard.add(QUICK_LINKS_WIDGET);
288
289
290 widget = new Widget();
291 widget.setTitle("Log Search");
292 widget.setSrc(new URI("/hicc/ajax-solr/chukwa"));
293 widget.setCol(1);
294 widget.setRow(1);
295 widget.setSize_x(6);
296 widget.setSize_y(6);
297 LOG_SEARCH_WIDGET = widget;
298
299
300 widget = new Widget();
301 widget.setTitle("YARN Applications");
302 widget.setSrc(new URI("http://localhost:8088/"));
303 widget.setCol(1);
304 widget.setRow(7);
305 widget.setSize_x(6);
306 widget.setSize_y(6);
307 YARN_APP_WIDGET = widget;
308
309
310 widget = new Widget();
311 widget.setTitle("HDFS");
312 widget.setSrc(new URI("http://localhost:50070/explorer.html#/"));
313 widget.setCol(1);
314 widget.setRow(7);
315 widget.setSize_x(6);
316 widget.setSize_y(6);
317 HDFS_WIDGET = widget;
318
319
320 widget = new Widget();
321 widget.setTitle("HBase Tables");
322 widget.setSrc(new URI("http://localhost:50654/tablesDetailed.jsp"));
323 widget.setCol(1);
324 widget.setRow(14);
325 widget.setSize_x(6);
326 widget.setSize_y(6);
327 HBASE_TABLE_WIDGET = widget;
328
329 widget = new Widget();
330 widget.setTitle("Top Applications");
331 widget.setSrc(new URI("/hicc/apps/"));
332 widget.setCol(1);
333 widget.setRow(1);
334 widget.setSize_x(2);
335 widget.setSize_y(2);
336 TOP_APP_WIDGET = widget;
337
338 widget = new Widget();
339 widget.setTitle("Top Users");
340 widget.setSrc(new URI("/hicc/users/"));
341 widget.setCol(1);
342 widget.setRow(3);
343 widget.setSize_x(2);
344 widget.setSize_y(2);
345 TOP_USER_WIDGET = widget;
346 USER_DASHBOARD = dashboard;
347
348
349 dashboard = new Dashboard();
350 widget = new Widget();
351 widget.setTitle("HDFS High Availability State");
352 widget.setSrc(new URI("/hicc/v1/tile/draw/11"));
353 widget.setCol(1);
354 widget.setRow(1);
355 widget.setSize_x(2);
356 widget.setSize_y(1);
357 HDFS_HA_STATE_WIDGET = widget;
358 dashboard.add(HDFS_HA_STATE_WIDGET);
359
360 widget = new Widget();
361 widget.setTitle("HDFS Load");
362 widget.setSrc(new URI("/hicc/v1/tile/draw/12"));
363 widget.setCol(3);
364 widget.setRow(1);
365 widget.setSize_x(2);
366 widget.setSize_y(1);
367 HDFS_LOAD_WIDGET = widget;
368 dashboard.add(HDFS_LOAD_WIDGET);
369
370 widget = new Widget();
371 widget.setTitle("HDFS Namenode Latency");
372 widget.setSrc(new URI("/hicc/v1/tile/draw/13"));
373 widget.setCol(5);
374 widget.setRow(1);
375 widget.setSize_x(2);
376 widget.setSize_y(1);
377 HDFS_NAMENODE_LATENCY_WIDGET = widget;
378 dashboard.add(HDFS_NAMENODE_LATENCY_WIDGET);
379
380 widget = new Widget();
381 widget.setTitle("Datanodes Health");
382 widget.setSrc(new URI("/hicc/v1/tile/draw/14"));
383 widget.setCol(7);
384 widget.setRow(1);
385 widget.setSize_x(2);
386 widget.setSize_y(1);
387 DATANODES_HEALTH_WIDGET = widget;
388 dashboard.add(DATANODES_HEALTH_WIDGET);
389
390 widget = new Widget();
391 widget.setTitle("Node Managers Health");
392 widget.setSrc(new URI("/hicc/v1/tile/draw/10"));
393 widget.setCol(9);
394 widget.setRow(1);
395 widget.setSize_x(2);
396 widget.setSize_y(1);
397 NODE_MANAGERS_HEALTH_WIDGET = widget;
398 dashboard.add(NODE_MANAGERS_HEALTH_WIDGET);
399
400 widget = new Widget();
401 widget.setTitle("HDFS Remaining");
402 widget.setSrc(new URI("/hicc/v1/circles/draw/8"));
403 widget.setCol(1);
404 widget.setRow(2);
405 widget.setSize_x(2);
406 widget.setSize_y(2);
407 HDFS_REMAINING_WIDGET = widget;
408 dashboard.add(HDFS_REMAINING_WIDGET);
409
410 widget = new Widget();
411 widget.setTitle("Namenode Memory");
412 widget.setSrc(new URI("/hicc/v1/circles/draw/7"));
413 widget.setCol(3);
414 widget.setRow(2);
415 widget.setSize_x(2);
416 widget.setSize_y(2);
417 NAMENODE_MEMORY_WIDGET = widget;
418 dashboard.add(NAMENODE_MEMORY_WIDGET);
419
420 widget = new Widget();
421 widget.setTitle("Resource Manager Memory");
422 widget.setSrc(new URI("/hicc/v1/circles/draw/9"));
423 widget.setCol(5);
424 widget.setRow(2);
425 widget.setSize_x(2);
426 widget.setSize_y(2);
427 RESOURCE_MANAGER_MEMORY_WIDGET = widget;
428 dashboard.add(RESOURCE_MANAGER_MEMORY_WIDGET);
429
430 widget = new Widget();
431 widget.setTitle("HBase Master Memory");
432 widget.setSrc(new URI("/hicc/v1/circles/draw/15"));
433 widget.setCol(7);
434 widget.setRow(2);
435 widget.setSize_x(2);
436 widget.setSize_y(2);
437 HBASE_MASTER_MOMORY_WIDGET = widget;
438 dashboard.add(HBASE_MASTER_MOMORY_WIDGET);
439
440 widget = new Widget();
441 widget.setTitle("System Load Average");
442 widget.setSrc(new URI("/hicc/v1/chart/draw/1"));
443 widget.setCol(9);
444 widget.setRow(2);
445 widget.setSize_x(2);
446 widget.setSize_y(1);
447 SYSTEM_LOAD_AVERAGE_WIDGET = widget;
448 dashboard.add(SYSTEM_LOAD_AVERAGE_WIDGET);
449
450 widget = new Widget();
451 widget.setTitle("CPU Utilization");
452 widget.setSrc(new URI("/hicc/v1/chart/draw/2"));
453 widget.setCol(9);
454 widget.setRow(3);
455 widget.setSize_x(2);
456 widget.setSize_y(1);
457 CPU_UTILIZATION_WIDGET = widget;
458 dashboard.add(CPU_UTILIZATION_WIDGET);
459
460 widget = new Widget();
461 widget.setTitle("Memory Utilization");
462 widget.setSrc(new URI("/hicc/v1/chart/draw/3"));
463 widget.setCol(9);
464 widget.setRow(4);
465 widget.setSize_x(2);
466 widget.setSize_y(1);
467 MEMORY_UTILIZATION_WIDGET = widget;
468 dashboard.add(MEMORY_UTILIZATION_WIDGET);
469
470 widget = new Widget();
471 widget.setTitle("Swap Utilization");
472 widget.setSrc(new URI("/hicc/v1/chart/draw/6"));
473 widget.setCol(9);
474 widget.setRow(5);
475 widget.setSize_x(2);
476 widget.setSize_y(1);
477 SWAP_UTILIZATION_WIDGET = widget;
478 dashboard.add(SWAP_UTILIZATION_WIDGET);
479
480 widget = new Widget();
481 widget.setTitle("Disk Utilization");
482 widget.setSrc(new URI("/hicc/v1/chart/draw/4"));
483 widget.setCol(1);
484 widget.setRow(4);
485 widget.setSize_x(4);
486 widget.setSize_y(2);
487 DISK_UTILIZATION_WIDGET = widget;
488 dashboard.add(DISK_UTILIZATION_WIDGET);
489
490 widget = new Widget();
491 widget.setTitle("Network Utilization");
492 widget.setSrc(new URI("/hicc/v1/chart/draw/5"));
493 widget.setCol(5);
494 widget.setRow(4);
495 widget.setSize_x(4);
496 widget.setSize_y(2);
497 NETWORK_UTILIZATION_WIDGET = widget;
498 dashboard.add(NETWORK_UTILIZATION_WIDGET);
499 SYSTEM_DASHBOARD = dashboard;
500
501
502 widget = new Widget();
503 widget.setTitle("CPU Heatmap");
504 widget.setSrc(new URI("/hicc/v1/heatmap/render/SystemMetrics/cpu.combined."));
505 widget.setCol(1);
506 widget.setRow(5);
507 widget.setSize_x(6);
508 widget.setSize_y(5);
509 CPU_HEAPMAP_WIDGET = widget;
510
511
512 widget = new Widget();
513 widget.setTitle("HDFS UI");
514 widget.setSrc(new URI("http://localhost:50070/"));
515 widget.setCol(1);
516 widget.setRow(11);
517 widget.setSize_x(6);
518 widget.setSize_y(6);
519 HDFS_UI_WIDGET = widget;
520
521
522 widget = new Widget();
523 widget.setTitle("HBase Master UI");
524 widget.setSrc(new URI("http://localhost:16010/"));
525 widget.setCol(1);
526 widget.setRow(18);
527 widget.setSize_x(6);
528 widget.setSize_y(6);
529 HBASE_MASTER_UI_WIDGET = widget;
530
531 WIDGET_LIST = new ArrayList<Widget>();
532 WIDGET_LIST.add(HDFS_HA_STATE_WIDGET);
533 WIDGET_LIST.add(HDFS_UI_WIDGET);
534 WIDGET_LIST.add(HDFS_LOAD_WIDGET);
535 } catch (URISyntaxException e) {
536 } catch (UnknownHostException e) {
537 }
538 }
539
540 }