|
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.XBFactoryBase org.xmlBlaster.util.queue.jdbc.XBDatabaseAccessor
public class XBDatabaseAccessor
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 class org.xmlBlaster.util.queue.jdbc.XBFactoryBase |
---|
DB2, FIREBIRD, HSQLDB, LDBC, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER_2000, SQLSERVER_2005, UNKNOWN |
Fields inherited from interface org.xmlBlaster.util.queue.I_StorageProblemListener |
---|
AVAILABLE, UNAVAILABLE, UNDEF |
Constructor Summary | |
---|---|
XBDatabaseAccessor()
|
Method Summary | |
---|---|
int[] |
addEntries(XBStore store,
I_Entry[] entries)
Adds several rows to the specified queue table in batch mode to improve performance |
boolean |
addEntry(XBStore store,
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(XBStore store)
Cleans up the specified queue. |
long |
clearQueue(XBStore store)
|
static XBDatabaseAccessor |
createInstance(Global glob,
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'). |
long |
deleteAllTransient(XBStore store)
deletes all transient messages |
long |
deleteEntries(XBStore store,
XBRef[] refs,
XBMeat[] meats)
Deletes the entries specified by the entries array. |
int |
deleteEntry(XBStore store,
long refId,
long meatId)
Deletes the entry specified |
long |
deleteFirstRefs(XBStore store,
long numOfEntries)
Deletes number of entries specified by the argument list. |
void |
deleteStore(long storeId)
Deletes the store. |
protected void |
doInit(org.xmlBlaster.contrib.I_Info info)
|
void |
dumpMetaData()
Dumps the metadata to the log object. |
java.util.List<XBStore> |
getAllOfType(java.lang.String node,
java.lang.String type)
|
ReturnDataHolder |
getAndDeleteLowest(XBStore store,
int numOfEntries,
long numOfBytes,
int maxPriority,
long minUniqueId,
boolean leaveOne,
boolean doDelete,
I_Storage storage)
Under the same transaction it gets and deletes all the entries which fit into the constrains specified in the argument list. |
java.util.List<I_Entry> |
getEntries(XBStore store,
int numOfEntries,
long numOfBytes,
I_EntryFilter entryFilter,
boolean isRef,
I_Storage storage)
gets the first numOfEntries of the queue. |
java.util.List<I_Entry> |
getEntries(XBStore store,
XBRef[] refs,
XBMeat[] meats)
gets all the entries which have the dataid specified in the argument list. |
java.util.List<I_Entry> |
getEntriesByPriority(XBStore store,
int numOfEntries,
long numOfBytes,
int minPrio,
int maxPrio)
gets the first numOfEntries of the queue which have the priority in the range specified by prioMin and prioMax (inclusive). |
java.util.List<I_Entry> |
getEntriesBySamePriority(XBStore store,
int numOfEntries,
long numOfBytes)
gets the first numOfEntries of the queue which have the same priority. |
XBEntry[] |
getEntriesLike(java.lang.String queueNamePattern,
java.lang.String flag,
int numOfEntries,
long numOfBytes,
I_EntryFilter entryFilter)
Raw access to the table. |
java.util.List<I_Entry> |
getEntriesWithLimit(XBStore store,
I_Entry limitEntry,
I_Storage storage)
gets the first numOfEntries of the queue until the limitEntry is reached. |
static java.lang.String |
getIsolationLevel(java.sql.Connection conn)
|
EntryCount |
getNumOfAll(XBStore store)
Gets the real number of entries. |
org.xmlBlaster.contrib.db.I_DbPool |
getPool()
Returns the pool associated to this object. |
java.util.List<I_Entry> |
getRefEntries(XBStore store,
int numOfEntries,
long numOfBytes,
I_EntryFilter entryFilter,
I_Storage storage,
I_QueueEntry firstEntryExlusive)
|
I_StorageProblemListener[] |
getStorageProblemListenerArr()
|
XBStore |
getXBStore(StorageId uniqueQueueId)
|
XBStoreFactory |
getXBStoreFactory()
|
org.xmlBlaster.contrib.I_Info |
init(org.xmlBlaster.contrib.I_Info origInfo)
|
protected boolean |
initFactory(Global global,
PluginInfo plugInfo)
|
static java.lang.String |
isolationToString(int isolation)
|
long |
modifyEntry(XBStore store,
XBMeat entry,
XBMeat oldEntry,
boolean onlyRefCounters)
modifies a row in the specified queue table |
boolean |
ping()
pings the 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(XBStore store,
XBRef limitEntry,
boolean inclusive)
deletes the first numOfEntries of the queue until the limitEntry is reached. |
void |
setUp(boolean deleteAllTransients)
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). |
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 org.xmlBlaster.util.queue.jdbc.XBFactoryBase |
---|
getDbVendor |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XBDatabaseAccessor()
Method Detail |
---|
protected boolean initFactory(Global global, PluginInfo plugInfo) throws XmlBlasterException
XmlBlasterException
public org.xmlBlaster.contrib.I_Info init(org.xmlBlaster.contrib.I_Info origInfo) throws XmlBlasterException
init
in class XBFactoryBase
XmlBlasterException
protected void doInit(org.xmlBlaster.contrib.I_Info info) throws XmlBlasterException
doInit
in class XBFactoryBase
storage
- TODOJdbcConnectionPool
- the pool to be used for the connections to
the database. IMPORTANT: The pool must have been previously
initialized.
XmlBlasterException
public boolean ping()
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 long modifyEntry(XBStore store, XBMeat entry, XBMeat oldEntry, boolean onlyRefCounters) 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 boolean addEntry(XBStore store, 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(XBStore store, 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 int cleanUp(XBStore store) throws XmlBlasterException
XmlBlasterException
public int wipeOutDB(boolean doSetupNewTables) throws XmlBlasterException
doSetupNewTables
- if set to 'true' it recreates the necessary empty tables.
XmlBlasterException
public static java.lang.String isolationToString(int isolation)
public static java.lang.String getIsolationLevel(java.sql.Connection conn)
public void dumpMetaData()
public final void setUp(boolean deleteAllTransients) throws XmlBlasterException
XmlBlasterException
public org.xmlBlaster.contrib.db.I_DbPool getPool()
public long deleteAllTransient(XBStore store) throws XmlBlasterException
XmlBlasterException
public ReturnDataHolder getAndDeleteLowest(XBStore store, int numOfEntries, long numOfBytes, int maxPriority, long minUniqueId, boolean leaveOne, boolean doDelete, I_Storage storage) throws XmlBlasterException
XmlBlasterException
I_Queue.takeLowest(int, long, org.xmlBlaster.util.queue.I_QueueEntry, boolean)
public void deleteStore(long storeId) throws XmlBlasterException
XmlBlasterException
public long deleteEntries(XBStore store, XBRef[] refs, XBMeat[] meats) throws XmlBlasterException
tableName
- the name of the table on which to delete the entriesrefs
- the array containing all entries to delete for the refs.meats
- the array containing all entries to delete for the meats.
XmlBlasterException
public int deleteEntry(XBStore store, long refId, long meatId) 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 long deleteFirstRefs(XBStore store, long numOfEntries) 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.List<I_Entry> getEntriesByPriority(XBStore store, int numOfEntries, long numOfBytes, int minPrio, int maxPrio) 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.List<I_Entry> getEntriesBySamePriority(XBStore store, int numOfEntries, long numOfBytes) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public java.util.List<I_Entry> getRefEntries(XBStore store, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter, I_Storage storage, I_QueueEntry firstEntryExlusive) throws XmlBlasterException
XmlBlasterException
public java.util.List<I_Entry> getEntries(XBStore store, int numOfEntries, long numOfBytes, I_EntryFilter entryFilter, boolean isRef, I_Storage storage) 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 XBEntry[] 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.List<I_Entry> getEntriesWithLimit(XBStore store, I_Entry limitEntry, I_Storage storage) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public long removeEntriesWithLimit(XBStore store, XBRef limitEntry, boolean inclusive) throws XmlBlasterException
numOfEntries
- the maximum number of elements to retrieve
XmlBlasterException
public java.util.List<I_Entry> getEntries(XBStore store, XBRef[] refs, XBMeat[] meats) throws XmlBlasterException
XmlBlasterException
public EntryCount getNumOfAll(XBStore store) throws XmlBlasterException
XmlBlasterException
public static XBDatabaseAccessor createInstance(Global glob, 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 void shutdown()
public void registerQueue(I_Queue queue)
public void unregisterQueue(I_Queue queue)
public XBStore getXBStore(StorageId uniqueQueueId) throws XmlBlasterException
XmlBlasterException
public java.util.List<XBStore> getAllOfType(java.lang.String node, java.lang.String type) throws XmlBlasterException
XmlBlasterException
public long clearQueue(XBStore store) throws XmlBlasterException
XmlBlasterException
public XBStoreFactory getXBStoreFactory()
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |