Class SequenceWriter
Writes to sequence of data writers created by a factory in turn and rolled based on a ISequenceStrategy policy.
Each writer is closed when the ISequenceStrategy indicates it sholud end and a new one is created by the factory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates the nested writer for each new sequence of aSequenceWriter.static classEnds a sequence once it has been running for a given time; checked only when the next record arrives.static interfaceDecides when aSequenceWriterends the current sequence and starts a new one.static classEnds the current sequence when any of the given strategies does.static classEnds each sequence once it has received the given number of records.static classEnds the current sequence at each time produced by aScheduler; checked only when the next record arrives.static classOne segment of aSequenceWriter's output, with its 0-based index, start time and record counts.Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionSequenceWriter(SequenceWriter.ISequenceStrategy strategy, SequenceWriter.DataWriterFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.protected voidCalled once a new sequence's writer has been created and opened; does nothing by default.protected voidCalled when a sequence ends -- after the next sequence's writer is created, or when this writer is closed; does nothing by default.protected voidCalled before the factory creates the writer for a new sequence; does nothing by default.voidclose()Indicates that this endpoint has finished reading or writing.Returns the current Sequence in use by this writer,nullif it hasn't started writing, or the last sequence if it has finished writing.longDeprecated.longReturns the number of sequences that have ended, including the last one once this writer is closed.longReturns the number of sequences (nested writers) created so far.protected voidOverridden by subclasses to write the specified record to thisDataWriter.Methods inherited from class com.northconcepts.datapipeline.core.ProxyWriter
available, getNestedWriter, interceptRecord, map, map, open, setNestedDataWriter, setNestedDataWriterMethods inherited from class com.northconcepts.datapipeline.core.DataWriter
getNestedEndpoint, getRootEndpoint, getRootWriter, getWriter, writeMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Constructor Details
-
SequenceWriter
public SequenceWriter(SequenceWriter.ISequenceStrategy strategy, SequenceWriter.DataWriterFactory factory)
-
-
Method Details
-
getStrategy
-
getFactory
-
getSequencesStarted
public long getSequencesStarted()Returns the number of sequences (nested writers) created so far. -
getSequencesFinished
public long getSequencesFinished()Returns the number of sequences that have ended, including the last one once this writer is closed. -
getSequenceCount
Deprecated.usegetSequencesStarted()instead The number of sequences created by this writer (alias forgetSequencesStarted()). -
getCurrentSequence
Returns the current Sequence in use by this writer,nullif it hasn't started writing, or the last sequence if it has finished writing. -
writeImpl
Description copied from class:DataWriterOverridden by subclasses to write the specified record to thisDataWriter.Contract for subclasses (see also
docs/authoring/DataWriter.md):- Do not call this method directly —
DataWriter.write(Record)is the template method that wraps exceptions, increments the record count, and attaches the offending record to thrownDataExceptions. - Do not call
DataEndpoint.incrementRecordCount()here;DataWriter.write(Record)already does. - Throw raw exceptions;
DataWriter.write(Record)wraps them viaexception(throwable).setRecord(record).
- Overrides:
writeImplin classProxyWriter- Throws:
Throwable
- Do not call this method directly —
-
beforeSequenceCreated
protected void beforeSequenceCreated()Called before the factory creates the writer for a new sequence; does nothing by default. -
afterSequenceCreated
protected void afterSequenceCreated()Called once a new sequence's writer has been created and opened; does nothing by default. -
afterSequenceFinished
protected void afterSequenceFinished()Called when a sequence ends -- after the next sequence's writer is created, or when this writer is closed; does nothing by default. -
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classProxyWriter- Throws:
DataException
-
addExceptionProperties
Description copied from class:EndpointAdds 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 classProxyWriter
-
getSequencesStarted()instead The number of sequences created by this writer (alias forgetSequencesStarted()).