Package org.teiid.common.buffer.impl
Class BufferManagerImpl
- java.lang.Object
-
- org.teiid.common.buffer.impl.BufferManagerImpl
-
- All Implemented Interfaces:
BufferManager
,SessionKiller
,StorageManager
,TupleBufferCache
,ReplicatedObject<String>
public class BufferManagerImpl extends Object implements BufferManager, ReplicatedObject<String>, SessionKiller
Default implementation of BufferManager. Responsible for creating/tracking TupleBuffers and providing access to the StorageManager. TODO: add detection of pinned batches to prevent unnecessary purging of non-persistent batches - this is not necessary for already persistent batches, since we hold a weak reference TODO: add a pre-fetch for tuplebuffers or some built-in correlation logic with the queue.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.common.buffer.BufferManager
BufferManager.BufferReserveMode, BufferManager.TupleSourceType
-
-
Field Summary
-
Fields inherited from interface org.teiid.common.buffer.BufferManager
DEFAULT_MAX_PROCESSING_KB, DEFAULT_PROCESSOR_BATCH_SIZE, DEFAULT_RESERVE_BUFFER_KB
-
-
Constructor Summary
Constructors Constructor Description BufferManagerImpl()
BufferManagerImpl(boolean sharedTimer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTupleBuffer(TupleBuffer tb)
FileStore
createFileStore(String name)
Creates a newFileStore
.STree
createSTree(List<? extends Expression> elements, String groupName, int keyLength)
TupleBuffer
createTupleBuffer(List elements, String groupName, BufferManager.TupleSourceType tupleSourceType)
void
distributeTupleBuffer(String uuid, TupleBuffer tb)
void
droppedMembers(Collection<Serializable> addresses)
Called when members are droppedlong
getActiveBatchBytes()
long
getBatchesAdded()
Cache
getCache()
int
getMaxProcessingSize()
Return the max that can be temporarily held potentially across even a blocked exception.int
getMaxReserveKB()
long
getMaxStorageSpace()
int
getMemoryCacheEntries()
Options
getOptions()
int
getProcessorBatchSize()
Get processor batch sizeint
getProcessorBatchSize(List<? extends Expression> schema)
Get the batch size to use during query processing.long
getReadAttempts()
long
getReadCount()
long
getReferenceHits()
long
getReserveBatchBytes()
int
getSchemaSize(List<? extends Expression> elements)
Get the size estimate for the given schema.void
getState(OutputStream ostream)
Allows an application to write a state through a provided OutputStream.void
getState(String state_id, OutputStream ostream)
Allows an application to write a partial state through a provided OutputStream.TupleBuffer
getTupleBuffer(String id)
long
getWriteCount()
boolean
hasState(String stateId)
Return true if the object has the given statevoid
initialize()
void
invalidCacheGroup(Long gid)
boolean
killLargestConsumer()
void
persistLob(Streamable<?> lob, FileStore store, byte[] bytes)
void
releaseBuffers(int count)
Releases the buffers reserved by a call toBufferManager.reserveBuffers(int, BufferReserveMode)
void
releaseOrphanedBuffers(long count)
int
reserveBuffers(int count, BufferManager.BufferReserveMode mode)
Reserve up to count buffers for use.int
reserveBuffersBlocking(int count, long[] val, boolean force)
void
setAddress(Serializable address)
Allows the replicator to set the local address from the channelvoid
setCache(Cache cache)
void
setEnforceMaxBatchManagerSizeEstimate(boolean enforceMaxBatchManagerSizeEstimate)
void
setInlineLobs(boolean inlineLobs)
void
setMaxActivePlans(int maxActivePlans)
Set the maxActivePlans as a hint at determining the maxProcessingvoid
setMaxBatchManagerSizeEstimate(long maxBatchManagerSizeEstimate)
void
setMaxProcessingKB(int maxProcessingKB)
void
setMaxReserveKB(int maxReserveBatchKB)
void
setMaxSessionBatchManagerSizeEstimate(long maxSessionBatchManagerSizeEstimate)
void
setOptions(Options options)
void
setProcessorBatchSize(int processorBatchSize)
void
setSessionService(SessionService sessionService)
void
setState(InputStream istream)
Allows an application to read a state through a provided InputStream.void
setState(String state_id, InputStream istream)
Allows an application to read a partial state through a provided InputStream.void
setStorageManager(StorageManager ssm)
void
setTargetBytesPerRow(int targetBytesPerRow)
void
setUseWeakReferences(boolean useWeakReferences)
void
shutdown()
-
-
-
Method Detail
-
getBatchesAdded
public long getBatchesAdded()
-
getReadCount
public long getReadCount()
-
getWriteCount
public long getWriteCount()
-
getReadAttempts
public long getReadAttempts()
-
getMaxProcessingSize
public int getMaxProcessingSize()
Description copied from interface:BufferManager
Return the max that can be temporarily held potentially across even a blocked exception.- Specified by:
getMaxProcessingSize
in interfaceBufferManager
- Returns:
-
getReserveBatchBytes
public long getReserveBatchBytes()
-
getProcessorBatchSize
public int getProcessorBatchSize()
Get processor batch size- Specified by:
getProcessorBatchSize
in interfaceBufferManager
- Returns:
- Number of rows in a processor batch
-
setTargetBytesPerRow
public void setTargetBytesPerRow(int targetBytesPerRow)
-
setProcessorBatchSize
public void setProcessorBatchSize(int processorBatchSize)
-
createTupleBuffer
public TupleBuffer createTupleBuffer(List elements, String groupName, BufferManager.TupleSourceType tupleSourceType)
- Specified by:
createTupleBuffer
in interfaceBufferManager
-
createSTree
public STree createSTree(List<? extends Expression> elements, String groupName, int keyLength)
- Specified by:
createSTree
in interfaceBufferManager
-
createFileStore
public FileStore createFileStore(String name)
Description copied from interface:BufferManager
Creates a newFileStore
.- Specified by:
createFileStore
in interfaceBufferManager
- Specified by:
createFileStore
in interfaceStorageManager
-
getMaxStorageSpace
public long getMaxStorageSpace()
- Specified by:
getMaxStorageSpace
in interfaceStorageManager
-
getCache
public Cache getCache()
-
setMaxActivePlans
public void setMaxActivePlans(int maxActivePlans)
Description copied from interface:BufferManager
Set the maxActivePlans as a hint at determining the maxProcessing- Specified by:
setMaxActivePlans
in interfaceBufferManager
-
setMaxProcessingKB
public void setMaxProcessingKB(int maxProcessingKB)
-
setMaxReserveKB
public void setMaxReserveKB(int maxReserveBatchKB)
-
initialize
public void initialize() throws TeiidComponentException
- Specified by:
initialize
in interfaceStorageManager
- Throws:
TeiidComponentException
-
releaseOrphanedBuffers
public void releaseOrphanedBuffers(long count)
- Specified by:
releaseOrphanedBuffers
in interfaceBufferManager
-
releaseBuffers
public void releaseBuffers(int count)
Description copied from interface:BufferManager
Releases the buffers reserved by a call toBufferManager.reserveBuffers(int, BufferReserveMode)
- Specified by:
releaseBuffers
in interfaceBufferManager
-
reserveBuffers
public int reserveBuffers(int count, BufferManager.BufferReserveMode mode)
Description copied from interface:BufferManager
Reserve up to count buffers for use.- Specified by:
reserveBuffers
in interfaceBufferManager
- Returns:
-
reserveBuffersBlocking
public int reserveBuffersBlocking(int count, long[] val, boolean force) throws BlockedException
- Specified by:
reserveBuffersBlocking
in interfaceBufferManager
- Throws:
BlockedException
-
getProcessorBatchSize
public int getProcessorBatchSize(List<? extends Expression> schema)
Description copied from interface:BufferManager
Get the batch size to use during query processing.- Specified by:
getProcessorBatchSize
in interfaceBufferManager
- Returns:
- Batch size (# of rows)
-
getSchemaSize
public int getSchemaSize(List<? extends Expression> elements)
Description copied from interface:BufferManager
Get the size estimate for the given schema.- Specified by:
getSchemaSize
in interfaceBufferManager
-
shutdown
public void shutdown()
-
addTupleBuffer
public void addTupleBuffer(TupleBuffer tb)
- Specified by:
addTupleBuffer
in interfaceBufferManager
-
distributeTupleBuffer
public void distributeTupleBuffer(String uuid, TupleBuffer tb)
- Specified by:
distributeTupleBuffer
in interfaceTupleBufferCache
-
getTupleBuffer
public TupleBuffer getTupleBuffer(String id)
- Specified by:
getTupleBuffer
in interfaceTupleBufferCache
-
setUseWeakReferences
public void setUseWeakReferences(boolean useWeakReferences)
-
getState
public void getState(OutputStream ostream)
Description copied from interface:ReplicatedObject
Allows an application to write a state through a provided OutputStream.- Specified by:
getState
in interfaceReplicatedObject<String>
- Parameters:
ostream
- the OutputStream
-
getState
public void getState(String state_id, OutputStream ostream)
Description copied from interface:ReplicatedObject
Allows an application to write a partial state through a provided OutputStream.- Specified by:
getState
in interfaceReplicatedObject<String>
- Parameters:
state_id
- id of the partial state requestedostream
- the OutputStream
-
setState
public void setState(InputStream istream)
Description copied from interface:ReplicatedObject
Allows an application to read a state through a provided InputStream.- Specified by:
setState
in interfaceReplicatedObject<String>
- Parameters:
istream
- the InputStream
-
setState
public void setState(String state_id, InputStream istream)
Description copied from interface:ReplicatedObject
Allows an application to read a partial state through a provided InputStream.- Specified by:
setState
in interfaceReplicatedObject<String>
- Parameters:
state_id
- id of the partial state requestedistream
- the InputStream
-
setAddress
public void setAddress(Serializable address)
Description copied from interface:ReplicatedObject
Allows the replicator to set the local address from the channel- Specified by:
setAddress
in interfaceReplicatedObject<String>
-
droppedMembers
public void droppedMembers(Collection<Serializable> addresses)
Description copied from interface:ReplicatedObject
Called when members are dropped- Specified by:
droppedMembers
in interfaceReplicatedObject<String>
-
setInlineLobs
public void setInlineLobs(boolean inlineLobs)
-
getMaxReserveKB
public int getMaxReserveKB()
-
setCache
public void setCache(Cache cache)
-
getMemoryCacheEntries
public int getMemoryCacheEntries()
-
getActiveBatchBytes
public long getActiveBatchBytes()
-
hasState
public boolean hasState(String stateId)
Description copied from interface:ReplicatedObject
Return true if the object has the given state- Specified by:
hasState
in interfaceReplicatedObject<String>
- Returns:
-
getReferenceHits
public long getReferenceHits()
-
persistLob
public void persistLob(Streamable<?> lob, FileStore store, byte[] bytes) throws TeiidComponentException
- Specified by:
persistLob
in interfaceBufferManager
- Throws:
TeiidComponentException
-
invalidCacheGroup
public void invalidCacheGroup(Long gid)
-
setOptions
public void setOptions(Options options)
- Specified by:
setOptions
in interfaceBufferManager
-
getOptions
public Options getOptions()
- Specified by:
getOptions
in interfaceBufferManager
-
setStorageManager
public void setStorageManager(StorageManager ssm)
-
setMaxSessionBatchManagerSizeEstimate
public void setMaxSessionBatchManagerSizeEstimate(long maxSessionBatchManagerSizeEstimate)
-
setMaxBatchManagerSizeEstimate
public void setMaxBatchManagerSizeEstimate(long maxBatchManagerSizeEstimate)
-
setEnforceMaxBatchManagerSizeEstimate
public void setEnforceMaxBatchManagerSizeEstimate(boolean enforceMaxBatchManagerSizeEstimate)
-
killLargestConsumer
public boolean killLargestConsumer()
- Specified by:
killLargestConsumer
in interfaceSessionKiller
- Returns:
- true if a session was successfully killed
-
setSessionService
public void setSessionService(SessionService sessionService)
-
-