xmlBlaster 2.2.0 API

org.xmlBlaster.util.queue.jdbc
Class CommonTableDatabaseAccessor

java.lang.Object
  extended by org.xmlBlaster.util.queue.jdbc.CommonTableDatabaseAccessor
All Implemented Interfaces:
I_StorageProblemListener, I_StorageProblemNotifier
Direct Known Subclasses:
CommonTableDatabaseAccessorDelegate

public class CommonTableDatabaseAccessor
extends java.lang.Object
implements I_StorageProblemListener, I_StorageProblemNotifier

Delegate class which takes care of SQL specific stuff for the JdbcQueuePlugin class.

One instance of this is created by Global for each StorageId prefix, so one instance for 'history', one for 'cb' etc.

The tables needed for each JdbcManagerCommonTable instance are the following:
- entriesTableName (defaults to 'ENTRIES')
The names of such tables are constituted by the tableNamePrefix (which defaults to 'XB') plus the entriesTableName

Author:
Marcel Ruff, Michele Laghi
See Also:
The queue.jdbc.commontable requirement

Field Summary
(package private) static int BLOB
           
private  java.lang.String blobTxt
           
private  java.lang.String blobVarName
           
private  java.lang.String booleanTxt
           
private  java.lang.String byteSizeColName
           
private  java.lang.String colNamePrefix
           
private  int countDumps
           
private  short countTest
           
(package private) static int DATA_ID
          Column index into XB_ENTRIES table
private  java.lang.String dataIdColName
           
private static java.lang.String DUMMY_VALUE
           
private  boolean enableBatchMode
          forces the desactivation of batch mode when adding entries
private  java.lang.String entriesTableName
           
private  I_EntryFactory factory
           
private static boolean first
           
private  Global glob
           
private  java.lang.String intTxt
           
private  boolean isConnected
           
private  boolean isDB2
           
private  boolean isFirebird
           
private  boolean isHSQLDatabaseEngine
           
private  boolean isLdbc
           
private  boolean isMicrosoftSQLServer
           
private  boolean isMySql
           
private  boolean isOracle
           
private  boolean isPostgres
           
private  boolean isSQLite
           
private  java.lang.String keyAttr
           
private  java.util.WeakHashMap listener
           
private static java.util.logging.Logger log
           
private  java.lang.String longintTxt
           
private  int maxNumStatements
           
private  int maxSelectLimit
           
private  int maxStatementLength
           
private static java.lang.String ME
           
(package private) static int PERSISTENT
           
private  java.sql.PreparedStatement pingPrepared
           
private  JdbcConnectionPool pool
           
(package private) static int PRIO
           
(package private) static int QUEUE_NAME
           
private  int queueCounter
          Counts the queues using this manager.
(package private) static int SIZE_IN_BYTES
           
private  I_Storage storage
           
private  java.lang.String stringTxt
           
private  boolean supportsBatch
          tells wether the used database supports batch updates or not.
private  java.lang.String tableNamePrefix
           
private  boolean testException
           
(package private) static int TYPE_NAME
           
 
Fields inherited from interface org.xmlBlaster.util.queue.I_StorageProblemListener
AVAILABLE, UNAVAILABLE, UNDEF
 
Constructor Summary
CommonTableDatabaseAccessor(JdbcConnectionPool pool, I_EntryFactory factory, java.lang.String managerName, I_Storage storage)
           
 
Method Summary
 int[] addEntries(java.lang.String queueName, I_Entry[] entries)
          Adds several rows to the specified queue table in batch mode to improve performance
private  int[] addEntriesSingleMode(java.sql.Connection conn, java.lang.String queueName, I_Entry[] entries)
           
 boolean addEntry(java.lang.String queueName, I_Entry entry)
          Adds a row to the specified queue table
private  boolean addSingleEntry(java.lang.String queueName, I_Entry entry, java.sql.Connection conn)
          Adds a row to the specified queue table
protected  boolean checkIfDBLoss(java.sql.Connection conn, java.lang.String location, java.lang.Throwable ex)
           
