|
@@ -378,25 +378,29 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
private INodeId inodeId;
|
|
private INodeId inodeId;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the last allocated inode id when fsimage is loaded or editlog is
|
|
|
|
- * applied.
|
|
|
|
- * @throws IOException
|
|
|
|
|
|
+ * Set the last allocated inode id when fsimage or editlog is loaded.
|
|
*/
|
|
*/
|
|
public void resetLastInodeId(long newValue) throws IOException {
|
|
public void resetLastInodeId(long newValue) throws IOException {
|
|
- inodeId.resetLastInodeId(newValue);
|
|
|
|
|
|
+ try {
|
|
|
|
+ inodeId.skipTo(newValue);
|
|
|
|
+ } catch(IllegalStateException ise) {
|
|
|
|
+ throw new IOException(ise);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/** Should only be used for tests to reset to any value */
|
|
/** Should only be used for tests to reset to any value */
|
|
void resetLastInodeIdWithoutChecking(long newValue) {
|
|
void resetLastInodeIdWithoutChecking(long newValue) {
|
|
- inodeId.resetLastInodeIdWithoutChecking(newValue);
|
|
|
|
|
|
+ inodeId.setCurrentValue(newValue);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** @return the last inode ID. */
|
|
public long getLastInodeId() {
|
|
public long getLastInodeId() {
|
|
- return inodeId.getLastInodeId();
|
|
|
|
|
|
+ return inodeId.getCurrentValue();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** Allocate a new inode ID. */
|
|
public long allocateNewInodeId() {
|
|
public long allocateNewInodeId() {
|
|
- return inodeId.allocateNewInodeId();
|
|
|
|
|
|
+ return inodeId.nextValue();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -405,9 +409,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
void clear() {
|
|
void clear() {
|
|
dir.reset();
|
|
dir.reset();
|
|
dtSecretManager.reset();
|
|
dtSecretManager.reset();
|
|
- generationStamp.setStamp(GenerationStamp.FIRST_VALID_STAMP);
|
|
|
|
|
|
+ generationStamp.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
|
|
leaseManager.removeAllLeases();
|
|
leaseManager.removeAllLeases();
|
|
- inodeId.resetLastInodeIdWithoutChecking(INodeId.LAST_RESERVED_ID);
|
|
|
|
|
|
+ inodeId.setCurrentValue(INodeId.LAST_RESERVED_ID);
|
|
}
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
@@ -2537,8 +2541,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
b.setBlockId(DFSUtil.getRandom().nextLong());
|
|
b.setBlockId(DFSUtil.getRandom().nextLong());
|
|
}
|
|
}
|
|
// Increment the generation stamp for every new block.
|
|
// Increment the generation stamp for every new block.
|
|
- nextGenerationStamp();
|
|
|
|
- b.setGenerationStamp(getGenerationStamp());
|
|
|
|
|
|
+ b.setGenerationStamp(nextGenerationStamp());
|
|
b = dir.addBlock(src, inodesInPath, b, targets);
|
|
b = dir.addBlock(src, inodesInPath, b, targets);
|
|
NameNode.stateChangeLog.info("BLOCK* allocateBlock: " + src + ". "
|
|
NameNode.stateChangeLog.info("BLOCK* allocateBlock: " + src + ". "
|
|
+ blockPoolId + " " + b);
|
|
+ blockPoolId + " " + b);
|
|
@@ -4762,14 +4765,14 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
* Sets the generation stamp for this filesystem
|
|
* Sets the generation stamp for this filesystem
|
|
*/
|
|
*/
|
|
void setGenerationStamp(long stamp) {
|
|
void setGenerationStamp(long stamp) {
|
|
- generationStamp.setStamp(stamp);
|
|
|
|
|
|
+ generationStamp.setCurrentValue(stamp);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Gets the generation stamp for this filesystem
|
|
* Gets the generation stamp for this filesystem
|
|
*/
|
|
*/
|
|
long getGenerationStamp() {
|
|
long getGenerationStamp() {
|
|
- return generationStamp.getStamp();
|
|
|
|
|
|
+ return generationStamp.getCurrentValue();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -4781,7 +4784,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
throw new SafeModeException(
|
|
throw new SafeModeException(
|
|
"Cannot get next generation stamp", safeMode);
|
|
"Cannot get next generation stamp", safeMode);
|
|
}
|
|
}
|
|
- long gs = generationStamp.nextStamp();
|
|
|
|
|
|
+ final long gs = generationStamp.nextValue();
|
|
getEditLog().logGenerationStamp(gs);
|
|
getEditLog().logGenerationStamp(gs);
|
|
// NB: callers sync the log
|
|
// NB: callers sync the log
|
|
return gs;
|
|
return gs;
|