Class MultiWriter
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataWriter
com.northconcepts.datapipeline.core.MultiWriter
Writes records to multiple
DataWriter.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWrites each record to a single writer by choosing the one with the highest available capacity (DataWriter.available()If all writers have identical capacities, this strategy behaves likeMultiWriter.RoundRobinWriteStrategyand writes to each writer in turn.static classWrites a clone (to prevent side effects) of each record to all writers.static classWrites each record to all writers.static classDivides records evenly between all writers by cycling through the list and writing each record to a single writer in turn.static classStrategy for distributing each record among aMultiWriter's target writers.Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MultiWriter.WriteStrategystatic final MultiWriter.WriteStrategyFields 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
ConstructorsConstructorDescriptionCreates a writer with no targets that uses theREPLICATE_CLONEstrategy.MultiWriter(DataWriter... sinks) Creates a writer for the given targets that uses theREPLICATE_CLONEstrategy.MultiWriter(MultiWriter.WriteStrategy writeStrategy) -
Method Summary
Modifier and TypeMethodDescriptionadd(DataWriter... sinks) Adds target writers; must be called beforeopen().addExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.get(int index) Returns the target writer at the given 0-based index.intgetCount()Returns the number of target writers.Returns how records are distributed among the target writers (defaults toREPLICATE_CLONE).voidopen()Makes this endpoint ready for reading or writing.remove(DataWriter sink) Removes all target writers; must be called beforeopen().setWriteStrategy(MultiWriter.WriteStrategy writeStrategy) Sets how records are distributed among the target writers (defaults toREPLICATE_CLONE).protected voidOverridden by subclasses to write the specified record to thisDataWriter.Methods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, 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
-
Field Details
-
REPLICATE
-
REPLICATE_CLONE
-
-
Constructor Details
-
MultiWriter
public MultiWriter()Creates a writer with no targets that uses theREPLICATE_CLONEstrategy. -
MultiWriter
-
MultiWriter
Creates a writer for the given targets that uses theREPLICATE_CLONEstrategy.
-
-
Method Details
-
getWriteStrategy
Returns how records are distributed among the target writers (defaults toREPLICATE_CLONE). -
setWriteStrategy
Sets how records are distributed among the target writers (defaults toREPLICATE_CLONE). -
add
Adds target writers; must be called beforeopen(). -
getCount
public int getCount()Returns the number of target writers. -
remove
-
removeAllDataSink
Removes all target writers; must be called beforeopen(). -
get
Returns the target writer at the given 0-based index. -
open
Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classDataEndpoint- Throws:
DataException
-
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classDataEndpoint- Throws:
DataException
-
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).
- Specified by:
writeImplin classDataWriter- Throws:
Throwable
- Do not call this method directly —
-
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 classDataWriter
-