protected  boolean checkIfDBLoss(java.sql.Connection conn, java.lang.String location, java.lang.Throwable ex, java.lang.String trace)
          Handles the SQLException.
 int cleanUp(java.lang.String queueName)
          Cleans up the specified queue.
static CommonTableDatabaseAccessor createInstance(Global glob, I_EntryFactory factory, java.lang.String confType, java.lang.String confVersion, java.util.Properties properties)
          The Properties to use as a default are these from the QueuePlugin with the configuration name specified by defaultConfName (default is 'JDBC').
 int deleteAllTransient(java.lang.String queueName)
          deletes all transient messages
 boolean[] deleteEntries(java.lang.String queueName, long[] uniqueIds)
          Deletes the entries specified by the entries array.
private  boolean[] deleteEntriesNoSplit(java.lang.String queueName, long[] uniqueIds)
           
 int deleteEntry(java.lang.String queueName, long uniqueId)
          Deletes the entry specified
 ReturnDataHolder deleteFirstEntries(java.lang.String queueName, long numOfEntries, long amount)
          Deletes number of entries specified by the argument list.
 void dumpMetaData()
          Dumps the metadata to the log object.
 ReturnDataHolder getAndDeleteLowest(StorageId storageId, int numOfEntries, long numOfBytes, int maxPriority, long minUniqueId, boolean leaveOne, boolean doDelete)
          Under the same transaction it gets and deletes all the entries which fit into the constrains specified in the argument list.
 java.util.ArrayList getEntries(StorageId storageId, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter)
          gets the first numOfEntries of the queue.
 java.util.ArrayList getEntries(StorageId storageId, long[] dataids)
          gets all the entries which have the dataid specified in the argument list.
 java.util.ArrayList getEntriesByPriority(StorageId storageId, int numOfEntries, long numOfBytes, int minPrio, int maxPrio, I_EntryFilter entryFilter)
          gets the first numOfEntries of the queue which have the priority in the range specified by prioMin and prioMax (inclusive).
 java.util.ArrayList getEntriesBySamePriority(StorageId storageId, int numOfEntries, long numOfBytes)
          gets the first numOfEntries of the queue which have the same priority.
 java.util.ArrayList getEntriesLike(java.lang.String queueNamePattern, java.lang.String flag, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter)
          Raw access to the table.
 java.util.ArrayList getEntriesWithLimit(StorageId storageId, I_Entry limitEntry)
          gets the first numOfEntries of the queue until the limitEntry is reached.
private  java.lang.String getLogId(java.lang.String queueName, java.lang.String methodName)
           
 EntryCount getNumOfAll(java.lang.String queueName)
          Gets the real number of entries.
 long getNumOfBytes(java.lang.String queueName)
          Deprecated. Use getNumOfAll(String)
 long getNumOfEntries(java.lang.String queueName)
          Deprecated. Use getNumOfAll(String)
 long getNumOfPersistents(java.lang.String queueName)
          Deprecated. Use getNumOfAll(String)
 JdbcConnectionPool getPool()
          Returns the pool associated to this object.
 long getSizeOfPersistents(java.lang.String queueName)
          Deprecated. Use getNumOfAll(String) Replaced all four selects with one: "select count(*), sum(byteSize), durable from XB_ENTRIES WHERE queueName='history_xmlBlaster_192_168_1_4_3412Hello' GROUP BY durable;"
 I_StorageProblemListener[] getStorageProblemListenerArr()
           
private  java.util.HashSet getXbTableNames(java.sql.Connection conn)
          Gets the names of all the tables used by XmlBlaster.
 boolean isDB2()
           
 boolean isFirebird()
           
 boolean isHSQLDatabaseEngine()
           
private  boolean isInsideRange(int numEntries, int maxNumEntries, long numBytes, long maxNumBytes)
          Helper method to find out if still to retrieve entries in getAndDeleteLowest or not.
 boolean isLdbc()
           
 boolean isMicrosoftSQLServer()
           
 boolean isMySql()
           
 boolean isOracle()
           
private  boolean isPersistent(java.lang.String persistentAsChar)
           
 boolean isPostgres()
           
 boolean isSQLite()
           
static void main(java.lang.String[] args)
          This main method can be used to delete all tables on the db which start with a certain prefix.
 long modifyEntry(java.lang.String queueName, I_Entry entry, I_Entry oldEntry)
          modifies a row in the specified queue table
 boolean pingDatabase()
          pings with a newly created jdbc connection to check if the DB is up and running.
private  java.util.ArrayList processResultSet(java.sql.ResultSet rs, StorageId storageIdDefault, int numOfEntries, long numOfBytes, boolean onlyId, I_EntryFilter entryFilter)
           
private  ReturnDataHolder processResultSetForDeleting(java.sql.ResultSet rs, int numOfEntries, long numOfBytes, java.util.List<java.lang.Long> retL)
          It accepts result sets with (long dataId, long size)
 void registerQueue(I_Queue queue)
           
 boolean registerStorageProblemListener(I_StorageProblemListener entry)
          Adds (registers) a listener for connection/disconnection events.
 long removeEntriesWithLimit(StorageId storageId, I_Entry limitEntry, boolean inclusive)
          deletes the first numOfEntries of the queue until the limitEntry is reached.
 void setUp()
          Sets up a table for the queue specified by this queue name.
 void shutdown()
           
 void storageAvailable(int oldStatus)
          Invoked by the I_StorageProblemNotifier when the storage becomes available again (for example on a DB when the jdbc connection is broken).
 void storageUnavailable(int oldStatus)
          Invoked by the I_StorageProblemNotifier when the storage becomes unavailable (for example on a DB when the jdbc connection is broken).
 boolean tablesCheckAndSetup(boolean createTables)
          Checks if all necessary tables exist.
 void unregisterQueue(I_Queue queue)
           
 boolean unRegisterStorageProblemListener(I_StorageProblemListener entry)
          Adds (registers) a listener for connection/disconnection events.
private  int update(java.lang.String request)
          A generic invocation for a simple update on the database.
private  int update(java.lang.String request, java.sql.Connection conn)
          This version makes an update but does no connection management, i.e.
private  java.util.ArrayList whereInStatement(java.lang.String reqPrefix, long[] uniqueIds)
          The prefix is the initial part of the SQL update/query.
 int wipeOutDB(boolean doSetupNewTables)
          Wipes out the entire DB.
static void wipeOutDB(Global glob, java.lang.String confType, java.lang.String confVersion, java.util.Properties properties, boolean setupNewTables)
          wipes out the db.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

glob

private final Global glob

log

private static java.util.logging.Logger log

pool

private final JdbcConnectionPool pool

factory

private final I_EntryFactory factory

listener

private final java.util.WeakHashMap listener

DUMMY_VALUE

private static final java.lang.String DUMMY_VALUE
See Also:
Constant Field Values

tableNamePrefix

private final java.lang.String tableNamePrefix

colNamePrefix

private final java.lang.String colNamePrefix

stringTxt

private java.lang.String stringTxt

longintTxt

private java.lang.String longintTxt

intTxt

private java.lang.String intTxt

blobTxt

private java.lang.String blobTxt

booleanTxt

private java.lang.String booleanTxt

maxStatementLength

private int maxStatementLength

isConnected

private boolean isConnected

first

private static boolean first

entriesTableName

private java.lang.String entriesTableName

blobVarName

private java.lang.String blobVarName

byteSizeColName

private java.lang.String byteSizeColName

dataIdColName

private java.lang.String dataIdColName

keyAttr

private java.lang.String keyAttr

isPostgres

private boolean isPostgres

isOracle

private boolean isOracle

isDB2

private boolean isDB2

isFirebird

private boolean isFirebird

isMicrosoftSQLServer

private boolean isMicrosoftSQLServer

isHSQLDatabaseEngine

private boolean isHSQLDatabaseEngine

isMySql

private boolean isMySql

isLdbc

private boolean isLdbc

isSQLite

private boolean isSQLite

storage

private final I_Storage storage

pingPrepared

private java.sql.PreparedStatement pingPrepared

queueCounter

private int queueCounter
Counts the queues using this manager.


