1 /** 2 * Copyright 2010 The Apache Software Foundation 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package org.apache.hadoop.hbase.util; 22 23 import org.apache.hadoop.hbase.VersionAnnotation; 24 25 /** 26 * This class finds the package info for hbase and the VersionAnnotation 27 * information. Taken from hadoop. Only name of annotation is different. 28 */ 29 public class VersionInfo { 30 private static Package myPackage; 31 private static VersionAnnotation version; 32 33 static { 34 myPackage = VersionAnnotation.class.getPackage(); 35 version = myPackage.getAnnotation(VersionAnnotation.class); 36 } 37 38 /** 39 * Get the meta-data for the hbase package. 40 * @return package 41 */ 42 static Package getPackage() { 43 return myPackage; 44 } 45 46 /** 47 * Get the hbase version. 48 * @return the hbase version string, eg. "0.6.3-dev" 49 */ 50 public static String getVersion() { 51 return version != null ? version.version() : "Unknown"; 52 } 53 54 /** 55 * Get the subversion revision number for the root directory 56 * @return the revision number, eg. "451451" 57 */ 58 public static String getRevision() { 59 return version != null ? version.revision() : "Unknown"; 60 } 61 62 /** 63 * The date that hbase was compiled. 64 * @return the compilation date in unix date format 65 */ 66 public static String getDate() { 67 return version != null ? version.date() : "Unknown"; 68 } 69 70 /** 71 * The user that compiled hbase. 72 * @return the username of the user 73 */ 74 public static String getUser() { 75 return version != null ? version.user() : "Unknown"; 76 } 77 78 /** 79 * Get the subversion URL for the root hbase directory. 80 * @return the url 81 */ 82 public static String getUrl() { 83 return version != null ? version.url() : "Unknown"; 84 } 85 86 public static void main(String[] args) { 87 System.out.println("HBase " + getVersion()); 88 System.out.println("Subversion " + getUrl() + " -r " + getRevision()); 89 System.out.println("Compiled by " + getUser() + " on " + getDate()); 90 } 91 }