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 void
close()
Closes the client and frees any resources associated with it.boolean
compareAndSetMark(Revision expected, Revision newLocation)
Records a provided location that can later be obtained by callingRevisionedStreamClient.getMark()
.Revision
fetchLatestRevision()
Returns the latest revision.Revision
fetchOldestRevision()
Returns the oldest revision that reads can start from.Revision
getMark()
Returns a location previously set byRevisionedStreamClient.compareAndSetMark(Revision, Revision)
.SegmentMetadataClient
getMeta()
long
getReadTimeout()
java.util.Iterator<java.util.Map.Entry<Revision,T>>
readFrom(Revision revision)
Read all data after a specified revision to the end of the stream.void
truncateToRevision(Revision newStart)
Removes all data through the revision provided.Revision
writeConditionally(Revision latestRevision, T value)
If the supplied revision is the latest revision in the stream write the provided value and return the new revision.void
writeUnconditionally(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:RevisionedStreamClient
If 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:
writeConditionally
in 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:RevisionedStreamClient
Write a new value to the stream.- Specified by:
writeUnconditionally
in interfaceRevisionedStreamClient<T>
- Parameters:
value
- The value to be written.
-
readFrom
public java.util.Iterator<java.util.Map.Entry<Revision,T>> readFrom(Revision revision)
Description copied from interface:RevisionedStreamClient
Read 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:
readFrom
in interfaceRevisionedStreamClient<T>
- Parameters:
revision
- The location the iterator should start at.- Returns:
- An iterator over Revision, value pairs.
-
fetchLatestRevision
public Revision fetchLatestRevision()
Description copied from interface:RevisionedStreamClient
Returns the latest revision.- Specified by:
fetchLatestRevision
in interfaceRevisionedStreamClient<T>
- Returns:
- Latest revision.
-
getMark
public Revision getMark()
Description copied from interface:RevisionedStreamClient
Returns a location previously set byRevisionedStreamClient.compareAndSetMark(Revision, Revision)
.- Specified by:
getMark
in 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:RevisionedStreamClient
Records 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:
compareAndSetMark
in 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:RevisionedStreamClient
Returns the oldest revision that reads can start from.- Specified by:
fetchOldestRevision
in interfaceRevisionedStreamClient<T>
- Returns:
- The oldest readable revision.
-
truncateToRevision
public void truncateToRevision(Revision newStart)
Description copied from interface:RevisionedStreamClient
Removes 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:
truncateToRevision
in interfaceRevisionedStreamClient<T>
- Parameters:
newStart
- The revision that should be the new oldest Revision.
-
close
public void close()
Description copied from interface:RevisionedStreamClient
Closes the client and frees any resources associated with it. (It may no longer be used)- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceRevisionedStreamClient<T>
- See Also:
AutoCloseable.close()
-
getReadTimeout
public long getReadTimeout()
-
getMeta
public SegmentMetadataClient getMeta()
-
-