supportsBatch

private boolean supportsBatch
tells wether the used database supports batch updates or not.


enableBatchMode

private boolean enableBatchMode
forces the desactivation of batch mode when adding entries


DATA_ID

static final int DATA_ID
Column index into XB_ENTRIES table

See Also:
Constant Field Values

QUEUE_NAME

static final int QUEUE_NAME
See Also:
Constant Field Values

PRIO

static final int PRIO
See Also:
Constant Field Values

TYPE_NAME

static final int TYPE_NAME
See Also:
Constant Field Values

PERSISTENT

static final int PERSISTENT
See Also:
Constant Field Values

SIZE_IN_BYTES

static final int SIZE_IN_BYTES
See Also:
Constant Field Values

BLOB

static final int BLOB
See Also:
Constant Field Values

maxNumStatements

private int maxNumStatements

maxSelectLimit

private int maxSelectLimit

testException

private final boolean testException
See Also:
Constant Field Values

countTest

private volatile short countTest

countDumps

private int countDumps
Constructor Detail

CommonTableDatabaseAccessor

public CommonTableDatabaseAccessor(JdbcConnectionPool pool,
                                   I_EntryFactory factory,
                                   java.lang.String managerName,
                                   I_Storage storage)
                            throws XmlBlasterException
Parameters:
storage - TODO
JdbcConnectionPool - the pool to be used for the connections to the database. IMPORTANT: The pool must have been previously initialized.
Throws:
XmlBlasterException
Method Detail

pingDatabase

public boolean pingDatabase()
pings with a newly created jdbc connection to check if the DB is up and running. It returns 'true' if the database is available, false otherwise. The ping is done by invocation

We don't use a connection from the pool for this check as it could be stale even if the database is alive.


registerStorageProblemListener

public boolean registerStorageProblemListener(I_StorageProblemListener entry)
Adds (registers) a listener for connection/disconnection events.

Specified by:
registerStorageProblemListener in interface I_StorageProblemNotifier

unRegisterStorageProblemListener

public boolean unRegisterStorageProblemListener(I_StorageProblemListener entry)
Adds (registers) a listener for connection/disconnection events.

Specified by:
unRegisterStorageProblemListener in interface I_StorageProblemNotifier
Returns:
boolean true if the entry was successfully removed.

storageUnavailable

public void storageUnavailable(int oldStatus)
Description copied from interface: I_StorageProblemListener
Invoked by the I_StorageProblemNotifier when the storage becomes unavailable (for example on a DB when the jdbc connection is broken).

Specified by:
storageUnavailable in interface I_StorageProblemListener
Parameters:
oldStatus - the status before the storage became unavailable.
See Also:
I_StorageProblemListener.storageUnavailable(int)

storageAvailable

public void storageAvailable(int oldStatus)
Description copied from interface: I_StorageProblemListener
Invoked by the I_StorageProblemNotifier when the storage becomes available again (for example on a DB when the jdbc connection is broken). Note that this method is invoked ONLY after the connection has become unavailable, it is NOT invoked the at startup, i.e. the first time the connection becomes available.

Specified by:
storageAvailable in interface I_StorageProblemListener
See Also:
I_StorageProblemListener.storageAvailable(int)

getStorageProblemListenerArr

public I_StorageProblemListener[] getStorageProblemListenerArr()
Returns:
A current snapshot of the connection listeners where we can work on (unsynchronized) and remove listeners without danger

checkIfDBLoss

protected final boolean checkIfDBLoss(java.sql.Connection conn,
                                      java.lang.String location,
                                      java.lang.Throwable ex)
See Also:
checkIfDBLoss(Connection, String, Throwable, String)

checkIfDBLoss

protected final boolean checkIfDBLoss(java.sql.Connection conn,
                                      java.lang.String location,
                                      java.lang.Throwable ex,
                                      java.lang.String trace)
Handles the SQLException. If it is a communication exception like the connection has been broken it will inform the connection pool.

Parameters:
location - where the exception occured.
ex - the exception which has to be handled.
trace - additional information to put in the logetLogId(tableName, storageId, "getEntries") logging trace.
Returns:
boolean true if it was a communication exception

