|
From: <sa...@us...> - 2003-11-12 10:22:34
|
Update of /cvsroot/jrobin/src/org/jrobin/core
In directory sc8-pr-cvs1:/tmp/cvs-serv5554/org/jrobin/core
Modified Files:
RrdDbPool.java
Log Message:
MRTD demo now uses RrdDbPool for maximum performance
Index: RrdDbPool.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDbPool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RrdDbPool.java 10 Nov 2003 08:52:27 -0000 1.2
--- RrdDbPool.java 12 Nov 2003 10:22:09 -0000 1.3
***************
*** 100,104 ****
* which still does not force garbage collector to run.
*/
! public static final int OPEN_FILES_DESIRED = 50;
private HashMap rrdMap = new HashMap();
--- 100,105 ----
* which still does not force garbage collector to run.
*/
! public static final int INITIAL_CAPACITY = 50;
! private static int capacity = INITIAL_CAPACITY;
private HashMap rrdMap = new HashMap();
***************
*** 216,219 ****
--- 217,224 ----
*/
public synchronized void release(RrdDb rrdDb) throws IOException, RrdException {
+ if(rrdDb == null) {
+ // we don't want NullPointerException
+ return;
+ }
RrdFile rrdFile = rrdDb.getRrdFile();
if(rrdFile == null) {
***************
*** 235,239 ****
private void gc() throws IOException {
int mapSize = rrdMap.size();
! if(mapSize <= OPEN_FILES_DESIRED) {
// nothing to do
debug("GC: no need to run");
--- 240,244 ----
private void gc() throws IOException {
int mapSize = rrdMap.size();
! if(mapSize <= capacity) {
// nothing to do
debug("GC: no need to run");
***************
*** 315,318 ****
--- 320,343 ----
}
return buff.toString();
+ }
+
+ /**
+ * Returns maximum number of internally open RRD files
+ * which still does not force garbage collector to run.
+ *
+ * @return Desired nuber of open files held in the pool.
+ */
+ public static int getCapacity() {
+ return capacity;
+ }
+
+ /**
+ * Sets maximum number of internally open RRD files
+ * which still does not force garbage collector to run.
+ *
+ * @param capacity Desired number of open files to hold in the pool
+ */
+ public static void setCapacity(int capacity) {
+ RrdDbPool.capacity = capacity;
}
|