Package cz.o2.proxima.direct.core.view
Interface CachedView
-
- All Superinterfaces:
AttributeWriterBase
,java.lang.AutoCloseable
,java.io.Closeable
,OnlineAttributeWriter
,RandomAccessReader
- All Known Implementing Classes:
LocalCachedPartitionedView
,TransactionalCachedView
@Stable public interface CachedView extends RandomAccessReader, OnlineAttributeWriter
A view of commit-log that caches (and potentially checkpoints) data from partitions and makes in random accessible.Client can provide callbacks to be called on data updates. Client might also update the view, all updates must be persisted in a way that will guarantee that subsequent reloads will contain the new data and that read-write operations have happens-before relation semantics.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CachedView.Factory
Serializable
factory forCachedView
.-
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.AttributeWriterBase
AttributeWriterBase.Type
-
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReader
RandomAccessReader.GetRequest<T>, RandomAccessReader.Listing, RandomAccessReader.MultiFetch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CachedView.Factory
asFactory()
Convert instance of this view toCachedView.Factory
suitable for serialization.default void
assign(java.util.Collection<Partition> partitions)
Assign and make given partitions accessible by random reads.default void
assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback)
Assign and make given partitions accessible by random reads.void
assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback, java.time.Duration ttl)
Assign and make given partitions accessible by random reads.default void
assign(java.util.Collection<Partition> partitions, java.time.Duration ttl)
Assign and make given partitions accessible by random reads.void
cache(StreamElement element)
Cache givenStreamElement
into local cache without writing it to the underlying writer.void
close()
Close allocated resources of this writer.java.util.Collection<Partition>
getAssigned()
Retrieve currently assigned partitions.default java.util.Collection<Partition>
getPartitions()
Retrieve all partitions of the underlying commit log.java.util.Optional<ObserveHandle>
getRunningHandle()
Retrieve a running handle (if present).CommitLogReader
getUnderlyingReader()
Retrieve underlyingCommitLogReader
.OnlineAttributeWriter
getUnderlyingWriter()
Retrieve underlyingOnlineAttributeWriter
.-
Methods inherited from interface cz.o2.proxima.direct.core.AttributeWriterBase
bulk, getUri, online
-
Methods inherited from interface cz.o2.proxima.direct.core.OnlineAttributeWriter
getType, isTransactional, rollback, transactional, write
-
Methods inherited from interface cz.o2.proxima.direct.core.randomaccess.RandomAccessReader
fetchOffset, get, get, get, get, get, getEntityDescriptor, listEntities, listEntities, multiFetch, scanWildcard, scanWildcard, scanWildcard, scanWildcard, scanWildcardAll, scanWildcardAll, scanWildcardAll, scanWildcardAll
-
-
-
-
Method Detail
-
assign
default void assign(java.util.Collection<Partition> partitions)
Assign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.- Parameters:
partitions
- the partitions to cache locally
-
assign
default void assign(java.util.Collection<Partition> partitions, java.time.Duration ttl)
Assign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.- Parameters:
partitions
- the partitions to cache locallyttl
- maximaul Duration that an update should be kept in the cache NOTE: this is not a hard limit, it is only a signal, that after this time the element can be removed to free up memory
-
assign
default void assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback)
Assign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.- Parameters:
partitions
- the partitions to cache locallyupdateCallback
- function that is called when cache gets updated the function takes the new ingest element and pair of the most recent object that was associated with the key and it's currently associated stamp
-
assign
void assign(java.util.Collection<Partition> partitions, BiConsumer<StreamElement,Pair<java.lang.Long,java.lang.Object>> updateCallback, @Nullable java.time.Duration ttl)
Assign and make given partitions accessible by random reads. If the view contains any partitions not listed in the collection, these partitions are dropped.- Parameters:
partitions
- the partitions to cache locallyupdateCallback
- function that is called when cache gets updated the function takes the new ingest element and pair of the most recent object that was associated with the key and it's currently associated stampttl
- maximaul Duration that an update should be kept in the cache NOTE: this is not a hard limit, it is only a signal, that after this time the element can be removed to free up memory
-
getAssigned
java.util.Collection<Partition> getAssigned()
Retrieve currently assigned partitions.- Returns:
- currently assigned partitions
-
cache
void cache(StreamElement element)
Cache givenStreamElement
into local cache without writing it to the underlying writer. This is used in conjunction with attribute family proxy.- Parameters:
element
- the data to cache
-
getPartitions
default java.util.Collection<Partition> getPartitions()
Retrieve all partitions of the underlying commit log.- Returns:
- all partitions of underlying commit log
-
getUnderlyingReader
CommitLogReader getUnderlyingReader()
Retrieve underlyingCommitLogReader
.
-
getUnderlyingWriter
OnlineAttributeWriter getUnderlyingWriter()
Retrieve underlyingOnlineAttributeWriter
. Note that using this write might not update the cache. In most cases, useOnlineAttributeWriter.write(StreamElement, CommitCallback)
directly.
-
getRunningHandle
java.util.Optional<ObserveHandle> getRunningHandle()
Retrieve a running handle (if present).
-
asFactory
CachedView.Factory asFactory()
Convert instance of this view toCachedView.Factory
suitable for serialization.- Specified by:
asFactory
in interfaceAttributeWriterBase
- Specified by:
asFactory
in interfaceOnlineAttributeWriter
- Specified by:
asFactory
in interfaceRandomAccessReader
- Returns:
- the
CachedView.Factory
representing this view
-
close
void close()
Description copied from interface:AttributeWriterBase
Close allocated resources of this writer. This is supposed to be idempotent.- Specified by:
close
in interfaceAttributeWriterBase
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-