getXbTableNames

private java.util.HashSet getXbTableNames(java.sql.Connection conn)
                                   throws java.sql.SQLException
Gets the names of all the tables used by XmlBlaster. This information is retrieved via the database's metadata.

Parameters:
conn - the connection on which to retrieve the metadata.
Returns:
HashSet the set containing all the existing tablenames.
Throws:
java.sql.SQLException

tablesCheckAndSetup

public final boolean tablesCheckAndSetup(boolean createTables)
                                  throws XmlBlasterException
Checks if all necessary tables exist. If a table does not exist and 'createTables' true, then the table is created.

Returns:
boolean 'true' if the tables are all there after the invocation to this method, 'false' if at least one of the required tables is missing after the invocation to this method.
Throws:
XmlBlasterException

modifyEntry

public long modifyEntry(java.lang.String queueName,
                        I_Entry entry,
                        I_Entry oldEntry)
                 throws XmlBlasterException
modifies a row in the specified queue table

Parameters:
queueName - The name of the queue on which to perform the operation
entry - the object to be stored.
oldEntry - the old one
Returns:
true on success
Throws:
XmlBlasterException - if an error occurred when trying to get a connection or an SQLException occurred.

addSingleEntry

private final boolean addSingleEntry(java.lang.String queueName,
                                     I_Entry entry,
                                     java.sql.Connection conn)
                              throws XmlBlasterException
Adds a row to the specified queue table

Parameters:
queueName - The name of the queue on which to perform the operation
entry - the object to be stored.
Returns:
true on success false if the entry was already in the table.
Throws:
java.sql.SQLException - if an error other than double entry occured while adding the row
XmlBlasterException - if an error occured when trying to get a connection

addEntry

public final boolean addEntry(java.lang.String queueName,
                              I_Entry entry)
                       throws XmlBlasterException
Adds a row to the specified queue table

Parameters:
queueName - The name of the queue on which to perform the operation
entry - the object to be stored.
Returns:
true on success
Throws:
java.sql.SQLException - if an error occured while adding the row
XmlBlasterException - if an error occured when trying to get a connection

addEntriesSingleMode

private int[] addEntriesSingleMode(java.sql.Connection conn,
                                   java.lang.String queueName,
                                   I_Entry[] entries)
                            throws XmlBlasterException
Throws:
XmlBlasterException

addEntries

public int[] addEntries(java.lang.String queueName,
                        I_Entry[] entries)
                 throws XmlBlasterException
Adds several rows to the specified queue table in batch mode to improve performance

Parameters:
queueName - The name of the queue on which to perform the operation
entries - the entries to store
Returns:
array of boolean telling which entries where stored and which not.
Throws:
java.sql.SQLException - if an error occured while adding the row
XmlBlasterException - if an error occured when trying to get a connection

cleanUp

public final int cleanUp(java.lang.String queueName)
                  throws XmlBlasterException
Cleans up the specified queue. It deletes all queue entries in the 'entries' table.

Returns:
the number of queues deleted (not the number of entries).
Throws:
XmlBlasterException

wipeOutDB

public int wipeOutDB(boolean doSetupNewTables)
              throws XmlBlasterException
Wipes out the entire DB. i.e. it deletes the three tables from the DB. IMPORTANT:

Parameters:
doSetupNewTables - if set to 'true' it recreates the necessary empty tables.
Throws:
XmlBlasterException

dumpMetaData

public void dumpMetaData()
Dumps the metadata to the log object. The log will write out this information as an info. This means you don't need to have the switch 'dump' set to true to see this information.


getNumOfBytes

public long getNumOfBytes(java.lang.String queueName)
                   throws XmlBlasterException
Deprecated. Use getNumOfAll(String)

returns the amount of bytes currently in the specified queue

Parameters:
tableName - the name of the table in which to count
Returns:
the current amount of bytes used in the table.
Throws:
XmlBlasterException

setUp

public final void setUp()
                 throws XmlBlasterException
