1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.util;
20
21 import org.apache.commons.logging.LogFactory;
22 import java.io.PrintStream;
23 import java.io.PrintWriter;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.hadoop.hbase.Version;
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28 import org.apache.hadoop.hbase.classification.InterfaceStability;
29
30
31
32
33 @InterfaceAudience.Public
34 @InterfaceStability.Evolving
35 public class VersionInfo {
36 private static final Log LOG = LogFactory.getLog(VersionInfo.class.getName());
37
38
39
40
41
42 public static String getVersion() {
43 return Version.version;
44 }
45
46
47
48
49
50 public static String getRevision() {
51 return Version.revision;
52 }
53
54
55
56
57
58 public static String getDate() {
59 return Version.date;
60 }
61
62
63
64
65
66 public static String getUser() {
67 return Version.user;
68 }
69
70
71
72
73
74 public static String getUrl() {
75 return Version.url;
76 }
77
78 static String[] versionReport() {
79 return new String[] {
80 "HBase " + getVersion(),
81 "Source code repository " + getUrl() + " revision=" + getRevision(),
82 "Compiled by " + getUser() + " on " + getDate(),
83 "From source with checksum " + getSrcChecksum()
84 };
85 }
86
87
88
89
90
91 public static String getSrcChecksum() {
92 return Version.srcChecksum;
93 }
94
95 public static void writeTo(PrintWriter out) {
96 for (String line : versionReport()) {
97 out.println(line);
98 }
99 }
100
101 public static void writeTo(PrintStream out) {
102 for (String line : versionReport()) {
103 out.println(line);
104 }
105 }
106
107 public static void logVersion() {
108 for (String line : versionReport()) {
109 LOG.info(line);
110 }
111 }
112
113 public static void main(String[] args) {
114 writeTo(System.out);
115 }
116 }