cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r634056 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/query/ main/java/org/apache/cayenne/remote/ test/java/org/apache/cayenne/access/ test/java/org/apac...
Date Wed, 05 Mar 2008 22:16:08 GMT
Author: aadamchik
Date: Wed Mar  5 14:16:04 2008
New Revision: 634056

URL: http://svn.apache.org/viewvc?rev=634056&view=rev
Log:
CAY-998 ROP paginated lists must recover from server LRU query cache overflow
(fixed... may need to optimize things a bit more)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannelQueryAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RemoteIncrementalFaultList.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannelQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannelQueryAction.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannelQueryAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ClientServerChannelQueryAction.java
Wed Mar  5 14:16:04 2008
@@ -82,8 +82,23 @@
 
             List cachedList = channel.getQueryCache().get(serverMetadata);
             if (cachedList == null) {
-                throw new CayenneRuntimeException("No cached list for "
-                        + serverMetadata.getCacheKey());
+
+                // attempt to refetch... respawn the action...
+
+                Query originatingQuery = serverMetadata.getOrginatingQuery();
+                if (originatingQuery != null) {
+
+                    ClientServerChannelQueryAction subaction = new ClientServerChannelQueryAction(
+                            channel,
+                            originatingQuery);
+                    subaction.execute();
+                    cachedList = channel.getQueryCache().get(serverMetadata);
+                }
+
+                if (cachedList == null) {
+                    throw new CayenneRuntimeException("No cached list for "
+                            + serverMetadata.getCacheKey());
+                }
             }
 
             int startIndex = serverMetadata.getFetchStartIndex();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
Wed Mar  5 14:16:04 2008
@@ -52,6 +52,10 @@
     public SQLResultSetMapping getResultSetMapping() {
         return null;
     }
+    
+    public Query getOrginatingQuery() {
+        return null;
+    }
 
     public String getName() {
         return null;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
Wed Mar  5 14:16:04 2008
@@ -50,6 +50,7 @@
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
+import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.RefreshQuery;
 import org.apache.cayenne.query.SQLResultSetMapping;
@@ -1157,6 +1158,10 @@
         }
 
         public SQLResultSetMapping getResultSetMapping() {
+            return null;
+        }
+        
+        public Query getOrginatingQuery() {
             return null;
         }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
Wed Mar  5 14:16:04 2008
@@ -356,6 +356,10 @@
     public int getPageSize() {
         return pageSize;
     }
