Package com.ibm.di.queue
Class MemBufferQ
- java.lang.Object
-
- com.ibm.di.queue.MemBufferQ
-
public class MemBufferQ extends java.lang.Object
A FIFO queue
-
-
Constructor Summary
Constructors Constructor Description MemBufferQ(int nEntries)
Deprecated.MemBufferQ(int nEntries, int pagesize)
Constructor Initializes the memory buffer pipe when paging is enabled.MemBufferQ(int nEntries, int pagesize, boolean doNotInitialiseDB)
Constructor Initializes the memory buffer pipe when paging is enabled.Initialization of the DB properties is done only when the queue is being created from the UserFunctions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquireLock()
void
blockAdd(boolean enable)
Enable disable blocking add this is used only when paging support is disabled.void
enablePersistence(boolean enable)
enablePersistence : enable/disable paging support using system storeDBHandler
getDbHandler()
int
getPercentMemoryUse()
void
initDB(java.lang.String sDBName, java.lang.String jdbcLogin, java.lang.String jdbcPassword, java.lang.String sTblName)
Initializes the system store paramemters.boolean
isEmpty()
boolean
isMemoryAvailable()
Checks if there is enough memory available as specified by the userboolean
isPurging()
java.lang.Object
peek()
Same as read but does not remove data from the memqvoid
purgeQueue()
Purges the queue.java.lang.Object
read()
synchronized method: The first item inserted in the queue and not yet removed.java.lang.Object
read(int timeout)
synchronized method: The first item inserted in the queue and not yet removed.void
releaseLock()
void
setDbHandler(DBHandler dbHandler)
void
setPercentMemoryUse(int percentMemoryUse)
int
size()
void
terminate(boolean dropSystemStore)
terminates the system store threads and drops table if dropSystemStore set to truevoid
write(java.lang.Object x)
write : add an object to the end of memq
-
-
-
Constructor Detail
-
MemBufferQ
public MemBufferQ(int nEntries, int pagesize) throws java.lang.Exception
Constructor Initializes the memory buffer pipe when paging is enabled.- Throws:
java.lang.Exception
-
MemBufferQ
public MemBufferQ(int nEntries, int pagesize, boolean doNotInitialiseDB) throws java.lang.Exception
Constructor Initializes the memory buffer pipe when paging is enabled.Initialization of the DB properties is done only when the queue is being created from the UserFunctions. For queues being created from the MemQueue Connector or FC , the DB table name is required to be specified by the user.- Throws:
java.lang.Exception
-
MemBufferQ
@Deprecated public MemBufferQ(int nEntries)
Deprecated.Constructor Initializes the memory buffer pipe when paging is disabled
-
-
Method Detail
-
initDB
public void initDB(java.lang.String sDBName, java.lang.String jdbcLogin, java.lang.String jdbcPassword, java.lang.String sTblName) throws java.lang.Exception
Initializes the system store paramemters.- Parameters:
sDBName
- system store database namejdbcLogin
- username to connect to the dbjdbcPassword
- password to connect to the dbsTblName
- table name- Throws:
java.lang.Exception
- if system store is not initialized properly
-
isEmpty
public boolean isEmpty()
- Returns:
- True if memQ is empty
-
size
public int size()
- Returns:
- Number of items in the memq.
-
read
public java.lang.Object read() throws java.lang.Exception
synchronized method: The first item inserted in the queue and not yet removed. Requires !isEmpty (). Reading removes the item from the queue. read with no timeout.- Throws:
java.lang.Exception
-
read
public java.lang.Object read(int timeout) throws java.lang.Exception
synchronized method: The first item inserted in the queue and not yet removed. Requires !isEmpty (). Reading removes the item from the queue. Waits for timeout- Throws:
java.lang.Exception
-
acquireLock
public void acquireLock() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
releaseLock
public void releaseLock()
-
write
public void write(java.lang.Object x) throws java.lang.Exception
write : add an object to the end of memq- Parameters:
x
- object to be added- Throws:
java.lang.Exception
- if add fails
-
peek
public java.lang.Object peek()
Same as read but does not remove data from the memq- Returns:
- object read
-
enablePersistence
public void enablePersistence(boolean enable)
enablePersistence : enable/disable paging support using system store- Parameters:
enable
- paging support enabled if true and disabled if false
-
isPurging
public boolean isPurging()
- Returns:
- isBeingPurged Returns if purging is enabled/disabled.
-
blockAdd
public void blockAdd(boolean enable)
Enable disable blocking add this is used only when paging support is disabled.- Parameters:
enable
- if true, add to memq blocks infinitely until there is space for an object to be added to memq if false, add throws an exception if memq is full
-
terminate
public void terminate(boolean dropSystemStore)
terminates the system store threads and drops table if dropSystemStore set to true- Parameters:
dropSystemStore
-
-
purgeQueue
public void purgeQueue() throws java.lang.Exception
Purges the queue. The isBeingPurged Flag is set which blocks all reader or writer threads until the purge operation is not completed. Deletes all data from the associated table in System Store if this queue has paging enabled.- Throws:
java.lang.Exception
-
getPercentMemoryUse
public int getPercentMemoryUse()
-
setPercentMemoryUse
public void setPercentMemoryUse(int percentMemoryUse)
-
isMemoryAvailable
public boolean isMemoryAvailable()
Checks if there is enough memory available as specified by the user
-
getDbHandler
public DBHandler getDbHandler()
-
setDbHandler
public void setDbHandler(DBHandler dbHandler)
-
-