|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.continuent.tungsten.replicator.extractor.mysql.BinlogReader
public class BinlogReader
Encapsulates logic to open, read data, and clone positions on MySQL binlog
files. This file takes care of validating the header and also eliminates much
of the tangled logic of validating headers and cloning positions present in
former implementations. It also leans on the BufferedFileDataInput
class to ensure reads are buffered and minimize use of disk metadata calls
that kill performance on network-attached storage.
The new implementation replaces the old BinlogPosition class authored by Seppo Jaakola; a few fields are copied into this implementation but the logic is quite different.
| Constructor Summary | |
|---|---|
BinlogReader(long start,
java.lang.String fileName,
java.lang.String directory,
java.lang.String baseName,
int bufferSize)
Defines all possible binlog parameters . |
|
BinlogReader(java.lang.String directory,
java.lang.String baseName,
int bufferSize)
Defines only binlog directory and binlog file base name. |
|
| Method Summary | |
|---|---|
boolean |
accept(java.io.File dir,
java.lang.String name)
|
long |
available()
Returns the number of bytes available in the current log file. |
BinlogReader |
clone()
Clones the current reader position. |
void |
close()
Closes the stream but leaves directory and base name intact |
java.lang.String |
getBaseName()
|
java.lang.String |
getDirectory()
|
int |
getEventID()
|
java.lang.String |
getFileName()
|
long |
getPosition()
|
int |
getVersion()
|
boolean |
isOpen()
Returns true if a binlog log file is currently open. |
void |
mark(int readLimit)
Mark binlog to read up to limit. |
void |
read(byte[] buf)
Read bytes fully into a byte buffer. |
void |
read(byte[] buf,
int offset,
int len)
Read bytes fully into a byte buffer. |
byte |
readByte()
Read a single byte from binlog. |
int |
readInt()
Read a 4-byte int from binlog. |
long |
readLong()
Read an 8-byte long from binlog. |
void |
reset()
Reset binlog back to last mark. |
void |
setBaseName(java.lang.String baseName)
|
void |
setDirectory(java.lang.String directory)
|
void |
setEventID(int eventID)
|
void |
setFileName(java.lang.String fileName)
|
void |
setStartPosition(long newPosition)
|
void |
setVersion(int version)
|
long |
skip(long bytes)
Skips a given number of bytes. |
java.lang.String |
toString()
|
long |
waitAvailable(int requested,
int waitMillis)
Wait for a specific number of bytes to be available or until we time out |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BinlogReader(java.lang.String directory,
java.lang.String baseName,
int bufferSize)
directory - Directory path where binlog files should residebaseName - File name pattern for binlog files: basenName001.bin
public BinlogReader(long start,
java.lang.String fileName,
java.lang.String directory,
java.lang.String baseName,
int bufferSize)
start - Start location in the file, will skip until thatfileName - Full file path name to opendirectory - Directory path where binlog files should residebaseName - File name pattern for binlog files: baseName-000001.binbufferSize - Size of buffer to read| Method Detail |
|---|
public BinlogReader clone()
clone in class java.lang.ObjectObject.clone()public boolean isOpen()
public void close()
throws ReplicatorException
ReplicatorException
public long available()
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException - Thrown if call fails
java.lang.InterruptedException
public long waitAvailable(int requested,
int waitMillis)
throws java.io.IOException,
java.lang.InterruptedException
requested - Number of bytes requestedwaitMillis - Timeout in milliseconds
java.io.IOException - Thrown if wait fails
java.lang.InterruptedException - Thrown if interrupted during wait
public long skip(long bytes)
throws java.io.IOException
java.io.IOException - Thrown if bytes cannot be skippedpublic void mark(int readLimit)
readLimit - Number of bytes that may be read before resetting
public void reset()
throws java.io.IOException,
java.lang.InterruptedException
java.io.IOException - Thrown if mark has been invalidated or not set
java.lang.InterruptedException - Thrown if we are interrupted
public void read(byte[] buf)
throws java.io.IOException
buf - Buffer into which to read bytes
java.io.IOException - Thrown if read fails.
public void read(byte[] buf,
int offset,
int len)
throws java.io.IOException
buf - Buffer into which to transfer bytesoffset - Point at which to write bytes in arraylen - Number of bytes to read
java.io.IOException - Thrown if read fails.
public long readLong()
throws java.io.IOException
java.io.IOException - Thrown if read fails.
public int readInt()
throws java.io.IOException
java.io.IOException - Thrown if read fails.
public byte readByte()
throws java.io.IOException
java.io.IOException - Thrown if read fails.public void setStartPosition(long newPosition)
public long getPosition()
public void setFileName(java.lang.String fileName)
public java.lang.String getFileName()
public void setDirectory(java.lang.String directory)
public java.lang.String getDirectory()
public boolean accept(java.io.File dir,
java.lang.String name)
accept in interface java.io.FilenameFilterpublic java.lang.String getBaseName()
public void setBaseName(java.lang.String baseName)
public int getEventID()
public void setEventID(int eventID)
public int getVersion()
public void setVersion(int version)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||