|
@@ -403,8 +403,10 @@ class FSDirectory implements FSConstants {
|
|
UTF8 name = new UTF8();
|
|
UTF8 name = new UTF8();
|
|
name.readFields(in);
|
|
name.readFields(in);
|
|
// version 0 does not support per file replication
|
|
// version 0 does not support per file replication
|
|
- if( !(imgVersion >= 0) )
|
|
|
|
|
|
+ if( !(imgVersion >= 0) ) {
|
|
replication = in.readShort(); // other versions do
|
|
replication = in.readShort(); // other versions do
|
|
|
|
+ replication = adjustReplication( replication, conf );
|
|
|
|
+ }
|
|
int numBlocks = in.readInt();
|
|
int numBlocks = in.readInt();
|
|
Block blocks[] = null;
|
|
Block blocks[] = null;
|
|
if (numBlocks > 0) {
|
|
if (numBlocks > 0) {
|
|
@@ -484,6 +486,7 @@ class FSDirectory implements FSConstants {
|
|
name = (UTF8) writables[0];
|
|
name = (UTF8) writables[0];
|
|
replication = Short.parseShort(
|
|
replication = Short.parseShort(
|
|
((UTF8)writables[1]).toString());
|
|
((UTF8)writables[1]).toString());
|
|
|
|
+ replication = adjustReplication( replication, conf );
|
|
}
|
|
}
|
|
// get blocks
|
|
// get blocks
|
|
aw = new ArrayWritable(Block.class);
|
|
aw = new ArrayWritable(Block.class);
|
|
@@ -501,8 +504,11 @@ class FSDirectory implements FSConstants {
|
|
UTF8 repl = new UTF8();
|
|
UTF8 repl = new UTF8();
|
|
src.readFields(in);
|
|
src.readFields(in);
|
|
repl.readFields(in);
|
|
repl.readFields(in);
|
|
|
|
+ replication=adjustReplication(
|
|
|
|
+ fromLogReplication(repl),
|
|
|
|
+ conf);
|
|
unprotectedSetReplication(src.toString(),
|
|
unprotectedSetReplication(src.toString(),
|
|
- fromLogReplication(repl),
|
|
|
|
|
|
+ replication,
|
|
null);
|
|
null);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -541,6 +547,17 @@ class FSDirectory implements FSConstants {
|
|
return numEdits;
|
|
return numEdits;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static short adjustReplication( short replication, Configuration conf) {
|
|
|
|
+ short minReplication = (short)conf.getInt("dfs.replication.min", 1);
|
|
|
|
+ if( replication<minReplication ) {
|
|
|
|
+ replication = minReplication;
|
|
|
|
+ }
|
|
|
|
+ short maxReplication = (short)conf.getInt("dfs.replication.max", 512);
|
|
|
|
+ if( replication>maxReplication ) {
|
|
|
|
+ replication = maxReplication;
|
|
|
|
+ }
|
|
|
|
+ return replication;
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* Save the contents of the FS image
|
|
* Save the contents of the FS image
|
|
*/
|
|
*/
|