Class Endpoint

java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
Direct Known Subclasses:
DataEndpoint, FileSystem

public abstract class Endpoint extends DataObject
Base class for anything that is opened and closed, such as readers, writers and file systems; tracks its state, open and close times, and elapsed time.
  • Field Details

    • BUFFER_SIZE

      public static final int BUFFER_SIZE
      See Also:
    • DEFAULT_READ_BUFFER_SIZE

      public static final int DEFAULT_READ_BUFFER_SIZE
      See Also:
    • captureElapsedTime

      protected static boolean captureElapsedTime
  • Constructor Details

    • Endpoint

      public Endpoint()
  • Method Details

    • getNestedEndpoint

      public Endpoint getNestedEndpoint()
      Returns the Endpoint held inside this one or null if there isn't one.
    • getRootEndpoint

      public Endpoint getRootEndpoint()
      Returns the deepest, nested Endpoint held inside this one, otherwise this instance is returned if there aren't any nested Endpoints.
    • getDescription

      public String getDescription()
      Returns the optional text shown for this endpoint in toString() and exception properties.
    • setDescription

      public Endpoint setDescription(String description)
      Sets the optional text shown for this endpoint in toString() and exception properties.
    • getOpenedOn

      public long getOpenedOn()
      Returns the time in milliseconds when this endpoint was opened or zero (0) if it hasn't yet been opened.
    • getClosedOn

      public long getClosedOn()
      Returns the time in milliseconds when this endpoint was closed or zero (0) if it hasn't yet been closed.
    • getOpenElapsedTime

      public long getOpenElapsedTime()
      Returns the number of milliseconds this endpoint was (or has been) opened for or zero (0) if it hasn't yet been opened.
    • getOpenElapsedTimeAsString

      public String getOpenElapsedTimeAsString()
      Returns the total time (as a human readable string) this endpoint was (or has been) opened for or "0 seconds" if it hasn't yet been opened.
    • open

      public void open() throws DataException
      Makes this endpoint ready for reading or writing.
      Throws:
      DataException
    • close

      public void close() throws DataException
      Indicates that this endpoint has finished reading or writing.
      Throws:
      DataException
    • getState

      public DataEndpoint.State getState()
    • isOpen

      public boolean isOpen()
      Indicates if this endpoint is ready for reading or writing.
    • isClosed

      public boolean isClosed()
      Indicates if this endpoint has finished transferring data.
    • assertOpened

      public void assertOpened()
      Asserts that this endpoint has started reading or writing, otherwise an exception is thrown.
    • assertClosed

      public void assertClosed()
      Asserts that this endpoint has finished reading or writing, otherwise an exception is thrown.
    • assertNotOpened

      public void assertNotOpened()
      Asserts that this endpoint has not yet started reading or writing, otherwise an exception is thrown.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class DataObject
    • finalize

      protected void finalize() throws Throwable
      Closes this endpoint if it's still open.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • toString

      public String toString()
      Overrides:
      toString in class DataObject
    • isCaptureElapsedTime

      public static boolean isCaptureElapsedTime()
      Indicates if all endpoints (readers and writers) should record their processing time. By default, endpoints do not record their processing time. See getElapsedTime()
    • getElapsedTime

      public long getElapsedTime()
      Returns the total time in milliseconds this endpoint spent reading (inside DataReader.read()) or writing (inside DataWriter.write(Record)) if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean) was called with true). By default this method returns zero (0) if the captureElapsedTime flag was not explicitly set.
    • getElapsedTimeAsString

      public String getElapsedTimeAsString()
      Returns the total time (as a human readable string) this endpoint spent reading (inside DataReader.read()) or writing (inside DataWriter.write(Record)) if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean) was called with true). By default this method returns "0 seconds" if the captureElapsedTime flag was not explicitly set.
    • addElapsedtime

      protected void addElapsedtime(long time)
      Adds time milliseconds to the total returned by getElapsedTime().
    • getSelfTime

      public long getSelfTime()
      Returns the total time in milliseconds this endpoint spent reading (inside DataReader.read()) or writing (inside DataWriter.write(Record)) minus the elapsed time from nested endpoints if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean) was called with true). By default this method returns zero (0) if the captureElapsedTime flag was not explicitly set.
    • getSelfTimeAsString

      public String getSelfTimeAsString()
      Returns the total time (as a human readable string) this endpoint spent reading (inside DataReader.read()) or writing (inside DataWriter.write(Record)) minus the elapsed time from nested endpoints if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean) was called with true). By default this method returns "0 seconds" if the captureElapsedTime flag was not explicitly set.
    • setCaptureElapsedTime

      public static void setCaptureElapsedTime(boolean captureElapsedTime)
      Indicates if all endpoints (readers and writers) should record their processing time. By default, endpoints do not record their processing time. See getElapsedTime()