Skip to content

Commit ca478fc

Browse files
committed
Merge pull request #34 from mattf/configurable-getfattrCmd-2
Configurable getfattr cmd, take 2
2 parents 6d4b387 + 4a2ca73 commit ca478fc

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.Iterator;
3030

31+
import org.apache.hadoop.conf.Configuration;
3132
import org.apache.hadoop.fs.BlockLocation;
3233

3334
public class GlusterFSXattr{
@@ -42,10 +43,14 @@ public enum CMD {
4243

4344
private static String hostname;
4445

45-
public GlusterFSXattr(){
46+
private String getFattrCmdBase;
47+
48+
public GlusterFSXattr(Configuration conf) {
49+
getFattrCmdBase=conf.get("fs.glusterfs.getfattrcmd",
50+
"getfattr -m . -n trusted.glusterfs.pathinfo");
4651
}
4752

48-
public static String brick2host(String brick) throws IOException{
53+
public String brick2host(String brick) throws IOException{
4954
String[] hf=null;
5055

5156
hf=brick.split(":");
@@ -57,7 +62,7 @@ public static String brick2host(String brick) throws IOException{
5762
return hf[0];
5863
}
5964

60-
public static String brick2file(String brick) throws IOException{
65+
public String brick2file(String brick) throws IOException{
6166
String[] hf=null;
6267

6368
hf=brick.split(":");
@@ -69,7 +74,7 @@ public static String brick2file(String brick) throws IOException{
6974
return hf[1];
7075
}
7176

72-
public static BlockLocation[] getPathInfo(String filename,long start,long len) throws IOException{
77+
public BlockLocation[] getPathInfo(String filename,long start,long len) throws IOException{
7378
HashMap<String, ArrayList<String>> vol=null;
7479
HashMap<String, Integer> meta=new HashMap<String, Integer>();
7580

@@ -78,7 +83,7 @@ public static BlockLocation[] getPathInfo(String filename,long start,long len) t
7883
return getHints(vol, meta, start, len, null);
7984
}
8085

81-
public static long getBlockSize(String filename) throws IOException{
86+
public long getBlockSize(String filename) throws IOException{
8287
HashMap<String, ArrayList<String>> vol=null;
8388
HashMap<String, Integer> meta=new HashMap<String, Integer>();
8489

@@ -91,7 +96,7 @@ public static long getBlockSize(String filename) throws IOException{
9196

9297
}
9398

94-
public static short getReplication(String filename) throws IOException{
99+
public short getReplication(String filename) throws IOException{
95100
HashMap<String, ArrayList<String>> vol=null;
96101
HashMap<String, Integer> meta=new HashMap<String, Integer>();
97102

@@ -101,7 +106,7 @@ public static short getReplication(String filename) throws IOException{
101106

102107
}
103108

104-
public static TreeMap<Integer, GlusterFSBrickClass> quickIOPossible(String filename,long start,long len) throws IOException{
109+
public TreeMap<Integer, GlusterFSBrickClass> quickIOPossible(String filename,long start,long len) throws IOException{
105110
String realpath=null;
106111
HashMap<String, ArrayList<String>> vol=null;
107112
HashMap<String, Integer> meta=new HashMap<String, Integer>();
@@ -117,7 +122,7 @@ public static TreeMap<Integer, GlusterFSBrickClass> quickIOPossible(String filen
117122
return hnts;
118123
}
119124

120-
public static HashMap<String, ArrayList<String>> execGetFattr(String filename,HashMap<String, Integer> meta,CMD cmd) throws IOException{
125+
public HashMap<String, ArrayList<String>> execGetFattr(String filename,HashMap<String, Integer> meta,CMD cmd) throws IOException{
121126
Process p=null;
122127
BufferedReader brInput=null;
123128
String s=null;
@@ -135,7 +140,7 @@ public static HashMap<String, ArrayList<String>> execGetFattr(String filename,Ha
135140

136141
HashMap<String, ArrayList<String>> vol=new HashMap<String, ArrayList<String>>();
137142

138-
getfattrCmd="getfattr -m . -n trusted.glusterfs.pathinfo "+filename;
143+
getfattrCmd=this.getFattrCmdBase + " " + filename;
139144

140145
p=Runtime.getRuntime().exec(getfattrCmd);
141146
brInput=new BufferedReader(new InputStreamReader(p.getInputStream()));
@@ -228,7 +233,7 @@ else if(enclosingXl.equalsIgnoreCase("distribute"))
228233
return vol;
229234
}
230235

231-
static BlockLocation[] getHints(HashMap<String, ArrayList<String>> vol,HashMap<String, Integer> meta,long start,long len,TreeMap<Integer, GlusterFSBrickClass> hnts) throws IOException{
236+
BlockLocation[] getHints(HashMap<String, ArrayList<String>> vol,HashMap<String, Integer> meta,long start,long len,TreeMap<Integer, GlusterFSBrickClass> hnts) throws IOException{
232237
String brick=null;
233238
String key=null;
234239
boolean done=false;
@@ -430,7 +435,7 @@ else if(allocCtr<=stripedBricks.size()){
430435
}
431436

432437
/* TODO: use meta{dcount,scount,rcount} for checking */
433-
public static int getReplicationFromLayout(HashMap<String, ArrayList<String>> vol,HashMap<String, Integer> meta) throws IOException{
438+
public int getReplicationFromLayout(HashMap<String, ArrayList<String>> vol,HashMap<String, Integer> meta) throws IOException{
434439
int replication=0;
435440
LAYOUT l=LAYOUT.valueOf(vol.get("layout").get(0));
436441

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void initialize(URI uri,Configuration conf) throws IOException{
140140
this.workingDir=new Path(glusterMount);
141141
this.uri=URI.create(uri.getScheme()+"://"+uri.getAuthority());
142142

143-
this.xattr=new GlusterFSXattr();
143+
this.xattr=new GlusterFSXattr(conf);
144144

145145
InetAddress addr=InetAddress.getLocalHost();
146146
this.hostname=addr.getHostName();

0 commit comments

Comments
 (0)