+    
+    public Query getOrginatingQuery() {
+        return null;
+    }
 
     /**
      * Always returns -1.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
Wed Mar  5 14:16:04 2008
@@ -61,6 +61,13 @@
     public SQLResultSetMapping getResultSetMapping() {
         return null;
     }
+    
+    /**
+     * @since 3.0
+     */
+    public Query getOrginatingQuery() {
+        return null;
+    }
 
     public DbEntity getDbEntity() {
         return null;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
Wed Mar  5 14:16:04 2008
@@ -197,6 +197,17 @@
     int getFetchLimit();
 
     /**
+     * Returns a query that originated this query. Most often than not the returned value
+     * is null. One example of non-null originating query is a query for a range of
+     * objects in a previously fetched paginated list. The query that fetched the original
+     * paginated list is an "originated" query. It may be used to restore a list that got
+     * lost due to a cache overflow, etc.
+     * 
+     * @since 3.0
+     */
+    Query getOrginatingQuery();
+
+    /**
      * Returns a root node of prefetch tree used by this query, or null of no prefetches
      * are configured.
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
Wed Mar  5 14:16:04 2008
@@ -85,6 +85,10 @@
         return info.getObjEntity();
     }
     
+    public Query getOrginatingQuery() {
+        return info.getOrginatingQuery();
+    }
+    
     /**
      * @since 3.0
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
Wed Mar  5 14:16:04 2008
@@ -60,6 +60,10 @@
         // ClientServerChannel behavior
 
         return new QueryMetadata() {
+            
+            public Query getOrginatingQuery() {
+                return null;
+            }
 
             public String getCacheKey() {
                 return cacheKey;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
Wed Mar  5 14:16:04 2008
@@ -71,6 +71,10 @@
 
         return new QueryMetadata() {
 
+            public Query getOrginatingQuery() {
+                return null;
+            }
+            
             public String getCacheKey() {
                 return cacheKey;
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
Wed Mar  5 14:16:04 2008
@@ -34,8 +34,8 @@
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
- * An Query wrapper that triggers pagination processing on the server. This query is
- * client-only and can't be executed on the server.
+ * A Query that fetches a range of objects from a previously fetched server-side paginated
+ * list. This query is client-only and can't be executed on the server.
  * 
  * @since 1.2
  * @author Andrus Adamchik
@@ -45,8 +45,7 @@
     private String cacheKey;
     private int fetchStartIndex;
     private int fetchLimit;
-    private boolean fetchingDataRows;
-    private PrefetchTreeNode prefetchTree;
+    private Query originatingQuery;
 
     // exists for hessian serialization.
     @SuppressWarnings("unused")
@@ -55,21 +54,25 @@
     }
 
     /**
-     * Creates a PaginatedQuery that returns a single page from an existing cached
-     * server-side result list.
+     * Creates a query that returns a single page from an existing cached server-side
+     * result list.
      */
-    public RangeQuery(String cacheKey, int fetchStartIndex, int fetchLimit,
-            QueryMetadata rootMetadata) {
+    RangeQuery(String cacheKey, int fetchStartIndex, int fetchLimit, Query originatingQuery)
{
         this.cacheKey = cacheKey;
         this.fetchStartIndex = fetchStartIndex;
         this.fetchLimit = fetchLimit;
-        this.fetchingDataRows = rootMetadata.isFetchingDataRows();
-        this.prefetchTree = rootMetadata.getPrefetchTree();
+        this.originatingQuery = originatingQuery;
     }
 
     public QueryMetadata getMetaData(EntityResolver resolver) {
+        final QueryMetadata originatingMetadata = originatingQuery.getMetaData(resolver);
+        
         return new QueryMetadata() {
             
+            public Query getOrginatingQuery() {
+                return originatingQuery;
+            }
+
             public SQLResultSetMapping getResultSetMapping() {
                 return null;
             }
@@ -91,7 +94,7 @@
             }
 
             public boolean isFetchingDataRows() {
-                return fetchingDataRows;
+                return originatingMetadata.isFetchingDataRows();
             }
 
             public int getPageSize() {
@@ -103,7 +106,7 @@
             }
 
             public PrefetchTreeNode getPrefetchTree() {
-                return prefetchTree;
+                return originatingMetadata.getPrefetchTree();
             }
 
             public DataMap getDataMap() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RemoteIncrementalFaultList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RemoteIncrementalFaultList.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RemoteIncrementalFaultList.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RemoteIncrementalFaultList.java
Wed Mar  5 14:16:04 2008
@@ -68,7 +68,7 @@
     protected String cacheKey;
     protected int pageSize;
     protected int unfetchedObjects;
-    protected QueryMetadata metadata;
+    protected Query paginatedQuery;
 
     protected transient ObjectContext context;
 
@@ -82,7 +82,7 @@
 
     public RemoteIncrementalFaultList(ObjectContext context, Query paginatedQuery) {
 
-        this.metadata = paginatedQuery.getMetaData(context.getEntityResolver());
+        QueryMetadata metadata = paginatedQuery.getMetaData(context.getEntityResolver());
 
         if (metadata.getPageSize() <= 0) {
             throw new IllegalArgumentException("Page size must be positive: "
@@ -116,6 +116,9 @@
             }
         }
 
+        // ensure that originating query is wrapped to include the right cache key....
+        this.paginatedQuery = query;
+
         // select directly from the channel, bypassing the context. Otherwise our query
         // wrapper can be intercepted incorrectly
         QueryResponse response = context.getChannel().onQuery(context, query);
@@ -251,7 +254,7 @@
 
         int fetchLimit = toIndex - fromIndex;
 
-        RangeQuery query = new RangeQuery(cacheKey, fromIndex, fetchLimit, metadata);
+        RangeQuery query = new RangeQuery(cacheKey, fromIndex, fetchLimit, paginatedQuery);
 
         List sublist = context.performQuery(query);
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ClientServerChannelQueryTest.java
Wed Mar  5 14:16:04 2008
@@ -80,7 +80,7 @@
         qc.clear();
         assertEquals(0, qc.size());
 
-        // assertTrue(results.get(3) instanceof ClientMtTable1);
+        assertTrue(results.get(3) instanceof ClientMtTable1);
     }
 
     public void testNamedQuery() throws Exception {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java?rev=634056&r1=634055&r2=634056&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
Wed Mar  5 14:16:04 2008
@@ -90,5 +90,8 @@
     public PrefetchTreeNode getPrefetchTree() {
         return null;
     }
-
+    
+    public Query getOrginatingQuery() {
+        return null;
+    }
 }



Mime
View raw message