1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.rest;
22
23 import java.io.IOException;
24
25 import javax.servlet.ServletContext;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.Path;
28 import javax.ws.rs.Produces;
29 import javax.ws.rs.core.CacheControl;
30 import javax.ws.rs.core.Context;
31 import javax.ws.rs.core.Response;
32 import javax.ws.rs.core.UriInfo;
33 import javax.ws.rs.core.Response.ResponseBuilder;
34
35 import org.apache.commons.logging.Log;
36 import org.apache.commons.logging.LogFactory;
37
38 import org.apache.hadoop.hbase.rest.model.VersionModel;
39
40
41
42
43
44
45
46
47 public class VersionResource extends ResourceBase {
48
49 private static final Log LOG = LogFactory.getLog(VersionResource.class);
50
51 static CacheControl cacheControl;
52 static {
53 cacheControl = new CacheControl();
54 cacheControl.setNoCache(true);
55 cacheControl.setNoTransform(false);
56 }
57
58
59
60
61
62 public VersionResource() throws IOException {
63 super();
64 }
65
66
67
68
69
70
71
72 @GET
73 @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
74 public Response get(final @Context ServletContext context,
75 final @Context UriInfo uriInfo) {
76 if (LOG.isDebugEnabled()) {
77 LOG.debug("GET " + uriInfo.getAbsolutePath());
78 }
79 servlet.getMetrics().incrementRequests(1);
80 ResponseBuilder response = Response.ok(new VersionModel(context));
81 response.cacheControl(cacheControl);
82 return response.build();
83 }
84
85
86
87
88 @Path("cluster")
89 public StorageClusterVersionResource getClusterVersionResource()
90 throws IOException {
91 return new StorageClusterVersionResource();
92 }
93
94
95
96
97 @Path("rest")
98 public VersionResource getVersionResource() {
99 return this;
100 }
101 }