Package cz.o2.proxima.direct.core
Class DirectDataOperator
- java.lang.Object
-
- cz.o2.proxima.direct.core.DirectDataOperator
-
- All Implemented Interfaces:
DataOperator
,ContextProvider
,java.lang.AutoCloseable
public class DirectDataOperator extends java.lang.Object implements DataOperator, ContextProvider
DataOperator
implementation for direct accesses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DirectDataOperator.DelegateDataAccessorFactory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the operator and release all allocated resources.java.util.Optional<DirectAttributeFamilyDescriptor>
findFamilyByName(java.lang.String name)
Retrieve family by given name.java.util.Optional<DataAccessorFactory>
getAccessorFactory(java.net.URI uri)
Retrieve factory that first matches given uri.java.util.stream.Stream<DirectAttributeFamilyDescriptor>
getAllFamilies()
Retrieve all families with their direct representation.java.util.Optional<BatchLogReader>
getBatchLogReader(AttributeDescriptor<?>... attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.java.util.Optional<BatchLogReader>
getBatchLogReader(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveBatchLogReader
for givenAttributeDescriptor
s.java.util.Optional<CachedView>
getCachedView(AttributeDescriptor<?>... attrs)
RetrieveCachedView
for givenAttributeDescriptor
s.java.util.Optional<CachedView>
getCachedView(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveCachedView
for givenAttributeDescriptor
s.ClientTransactionManager
getClientTransactionManager()
java.util.Optional<CommitLogReader>
getCommitLogReader(AttributeDescriptor<?>... attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.java.util.Optional<CommitLogReader>
getCommitLogReader(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.Context
getContext()
RetrieveContext
that is used in all distributed operations.java.util.Set<DirectAttributeFamilyDescriptor>
getFamiliesForAttribute(AttributeDescriptor<?> desc)
Resolve all direct attribute representations of given attribute.DirectAttributeFamilyDescriptor
getFamilyByName(java.lang.String name)
Retrieve family by given name.TransactionalOnlineAttributeWriter
getGlobalTransactionWriter()
Retrieve aTransactionalOnlineAttributeWriter
with GLOBAL transactions capable to fulfil any transactional requests.java.util.Optional<RandomAccessReader>
getRandomAccess(AttributeDescriptor<?>... attrs)
RetrieveRandomAccessReader
for givenAttributeDescriptor
s.java.util.Optional<RandomAccessReader>
getRandomAccess(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveRandomAccessReader
for givenAttributeDescriptor
s.Repository
getRepository()
Retrieve repository associated with the operator.ServerTransactionManager
getServerTransactionManager()
java.util.Optional<OnlineAttributeWriter>
getWriter(AttributeDescriptor<?> attr)
Retrieve writer for givenAttributeDescriptor
.void
reload()
Reload the operator afterRepository
has been changed.java.util.Optional<DirectAttributeFamilyDescriptor>
resolve(AttributeFamilyDescriptor family)
Optionally convert given family to direct representation.DirectAttributeFamilyDescriptor
resolveRequired(AttributeFamilyDescriptor family)
Convert given core family to direct representation.DirectDataOperator
withExecutorFactory(Factory<java.util.concurrent.ExecutorService> factory)
Explicitly specifyExecutorService
to use when constructing threads.
-
-
-
Method Detail
-
withExecutorFactory
public DirectDataOperator withExecutorFactory(Factory<java.util.concurrent.ExecutorService> factory)
Explicitly specifyExecutorService
to use when constructing threads.- Parameters:
factory
- the factory forExecutorService
- Returns:
- this
-
reload
public final void reload()
Description copied from interface:DataOperator
Reload the operator afterRepository
has been changed.This method is called automatically, when
ConfigRepository.reloadConfig(boolean, cz.o2.proxima.typesafe.config.Config)
is called.- Specified by:
reload
in interfaceDataOperator
-
getContext
public Context getContext()
RetrieveContext
that is used in all distributed operations.- Specified by:
getContext
in interfaceContextProvider
- Returns:
- the serializable context
-
resolveRequired
public DirectAttributeFamilyDescriptor resolveRequired(AttributeFamilyDescriptor family)
Convert given core family to direct representation.- Parameters:
family
- the family to convert- Returns:
- the converted family
-
resolve
public java.util.Optional<DirectAttributeFamilyDescriptor> resolve(AttributeFamilyDescriptor family)
Optionally convert given family to direct representation.- Parameters:
family
- the family to convert- Returns:
- the optionally converted family
-
getAccessorFactory
public java.util.Optional<DataAccessorFactory> getAccessorFactory(java.net.URI uri)
Retrieve factory that first matches given uri.- Parameters:
uri
- the URI to search factory for- Returns:
- optional
DataAccessorFactory
for specified URI
-
getWriter
public java.util.Optional<OnlineAttributeWriter> getWriter(AttributeDescriptor<?> attr)
Retrieve writer for givenAttributeDescriptor
.- Parameters:
attr
- the attribute to find writer for- Returns:
- optional writer
-
getGlobalTransactionWriter
public TransactionalOnlineAttributeWriter getGlobalTransactionWriter()
Retrieve aTransactionalOnlineAttributeWriter
with GLOBAL transactions capable to fulfil any transactional requests.Note that global transactions are required to be processed by a single instance of
TransactionManager
and therefore are not scalable.Use with caution.
- Returns:
- the global
TransactionalOnlineAttributeWriter
that is able to handle all transactions
-
getCommitLogReader
public java.util.Optional<CommitLogReader> getCommitLogReader(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find commit log reader for- Returns:
- optional commit log reader
-
getCommitLogReader
@SafeVarargs public final java.util.Optional<CommitLogReader> getCommitLogReader(AttributeDescriptor<?>... attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find commit log reader for- Returns:
- optional commit log reader
-
getBatchLogReader
public java.util.Optional<BatchLogReader> getBatchLogReader(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveBatchLogReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find commit log reader for- Returns:
- optional batch log reader
-
getBatchLogReader
@SafeVarargs public final java.util.Optional<BatchLogReader> getBatchLogReader(AttributeDescriptor<?>... attrs)
RetrieveCommitLogReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find commit log reader for- Returns:
- optional commit log reader
-
getCachedView
public java.util.Optional<CachedView> getCachedView(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveCachedView
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find cached view for- Returns:
- optional cached view
-
getCachedView
@SafeVarargs public final java.util.Optional<CachedView> getCachedView(AttributeDescriptor<?>... attrs)
RetrieveCachedView
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find cached view for- Returns:
- optional cached view
-
getRandomAccess
public java.util.Optional<RandomAccessReader> getRandomAccess(java.util.Collection<AttributeDescriptor<?>> attrs)
RetrieveRandomAccessReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find radom access reader for- Returns:
- optional random access reader
-
getRandomAccess
@SafeVarargs public final java.util.Optional<RandomAccessReader> getRandomAccess(AttributeDescriptor<?>... attrs)
RetrieveRandomAccessReader
for givenAttributeDescriptor
s.- Parameters:
attrs
- the attributes to find random access reader for- Returns:
- optional random access reader
-
close
public void close()
Close the operator and release all allocated resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceDataOperator
-
getFamiliesForAttribute
public java.util.Set<DirectAttributeFamilyDescriptor> getFamiliesForAttribute(AttributeDescriptor<?> desc)
Resolve all direct attribute representations of given attribute.- Parameters:
desc
- descriptor of attribute- Returns:
- the set of all direct attribute representations
-
getAllFamilies
public java.util.stream.Stream<DirectAttributeFamilyDescriptor> getAllFamilies()
Retrieve all families with their direct representation.- Returns:
- stream of all
DirectAttributeFamilyDescriptor
s.
-
getFamilyByName
public DirectAttributeFamilyDescriptor getFamilyByName(java.lang.String name)
Retrieve family by given name.- Parameters:
name
- name of the family to search for- Returns:
DirectAttributeFamilyDescriptor
for given family- Throws:
java.lang.IllegalArgumentException
- when family not found
-
findFamilyByName
public java.util.Optional<DirectAttributeFamilyDescriptor> findFamilyByName(java.lang.String name)
Retrieve family by given name.- Parameters:
name
- name of the family to search for- Returns:
Optional
ofDirectAttributeFamilyDescriptor
for given family ofOptional.empty()
-
getClientTransactionManager
@Internal public ClientTransactionManager getClientTransactionManager()
- Returns:
- cached implementation of
ClientTransactionManager
. Should not be called from client code.
-
getServerTransactionManager
@Internal public ServerTransactionManager getServerTransactionManager()
- Returns:
- cached implementation of
ServerTransactionManager
. Should not be called from client code.
-
getRepository
public Repository getRepository()
Description copied from interface:DataOperator
Retrieve repository associated with the operator.- Specified by:
getRepository
in interfaceDataOperator
- Returns:
Repository
associated with the operator
-
-