|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.queue.jdbc.CommonTableDatabaseAccessor
public class CommonTableDatabaseAccessor
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:
Field Summary |
---|
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 |
boolean |
addEntry(java.lang.String queueName,
I_Entry entry)
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. |
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. |
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()
|
boolean |
isDB2()
|
boolean |
isFirebird()
|
boolean |
isHSQLDatabaseEngine()
|
boolean |
isLdbc()
|
boolean |
isMicrosoftSQLServer()
|
boolean |
isMySql()
|
boolean |
isOracle()
|
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. |
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. |
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 |
Constructor Detail |
---|
public CommonTableDatabaseAccessor(JdbcConnectionPool pool, I_EntryFactory factory, java.lang.String managerName, I_Storage storage) throws XmlBlasterException
storage
- TODOJdbcConnectionPool
- the pool to be used for the connections to
the database. IMPORTANT: The pool must have been previously
initialized.
XmlBlasterException
Method Detail |
---|
public boolean pingDatabase()
We don't use a connection from the pool for this check as it could be stale even if the database is alive.
public boolean registerStorageProblemListener(I_StorageProblemListener entry)
registerStorageProblemListener
in interface I_StorageProblemNotifier
public boolean unRegisterStorageProblemListener(I_StorageProblemListener entry)
unRegisterStorageProblemListener
in interface I_StorageProblemNotifier
public void storageUnavailable(int oldStatus)
I_StorageProblemListener
storageUnavailable
in interface I_StorageProblemListener
oldStatus
- the status before the storage became unavailable.I_StorageProblemListener.storageUnavailable(int)
public void storageAvailable(int oldStatus)
I_StorageProblemListener
storageAvailable
in interface I_StorageProblemListener
I_StorageProblemListener.storageAvailable(int)
public I_StorageProblemListener[] getStorageProblemListenerArr()
protected final boolean checkIfDBLoss(java.sql.Connection conn, java.lang.String location, java.lang.Throwable ex)
checkIfDBLoss(Connection, String, Throwable, String)
protected final boolean checkIfDBLoss(java.sql.Connection conn, java.lang.String location, java.lang.Throwable ex, java.lang.String trace)
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.
public final boolean tablesCheckAndSetup(boolean createTables) throws XmlBlasterException
XmlBlasterException
public long modifyEntry(java.lang.String queueName, I_Entry entry, I_Entry oldEntry) throws XmlBlasterException
queueName
- The name of the queue on which to perform the operationentry
- the object to be stored.oldEntry
- the old one
XmlBlasterException
- if an error occurred when trying to get a connection or an SQLException
occurred.public final boolean addEntry(java.lang.String queueName, I_Entry entry) throws XmlBlasterException
queueName
- The name of the queue on which to perform the operationentry
- the object to be stored.
java.sql.SQLException
- if an error occured while adding the row
XmlBlasterException
- if an error occured when trying to get a connectionpublic int[] addEntries(java.lang.String queueName, I_Entry[] entries) throws XmlBlasterException
queueName
- The name of the queue on which to perform the operationentries
- the entries to store
java.sql.SQLException
- if an error occured while adding the row
XmlBlasterException
- if an error occured when trying to get a connectionpublic final int cleanUp(java.lang.String queueName) throws XmlBlasterException
XmlBlasterException
public int wipeOutDB(boolean doSetupNewTables) throws XmlBlasterException
doSetupNewTables
- if set to 'true' it recreates the necessary empty tables.
XmlBlasterException
public void dumpMetaData()
public long getNumOfBytes(java.lang.String queueName) throws XmlBlasterException
getNumOfAll(String)
tableName
- the name of the table in which to count
XmlBlasterException
public final void setUp() throws XmlBlasterException
XmlBlasterException
public JdbcConnectionPool getPool()
public int deleteAllTransient(java.lang.String queueName) throws XmlBlasterException
XmlBlasterException
public ReturnDataHolder getAndDeleteLowest(StorageId storageId, int numOfEntries, long numOfBytes, int maxPriority, long minUniqueId, boolean leaveOne, boolean doDelete) throws XmlBlasterException
XmlBlasterException
I_Queue.takeLowest(int, long, org.xmlBlaster.util.queue.I_QueueEntry, boolean)
public boolean[] deleteEntries(java.lang.String queueName, long[] uniqueIds) throws XmlBlasterException
tableName
- the name of the table on which to delete the entriesuniqueIds
- the array containing all the uniqueId for the entries to delete.
XmlBlasterException
public int deleteEntry(java.lang.String queueName, long uniqueId) throws XmlBlasterException
tableName
- the name of the table on which to delete the entriesuniqueIds
- the array containing all the uniqueId for the entries to delete.
XmlBlasterException
public ReturnDataHolder deleteFirstEntries(java.lang.String queueName, long numOfEntries, long amount) throws XmlBlasterException
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)
XmlBlasterException
public java.util.ArrayList getEntriesByPriority(StorageId storageId, int numOfEntries, long numOfBytes, int minPrio, int maxPrio, I_EntryFilter entryFilter) throws XmlBlasterException
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).
XmlBlasterException
public java.util.ArrayList getEntriesBySamePriority(StorageId storageId, int numOfEntries, long numOfBytes) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public java.util.ArrayList getEntries(StorageId storageId, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter) throws XmlBlasterException
Is public for testsuite only.
numOfEntries
- Access num entries, if -1 access all entries currently foundnumOfBytes
- is the maximum size in bytes of the array to return, -1 is unlimited .
XmlBlasterException
public java.util.ArrayList getEntriesLike(java.lang.String queueNamePattern, java.lang.String flag, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public java.util.ArrayList getEntriesWithLimit(StorageId storageId, I_Entry limitEntry) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public long removeEntriesWithLimit(StorageId storageId, I_Entry limitEntry, boolean inclusive) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public java.util.ArrayList getEntries(StorageId storageId, long[] dataids) throws XmlBlasterException
XmlBlasterException
public final EntryCount getNumOfAll(java.lang.String queueName) throws XmlBlasterException
XmlBlasterException
public final long getNumOfEntries(java.lang.String queueName) throws XmlBlasterException
getNumOfAll(String)
XmlBlasterException
public final long getNumOfPersistents(java.lang.String queueName) throws XmlBlasterException
getNumOfAll(String)
XmlBlasterException
public final long getSizeOfPersistents(java.lang.String queueName) throws XmlBlasterException
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;"
XmlBlasterException
public static CommonTableDatabaseAccessor createInstance(Global glob, I_EntryFactory factory, java.lang.String confType, java.lang.String confVersion, java.util.Properties properties) throws XmlBlasterException
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.
XmlBlasterException
public static void wipeOutDB(Global glob, java.lang.String confType, java.lang.String confVersion, java.util.Properties properties, boolean setupNewTables) throws XmlBlasterException
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.
XmlBlasterException
public static void main(java.lang.String[] args)
public void shutdown()
public void registerQueue(I_Queue queue)
public void unregisterQueue(I_Queue queue)
public boolean isDB2()
public boolean isHSQLDatabaseEngine()
public boolean isMicrosoftSQLServer()
public boolean isMySql()
public boolean isOracle()
public boolean isPostgres()
public boolean isFirebird()
public boolean isLdbc()
public boolean isSQLite()
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |