Skip to content

Commit 7f5318e

Browse files
committed
Merge pull request #52 from jayunit100/master
Patch to add logging of version back in.
2 parents 2ecf673 + 7804454 commit 7f5318e

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@
144144
by default describe will run "just like git-describe on the command line", even though it's a JGit reimplementation.
145145
-->
146146
<gitDescribe>
147-
147+
<!-- This will show the available tags-->
148+
<tags>true</tags>
149+
148150
<!-- don't generate the describe property -->
149151
<skip>false</skip>
150-
151152
<!--
152153
if no tag was found "near" this commit, just print the commit's id instead,
153154
helpful when you always expect this field to be not-empty

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFileSystem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public void initialize(URI name,Configuration conf) throws IOException{
6262

6363
public GlusterFileSystem(){
6464
this(new GlusterVolume());
65+
Version v=new Version();
6566
log.info("Initializing GlusterFS, CRC disabled.");
67+
log.info("GIT INFO="+v);
68+
log.info("GIT_TAG="+v.getTag());
6669
}
6770

6871
public GlusterFileSystem(FileSystem rawLocalFileSystem){

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFileSystemCRC.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public class GlusterFileSystemCRC extends LocalFileSystem{
4343

4444
public GlusterFileSystemCRC(){
4545
super(new GlusterVolume());
46+
Version v = new Version();
47+
log.info("GIT INFO="+v);
48+
log.info("GIT_TAG="+v.getTag());
4649
}
4750

4851
public void setConf(Configuration conf){
Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
11
package org.apache.hadoop.fs.glusterfs;
22

33
import java.io.IOException;
4-
import java.util.Properties;
54

6-
import org.slf4j.Logger;
7-
import org.slf4j.LoggerFactory;
5+
import java.util.Properties;
86

7+
/**
8+
* Versioning stuff for the shim. This class is not tested since there is no
9+
* deterministic behaviour (i.e. it might not work if not building from binary),
10+
* and the effects are pure side effects.
11+
*/
912
public class Version extends Properties{
10-
final static Logger lg = LoggerFactory.getLogger(Version.class);
1113
public Version() {
1214
super();
1315
try{
1416
load(this.getClass().getClassLoader().getResourceAsStream("git.properties"));
1517
}
1618
catch(Throwable t){
17-
lg.error("Couldn't find git properties for version info " + t.getMessage());
19+
throw new RuntimeException("Couldn't find git properties for version info " + t.getMessage());
20+
}
21+
}
22+
public String getTag(){
23+
return this.getProperty("git.commit.id.describe").split("-")[0];
24+
}
25+
26+
/**
27+
* For use with terminal version checking.
28+
29+
Example, run with an argument to get single property:
30+
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
31+
org.apache.hadoop.fs.glusterfs.Version git.commit.id.describe | cut -d'-' -f 1
32+
33+
Or just run (no args, prints all properties)
34+
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
35+
*/
36+
public static void main(String[] args){
37+
Version v = new Version();
38+
//Dump the whole version info if no arg
39+
if(args.length==0){
40+
System.out.println(v);
41+
}
42+
//if specific arg given, print just that.
43+
else{
44+
String prop = v.get(args[0])+"";
45+
System.out.println(
46+
prop!=null?
47+
prop
48+
:"Couldnt find property "+prop);
1849
}
1950
}
2051
}

0 commit comments

Comments
 (0)