public interface WireOut extends WireCommon, MarshallableOut
MarshallableOut.Padding
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SAFE_LENGTH |
static long |
TRY_WRITE_HEADER_FAILED |
Modifier and Type | Method and Description |
---|---|
WireOut |
addPadding(int paddingToAdd) |
void |
clear()
This will reset the positions and the header number.
|
default WireOut |
dropDefault(boolean dropDefault) |
void |
endEvent() |
ValueOut |
getValueOut()
Obtain the value out
|
ObjectOutput |
objectOutput() |
default WireOut |
padToCacheAlign()
If near the end of a cache line, pad it so a following 4-byte int value will not split a
cache line.
|
void |
startEvent()
Start an event object, mostly for internal use.
|
long |
tryWriteHeader(int safeLength)
Makes a single attempt to try and write the header.
|
void |
updateFirstHeader()
update the first header after writing.
|
void |
updateHeader(long position,
boolean metaData)
Change the header from NOT_COMPLETE | UNKNOWN_LENGTH to metaData * META_DATA | length.
|
ValueOut |
write()
Write an empty filed marker
|
ValueOut |
write(CharSequence key) |
ValueOut |
write(WireKey key)
Write a key for wires that support fields.
|
default WireOut |
writeAlignTo(int alignment,
int plus) |
default <K,V> void |
writeAllAsMap(Class<K> kClass,
Class<V> vClass,
Map<K,V> map) |
WireOut |
writeComment(CharSequence s) |
default void |
writeDocument(boolean metaData,
WriteMarshallable writer)
This will increment the headerNumber as appropriate if successful
|
void |
writeEndOfWire(long timeout,
TimeUnit timeUnit,
long lastPosition)
Write the end of wire marker, unless one is already written.
|
default ValueOut |
writeEvent(Class expectedType,
Object eventKey) |
default ValueOut |
writeEventId(int methodId) |
default ValueOut |
writeEventName(CharSequence key) |
default ValueOut |
writeEventName(WireKey key)
Always write a key.
|
boolean |
writeFirstHeader()
Start the first header, if there is none This will increment the headerNumber as appropriate
if successful
|
default long |
writeHeader(long timeout,
TimeUnit timeUnit,
net.openhft.chronicle.core.values.LongValue lastPosition,
Sequence sequence)
Write a new header, an unknown length, handling timeouts and the end of wire marker.
|
long |
writeHeaderOfUnknownLength(int safeLength,
long timeout,
TimeUnit timeUnit,
net.openhft.chronicle.core.values.LongValue lastPosition,
Sequence sequence)
Write a message of unknown length, handling timeouts and the end of wire marker.
|
default long |
writeHeaderOfUnknownLength(long timeout,
TimeUnit timeUnit,
net.openhft.chronicle.core.values.LongValue lastPosition,
Sequence sequence) |
default void |
writeNotCompleteDocument(boolean metaData,
WriteMarshallable writer)
Deprecated.
|
default DocumentContext |
writingDocument()
Start a document which is completed when DocumentContext.close() is called.
|
DocumentContext |
writingDocument(boolean metaData)
This will increment the headerNumber as appropriate if successful
|
bytes, bytesComment, classLookup, classLookup, endUse, headerNumber, headerNumber, newBooleanReference, newIntReference, newLongArrayReference, newLongReference, newTwoLongReference, notCompleteIsNotPresent, notCompleteIsNotPresent, parent, parent, pauser, pauser, startUse
methodWriter, methodWriter, methodWriterBuilder, padToCacheAlignMode, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeText
static final long TRY_WRITE_HEADER_FAILED
static final int DEFAULT_SAFE_LENGTH
@NotNull ValueOut write()
@NotNull default ValueOut writeEventName(WireKey key)
default ValueOut writeEventName(CharSequence key)
default ValueOut writeEventId(int methodId)
ValueOut write(CharSequence key)
@NotNull ValueOut getValueOut()
ObjectOutput objectOutput()
@NotNull WireOut writeComment(CharSequence s)
@NotNull WireOut addPadding(int paddingToAdd)
@NotNull default WireOut padToCacheAlign()
@NotNull default WireOut writeAlignTo(int alignment, int plus)
void clear()
clear
in interface WireCommon
default void writeDocument(boolean metaData, @NotNull WriteMarshallable writer)
metaData
- writer
- DocumentContext writingDocument(boolean metaData)
writingDocument
in interface MarshallableOut
metaData
- if true
the document context will be used for writing meta data,
otherwise data@NotNull default DocumentContext writingDocument()
MarshallableOut
try(DocumentContext dc = appender.writingDocument()) { dc.wire().write("message").text("Hello World"); }
WARNING : any data written inside the writingDocument(), should be performed as quickly as possible because a write lock is held until the DocumentContext is closed by the try-with-resources, this blocks other appenders and tailers.
try (DocumentContext dc = appender.writingDocument()) { // this should be performed as quickly as possible because a write lock is held until the // DocumentContext is closed by the try-with-resources, this blocks other appenders and tailers. }
writingDocument
in interface MarshallableOut
@Deprecated default void writeNotCompleteDocument(boolean metaData, @NotNull WriteMarshallable writer)
metaData
- true
if the write should write metaData rather than datawriter
- writes bytes to the wiredefault long writeHeader(long timeout, TimeUnit timeUnit, @Nullable net.openhft.chronicle.core.values.LongValue lastPosition, Sequence sequence) throws TimeoutException, EOFException
timeout
- throw a TimeoutException if the header could not be written in this
time.timeUnit
- of the timeOutlastPosition
- the last known positionsequence
- sequence number accessTimeoutException
- the underlying pauser timed out.EOFException
- the end of wire marker was reached.void updateHeader(long position, boolean metaData) throws StreamCorruptedException, EOFException
position
- returned by writeHeadermetaData
- whether the message is meta data or not.StreamCorruptedException
- if the steam has become corruptedEOFException
long writeHeaderOfUnknownLength(int safeLength, long timeout, TimeUnit timeUnit, @Nullable net.openhft.chronicle.core.values.LongValue lastPosition, Sequence sequence) throws TimeoutException, EOFException
timeout
- throw a TimeoutException if the header could not be written in this
time.timeUnit
- of the timeOutlastPosition
- the last known positionTimeoutException
- the underlying pauser timed out.EOFException
- the end of wire marker was reached.default long writeHeaderOfUnknownLength(long timeout, TimeUnit timeUnit, @Nullable net.openhft.chronicle.core.values.LongValue lastPosition, Sequence sequence) throws TimeoutException, EOFException
TimeoutException
EOFException
long tryWriteHeader(int safeLength)
safeLength
- assume this safe lengthboolean writeFirstHeader()
Note: the file might contain other data and the caller has to check this.
void updateFirstHeader()
void writeEndOfWire(long timeout, TimeUnit timeUnit, long lastPosition)
timeout
- throw TimeoutException if it could not write the marker in time.timeUnit
- of the timeoutlastPosition
- the end of the wirevoid startEvent()
void endEvent()
default <K,V> void writeAllAsMap(Class<K> kClass, Class<V> vClass, @NotNull Map<K,V> map)
@NotNull default WireOut dropDefault(boolean dropDefault)
Copyright © 2018. All rights reserved.