Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@
by default describe will run "just like git-describe on the command line", even though it's a JGit reimplementation.
-->
<gitDescribe>

<!-- This will show the available tags-->
<tags>true</tags>

<!-- don't generate the describe property -->
<skip>false</skip>

<!--
if no tag was found "near" this commit, just print the commit's id instead,
helpful when you always expect this field to be not-empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public void initialize(URI name,Configuration conf) throws IOException{

public GlusterFileSystem(){
this(new GlusterVolume());
Version v=new Version();
log.info("Initializing GlusterFS, CRC disabled.");
log.info("GIT INFO="+v);
log.info("GIT_TAG="+v.getTag());
}

public GlusterFileSystem(FileSystem rawLocalFileSystem){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class GlusterFileSystemCRC extends LocalFileSystem{

public GlusterFileSystemCRC(){
super(new GlusterVolume());
Version v = new Version();
log.info("GIT INFO="+v);
log.info("GIT_TAG="+v.getTag());
}

public void setConf(Configuration conf){
Expand Down
41 changes: 36 additions & 5 deletions src/main/java/org/apache/hadoop/fs/glusterfs/Version.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
package org.apache.hadoop.fs.glusterfs;

import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties;

/**
* Versioning stuff for the shim. This class is not tested since there is no
* deterministic behaviour (i.e. it might not work if not building from binary),
* and the effects are pure side effects.
*/
public class Version extends Properties{
final static Logger lg = LoggerFactory.getLogger(Version.class);
public Version() {
super();
try{
load(this.getClass().getClassLoader().getResourceAsStream("git.properties"));
}
catch(Throwable t){
lg.error("Couldn't find git properties for version info " + t.getMessage());
throw new RuntimeException("Couldn't find git properties for version info " + t.getMessage());
}
}
public String getTag(){
return this.getProperty("git.commit.id.describe").split("-")[0];
}

/**
* For use with terminal version checking.

Example, run with an argument to get single property:
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
org.apache.hadoop.fs.glusterfs.Version git.commit.id.describe | cut -d'-' -f 1

Or just run (no args, prints all properties)
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
*/
public static void main(String[] args){
Version v = new Version();
//Dump the whole version info if no arg
if(args.length==0){
System.out.println(v);
}
//if specific arg given, print just that.
else{
String prop = v.get(args[0])+"";
System.out.println(
prop!=null?
prop
:"Couldnt find property "+prop);
}
}
}