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  FSNamesystem namesystem
           
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, LOG, PRE_GENERATIONSTAMP_LAYOUT_VERSION, PRE_RBW_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
protected  void corruptPreUpgradeStorage(File rootDir)
           
 void format()
           
 FSEditLog getEditLog()
           
protected  void getFields(Properties props, Storage.StorageDirectory sd)
          Get common storage fields.
 File getFsEditName()
           
protected  FSNamesystem getFSNamesystem()
           
 boolean getRestoreFailedStorage()
           
 boolean isConversionNeeded(Storage.StorageDirectory sd)
           
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
static byte[] readBytes(DataInputStream in)
           
static String readString(DataInputStream in)
           
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 setRestoreFailedStorage(boolean val)
           
 
Methods inherited from class org.apache.hadoop.hdfs.server.common.Storage
addStorageDir, checkVersionUpgradable, deleteDir, dirIterator, dirIterator, getBuildVersion, getNumStorageDirs, getRegistrationID, getStorageDir, isLockSupported, listStorageDirectories, rename, unlockAll, writeAll, writeCorruptedData
 
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

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()

isConversionNeeded

public boolean isConversionNeeded(Storage.StorageDirectory sd)
                           throws IOException
Specified by:
isConversionNeeded in class Storage
Throws:
IOException

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

corruptPreUpgradeStorage

protected void corruptPreUpgradeStorage(File rootDir)
                                 throws IOException
Specified by:
corruptPreUpgradeStorage in class Storage
Throws:
IOException

readString

public static String readString(DataInputStream in)
                         throws IOException
Throws:
IOException

readBytes

public static byte[] readBytes(DataInputStream in)
                        throws IOException
Throws:
IOException


Copyright © 2009 The Apache Software Foundation