Package com.nt.udc.io
Class CDataSourceSuperTail
java.lang.Object
com.nt.udc.io.CDataSourceSuperTail
- All Implemented Interfaces:
IDataSource
This class is used as the source of data retrieved from SuperTail.
- Since:
- JDK1.1.7
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanThis member represents an error flag set if the connection to SuperTail cannot be established.protected FileThis member represents the bookmark-file associated to the file currently being processed.protected RandomAccessFileThis member represents the bookmark-stream opened on m_bookmarkFile.protected intprotected StringThis member represents the name of the file currently being processed.protected intThis is the current index in m_crtLine.protected StringThis member represents the current line read from SuperTail.protected intThis member represents the current line number.protected doubleThis member represents the number of days for preserving check-point files.protected static intprotected CDataSourceSuperTail.DelegateThis delegate is used to check if we need to wait or not.protected final Stringprotected FilenameFilterThis member is used to filter files to process.protected StringThis member represents the hostname.protected ILoggerThis member is used to report errors and warnings.protected BufferedInputStreamThis member represents the input stream from SuperTail.protected PrintWriterThis member is used to send messages from SuperTail.protected intThis member represents the port-number.protected BufferedReaderThis member is used to read characters from SuperTail.protected intprotected StringThis member represents the remote directory on SuperTail's host.protected COSARReporterThis member is used to send reports to.protected StringThis member represents the scratch directory.protected SocketThis member represents the remote socket to access SuperTail.Fields inherited from interface com.nt.udc.io.IDataSource
EOF -
Constructor Summary
ConstructorsConstructorDescriptionCDataSourceSuperTail(String remoteHost, int remotePort, int localPort, String remoteDir, String scratchDir, ILogger iLogger) CDataSourceSuperTail(String remoteHost, int remotePort, String remoteDir, String scratchDir, ILogger iLogger) CDataSourceSuperTail(InetAddress remoteIP, int remotePort, int localPort, String remoteDir, String scratchDir, ILogger iLogger) CDataSourceSuperTail(InetAddress remoteIP, int remotePort, String remoteDir, String scratchDir, ILogger iLogger) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanend()This function is called to end reading.protected voidprotected StringgetBookmarkFileName(String inputFile) intdoublestatic intintintintbooleanbooleanThis function is called to initiate the communication protocol with SuperTail.booleancharnextChar()Function used to read a character from the input mediumprotected voidThis function is used to purge the checkpoint files that are older than one week.intread(char[] buf, int len) This function reads a given number of characters from the source.recv()booleanbooleansetBookmark(int lineNo) Function used to mark a position in the input mediumvoidsetConnectTimeout(int connectTimeout) voidsetDaysToKeepCpt(double daysToKeepCpt) static voidsetDebugLevel(int debugLevel) final voidsetDelegate(CDataSourceSuperTail.Delegate delegate) voidsetFilenameFilter(FilenameFilter filenameFilter) voidsetReadTimeout(int readTimeout) voidsetReporter(COSARReporter reporter) booleanstart()This function is called to start reading.booleanstart1()This function is called to start reading.booleanFunction used to end communication with SuperTail
-
Field Details
-
m_fileHead
- See Also:
-
m_debugLevel
protected static int m_debugLevel -
m_iLogger
This member is used to report errors and warnings. -
m_hostName
This member represents the hostname. -
m_port
protected int m_portThis member represents the port-number. -
m_socket
This member represents the remote socket to access SuperTail. -
m_remoteDir
This member represents the remote directory on SuperTail's host. -
m_scratchDir
This member represents the scratch directory. -
m_daysToKeepCpt
protected double m_daysToKeepCptThis member represents the number of days for preserving check-point files. -
m_inputStream
This member represents the input stream from SuperTail. -
m_reader
This member is used to read characters from SuperTail. It is opened on the socket's input stream. -
m_out
This member is used to send messages from SuperTail. It is opened on the socket's output stream. -
m_crtLine
This member represents the current line read from SuperTail. -
m_crtIndexInLine
protected int m_crtIndexInLineThis is the current index in m_crtLine. -
m_crtLineNumber
protected int m_crtLineNumberThis member represents the current line number. It is used for bookmarking purposes. -
m_crtFile
This member represents the name of the file currently being processed. -
m_bookmarkFile
This member represents the bookmark-file associated to the file currently being processed. -
m_bookmarkStream
This member represents the bookmark-stream opened on m_bookmarkFile. -
m_bConnectErrorIssued
protected boolean m_bConnectErrorIssuedThis member represents an error flag set if the connection to SuperTail cannot be established. -
m_reporter
This member is used to send reports to. Example: startFile, endFile. -
m_filenameFilter
This member is used to filter files to process. -
m_delegate
This delegate is used to check if we need to wait or not. -
m_connectTimeout
protected int m_connectTimeout -
m_readTimeout
protected int m_readTimeout
-
-
Constructor Details
-
CDataSourceSuperTail
public CDataSourceSuperTail(InetAddress remoteIP, int remotePort, String remoteDir, String scratchDir, ILogger iLogger) throws Exception - Parameters:
remoteIP- IP of the host to connect toremotePort- Port number to connect toremoteDir- Remote directory to get data fromscratchDir- Work-directoryiLogger- Interface used for logging messages- Throws:
Exception
-
CDataSourceSuperTail
public CDataSourceSuperTail(String remoteHost, int remotePort, String remoteDir, String scratchDir, ILogger iLogger) throws Exception - Parameters:
remoteHost- Name of host to connect toremotePort- Port number to connect toremoteDir- Remote directory to get data fromscratchDir- Work-directoryiLogger- Interface used for logging messages- Throws:
Exception
-
CDataSourceSuperTail
public CDataSourceSuperTail(InetAddress remoteIP, int remotePort, int localPort, String remoteDir, String scratchDir, ILogger iLogger) throws Exception - Parameters:
remoteIP- IP of the host to connect toremotePort- Port number to connect tolocalPort- Local port number to use when connectingremoteDir- Remote directory to get data fromscratchDir- Work-directoryiLogger- Interface used for logging messages- Throws:
Exception
-
CDataSourceSuperTail
public CDataSourceSuperTail(String remoteHost, int remotePort, int localPort, String remoteDir, String scratchDir, ILogger iLogger) throws Exception - Parameters:
remoteHost- Name of host to connect toremotePort- Port number to connect tolocalPort- Local port number to use when connectingremoteDir- Remote directory to get data fromscratchDir- Work-directoryiLogger- Interface used for logging messages- Throws:
Exception
-
-
Method Details
-
getDebugLevel
public static int getDebugLevel() -
getRemoteInetAddress
-
getRemotePort
public int getRemotePort() -
getLocalPort
public int getLocalPort() -
getRemoteDir
-
getScratchDir
-
getDaysToKeepCpt
public double getDaysToKeepCpt() -
getFilenameFilter
-
getReporter
-
getReadTimeout
public int getReadTimeout() -
getConnectTimeout
public int getConnectTimeout() -
setDaysToKeepCpt
public void setDaysToKeepCpt(double daysToKeepCpt) -
setFilenameFilter
-
setDebugLevel
public static void setDebugLevel(int debugLevel) -
setReporter
-
setDelegate
-
setReadTimeout
public void setReadTimeout(int readTimeout) -
setConnectTimeout
public void setConnectTimeout(int connectTimeout) -
getSourceName
- Specified by:
getSourceNamein interfaceIDataSource- Returns:
- The name of the current file
-
hasMoreData
public boolean hasMoreData()- Specified by:
hasMoreDatain interfaceIDataSource- Returns:
- true if data is available, false otherwise
-
nextChar
Function used to read a character from the input mediumIf there is a current file to process, the character is retrieved from this file, otherwise the next file is selected for processing
- Specified by:
nextCharin interfaceIDataSource- Returns:
- A valid character if successful, IDataSource.EOF if the end-of-file was reached or if unsuccessful
- Throws:
Exception
-
read
Description copied from interface:IDataSourceThis function reads a given number of characters from the source.- Specified by:
readin interfaceIDataSource- Returns:
- The number of characters actually read.
- Throws:
Exception
-
start1
public boolean start1()This function is called to start reading. -
start
public boolean start()Description copied from interface:IDataSourceThis function is called to start reading. Classes implementing IDataSource may use it for initialization.- Specified by:
startin interfaceIDataSource- Returns:
- true if successful, false otherwise
-
end
public boolean end()This function is called to end reading.- Specified by:
endin interfaceIDataSource- Returns:
- true if successful, false otherwise
-
initialize
public boolean initialize()This function is called to initiate the communication protocol with SuperTail.The input and output streams are initialized. The initialization of communication with SuperTail requires following protocol on the part of CDataSourceSupertail:
- ignore the prompt "filemon> "
- send "cd
\n" - ignore SuperTail's output for ls
- send "start\n"
- Specified by:
initializein interfaceIDataSource- Returns:
- true if successful, false otherwise
-
terminate
public boolean terminate()Function used to end communication with SuperTail- Specified by:
terminatein interfaceIDataSource- Returns:
- true if successful, false otherwise
-
setBookmark
public boolean setBookmark(int lineNo) Function used to mark a position in the input medium- Specified by:
setBookmarkin interfaceIDataSource- Returns:
- true if successful, false otherwise
-
send
-
recv
-
isHealthy
public boolean isHealthy()- Specified by:
isHealthyin interfaceIDataSource- Returns:
- true if the data-source is functional, false otherwise
-
purgeCheckpointFiles
protected void purgeCheckpointFiles()This function is used to purge the checkpoint files that are older than one week. -
getBookmarkFileName
-
error
-
debug
-