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