org.apache.hadoop.hdfs.server.namenode
Class FSImage

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.common.StorageInfo
      extended by org.apache.hadoop.hdfs.server.common.Storage
          extended by org.apache.hadoop.hdfs.server.namenode.FSImage
All Implemented Interfaces:
org.apache.hadoop.io.Writable
Direct Known Subclasses:
BackupStorage

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class FSImage
extends Storage

FSImage handles checkpointing and logging of the namespace edits.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.common.Storage
Storage.StorageDirectory, Storage.StorageDirType, Storage.StorageState
 
Field Summary
protected  long checkpointTime
           
protected  org.apache.hadoop.hdfs.server.namenode.FSImage.CheckpointStates ckptState
          Can fs-image be rolled?
protected  FSEditLog editLog
           
protected  org.apache.hadoop.io.MD5Hash imageDigest
           
protected  FSNamesystem namesystem
           
protected  org.apache.hadoop.io.MD5Hash newImageDigest
           
protected  List<Storage.StorageDirectory> removedStorageDirs
          list of failed (and thus removed) storages
 
Fields inherited from class org.apache.hadoop.hdfs.server.common.Storage
LAST_PRE_UPGRADE_LAYOUT_VERSION, LAST_UPGRADABLE_HADOOP_VERSION, LAST_UPGRADABLE_LAYOUT_VERSION, LAYOUT_VERSIONS_203, LOG, PRE_GENERATIONSTAMP_LAYOUT_VERSION, STORAGE_DIR_CURRENT, STORAGE_FILE_VERSION, storageDirs
 
Fields inherited from class org.apache.hadoop.hdfs.server.common.StorageInfo
cTime, layoutVersion, namespaceID
 
Constructor Summary
FSImage(StorageInfo storageInfo)
           
 
Method Summary
 void format()
           
 FSEditLog getEditLog()
           
protected  void getFields(Properties props, Storage.StorageDirectory sd)
          Get common storage fields.
 File getFsEditName()
           
protected  FSNamesystem getFSNamesystem()
           
 boolean getRestoreFailedStorage()
           
 boolean isPreUpgradableLayout(Storage.StorageDirectory sd)
          Return true if the layout of the given storage directory is from a version of Hadoop prior to the introduction of the "current" and "previous" directories which allow upgrade and rollback.
protected  void moveCurrent(Storage.StorageDirectory sd)
          Move current to lastcheckpoint.tmp and recreate empty current.
protected  void moveLastCheckpoint(Storage.StorageDirectory sd)
          Move lastcheckpoint.tmp to previous.checkpoint
protected  void saveCurrent(Storage.StorageDirectory sd)
          Save current image and empty journal into current directory.
protected  void setFields(Properties props, Storage.StorageDirectory sd)
          Write last checkpoint time and version file into the storage directory.
 void setImageDigest(org.apache.hadoop.io.MD5Hash digest)
           
 void setRestoreFailedStorage(boolean val)
           
 
Methods inherited from class org.apache.hadoop.hdfs.server.common.Storage
addStorageDir, checkVersionUpgradable, deleteDir, dirIterator, dirIterator, getBuildVersion, getNumStorageDirs, getRegistrationID, getStorageDir, is203LayoutVersion, isLockSupported, listStorageDirectories, rename, unlockAll, writeAll
 
Methods inherited from class org.apache.hadoop.hdfs.server.common.StorageInfo
getCTime, getLayoutVersion, getNamespaceID, readFields, setStorageInfo, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namesystem

protected FSNamesystem namesystem

checkpointTime

protected long checkpointTime

editLog

protected FSEditLog editLog

imageDigest

protected org.apache.hadoop.io.MD5Hash imageDigest

newImageDigest

protected org.apache.hadoop.io.MD5Hash newImageDigest

removedStorageDirs

protected List<Storage.StorageDirectory> removedStorageDirs
list of failed (and thus removed) storages


ckptState

protected volatile org.apache.hadoop.hdfs.server.namenode.FSImage.CheckpointStates ckptState
Can fs-image be rolled?

Constructor Detail

FSImage

public FSImage(StorageInfo storageInfo)
Method Detail

getFSNamesystem

protected FSNamesystem getFSNamesystem()

setRestoreFailedStorage

public void setRestoreFailedStorage(boolean val)

getRestoreFailedStorage

public boolean getRestoreFailedStorage()

getFields

protected void getFields(Properties props,
                         Storage.StorageDirectory sd)
                  throws IOException
Description copied from class: Storage
Get common storage fields. Should be overloaded if additional fields need to be get.

Overrides:
getFields in class Storage
Throws:
IOException

setFields

protected void setFields(Properties props,
                         Storage.StorageDirectory sd)
                  throws IOException
Write last checkpoint time and version file into the storage directory. The version file should always be written last. Missing or corrupted version file indicates that the checkpoint is not valid.

Overrides:
setFields in class Storage
Parameters:
sd - storage directory
Throws:
IOException

getEditLog

public FSEditLog getEditLog()

isPreUpgradableLayout

public boolean isPreUpgradableLayout(Storage.StorageDirectory sd)
                              throws IOException
Description copied from class: Storage
Return true if the layout of the given storage directory is from a version of Hadoop prior to the introduction of the "current" and "previous" directories which allow upgrade and rollback.

Specified by:
isPreUpgradableLayout in class Storage
Throws:
IOException

setImageDigest

public void setImageDigest(org.apache.hadoop.io.MD5Hash digest)

saveCurrent

protected void saveCurrent(Storage.StorageDirectory sd)
                    throws IOException
Save current image and empty journal into current directory.

Throws:
IOException

moveCurrent

protected void moveCurrent(Storage.StorageDirectory sd)
                    throws IOException
Move current to lastcheckpoint.tmp and recreate empty current. current is moved only if it is well formatted, that is contains VERSION file.

Throws:
IOException
See Also:
Storage.StorageDirectory.getLastCheckpointTmp(), Storage.StorageDirectory.getPreviousCheckpoint()

moveLastCheckpoint

protected void moveLastCheckpoint(Storage.StorageDirectory sd)
                           throws IOException
Move lastcheckpoint.tmp to previous.checkpoint

Throws:
IOException
See Also:
Storage.StorageDirectory.getPreviousCheckpoint(), Storage.StorageDirectory.getLastCheckpointTmp()

format

public void format()
            throws IOException
Throws:
IOException

getFsEditName

public File getFsEditName()
                   throws IOException
Throws:
IOException


Copyright © 2009 The Apache Software Foundation