Author: mgrigorov
Date: Thu Jun 16 13:35:45 2011
New Revision: 1136432

URL: http://svn.apache.org/viewvc?rev=1136432&view=rev
Log:
WICKET-3791 Improve AsynchronousDataStore
WICKET-3803 Add JMX MBean for the new StoreSettings

Make the settings of IStoreSettings read-only in JMX because they are read at 
the start of the application and the modifications later will be ignored.
Add setting for AsynchronousDataStore's queue capacity.


Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IStoreSettings.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/StoreSettings.java
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/page/persistent/disk/DiskDataStoreTest.java
    
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettings.java
    
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IStoreSettings.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IStoreSettings.java?rev=1136432&r1=1136431&r2=1136432&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IStoreSettings.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IStoreSettings.java
 Thu Jun 16 13:35:45 2011
@@ -19,6 +19,7 @@ package org.apache.wicket.settings;
 import java.io.File;
 
 import org.apache.wicket.page.IPageManager;
+import org.apache.wicket.pageStore.AsynchronousDataStore;
 import org.apache.wicket.pageStore.DiskDataStore;
 import org.apache.wicket.pageStore.IDataStore;
 import org.apache.wicket.pageStore.IPageStore;
@@ -27,6 +28,8 @@ import org.apache.wicket.util.lang.Bytes
 /**
  * An interface for settings related to the the storages where page instances 
are persisted -
  * {@link IPageStore}, {@link IDataStore} and {@link IPageManager}.
+ * 
+ * @since 1.5
  */
 public interface IStoreSettings
 {
@@ -90,4 +93,19 @@ public interface IStoreSettings
         *            the new location
         */
        void setFileStoreFolder(File fileStoreFolder);
+
+       /**
+        * @return the capacity of the queue used to store the pages which will 
be stored asynchronously
+        * @see AsynchronousDataStore
+        */
+       int getAsynchronousQueueCapacity();
+
+       /**
+        * Sets the capacity of the queue used to store the pages which will be 
stored asynchronously
+        * 
+        * @param capacity
+        *            the capacity of the queue
+        * @see AsynchronousDataStore
+        */
+       void setAsynchronousQueueCapacity(int capacity);
 }

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/StoreSettings.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/StoreSettings.java?rev=1136432&r1=1136431&r2=1136432&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/StoreSettings.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/StoreSettings.java
 Thu Jun 16 13:35:45 2011
@@ -37,6 +37,8 @@ public class StoreSettings implements IS
 
        private static final Bytes DEFAULT_MAX_SIZE_PER_SESSION = 
Bytes.megabytes(10);
 
+       private static final int DEFAULT_ASYNCHRONOUS_QUEUE_CAPACITY = 100;
+
        private int fileChannelPoolCapacity = 
DEFAULT_FILE_CHANNEL_POOL_CAPACITY;
 
        private int inmemoryCacheSize = DEFAULT_CACHE_SIZE;
@@ -45,6 +47,8 @@ public class StoreSettings implements IS
 
        private File fileStoreFolder = null;
 
+       private int asynchronousQueueCapacity = 
DEFAULT_ASYNCHRONOUS_QUEUE_CAPACITY;
+
        /**
         * Construct.
         * 
@@ -120,4 +124,19 @@ public class StoreSettings implements IS
        {
                this.fileStoreFolder = Args.notNull(fileStoreFolder, 
"fileStoreFolder");
        }
+
+       public int getAsynchronousQueueCapacity()
+       {
+               return asynchronousQueueCapacity;
+       }
+
+       public void setAsynchronousQueueCapacity(int queueCapacity)
+       {
+               if (queueCapacity < 1)
+               {
+                       throw new IllegalArgumentException(
+                               "The capacity of the asynchronous queue should 
be at least 1.");
+               }
+               asynchronousQueueCapacity = queueCapacity;
+       }
 }

Modified: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/page/persistent/disk/DiskDataStoreTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/page/persistent/disk/DiskDataStoreTest.java?rev=1136432&r1=1136431&r2=1136432&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/page/persistent/disk/DiskDataStoreTest.java
 (original)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/page/persistent/disk/DiskDataStoreTest.java
 Thu Jun 16 13:35:45 2011
@@ -339,7 +339,8 @@ public class DiskDataStoreTest extends T
 
                dataStore = new DiskDataStore("app1", fileStoreFolder, 
MAX_SIZE_PER_SESSION,
                        FILE_CHANNEL_POOL_CAPACITY);
-               dataStore = new AsynchronousDataStore(dataStore, 100);
+               int asynchronousQueueCapacity = 
storeSettings.getAsynchronousQueueCapacity();
+               dataStore = new AsynchronousDataStore(dataStore, 
asynchronousQueueCapacity);
 
                doTestDataStore();
 

Modified: 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettings.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettings.java?rev=1136432&r1=1136431&r2=1136432&view=diff
==============================================================================
--- 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettings.java 
(original)
+++ 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettings.java 
Thu Jun 16 13:35:45 2011
@@ -16,10 +16,7 @@
  */
 package org.apache.wicket.jmx;
 
-import java.io.File;
-
 import org.apache.wicket.Application;
-import org.apache.wicket.util.lang.Bytes;
 
 /**
  * Exposes Application's StoreSettings for JMX.
@@ -43,41 +40,24 @@ public class StoreSettings implements St
                return 
application.getStoreSettings().getFileChannelPoolCapacity();
        }
 
-       public void setFileChannelPoolCapacity(int capacity)
-       {
-               
application.getStoreSettings().setFileChannelPoolCapacity(capacity);
-       }
-
        public int getInmemoryCacheSize()
        {
                return application.getStoreSettings().getInmemoryCacheSize();
        }
 
-       public void setInmemoryCacheSize(int inmemoryCacheSize)
-       {
-               
application.getStoreSettings().setInmemoryCacheSize(inmemoryCacheSize);
-       }
-
        public long getMaxSizePerSession()
        {
                return 
application.getStoreSettings().getMaxSizePerSession().bytes();
        }
 
-       public void setMaxSizePerSession(long maxSizePerSession)
-       {
-               Bytes bytes = Bytes.bytes(maxSizePerSession);
-               application.getStoreSettings().setMaxSizePerSession(bytes);
-       }
-
        public String getFileStoreFolder()
        {
                return 
application.getStoreSettings().getFileStoreFolder().getAbsolutePath();
        }
 
-       public void setFileStoreFolder(String fileStoreFolder)
+       public int getAsynchronousQueueCapacity()
        {
-               File storeFolder = new File(fileStoreFolder);
-               application.getStoreSettings().setFileStoreFolder(storeFolder);
+               return 
application.getStoreSettings().getAsynchronousQueueCapacity();
        }
 
 }

Modified: 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java?rev=1136432&r1=1136431&r2=1136432&view=diff
==============================================================================
--- 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
 (original)
+++ 
wicket/trunk/wicket-jmx/src/main/java/org/apache/wicket/jmx/StoreSettingsMBean.java
 Thu Jun 16 13:35:45 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket.jmx;
 
-import java.io.File;
-
 import org.apache.wicket.pageStore.DiskDataStore;
 
 /**
@@ -32,57 +30,25 @@ public interface StoreSettingsMBean
        int getFileChannelPoolCapacity();
 
        /**
-        * Sets the number of maximum opened file channels by {@link 
DiskDataStore}
-        * 
-        * @param capacity
-        *            the new maximum number of opened file channels
-        */
-       void setFileChannelPoolCapacity(int capacity);
-
-       /**
         * @return the number of page instances which will be stored in the 
http session for faster
         *         retrieval
         */
        int getInmemoryCacheSize();
 
        /**
-        * Sets the maximum number of page instances which will be stored in 
the http session for faster
-        * retrieval
-        * 
-        * @param inmemoryCacheSize
-        *            the maximum number of page instances which will be held 
in the http session
-        */
-       void setInmemoryCacheSize(int inmemoryCacheSize);
-
-       /**
         * @return maximum page size. After this size is exceeded, the {@link 
DiskDataStore} will start
         *         saving the pages at the beginning of file.
         */
        long getMaxSizePerSession();
 
        /**
-        * Sets the maximum size of the {@link File} where page instances per 
session are stored. After
-        * reaching this size the {@link DiskDataStore} will start overriding 
the oldest pages at the
-        * beginning of the file.
-        * 
-        * @param maxSizePerSession
-        *            the maximum size of the file where page instances are 
stored per session. In
-        *            bytes.
-        */
-       void setMaxSizePerSession(long maxSizePerSession);
-
-       /**
         * @return the location of the folder where {@link DiskDataStore} will 
store the files with page
         *         instances per session
         */
        String getFileStoreFolder();
 
        /**
-        * Sets the folder where {@link DiskDataStore} will store the files 
with page instances per
-        * session
-        * 
-        * @param fileStoreFolder
-        *            the new location
+        * @return the capacity of the queue used to store the pages which will 
be stored asynchronously
         */
-       void setFileStoreFolder(String fileStoreFolder);
+       int getAsynchronousQueueCapacity();
 }


Reply via email to