com.ibm.di.queue
Class MemBufferQ

java.lang.Object
  extended by com.ibm.di.queue.MemBufferQ

public class MemBufferQ
extends Object

A FIFO queue


Constructor Summary
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
 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 store
 DBHandler getDbHandler()
           
 int getPercentMemoryUse()
           
 void initDB(String sDBName, String jdbcLogin, String jdbcPassword, String sTblName)
          Initializes the system store paramemters.
 boolean isEmpty()
           
 boolean isMemoryAvailable()
          Checks if there is enough memory available as specified by the user
 boolean isPurging()
           
 Object peek()
          Same as read but does not remove data from the memq
 void purgeQueue()
          Purges the queue.
 Object read()
          synchronized method: The first item inserted in the queue and not yet removed.
 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 true
 void write(Object x)
          write : add an object to the end of memq
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemBufferQ

public MemBufferQ(int nEntries,
                  int pagesize)
           throws Exception
Constructor Initializes the memory buffer pipe when paging is enabled.

Throws:
Exception

MemBufferQ

public MemBufferQ(int nEntries,
                  int pagesize,
                  boolean doNotInitialiseDB)
           throws 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:
Exception

MemBufferQ

@Deprecated
public MemBufferQ(int nEntries)
Deprecated. 

Constructor Initializes the memory buffer pipe when paging is disabled

Method Detail

initDB

public void initDB(String sDBName,
                   String jdbcLogin,
                   String jdbcPassword,
                   String sTblName)
            throws Exception
Initializes the system store paramemters.

Parameters:
sDBName - system store database name
jdbcLogin - username to connect to the db
jdbcPassword - password to connect to the db
sTblName - table name
Throws:
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 Object read()
            throws 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:
Exception

read

public Object read(int timeout)
            throws 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:
Exception

acquireLock

public void acquireLock()
                 throws InterruptedException
Throws:
InterruptedException

releaseLock

public void releaseLock()

write

public void write(Object x)
           throws Exception
write : add an object to the end of memq

Parameters:
x - object to be added
Throws:
Exception - if add fails

peek

public 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 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:
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)