Sets up a table for the queue specified by this queue name. If one already exists (i.e. if it recovers from a crash) its associated table name is returned.

Throws:
XmlBlasterException

isPersistent

private boolean isPersistent(java.lang.String persistentAsChar)

processResultSet

private final java.util.ArrayList processResultSet(java.sql.ResultSet rs,
                                                   StorageId storageIdDefault,
                                                   int numOfEntries,
                                                   long numOfBytes,
                                                   boolean onlyId,
                                                   I_EntryFilter entryFilter)
                                            throws java.sql.SQLException,
                                                   XmlBlasterException
Throws:
java.sql.SQLException
XmlBlasterException

processResultSetForDeleting

private final ReturnDataHolder processResultSetForDeleting(java.sql.ResultSet rs,
                                                           int numOfEntries,
                                                           long numOfBytes,
                                                           java.util.List<java.lang.Long> retL)
                                                    throws java.sql.SQLException,
                                                           XmlBlasterException
It accepts result sets with (long dataId, long size)

Parameters:
numOfBytes - as input is the maximum number of bytes to process. As output it stores the number of bytes processed.
numOfEntries - the maximum number of entries to process
Throws:
java.sql.SQLException
XmlBlasterException

getPool

public JdbcConnectionPool getPool()
Returns the pool associated to this object.

Returns:
JdbcConnectionPool the pool managing the connections to the DB

update

private final int update(java.lang.String request)
                  throws java.sql.SQLException,
                         XmlBlasterException
A generic invocation for a simple update on the database. It will use a normal statement (not a prepared statement),

Parameters:
request - the request string
fetchSize - the number of entries to fetch, i.e. to update
Throws:
java.sql.SQLException
XmlBlasterException

update

private final int update(java.lang.String request,
                         java.sql.Connection conn)
                  throws java.sql.SQLException
This version makes an update but does no connection management, i.e. a connection must be established outside this method and passed in the argument list. The closing and cleaning up of the connection must also be handled outside.

Parameters:
request - the string specifying which request to make
conn - the connection to use for this request
Throws:
java.sql.SQLException

deleteAllTransient

public int deleteAllTransient(java.lang.String queueName)
                       throws XmlBlasterException
deletes all transient messages

Throws:
XmlBlasterException

whereInStatement

private final java.util.ArrayList whereInStatement(java.lang.String reqPrefix,
                                                   long[] uniqueIds)
The prefix is the initial part of the SQL update/query. Note that this method can be used both for SELECT statements as for updates such as DELETE or UPDATE. An example of prefix: "delete from tableName where dataId in(";


isInsideRange

private final boolean isInsideRange(int numEntries,
                                    int maxNumEntries,
                                    long numBytes,
                                    long maxNumBytes)
Helper method to find out if still to retrieve entries in getAndDeleteLowest or not.


getAndDeleteLowest

public ReturnDataHolder getAndDeleteLowest(StorageId storageId,
                                           int numOfEntries,
                                           long numOfBytes,
                                           int maxPriority,
                                           long minUniqueId,
                                           boolean leaveOne,
                                           boolean doDelete)
                                    throws XmlBlasterException
Under the same transaction it gets and deletes all the entries which fit into the constrains specified in the argument list. The entries are really deleted only if doDelete is true, otherwise they are left untouched on the queue

Throws:
XmlBlasterException
See Also:
I_Queue.takeLowest(int, long, org.xmlBlaster.util.queue.I_QueueEntry, boolean)

deleteEntries

public boolean[] deleteEntries(java.lang.String queueName,
                               long[] uniqueIds)
                        throws XmlBlasterException
Deletes the entries specified by the entries array. Since all entries are deleted at the same time, in case of an exception the result is uncertain (it depends on what the used database will do). In case the statement would be too long for the DB, the request is split into several statements which are invoked separately.

Parameters:
tableName - the name of the table on which to delete the entries
uniqueIds - the array containing all the uniqueId for the entries to delete.
Throws:
XmlBlasterException

deleteEntriesNoSplit

private boolean[] deleteEntriesNoSplit(java.lang.String queueName,
                                       long[] uniqueIds)
                                throws XmlBlasterException
Throws:
XmlBlasterException

deleteEntry

public int deleteEntry(java.lang.String queueName,
                       long uniqueId)
                throws XmlBlasterException
Deletes the entry specified

Parameters:
tableName - the name of the table on which to delete the entries
uniqueIds - the array containing all the uniqueId for the entries to delete.
Throws:
XmlBlasterException

deleteFirstEntries

public ReturnDataHolder deleteFirstEntries(java.lang.String queueName,
                                           long numOfEntries,
                                           long amount)
                                    throws XmlBlasterException
Deletes number of entries specified by the argument list. If less than that amount of elements is given, then all entries will be deleted. If you specify -1 as the number of entries, then all entries will be deleted.

Parameters:
tableName - the name of the table on which to act.
numOfEntries - the number of entries to be deleted.
amount - the maximum amount of bytes to remove. Note that if no entries fit into this size, the first entry is taken anyway (to avoid deadlocks)
Throws:
XmlBlasterException

getEntriesByPriority

public java.util.ArrayList getEntriesByPriority(StorageId storageId,
                                                int numOfEntries,
                                                long numOfBytes,
                                                int minPrio,
                                                int maxPrio,
                                                I_EntryFilter entryFilter)
                                         throws XmlBlasterException
gets the first numOfEntries of the queue which have the priority in the range specified by prioMin and prioMax (inclusive). If there are not so many entries in the queue, all elements in the queue are returned.

Parameters:
storageId - the storageId of the queue/storage from which to retrieve the information.
numOfEntries - the maximum number of elements to retrieve. If negative there is no constriction.
numOfBytes - the maximum number of bytes to retrieve. If negative, there is no constriction.
minPrio - the minimum priority to retreive (inclusive).
maxPrio - the maximum priority to retrieve (inclusive).
Throws:
XmlBlasterException

getEntriesBySamePriority

public java.util.ArrayList getEntriesBySamePriority(StorageId storageId,
                                                    int numOfEntries,
                                                    long numOfBytes)
                                             throws XmlBlasterException
gets the first numOfEntries of the queue which have the same priority. If there are not so many entries in the queue, all elements in the queue are returned.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
XmlBlasterException

getEntries

public java.util.ArrayList getEntries(StorageId storageId,
                                      int numOfEntries,
                                      long numOfBytes,
                                      I_EntryFilter entryFilter)
                               throws XmlBlasterException
gets the first numOfEntries of the queue. If there are not so many entries in the queue, all elements in the queue are returned.

Is public for testsuite only.

Parameters:
numOfEntries - Access num entries, if -1 access all entries currently found
numOfBytes - is the maximum size in bytes of the array to return, -1 is unlimited .
Throws:
XmlBlasterException

getEntriesLike

public java.util.ArrayList getEntriesLike(java.lang.String queueNamePattern,
                                          java.lang.String flag,
                                          int numOfEntries,
                                          long numOfBytes,
                                          I_EntryFilter entryFilter)
                                   throws XmlBlasterException
Raw access to the table. If there are not so many entries in the queue, all elements in the queue are returned.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
XmlBlasterException

getEntriesWithLimit

public java.util.ArrayList getEntriesWithLimit(StorageId storageId,
                                               I_Entry limitEntry)
                                        throws XmlBlasterException
gets the first numOfEntries of the queue until the limitEntry is reached.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
XmlBlasterException

removeEntriesWithLimit

public long removeEntriesWithLimit(StorageId storageId,
                                   I_Entry limitEntry,
                                   boolean inclusive)
                            throws XmlBlasterException
deletes the first numOfEntries of the queue until the limitEntry is reached.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
XmlBlasterException

getEntries

public java.util.ArrayList getEntries(StorageId storageId,
                                      long[] dataids)
                               throws XmlBlasterException
gets all the entries which have the dataid specified in the argument list. If the list is empty or null, an empty ArrayList object is returned.

Throws:
XmlBlasterException

getNumOfAll

public final EntryCount getNumOfAll(java.lang.String queueName)
                             throws XmlBlasterException
