Commit cc7b2e7a authored by guus's avatar guus

Capping queue size (OF-77)

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11374 b35dd754-fafc-0310-a699-88a17e54d16e
parent a8966020
......@@ -73,6 +73,8 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
private static final String DELETE_OFFLINE_MESSAGE =
"DELETE FROM ofOffline WHERE username=? AND creationDate=?";
private static final int POOL_SIZE = 10;
private Cache<String, Integer> sizeCache;
private FastDateFormat dateFormat;
/**
......@@ -93,7 +95,7 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
/**
* Pool of SAX Readers. SAXReader is not thread safe so we need to have a pool of readers.
*/
private BlockingQueue<SAXReader> xmlReaders = new LinkedBlockingQueue<SAXReader>();
private BlockingQueue<SAXReader> xmlReaders = new LinkedBlockingQueue<SAXReader>(POOL_SIZE);
/**
* Constructs a new offline message store.
......@@ -421,7 +423,7 @@ public class OfflineMessageStore extends BasicModule implements UserEventListene
public void start() throws IllegalStateException {
super.start();
// Initialize the pool of sax readers
for (int i=0; i<10; i++) {
for (int i=0; i<POOL_SIZE; i++) {
SAXReader xmlReader = new SAXReader();
xmlReader.setEncoding("UTF-8");
xmlReaders.add(xmlReader);
......
......@@ -58,6 +58,8 @@ public class PrivateStorage extends BasicModule implements UserEventListener {
private static final String DELETE_PRIVATES =
"DELETE FROM ofPrivate WHERE username=?";
private static final int POOL_SIZE = 10;
// Currently no delete supported, we can detect an add of an empty element and
// use that to signal a delete but that optimization doesn't seem necessary.
// private static final String DELETE_PRIVATE =
......@@ -68,7 +70,7 @@ public class PrivateStorage extends BasicModule implements UserEventListener {
/**
* Pool of SAX Readers. SAXReader is not thread safe so we need to have a pool of readers.
*/
private BlockingQueue<SAXReader> xmlReaders = new LinkedBlockingQueue<SAXReader>();
private BlockingQueue<SAXReader> xmlReaders = new LinkedBlockingQueue<SAXReader>(POOL_SIZE);
/**
* Constructs a new PrivateStore instance.
......@@ -230,7 +232,7 @@ public class PrivateStorage extends BasicModule implements UserEventListener {
public void start() throws IllegalStateException {
super.start();
// Initialize the pool of sax readers
for (int i=0; i<10; i++) {
for (int i=0; i<POOL_SIZE; i++) {
SAXReader xmlReader = new SAXReader();
xmlReader.setEncoding("UTF-8");
xmlReaders.add(xmlReader);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment