Package io.pravega.client.state.impl
Class RevisionedStreamClientImpl<T>
- java.lang.Object
-
- io.pravega.client.state.impl.RevisionedStreamClientImpl<T>
-
- All Implemented Interfaces:
RevisionedStreamClient<T>,java.lang.AutoCloseable
public class RevisionedStreamClientImpl<T> extends java.lang.Object implements RevisionedStreamClient<T>
-
-
Constructor Summary
Constructors Constructor Description RevisionedStreamClientImpl(Segment segment, EventSegmentReader in, SegmentOutputStreamFactory outFactory, ConditionalOutputStream conditional, SegmentMetadataClient meta, Serializer<T> serializer, EventWriterConfig config, DelegationTokenProvider tokenProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the client and frees any resources associated with it.booleancompareAndSetMark(Revision expected, Revision newLocation)Records a provided location that can later be obtained by callingRevisionedStreamClient.getMark().RevisionfetchLatestRevision()Returns the latest revision.RevisionfetchOldestRevision()Returns the oldest revision that reads can start from.RevisiongetMark()Returns a location previously set byRevisionedStreamClient.compareAndSetMark(Revision, Revision).SegmentMetadataClientgetMeta()longgetReadTimeout()java.util.Iterator<java.util.Map.Entry<Revision,T>>readFrom(Revision start)Read all data after a specified revision to the end of the stream.voidtruncateToRevision(Revision newStart)Removes all data through the revision provided.RevisionwriteConditionally(Revision latestRevision, T value)If the supplied revision is the latest revision in the stream write the provided value and return the new revision.voidwriteUnconditionally(T value)Write a new value to the stream.
-
-
-
Constructor Detail
-
RevisionedStreamClientImpl
public RevisionedStreamClientImpl(Segment segment, EventSegmentReader in, SegmentOutputStreamFactory outFactory, ConditionalOutputStream conditional, SegmentMetadataClient meta, Serializer<T> serializer, EventWriterConfig config, DelegationTokenProvider tokenProvider)
-
-
Method Detail
-
writeConditionally
public Revision writeConditionally(Revision latestRevision, T value)
Description copied from interface:RevisionedStreamClientIf the supplied revision is the latest revision in the stream write the provided value and return the new revision. If the supplied revision is not the latest, nothing will occur and null will be returned.- Specified by:
writeConditionallyin interfaceRevisionedStreamClient<T>- Parameters:
latestRevision- The version to verify is the most recent.value- The value to be written to the stream.- Returns:
- The new revision if the data was written successfully or null if it was not.
-
writeUnconditionally
public void writeUnconditionally(T value)
Description copied from interface:RevisionedStreamClientWrite a new value to the stream.- Specified by:
writeUnconditionallyin interfaceRevisionedStreamClient<T>- Parameters:
value- The value to be written.
-
readFrom
public java.util.Iterator<java.util.Map.Entry<Revision,T>> readFrom(Revision start)
Description copied from interface:RevisionedStreamClientRead all data after a specified revision to the end of the stream. The iterator returned will stop once it reaches the end of the data that was in the stream at the time this method was called.- Specified by:
readFromin interfaceRevisionedStreamClient<T>- Parameters:
start- The location the iterator should start at.- Returns:
- An iterator over Revision, value pairs.
-
fetchLatestRevision
public Revision fetchLatestRevision()
Description copied from interface:RevisionedStreamClientReturns the latest revision.- Specified by:
fetchLatestRevisionin interfaceRevisionedStreamClient<T>- Returns:
- Latest revision.
-
getMark
public Revision getMark()
Description copied from interface:RevisionedStreamClientReturns a location previously set byRevisionedStreamClient.compareAndSetMark(Revision, Revision).- Specified by:
getMarkin interfaceRevisionedStreamClient<T>- Returns:
- The marked location. (null if setMark was never been called)
-
compareAndSetMark
public boolean compareAndSetMark(Revision expected, Revision newLocation)
Description copied from interface:RevisionedStreamClientRecords a provided location that can later be obtained by callingRevisionedStreamClient.getMark(). Atomically set the mark to newLocation if it is the expected value.- Specified by:
compareAndSetMarkin interfaceRevisionedStreamClient<T>- Parameters:
expected- The expected value (May be null to indicate the mark is expected to be null)newLocation- The new value- Returns:
- true if it was successful. False if the mark was not the expected value.
-
fetchOldestRevision
public Revision fetchOldestRevision()
Description copied from interface:RevisionedStreamClientReturns the oldest revision that reads can start from.- Specified by:
fetchOldestRevisionin interfaceRevisionedStreamClient<T>- Returns:
- The oldest readable revision.
-
truncateToRevision
public void truncateToRevision(Revision newStart)
Description copied from interface:RevisionedStreamClientRemoves all data through the revision provided. This will updateRevisionedStreamClient.fetchOldestRevision()to the provided revision. After this call returns ifRevisionedStreamClient.readFrom(Revision)is called with an older revision it will throw.- Specified by:
truncateToRevisionin interfaceRevisionedStreamClient<T>- Parameters:
newStart- The revision that should be the new oldest Revision.
-
close
public void close()
Description copied from interface:RevisionedStreamClientCloses the client and frees any resources associated with it. (It may no longer be used)- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceRevisionedStreamClient<T>- See Also:
AutoCloseable.close()
-
getReadTimeout
public long getReadTimeout()
-
getMeta
public SegmentMetadataClient getMeta()
-
-