Package com.nt.udc.io

Class CDataSourceSuperTail

java.lang.Object
com.nt.udc.io.CDataSourceSuperTail
All Implemented Interfaces:
IDataSource

public class CDataSourceSuperTail extends Object implements IDataSource
This class is used as the source of data retrieved from SuperTail.
Since:
JDK1.1.7
  • Field Details

    • m_fileHead

      protected final String m_fileHead
      See Also:
    • m_debugLevel

      protected static int m_debugLevel
    • m_iLogger

      protected ILogger m_iLogger
      This member is used to report errors and warnings.
    • m_hostName

      protected String m_hostName
      This member represents the hostname.
    • m_port

      protected int m_port
      This member represents the port-number.
    • m_socket

      protected Socket m_socket
      This member represents the remote socket to access SuperTail.
    • m_remoteDir

      protected String m_remoteDir
      This member represents the remote directory on SuperTail's host.
    • m_scratchDir

      protected String m_scratchDir
      This member represents the scratch directory.
    • m_daysToKeepCpt

      protected double m_daysToKeepCpt
      This member represents the number of days for preserving check-point files.
    • m_inputStream

      protected BufferedInputStream m_inputStream
      This member represents the input stream from SuperTail.
    • m_reader

      protected BufferedReader m_reader
      This member is used to read characters from SuperTail. It is opened on the socket's input stream.
    • m_out

      protected PrintWriter m_out
      This member is used to send messages from SuperTail. It is opened on the socket's output stream.
    • m_crtLine

      protected String m_crtLine
      This member represents the current line read from SuperTail.
    • m_crtIndexInLine

      protected int m_crtIndexInLine
      This is the current index in m_crtLine.
    • m_crtLineNumber

      protected int m_crtLineNumber
      This member represents the current line number. It is used for bookmarking purposes.
    • m_crtFile

      protected String m_crtFile
      This member represents the name of the file currently being processed.
    • m_bookmarkFile

      protected File m_bookmarkFile
      This member represents the bookmark-file associated to the file currently being processed.
    • m_bookmarkStream

      protected RandomAccessFile m_bookmarkStream
      This member represents the bookmark-stream opened on m_bookmarkFile.
    • m_bConnectErrorIssued

      protected boolean m_bConnectErrorIssued
      This member represents an error flag set if the connection to SuperTail cannot be established.
    • m_reporter

      protected COSARReporter m_reporter
      This member is used to send reports to. Example: startFile, endFile.
    • m_filenameFilter

      protected FilenameFilter m_filenameFilter
      This member is used to filter files to process.
    • m_delegate

      protected CDataSourceSuperTail.Delegate 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 to
      remotePort - Port number to connect to
      remoteDir - Remote directory to get data from
      scratchDir - Work-directory
      iLogger - 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 to
      remotePort - Port number to connect to
      remoteDir - Remote directory to get data from
      scratchDir - Work-directory
      iLogger - 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 to
      remotePort - Port number to connect to
      localPort - Local port number to use when connecting
      remoteDir - Remote directory to get data from
      scratchDir - Work-directory
      iLogger - 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 to
      remotePort - Port number to connect to
      localPort - Local port number to use when connecting
      remoteDir - Remote directory to get data from
      scratchDir - Work-directory
      iLogger - Interface used for logging messages
      Throws:
      Exception
  • Method Details

    • getDebugLevel

      public static int getDebugLevel()
    • getRemoteInetAddress

      public InetAddress getRemoteInetAddress()
    • getRemotePort

      public int getRemotePort()
    • getLocalPort

      public int getLocalPort()
    • getRemoteDir

      public String getRemoteDir()
    • getScratchDir

      public String getScratchDir()
    • getDaysToKeepCpt

      public double getDaysToKeepCpt()
    • getFilenameFilter

      public FilenameFilter getFilenameFilter()
    • getReporter

      public COSARReporter getReporter()
    • getReadTimeout

      public int getReadTimeout()
    • getConnectTimeout

      public int getConnectTimeout()
    • setDaysToKeepCpt

      public void setDaysToKeepCpt(double daysToKeepCpt)
    • setFilenameFilter

      public void setFilenameFilter(FilenameFilter filenameFilter)
    • setDebugLevel

      public static void setDebugLevel(int debugLevel)
    • setReporter

      public void setReporter(COSARReporter reporter)
    • setDelegate

      public final void setDelegate(CDataSourceSuperTail.Delegate delegate)
    • setReadTimeout

      public void setReadTimeout(int readTimeout)
    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)
    • getSourceName

      public String getSourceName()
      Specified by:
      getSourceName in interface IDataSource
      Returns:
      The name of the current file
    • hasMoreData

      public boolean hasMoreData()
      Specified by:
      hasMoreData in interface IDataSource
      Returns:
      true if data is available, false otherwise
    • nextChar

      public char nextChar() throws Exception
      Function used to read a character from the input medium

      If 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 interface IDataSource
      Returns:
      A valid character if successful, IDataSource.EOF if the end-of-file was reached or if unsuccessful
      Throws:
      Exception
    • read

      public int read(char[] buf, int len) throws Exception
      Description copied from interface: IDataSource
      This function reads a given number of characters from the source.
      Specified by:
      read in interface IDataSource
      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 interface IDataSource
      Returns:
      true if successful, false otherwise
    • end

      public boolean end()
      This function is called to end reading.
      Specified by:
      end in interface IDataSource
      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 interface IDataSource
      Returns:
      true if successful, false otherwise
    • terminate

      public boolean terminate()
      Function used to end communication with SuperTail
      Specified by:
      terminate in interface IDataSource
      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 interface IDataSource
      Returns:
      true if successful, false otherwise
    • send

      public boolean send(String msg)
    • recv

      public String recv()
    • isHealthy

      public boolean isHealthy()
      Specified by:
      isHealthy in interface IDataSource
      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

      protected String getBookmarkFileName(String inputFile)
    • error

      protected void error(String fName, String msg)
    • debug

      protected void debug(String fName, String msg)