Class Endpoint
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
- Direct Known Subclasses:
DataEndpoint,FileSystem
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected static booleanstatic final intFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddElapsedtime(long time) Addstimemilliseconds to the total returned bygetElapsedTime().addExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidAsserts that this endpoint has finished reading or writing, otherwise an exception is thrown.voidAsserts that this endpoint has not yet started reading or writing, otherwise an exception is thrown.voidAsserts that this endpoint has started reading or writing, otherwise an exception is thrown.voidclose()Indicates that this endpoint has finished reading or writing.protected voidfinalize()Closes this endpoint if it's still open.longReturns the time in milliseconds when this endpoint was closed or zero (0) if it hasn't yet been closed.Returns the optional text shown for this endpoint intoString()and exception properties.longReturns the total time in milliseconds this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.write(Record)) if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean)was called with true).Returns the total time (as a human readable string) this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.write(Record)) if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean)was called with true).Returns theEndpointheld inside this one ornullif there isn't one.longReturns the time in milliseconds when this endpoint was opened or zero (0) if it hasn't yet been opened.longReturns the number of milliseconds this endpoint was (or has been) opened for or zero (0) if it hasn't yet been opened.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.Returns the deepest, nestedEndpointheld inside this one, otherwise this instance is returned if there aren't any nestedEndpoints.longReturns the total time in milliseconds this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.write(Record)) minus the elapsed time from nested endpoints if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean)was called with true).Returns the total time (as a human readable string) this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.write(Record)) minus the elapsed time from nested endpoints if the captureElapsedTime flag is set (setCaptureElapsedTime(boolean)was called with true).getState()static booleanIndicates if all endpoints (readers and writers) should record their processing time.booleanisClosed()Indicates if this endpoint has finished transferring data.booleanisOpen()Indicates if this endpoint is ready for reading or writing.voidopen()Makes this endpoint ready for reading or writing.static voidsetCaptureElapsedTime(boolean captureElapsedTime) Indicates if all endpoints (readers and writers) should record their processing time.setDescription(String description) Sets the optional text shown for this endpoint intoString()and exception properties.toString()
-
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
Returns theEndpointheld inside this one ornullif there isn't one. -
getRootEndpoint
Returns the deepest, nestedEndpointheld inside this one, otherwise this instance is returned if there aren't any nestedEndpoints. -
getDescription
Returns the optional text shown for this endpoint intoString()and exception properties. -
setDescription
Sets the optional text shown for this endpoint intoString()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
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
Makes this endpoint ready for reading or writing.- Throws:
DataException
-
close
Indicates that this endpoint has finished reading or writing.- Throws:
DataException
-
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
Adds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classDataObject
-
finalize
Closes this endpoint if it's still open. -
toString
- Overrides:
toStringin classDataObject
-
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. SeegetElapsedTime() -
getElapsedTime
public long getElapsedTime()Returns the total time in milliseconds this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.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
Returns the total time (as a human readable string) this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.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) Addstimemilliseconds to the total returned bygetElapsedTime(). -
getSelfTime
public long getSelfTime()Returns the total time in milliseconds this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.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
Returns the total time (as a human readable string) this endpoint spent reading (insideDataReader.read()) or writing (insideDataWriter.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. SeegetElapsedTime()
-