1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.http;
21
22 import java.io.IOException;
23 import java.net.URI;
24
25 import javax.servlet.http.HttpServlet;
26
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28 import org.apache.hadoop.conf.Configuration;
29
30
31
32
33
34
35
36
37
38 @InterfaceAudience.Private
39 public class InfoServer {
40
41 private static final String HBASE_APP_DIR = "hbase-webapps";
42 private final org.apache.hadoop.hbase.http.HttpServer httpServer;
43
44
45
46
47
48
49
50
51
52
53
54 public InfoServer(String name, String bindAddress, int port, boolean findPort,
55 final Configuration c)
56 throws IOException {
57 HttpConfig httpConfig = new HttpConfig(c);
58 HttpServer.Builder builder =
59 new org.apache.hadoop.hbase.http.HttpServer.Builder();
60
61 builder.setName(name).addEndpoint(URI.create(httpConfig.getSchemePrefix() +
62 bindAddress + ":" +
63 port)).setAppDir(HBASE_APP_DIR).setFindPort(findPort).setConf(c);
64 String logDir = System.getProperty("hbase.log.dir");
65 if (logDir != null) {
66 builder.setLogDir(logDir);
67 }
68 if (httpConfig.isSecure()) {
69 builder.keyPassword(c.get("ssl.server.keystore.keypassword"))
70 .keyStore(c.get("ssl.server.keystore.location"),
71 c.get("ssl.server.keystore.password"),
72 c.get("ssl.server.keystore.type", "jks"))
73 .trustStore(c.get("ssl.server.truststore.location"),
74 c.get("ssl.server.truststore.password"),
75 c.get("ssl.server.truststore.type", "jks"));
76 }
77 this.httpServer = builder.build();
78 }
79
80 public void addServlet(String name, String pathSpec,
81 Class<? extends HttpServlet> clazz) {
82 this.httpServer.addServlet(name, pathSpec, clazz);
83 }
84
85 public void setAttribute(String name, Object value) {
86 this.httpServer.setAttribute(name, value);
87 }
88
89 public void start() throws IOException {
90 this.httpServer.start();
91 }
92
93 @Deprecated
94 public int getPort() {
95 return this.httpServer.getPort();
96 }
97
98 public void stop() throws Exception {
99 this.httpServer.stop();
100 }
101
102 }