|
xmlBlaster 2.2.0 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:
Nested Class Summary | |
---|---|
private class |
XBDatabaseAccessor.QueueGlobalInfo
|
Field Summary | |
---|---|
(package private) static int |
BLOB
|
(package private) static int |
DATA_ID
Column index into XB_ENTRIES table |
private boolean |
dbAdmin
|
private static java.lang.String |
DUMMY_VALUE
|
private boolean |
enableBatchMode
forces the desactivation of batch mode when adding entries |
private I_EntryFactory |
factory
|
private static boolean |
first
|
private Global |
glob
|
private long |
initCount
|
private boolean |
isConnected
|
private java.util.WeakHashMap<I_StorageProblemListener,java.lang.String> |
listener
|
private static java.util.logging.Logger |
log
|
private static boolean |
logOnceDone
|
private int |
maxNumStatements
|
private int |
maxSelectLimit
|
private int |
maxStatementLength
|
private static java.lang.String |
ME
|
private XBMeatFactory |
meatFactory
|
(package private) static int |
PERSISTENT
|
private I_DbPool |
pool
|
(package private) static int |
PRIO
|
(package private) static int |
QUEUE_NAME
|
private int |
queueCounter
Counts the queues using this manager. |
private XBRefFactory |
refFactory
|
(package private) static int |
SIZE_IN_BYTES
|
private XBStoreFactory |
storeFactory
|
private boolean |
supportsBatch
tells wether the used database supports batch updates or not. |
private int |
timeout
|
(package private) static int |
TYPE_NAME
|
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 |
private int[] |
addEntriesSingleMode(java.sql.Connection conn,
XBStore store,
I_Entry[] entries)
|
boolean |
addEntry(XBStore store,
I_Entry entry)
Adds a row to the specified queue table |
private boolean |
addSingleEntry(XBStore store,
I_Entry entry,
java.sql.Connection conn)
Adds a row to the specified queue table |
private boolean |
areSameCounters(XBMeat newEntry,
XBMeat oldEntry)
|
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)
|
private java.util.List<I_Entry> |
createEntries(XBStore store,
java.util.List<XBMeat> meatList,
java.util.List<XBRef> refList,
I_EntryFilter filter,
I_Storage storage)
|
private I_Entry |
createEntry(XBStore store,
XBMeat meat,
XBRef ref)
|
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 |
private long |
deleteEntries(java.sql.Connection conn,
XBStore store,
XBRef[] refs,
XBMeat[] meats)
|
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(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)
|
private java.lang.String |
getLogId(java.lang.String queueName,
java.lang.String methodName)
|
private java.util.List<XBMeat> |
getMeatList(XBStore store,
java.sql.Connection conn,
XBMeat[] refs,
int maxStLength,
int maxNumSt,
int timeout)
|
EntryCount |
getNumOfAll(XBStore store)
Gets the real number of entries. |
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)
|
private java.util.List<XBRef> |
getRefList(XBStore store,
java.sql.Connection conn,
XBRef[] refs,
int maxStLength,
int maxNumSt,
int timeout)
|
I_StorageProblemListener[] |
getStorageProblemListenerArr()
|
XBStore |
getXBStore(StorageId uniqueQueueId)
|
XBStoreFactory |
getXBStoreFactory()
|
I_Info |
init(I_Info origInfo)
|
protected boolean |
initFactory(Global global,
PluginInfo plugInfo)
|
static java.lang.String |
isolationToString(int isolation)
|
private boolean |
isSame(XBMeat newEntry,
XBMeat oldEntry,
boolean checkCounters,
boolean checkContent)
|
private boolean |
isSameString(java.lang.String str1,
java.lang.String str2)
|
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. |
private boolean |
ping(java.sql.Connection conn)
pings the jdbc connection to check if the DB is up and running. |
private void |
prepareDefaultStatements()
|
void |
registerQueue(I_Queue queue)
|
boolean |
registerStorageProblemListener(I_StorageProblemListener entry)
Adds (registers) a listener for connection/disconnection events. |
private void |
releaseConnection(java.sql.Connection conn,
boolean success,
java.lang.String msg)
|
long |
removeEntriesWithLimit(XBStore store,
XBRef limitEntry,
boolean inclusive)
deletes the first numOfEntries of the queue until the limitEntry is reached. |
private void |
rollback(java.sql.Connection conn)
|
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). |
private void |
throwXblEx(java.lang.Throwable origEx,
ErrorCode errCode,
java.lang.String msg)
|
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 |
Field Detail |
---|
private static boolean logOnceDone
private static final java.lang.String ME
private static java.util.logging.Logger log
private I_DbPool pool
private I_EntryFactory factory
private java.util.WeakHashMap<I_StorageProblemListener,java.lang.String> listener
private XBStoreFactory storeFactory
private XBMeatFactory meatFactory
private XBRefFactory refFactory
private long initCount
private static java.lang.String DUMMY_VALUE
private int maxStatementLength
private boolean isConnected
private static boolean first
private int queueCounter
private boolean supportsBatch
private boolean enableBatchMode
private Global glob
static final int DATA_ID
static final int QUEUE_NAME
static final int PRIO
static final int TYPE_NAME
static final int PERSISTENT
static final int SIZE_IN_BYTES
static final int BLOB
private int maxNumStatements
private int maxSelectLimit
private int timeout
private boolean dbAdmin
Constructor Detail |
---|
public XBDatabaseAccessor()
Method Detail |
---|
private final void prepareDefaultStatements()
protected boolean initFactory(Global global, PluginInfo plugInfo) throws XmlBlasterException
XmlBlasterException
public I_Info init(I_Info origInfo) throws XmlBlasterException
init
in class XBFactoryBase
XmlBlasterException
protected void doInit(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
private final void throwXblEx(java.lang.Throwable origEx, ErrorCode errCode, java.lang.String msg) throws XmlBlasterException
XmlBlasterException
private final void releaseConnection(java.sql.Connection conn, boolean success, java.lang.String msg) throws XmlBlasterException
XmlBlasterException
public boolean ping()
private boolean ping(java.sql.Connection conn)
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.
private final boolean isSameString(java.lang.String str1, java.lang.String str2)
private final boolean areSameCounters(XBMeat newEntry, XBMeat oldEntry)
private final boolean isSame(XBMeat newEntry, XBMeat oldEntry, boolean checkCounters, boolean checkContent)
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.private final boolean addSingleEntry(XBStore store, I_Entry entry, java.sql.Connection conn) 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 other than double entry occured while adding the row
XmlBlasterException
- if an error occured when trying to get a connectionpublic 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 connectionprivate int[] addEntriesSingleMode(java.sql.Connection conn, XBStore store, I_Entry[] entries) throws XmlBlasterException
XmlBlasterException
public 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 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)
private long deleteEntries(java.sql.Connection conn, XBStore store, XBRef[] refs, XBMeat[] meats) throws java.sql.SQLException
java.sql.SQLException
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
private final void rollback(java.sql.Connection conn)
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
private java.util.List<XBRef> getRefList(XBStore store, java.sql.Connection conn, XBRef[] refs, int maxStLength, int maxNumSt, int timeout) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
private java.util.List<XBMeat> getMeatList(XBStore store, java.sql.Connection conn, XBMeat[] refs, int maxStLength, int maxNumSt, int timeout) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public java.util.List<I_Entry> getEntries(XBStore store, XBRef[] refs, XBMeat[] meats) throws XmlBlasterException
XmlBlasterException
public EntryCount getNumOfAll(XBStore store) throws XmlBlasterException
XmlBlasterException
private final java.lang.String getLogId(java.lang.String queueName, java.lang.String methodName)
queueName
- or null
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)
private I_Entry createEntry(XBStore store, XBMeat meat, XBRef ref) throws XmlBlasterException
XmlBlasterException
private java.util.List<I_Entry> createEntries(XBStore store, java.util.List<XBMeat> meatList, java.util.List<XBRef> refList, I_EntryFilter filter, I_Storage storage) throws XmlBlasterException
XmlBlasterException
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 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |