commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore StoreJanitorImpl.java StoreJanitor.java Store.java MRUMemoryStore.java JispStringKey.java JispFilesystemStore.java
Date Sat, 12 Jan 2002 18:24:15 GMT
froehlich    02/01/12 10:24:15

  Modified:    simplestore/src/java/org/apache/commons/simplestore
                        StoreJanitorImpl.java StoreJanitor.java Store.java
                        MRUMemoryStore.java JispStringKey.java
                        JispFilesystemStore.java
  Log:
  javadoc update
  
  Revision  Changes    Path
  1.2       +72 -5     jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/StoreJanitorImpl.java
  
  Index: StoreJanitorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/StoreJanitorImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StoreJanitorImpl.java	12 Jan 2002 16:55:43 -0000	1.1
  +++ StoreJanitorImpl.java	12 Jan 2002 18:24:15 -0000	1.2
  @@ -16,6 +16,19 @@
    * can register to the StoreJanitor. When memory is too low,
    * the StoreJanitor frees the registered caches until memory is normal.
    *
  + * NOTE:
  + * Be careful with the setFreeMemory and setHeapsize methods. Wrong values can
  + * cause high cpu usage.
  + * Example configuration:
  + * Jvm settings: 
  + *    -Xms100000000 -Xmx200000000
  + * StoreJanitor settings:
  + *   setFreeMemory(50000000)
  + *   setHeapsize(150000000)
  + *
  + * Heapsize must be higher then the -Xms parameter and freememory
  + * between those both.    
  + *
    * @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
    */
   public class StoreJanitorImpl 
  @@ -34,14 +47,18 @@
       /**
        * Initialize the StoreJanitorImpl.
        *
  -     * @param the Configuration of the application
  -     * @exception ConfigurationException
  +     * @param - the Configuration of the application
  +     * @exception - ConfigurationException
        */
       public void initialize() {
           this.mJVM = Runtime.getRuntime();
           this.mStoreList = new ArrayList();
       }
   
  +    /**
  +     * This method starts the background Thread, which
  +     * checks periodic if memory is running low.
  +     */
       public void start() {
           mDoRun = true;
           Thread checker = new Thread(this);
  @@ -51,6 +68,9 @@
           checker.start();
       }
   
  +    /**
  +     * This method stops the background Thread.
  +     */
       public void stop() {
           mDoRun = false;
       }
  @@ -79,7 +99,7 @@
       /**
        * Method to check if memory is running low in the JVM.
        *
  -     * @return true if memory is low
  +     * @return - true if memory is low
        */
       private boolean memoryLow() {
           return this.mJVM.totalMemory() > this.getHeapsize() && this.mJVM.freeMemory()
< this.getFreememory();
  @@ -88,7 +108,7 @@
       /**
        * This method register the stores
        *
  -     * @param the store to be registered
  +     * @param - the store to be registered
        */
       public void register(Store store) {
           this.mStoreList.add(store);
  @@ -97,7 +117,7 @@
       /**
        * This method unregister the stores
        *
  -     * @param the store to be unregistered
  +     * @param - the store to be unregistered
        */
       public void unregister(Store store) {
           this.mStoreList.remove(store);
  @@ -144,34 +164,81 @@
           this.mJVM.gc();
       }
   
  +    /**
  +     * This method returns the current free memory
  +     * setting.
  +     *
  +     * @return - current value of free memory in bytes
  +     */
       public int getFreememory() {
           return mFreeMemory;
       }
   
  +    /**
  +     * This method sets how much memory should be available
  +     * in the JVM.
  +     *
  +     * @param - free memory in bytes
  +     */
       public void setFreeMemory(int _freememory) {
           this.mFreeMemory = _freememory;
       }
   
  +    /**
  +     * This method returns current Heapsize setting.
  +     *
  +     * @return - current value of the Heapsize in bytes
  +     */
       public int getHeapsize() {
           return this.mHeapSize;
       }
   
  +    /**
  +     * This method sets the maximum JVM consumptions, called
  +     * Heapsize.
  +     *
  +     * @param - maximum JVM consumption in bytes.
  +     */
       public void setHeapsize(int _heapsize) {
           this.mHeapSize = _heapsize;
       }
   
  +    /**
  +     * This method return the current setting of the background
  +     * Thread interval.
  +     * 
  +     * @return - current interval in seconds
  +     */
       public int getThreadInterval() {
           return this.mThreadInterval;
       }
   
  +    /**
  +     * This method sets the background Thread interval in
  +     * seconds.
  +     * 
  +     * @param - current interval in seconds
  +     */
       public void setThreadInterval(int _cleanupthreadinterval) {
           this.mThreadInterval = _cleanupthreadinterval;
       }
   
  +    /**
  +     * This method returns the priority of the background
  +     * Thread.
  +     * 
  +     * @return - current Thread priority
  +     */
       public int getThreadPriority() {
           return this.mThreadPriority;
       }
   
  +    /**
  +     * This method sets the priority of the background
  +     * Thread.
  +     * 
  +     * @param - current Thread priority
  +     */
       public void setThreadPriority(int _priority) {
           this.mThreadPriority = _priority;
       }
  
  
  
  1.2       +14 -3     jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/StoreJanitor.java
  
  Index: StoreJanitor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/StoreJanitor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StoreJanitor.java	12 Jan 2002 16:55:43 -0000	1.1
  +++ StoreJanitor.java	12 Jan 2002 18:24:15 -0000	1.2
  @@ -5,6 +5,7 @@
    * version 1.1, a copy of which has been included  with this distribution in *
    * the LICENSE file.                                                         *
    *****************************************************************************/
  +
   package org.apache.commons.simplestore;
   
   import java.util.Iterator;
  @@ -16,12 +17,22 @@
    */
   public interface StoreJanitor {
   
  -    /** register method for the stores */
  +    /** 
  +     * register method for the stores
  +     * 
  +     * @param - the Store to be registered
  +     */
       void register(Store store);
   
  -    /** unregister method for the stores */
  +    /** 
  +     * unregister method for the stores 
  +     *
  +     * @param - the Store to be unregistered
  +     */
       void unregister(Store store);
       
  -    /** get an iterator to list registered stores */
  +    /** 
  +     * get an iterator to list registered stores 
  +     */
       Iterator iterator();
   }
  
  
  
  1.2       +16 -0     jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/Store.java
  
  Index: Store.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/Store.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Store.java	12 Jan 2002 16:55:43 -0000	1.1
  +++ Store.java	12 Jan 2002 18:24:15 -0000	1.2
  @@ -5,6 +5,7 @@
    * version 1.1, a copy of which has been included  with this distribution in *
    * the LICENSE file.                                                         *
    *****************************************************************************/
  +
   package org.apache.commons.simplestore;
   
   import java.io.IOException;
  @@ -19,6 +20,8 @@
   
       /**
        * Get the object associated to the given unique key.
  +     *
  +     * @param - the Key Object
        */
       Object get(Object key);
   
  @@ -26,6 +29,9 @@
        * Store the given object in a persistent state. It is up to the
        * caller to ensure that the key has a persistent state across
        * different JVM executions.
  +     *
  +     * @param - the Key Object
  +     * @param - the Value Object
        */
       void store(Object key, Object value) throws IOException;
   
  @@ -33,18 +39,28 @@
        * Holds the given object in a volatile state. This means
        * the object store will discard held objects if the
        * virtual machine is restarted or some error happens.
  +     *
  +     * @param - the Key Object
  +     * @param - the Value Object
        */
       void hold(Object key, Object value) throws IOException;
   
  +    /**
  +     * Frees some object out of the Store.
  +     */
       void free();
   
       /**
        * Remove the object associated to the given key.
  +     *
  +     * @param - the Key Object
        */
       void remove(Object key);
   
       /**
        * Indicates if the given key is associated to a contained object.
  +     *
  +     * @param - the Key Object
        */
       boolean containsKey(Object key);
   
  
  
  
  1.2       +17 -0     jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/MRUMemoryStore.java
  
  Index: MRUMemoryStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/MRUMemoryStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MRUMemoryStore.java	12 Jan 2002 16:55:43 -0000	1.1
  +++ MRUMemoryStore.java	12 Jan 2002 18:24:15 -0000	1.2
  @@ -27,14 +27,31 @@
       private LinkedList mMRUList;
       private StoreJanitor mStorejanitor;
   
  +    /**
  +     * This method sets the number of objects the Store is
  +     * allowed to hold. Default is 100 objects.
  +     *
  +     * @param maxobjects - number of objects which are allowed
  +     * to be stored.
  +     */
       public void setMaxObjects(int maxobjects) {
           this.mMaxObjects = maxobjects;
       }
   
  +    /**
  +     * This method returns the current set of the object limit.
  +     *
  +     * @return value of the object limit.
  +     */
       public int getMaxObjects() {
           return this.mMaxObjects;
       }
   
  +    /**
  +     * This method initializes the MRUMemoryStore. NOTE: You should
  +     * first call the setMaxObjects(int maxobjects) method to set the
  +     * the limit of the Store. Default the limit is 100 Objects. 
  +     */
       public void initialize() {
           this.mCache = new Hashtable((int) (this.getMaxObjects() * 1.2));
           this.mMRUList = new LinkedList();
  
  
  
  1.2       +9 -9      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispStringKey.java
  
  Index: JispStringKey.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispStringKey.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JispStringKey.java	12 Jan 2002 16:55:43 -0000	1.1
  +++ JispStringKey.java	12 Jan 2002 18:24:15 -0000	1.2
  @@ -14,8 +14,8 @@
   import java.io.ObjectOutput;
   
   /**
  - *  Wrapper class to make our cache Key compatible with the Jisp KeyObject NOTE:
  - *  This Wrapper is only for String Keys.
  + * Wrapper class for String Keys to be compatible with the
  + * Jisp KeyObject.
    *
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
    *      g-froehlich@gmx.de</a>
  @@ -35,7 +35,7 @@
       /**
        *  Constructor for the JispStringKey object
        *
  -     * @param  the Value of the Key as String
  +     * @param - the Value of the Key as String
        */
       public JispStringKey(String keyValue) {
           mKey = keyValue;
  @@ -44,8 +44,8 @@
       /**
        * Compares two String Keys
        *
  -     * @param  the KeyObject to be compared
  -     * @return 0 if equal, 1 if greater, -1 if less
  +     * @param - the KeyObject to be compared
  +     * @return - 0 if equal, 1 if greater, -1 if less
        */
   
       public int compareTo(KeyObject key) {
  @@ -68,7 +68,7 @@
       /**
        *  Composes a null Kewy
        *
  -     * @return a null Key 
  +     * @return - a null Key 
        */
       public KeyObject makeNullKey() {
           return new JispStringKey();
  @@ -80,8 +80,8 @@
        * calling the writeObject method of ObjectOutput for objects, strings, 
        * and arrays.
        *
  -     * @param   out - the stream to write the object to
  -     * @exception IOException
  +     * @param  out - the stream to write the object to
  +     * @exception - IOException
        */
       public void writeExternal(ObjectOutput out)
           throws IOException {
  @@ -109,7 +109,7 @@
       /**
        *  Overrides the toString() method
        *
  -     * @return the Key as String
  +     * @return - the Key as String
        */
       public String toString() {
           return mKey;
  
  
  
  1.3       +57 -26    jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispFilesystemStore.java
  
  Index: JispFilesystemStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispFilesystemStore.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JispFilesystemStore.java	12 Jan 2002 17:25:01 -0000	1.2
  +++ JispFilesystemStore.java	12 Jan 2002 18:24:15 -0000	1.3
  @@ -46,18 +46,42 @@
       private BTreeIndex mIndex;
   
   
  +    /**
  +     * This method sets the name of the data file. Default
  +     * is default.dat.
  +     *
  +     * @param name - name of the data file
  +     */
       public void setDatabaseName(String name) {
           this.mDatabaseName = name;
       }
   
  +   /**
  +     * This method returns the name of the data file. Default
  +     * is default.dat.
  +     *
  +     * @return - name of the data file
  +     */
       public String getDatabaseName() {
           return this.mDatabaseName;
       }
   
  +    /**
  +     * This method sets the name of the index file. Default
  +     * is default.idx.
  +     *
  +     * @param name - name of the index file
  +     */
       public void setIndexfileName(String name) {
           this.mIndexName = name;
       }
   
  +    /**
  +     * This method returns the name of the index file. Default
  +     * is default.idx.
  +     *
  +     * @return - name of the index file
  +     */
       public String getIndexfileName() {
           return this.mIndexName;
       }
  @@ -71,10 +95,10 @@
       }
   
       /**
  -     *  Sets the repository's location
  +     * Sets the repository's location
        *
  -     * @param  the new directory value
  -     * @exception  IOException
  +     * @param - the new directory value
  +     * @exception - IOException
        */
       public void setDirectory(final String directory)
           throws IOException {
  @@ -82,10 +106,10 @@
       }
   
       /**
  -     *  Sets the repository's location
  +     * Sets the repository's location
        *
  -     * @param  the new directory value
  -     * @exception  IOException
  +     * @param - the new directory value
  +     * @exception - IOException
        */
       public void setDirectory(final File directory)
           throws IOException {
  @@ -121,9 +145,9 @@
   
   
       /**
  -     *  Returns the repository's full pathname
  +     * Returns the repository's full pathname
        *
  -     * @return the directory as String
  +     * @return - the directory as String
        */
       public String getDirectoryPath() {
           return this.mDirectoryPath;
  @@ -132,8 +156,8 @@
       /**
        *  Returns a Object from the store associated with the Key Object
        *
  -     * @param the Key object
  -     * @return the Object associated with Key Object
  +     * @param - the Key object
  +     * @return - the Object associated with Key Object
        */
       public Object get(Object key) {
           Object readObj = null;
  @@ -173,9 +197,9 @@
       /**
        *  Store the given Object in the indexed data file.
        *
  -     * @param  the Key Object
  -     * @param  the Value Object 
  -     * @exception  IOException
  +     * @param - the Key Object
  +     * @param - the Value Object 
  +     * @exception - IOException
        */
       public void store(Object key, Object value)
           throws IOException {
  @@ -193,11 +217,11 @@
       }
   
       /**
  -     *  Holds the given Object in the indexed data file.
  +     * Holds the given Object in the indexed data file.
        *
  -     * @param  the Key Object
  -     * @param  the Value Object 
  -     * @exception  IOException
  +     * @param - the Key Object
  +     * @param - the Value Object 
  +     * @exception - IOException
        */
       public void hold(Object key, Object value)
           throws IOException {
  @@ -205,16 +229,17 @@
       }
   
       /**
  -     *  Frees some values of the data file
  +     * Frees some values of the data file. NOTE:
  +     * not implemented, yet.
        */
       public void free() { 
          //TODO: implementation
       }
   
       /**
  -     *  Removes a value from the data file with the given key.
  +     * Removes a value from the data file with the given key.
        *
  -     * @param the Key Object
  +     * @param - the Key Object
        */
       public void remove(Object key) {
           try {
  @@ -228,10 +253,10 @@
       }
   
       /**
  -     *  Test if the the index file contains the given key
  +     * Test if the the index file contains the given key
        *
  -     * @param the Key Object
  -     * @return true if Key exists and false if not
  +     * @param - the Key Object
  +     * @return - true if Key exists and false if not
        */
       public boolean containsKey(Object key) {
           long res = -1;
  @@ -251,21 +276,27 @@
       }
   
       /**
  -     *  Returns a Enumeration of all Keys in the indexed file
  +     * Returns a Enumeration of all Keys in the indexed file
        *
  -     * @return  Enumeration Object with all existing keys
  +     * @return - Enumeration Object with all existing keys
        */
       public Enumeration keys() {
           //TODO: Implementation
           return null;
       }
   
  +    /**
  +     * This method wraps around the key Object a Jisp KeyObject.
  +     * 
  +     * @param key - the key Object
  +     * @return - the wraped key Object
  +     */
       private KeyObject wrapKeyObject(Object key) {
   
           if(key instanceof String) {
               return new JispStringKey(key.toString());
           } else {
  -            //TODO: Implementation
  +            //TODO: Implementation of Integer and Long keys
               return null;
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message