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