Class EditLogFileInputStream
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
org.apache.hadoop.hdfs.server.namenode.EditLogFileInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An implementation of the abstract class
EditLogInputStream, which
reads edits from a file. That file may be either on the local disk or
accessible via a URL.-
Constructor Summary
ConstructorsConstructorDescriptionEditLogFileInputStream(File name, long firstTxId, long lastTxId, boolean isInProgress) Open an EditLogInputStream for the given file. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the stream.static EditLogInputStreamfromByteString(org.apache.hadoop.thirdparty.protobuf.ByteString bytes, long startTxId, long endTxId, boolean inProgress) Create an EditLogInputStream from aByteString, i.e. an in-memory collection of bytes.static EditLogInputStreamfromUrl(org.apache.hadoop.hdfs.web.URLConnectionFactory connectionFactory, URL url, long startTxId, long endTxId, boolean inProgress) Open an EditLogInputStream for the given URL.longlonggetName()longGet the "position" of in the stream.intgetVersion(boolean verifyVersion) Get the layout version of the data in the stream.booleanReturn true if this stream is in progress, false if it is finalized.booleanReturns true if we are currently reading the log from a local disk or an even faster data source (e.g. a byte buffer).longlength()Return the size of the current edits log or -1 if unknown.protected FSEditLogOpnextOp()Get the next operation from the stream storage.protected FSEditLogOpGet the next valid operation from the stream storage.protected longGo through the next operation from the stream storage.voidsetMaxOpSize(int maxOpSize) Set the maximum opcode size in bytes.toString()Methods inherited from class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
getCurrentStreamName, readOp, resync, skipUntil
-
Constructor Details
-
EditLogFileInputStream
Open an EditLogInputStream for the given file.- Parameters:
name- filename to openfirstTxId- first transaction found in filelastTxId- last transaction id found in file
-
-
Method Details
-
fromUrl
public static EditLogInputStream fromUrl(org.apache.hadoop.hdfs.web.URLConnectionFactory connectionFactory, URL url, long startTxId, long endTxId, boolean inProgress) Open an EditLogInputStream for the given URL.- Parameters:
connectionFactory- the URLConnectionFactory used to create the connection.url- the url hosting the logstartTxId- the expected starting txidendTxId- the expected ending txidinProgress- whether the log is in-progress- Returns:
- a stream from which edits may be read
-
fromByteString
public static EditLogInputStream fromByteString(org.apache.hadoop.thirdparty.protobuf.ByteString bytes, long startTxId, long endTxId, boolean inProgress) Create an EditLogInputStream from aByteString, i.e. an in-memory collection of bytes.- Parameters:
bytes- The byte string to read fromstartTxId- the expected starting transaction IDendTxId- the expected ending transaction IDinProgress- whether the log is in-progress- Returns:
- An edit stream to read from
-
getFirstTxId
public long getFirstTxId()- Specified by:
getFirstTxIdin classEditLogInputStream- Returns:
- the first transaction which will be found in this stream
-
getLastTxId
public long getLastTxId()- Specified by:
getLastTxIdin classEditLogInputStream- Returns:
- the last transaction which will be found in this stream
-
getName
- Specified by:
getNamein classEditLogInputStream- Returns:
- the name of the EditLogInputStream
-
scanNextOp
Description copied from class:EditLogInputStreamGo through the next operation from the stream storage.- Overrides:
scanNextOpin classEditLogInputStream- Returns:
- the txid of the next operation.
- Throws:
IOException
-
nextOp
Description copied from class:EditLogInputStreamGet the next operation from the stream storage.- Specified by:
nextOpin classEditLogInputStream- Returns:
- an operation from the stream or null if at end of stream
- Throws:
IOException- if there is an error reading from the stream
-
nextValidOp
Description copied from class:EditLogInputStreamGet the next valid operation from the stream storage. This is exactly like nextOp, except that we attempt to skip over damaged parts of the edit log- Overrides:
nextValidOpin classEditLogInputStream- Returns:
- an operation from the stream or null if at end of stream
-
getVersion
Description copied from class:EditLogInputStreamGet the layout version of the data in the stream.- Specified by:
getVersionin classEditLogInputStream- Returns:
- the layout version of the ops in the stream.
- Throws:
IOException- if there is an error reading the version
-
getPosition
public long getPosition()Description copied from class:EditLogInputStreamGet the "position" of in the stream. This is useful for debugging and operational purposes. Different stream types can have a different meaning for what the position is. For file streams it means the byte offset from the start of the file.- Specified by:
getPositionin classEditLogInputStream- Returns:
- the position in the stream
-
close
Description copied from class:EditLogInputStreamClose the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classEditLogInputStream- Throws:
IOException- if an error occurred while closing
-
length
Description copied from class:EditLogInputStreamReturn the size of the current edits log or -1 if unknown.- Specified by:
lengthin classEditLogInputStream- Returns:
- long size of the current edits log or -1 if unknown
- Throws:
IOException
-
isInProgress
public boolean isInProgress()Description copied from class:EditLogInputStreamReturn true if this stream is in progress, false if it is finalized.- Specified by:
isInProgressin classEditLogInputStream
-
toString
- Overrides:
toStringin classEditLogInputStream
-
setMaxOpSize
public void setMaxOpSize(int maxOpSize) Description copied from class:EditLogInputStreamSet the maximum opcode size in bytes.- Specified by:
setMaxOpSizein classEditLogInputStream
-
isLocalLog
public boolean isLocalLog()Description copied from class:EditLogInputStreamReturns true if we are currently reading the log from a local disk or an even faster data source (e.g. a byte buffer).- Specified by:
isLocalLogin classEditLogInputStream
-