Gets the real number of entries. That is it really makes a call to the DB to find out how big the size is.

Returns:
never null
Throws:
XmlBlasterException

getNumOfEntries

public final long getNumOfEntries(java.lang.String queueName)
                           throws XmlBlasterException
Deprecated. Use getNumOfAll(String)

Gets the real number of entries. That is it really makes a call to the DB to find out how big the size is.

Throws:
XmlBlasterException

getNumOfPersistents

public final long getNumOfPersistents(java.lang.String queueName)
                               throws XmlBlasterException
Deprecated. Use getNumOfAll(String)

Gets the real number of persistent entries. That is it really makes a call to the DB to find out how big the size is.

Throws:
XmlBlasterException

getSizeOfPersistents

public final long getSizeOfPersistents(java.lang.String queueName)
                                throws XmlBlasterException
Deprecated. Use getNumOfAll(String) Replaced all four selects with one: "select count(*), sum(byteSize), durable from XB_ENTRIES WHERE queueName='history_xmlBlaster_192_168_1_4_3412Hello' GROUP BY durable;"

gets the real size of persistent entries, that is it really makes a call to the DB to find out how big the size is.

Throws:
XmlBlasterException

getLogId

private final java.lang.String getLogId(java.lang.String queueName,
                                        java.lang.String methodName)
Parameters:
queueName - or null
Returns:
A nice location string for logging (instead of plain ME)

createInstance

public static CommonTableDatabaseAccessor createInstance(Global glob,
                                                         I_EntryFactory factory,
                                                         java.lang.String confType,
                                                         java.lang.String confVersion,
                                                         java.util.Properties properties)
                                                  throws XmlBlasterException
The Properties to use as a default are these from the QueuePlugin with the configuration name specified by defaultConfName (default is 'JDBC'). You can overwrite these properties entirely or partially with 'properties'.

Parameters:
confType - the name of the configuration to use as default. If you pass null, then 'JDBC' will be taken.
confVersion - the version to use as a default. If you pass null, then '1.0' will be taken.
properties - the properties to use to overwrite the default properties. If you pass null, no properties will be overwritten, and the default will be used.
Throws:
XmlBlasterException

wipeOutDB

public static void wipeOutDB(Global glob,
                             java.lang.String confType,
                             java.lang.String confVersion,
                             java.util.Properties properties,
                             boolean setupNewTables)
                      throws XmlBlasterException
wipes out the db. The Properties to use as a default are these from the QueuePlugin with the configuration name specified by defaultConfName (default is 'JDBC'). You can overwrite these properties entirely or partially with 'properties'.

Parameters:
confType - the name of the configuration to use as default. If you pass null, then 'JDBC' will be taken.
confVersion - the version to use as a default. If you pass null, then '1.0' will be taken.
properties - the properties to use to overwrite the default properties. If you pass null, no properties will be overwritten, and the default will be used.
setupNewTables - tells the manager to recreate empty tables if set to 'true'. Note that this flag only has effect if the JdbcManagerCommonTable is used.
Throws:
XmlBlasterException

main

public static void main(java.lang.String[] args)
This main method can be used to delete all tables on the db which start with a certain prefix. It is useful to cleanup the entire DB.


shutdown

public void shutdown()

registerQueue

public void registerQueue(I_Queue queue)

unregisterQueue

public void unregisterQueue(I_Queue queue)

isDB2

public boolean isDB2()
Returns:
the isDb2

isHSQLDatabaseEngine

public boolean isHSQLDatabaseEngine()
Returns:
the isHsqlDb

isMicrosoftSQLServer

public boolean isMicrosoftSQLServer()
Returns:
the isMsSqlServer

isMySql

public boolean isMySql()
Returns:
the isMySql

isOracle

public boolean isOracle()
Returns:
the isOracle

isPostgres

public boolean isPostgres()
Returns:
the isPostgres

isFirebird

public boolean isFirebird()
Returns:
the firebird

isLdbc

public boolean isLdbc()
Returns:
the isLdbc

isSQLite

public boolean isSQLite()
Returns:
the isSQLite

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.