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 boolean
This member represents an error flag set if the connection to SuperTail cannot be established.protected File
This member represents the bookmark-file associated to the file currently being processed.protected RandomAccessFile
This member represents the bookmark-stream opened on m_bookmarkFile.protected int
protected String
This member represents the name of the file currently being processed.protected int
This is the current index in m_crtLine.protected String
This member represents the current line read from SuperTail.protected int
This member represents the current line number.protected double
This member represents the number of days for preserving check-point files.protected static int
protected CDataSourceSuperTail.Delegate
This delegate is used to check if we need to wait or not.protected final String
protected FilenameFilter
This member is used to filter files to process.protected String
This member represents the hostname.protected ILogger
This member is used to report errors and warnings.protected BufferedInputStream
This member represents the input stream from SuperTail.protected PrintWriter
This member is used to send messages from SuperTail.protected int
This member represents the port-number.protected BufferedReader
This member is used to read characters from SuperTail.protected int
protected String
This member represents the remote directory on SuperTail's host.protected COSARReporter
This member is used to send reports to.protected String
This member represents the scratch directory.protected Socket
This 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 void
boolean
end()
This function is called to end reading.protected void
protected String
getBookmarkFileName
(String inputFile) int
double
static int
int
int
int
boolean
boolean
This function is called to initiate the communication protocol with SuperTail.boolean
char
nextChar()
Function used to read a character from the input mediumprotected void
This function is used to purge the checkpoint files that are older than one week.int
read
(char[] buf, int len) This function reads a given number of characters from the source.recv()
boolean
boolean
setBookmark
(int lineNo) Function used to mark a position in the input mediumvoid
setConnectTimeout
(int connectTimeout) void
setDaysToKeepCpt
(double daysToKeepCpt) static void
setDebugLevel
(int debugLevel) final void
setDelegate
(CDataSourceSuperTail.Delegate delegate) void
setFilenameFilter
(FilenameFilter filenameFilter) void
setReadTimeout
(int readTimeout) void
setReporter
(COSARReporter reporter) boolean
start()
This function is called to start reading.boolean
start1()
This function is called to start reading.boolean
Function 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:
getSourceName
in interfaceIDataSource
- Returns:
- The name of the current file
-
hasMoreData
public boolean hasMoreData()- Specified by:
hasMoreData
in 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:
nextChar
in 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:IDataSource
This function reads a given number of characters from the source.- Specified by:
read
in 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:IDataSource
This function is called to start reading. Classes implementing IDataSource may use it for initialization.- Specified by:
start
in interfaceIDataSource
- Returns:
- true if successful, false otherwise
-
end
public boolean end()This function is called to end reading.- Specified by:
end
in 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:
initialize
in interfaceIDataSource
- Returns:
- true if successful, false otherwise
-
terminate
public boolean terminate()Function used to end communication with SuperTail- Specified by:
terminate
in 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:
setBookmark
in interfaceIDataSource
- Returns:
- true if successful, false otherwise
-
send
-
recv
-
isHealthy
public boolean isHealthy()- Specified by:
isHealthy
in 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
-