28
28
import java .util .ArrayList ;
29
29
import java .util .Iterator ;
30
30
31
+ import org .apache .hadoop .conf .Configuration ;
31
32
import org .apache .hadoop .fs .BlockLocation ;
32
33
33
34
public class GlusterFSXattr {
@@ -42,10 +43,14 @@ public enum CMD {
42
43
43
44
private static String hostname ;
44
45
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" );
46
51
}
47
52
48
- public static String brick2host (String brick ) throws IOException {
53
+ public String brick2host (String brick ) throws IOException {
49
54
String [] hf =null ;
50
55
51
56
hf =brick .split (":" );
@@ -57,7 +62,7 @@ public static String brick2host(String brick) throws IOException{
57
62
return hf [0 ];
58
63
}
59
64
60
- public static String brick2file (String brick ) throws IOException {
65
+ public String brick2file (String brick ) throws IOException {
61
66
String [] hf =null ;
62
67
63
68
hf =brick .split (":" );
@@ -69,7 +74,7 @@ public static String brick2file(String brick) throws IOException{
69
74
return hf [1 ];
70
75
}
71
76
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 {
73
78
HashMap <String , ArrayList <String >> vol =null ;
74
79
HashMap <String , Integer > meta =new HashMap <String , Integer >();
75
80
@@ -78,7 +83,7 @@ public static BlockLocation[] getPathInfo(String filename,long start,long len) t
78
83
return getHints (vol , meta , start , len , null );
79
84
}
80
85
81
- public static long getBlockSize (String filename ) throws IOException {
86
+ public long getBlockSize (String filename ) throws IOException {
82
87
HashMap <String , ArrayList <String >> vol =null ;
83
88
HashMap <String , Integer > meta =new HashMap <String , Integer >();
84
89
@@ -91,7 +96,7 @@ public static long getBlockSize(String filename) throws IOException{
91
96
92
97
}
93
98
94
- public static short getReplication (String filename ) throws IOException {
99
+ public short getReplication (String filename ) throws IOException {
95
100
HashMap <String , ArrayList <String >> vol =null ;
96
101
HashMap <String , Integer > meta =new HashMap <String , Integer >();
97
102
@@ -101,7 +106,7 @@ public static short getReplication(String filename) throws IOException{
101
106
102
107
}
103
108
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 {
105
110
String realpath =null ;
106
111
HashMap <String , ArrayList <String >> vol =null ;
107
112
HashMap <String , Integer > meta =new HashMap <String , Integer >();
@@ -117,7 +122,7 @@ public static TreeMap<Integer, GlusterFSBrickClass> quickIOPossible(String filen
117
122
return hnts ;
118
123
}
119
124
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 {
121
126
Process p =null ;
122
127
BufferedReader brInput =null ;
123
128
String s =null ;
@@ -135,7 +140,7 @@ public static HashMap<String, ArrayList<String>> execGetFattr(String filename,Ha
135
140
136
141
HashMap <String , ArrayList <String >> vol =new HashMap <String , ArrayList <String >>();
137
142
138
- getfattrCmd ="getfattr -m . -n trusted.glusterfs.pathinfo " + filename ;
143
+ getfattrCmd =this . getFattrCmdBase + " " + filename ;
139
144
140
145
p =Runtime .getRuntime ().exec (getfattrCmd );
141
146
brInput =new BufferedReader (new InputStreamReader (p .getInputStream ()));
@@ -228,7 +233,7 @@ else if(enclosingXl.equalsIgnoreCase("distribute"))
228
233
return vol ;
229
234
}
230
235
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 {
232
237
String brick =null ;
233
238
String key =null ;
234
239
boolean done =false ;
@@ -430,7 +435,7 @@ else if(allocCtr<=stripedBricks.size()){
430
435
}
431
436
432
437
/* 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 {
434
439
int replication =0 ;
435
440
LAYOUT l =LAYOUT .valueOf (vol .get ("layout" ).get (0 ));
436
441
0 commit comments