You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by pa...@apache.org on 2002/02/02 06:25:01 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache GlobalCache.java TestTurbineCache.java
paulsp 02/02/01 21:25:01
Modified: xdocs changes.xml
docs/site changes.html
src/java/org/apache/jetspeed/portal/portlets/admin
GlobalAdminPortlet.java
src/java/org/apache/jetspeed/services/portletcache
GlobalCache.java TestTurbineCache.java
Log:
Cache updates (part 1) (PS)
o Add getNumberOfObject() to GlobalCache
o Add getCacheSize() to GlobalCache
o Add flushCache() to GlobalCache
o Display number of cached object to Global Admin Portlet
o Update TestTurbineCache to include turbine fixes and enhancements
Revision Changes Path
1.16 +11 -1 jakarta-jetspeed/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- changes.xml 2 Feb 2002 03:08:53 -0000 1.15
+++ changes.xml 2 Feb 2002 05:25:00 -0000 1.16
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
-$Id: changes.xml,v 1.15 2002/02/02 03:08:53 paulsp Exp $
+$Id: changes.xml,v 1.16 2002/02/02 05:25:00 paulsp Exp $
-->
<document>
<properties>
@@ -82,6 +82,16 @@
Fix -Update to the current Turbine 2.2-b1 jar. This jar contains fixes and enhancements
to the GlobalCache service required by upcomming changes to Jetspeed memory cache
require. (PS)
+</li>
+<li>
+ Add - Cache updates (part 1) (PS)
+ <ul>
+ <li>Add getNumberOfObject() to GlobalCache</li>
+ <li>Add getCacheSize() to GlobalCache</li>
+ <li>Add flushCache() to GlobalCache</li>
+ <li>Display number of cached object to Global Admin Portlet</li>
+ <li>Update TestTurbineCache to include turbine fixes and enhancements</li>
+ </ul>
</li>
</ul>
</section>
1.8 +10 -0 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- changes.html 2 Feb 2002 03:08:53 -0000 1.7
+++ changes.html 2 Feb 2002 05:25:01 -0000 1.8
@@ -187,6 +187,16 @@
to the GlobalCache service required by upcomming changes to Jetspeed memory cache
require. (PS)
</li>
+<li>
+ Add - Cache updates (part 1) (PS)
+ <ul>
+ <li>Add getNumberOfObject() to GlobalCache</li>
+ <li>Add getCacheSize() to GlobalCache</li>
+ <li>Add flushCache() to GlobalCache</li>
+ <li>Display number of cached object to Global Admin Portlet</li>
+ <li>Update TestTurbineCache to include turbine fixes and enhancements</li>
+ </ul>
+</li>
</ul>
</blockquote>
</p>
1.16 +5 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/admin/GlobalAdminPortlet.java
Index: GlobalAdminPortlet.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/admin/GlobalAdminPortlet.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- GlobalAdminPortlet.java 18 Jan 2002 21:53:34 -0000 1.15
+++ GlobalAdminPortlet.java 2 Feb 2002 05:25:01 -0000 1.16
@@ -83,7 +83,7 @@
Returns global information about Jetspeed.
@author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
-@version $Id: GlobalAdminPortlet.java,v 1.15 2002/01/18 21:53:34 paulsp Exp $
+@version $Id: GlobalAdminPortlet.java,v 1.16 2002/02/02 05:25:01 paulsp Exp $
*/
public class GlobalAdminPortlet extends AbstractPortlet {
@@ -139,6 +139,10 @@
URLManager.list( URLManagerService.STATUS_BAD ).size() ) );
ec.addElement( this.getEntry( "URLs Loading/Refreshing",
URLFetcher.getRealtimeURLs().size() ) );
+
+ this.createCategory( ec, "Global Memory Cache" );
+ ec.addElement( this.getEntry( "Objects in Cache",
+ GlobalCache.getNumberOfObjects()));
return ec;
1.6 +41 -1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/GlobalCache.java
Index: GlobalCache.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/GlobalCache.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GlobalCache.java 18 Jan 2002 23:33:10 -0000 1.5
+++ GlobalCache.java 2 Feb 2002 05:25:01 -0000 1.6
@@ -68,7 +68,7 @@
*
* @see org.apache.turbine.services.cache.GlobalCacheService
* @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
- * @version $Id: GlobalCache.java,v 1.5 2002/01/18 23:33:10 paulsp Exp $
+ * @version $Id: GlobalCache.java,v 1.6 2002/02/02 05:25:01 paulsp Exp $
*/
public class GlobalCache {
@@ -106,4 +106,44 @@
return gcs.getObject( id );
}
+ /**
+ * Gets size, in bytes, of cache
+ *
+ * @return int Size, in byte, of cache
+ * @exception IOException Exception passed from
+ */
+ public static int getCacheSize()
+ throws IOException {
+ GlobalCacheService gcs = (GlobalCacheService)TurbineServices
+ .getInstance()
+ .getService( GlobalCacheService.SERVICE_NAME );
+
+ return gcs.getCacheSize();
+ }
+
+ /**
+ * Gets size, in bytes, of cache
+ *
+ * @return int, Size, in byte, of cache
+ */
+ public static int getNumberOfObjects() {
+ int tempInt = 0;
+ GlobalCacheService gcs = (GlobalCacheService)TurbineServices
+ .getInstance()
+ .getService( GlobalCacheService.SERVICE_NAME );
+
+ tempInt = gcs.getNumberOfObjects();
+ return tempInt;
+ }
+
+ /**
+ * Flush the cache of <B>ALL</B> objects
+ */
+ public void flushCache() {
+ GlobalCacheService gcs = (GlobalCacheService)TurbineServices
+ .getInstance()
+ .getService( GlobalCacheService.SERVICE_NAME );
+
+ gcs.flushCache();
+ }
}
1.3 +11 -95 jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/TestTurbineCache.java
Index: TestTurbineCache.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/TestTurbineCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestTurbineCache.java 23 Jan 2002 22:29:23 -0000 1.2
+++ TestTurbineCache.java 2 Feb 2002 05:25:01 -0000 1.3
@@ -72,7 +72,7 @@
* TestTurbineCache
*
* @author <a href="paulsp@apache.org">Paul Spencer</a>
- * @version $Id: TestTurbineCache.java,v 1.2 2002/01/23 22:29:23 paulsp Exp $
+ * @version $Id: TestTurbineCache.java,v 1.3 2002/02/02 05:25:01 paulsp Exp $
*/
public class TestTurbineCache extends ServletTestCase {
@@ -81,7 +81,7 @@
private static final long TURBINE_CACHE_REFRESH = 5000; // in millis
private static final long TEST_EXPIRETIME = TURBINE_CACHE_REFRESH + 1000;
private static final long TEST_TIMETOLIVE = TEST_EXPIRETIME * 5;
- private static final boolean turbineCachePatchApplied = false;
+
/**
* Defines the testcase name for JUnit.
*
@@ -280,21 +280,6 @@
CachedObject cacheObject = null;
- /* FIXME: Remove this test when the caching
- * patch to Turbine has been applied
- */
- if (turbineCachePatchApplied == false) {
- System.out.println( "*** ");
- System.out.println( "* This test will NOT be run because the cache patch to Turbine has");
- System.out.println( "* not been applied.");
- System.out.println( "*** ");
-// getLogger().warn( "This test will NOT be run because the "
-// + "cache patch to Turbine has not been applied.");
- }
-
-/*
- * FIXME: Uncomment the following after the cache path is applied
- *
GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
.getInstance()
.getService( GlobalCacheService.SERVICE_NAME );
@@ -317,7 +302,6 @@
assertEquals("After refresh", 0, globalCache.getNumberOfObjects());
// Remove objects
globalCache.removeObject(cacheKey);
-*/
}
/**
@@ -333,21 +317,6 @@
Object retrievedObject = null;
CachedObject cacheObject = null;
- /* FIXME: Remove this test when the caching
- * patch to Turbine has been applied
- */
- if (turbineCachePatchApplied == false) {
- System.out.println( "*** ");
- System.out.println( "* This test will NOT be run because the cache patch to Turbine has");
- System.out.println( "* not been applied.");
- System.out.println( "*** ");
-// getLogger().warn( "This test will NOT be run because the "
-// + "cache patch to Turbine has not been applied.");
- }
-
-/*
- * FIXME: Uncomment the following after the cache path is applied
- *
GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
.getInstance()
.getService( GlobalCacheService.SERVICE_NAME );
@@ -374,7 +343,6 @@
// Remove objects
globalCache.removeObject(cacheKey);
-*/
}
/**
@@ -427,40 +395,16 @@
assertNotNull( "Did not retrieved a cached object, after sleep", retrievedObject);
assertNotNull( "Cached object has no contents, after sleep.", ((RefreshableCachedObject)retrievedObject).getContents());
assertTrue( "Object did not refresh.", ( ((RefreshableObject)((RefreshableCachedObject)retrievedObject).getContents()).getRefreshCount() > 0));
- if (turbineCachePatchApplied == false) {
- System.out.println( "*** ");
- System.out.println( "* It appears the cache patch to Turbine MAY be applied, but");
- System.out.println( "* this test has not been updated!");
- System.out.println( "*** ");
-// getLogger().warn( "It appears the cache patch to Turbine has "
-// + "been applied, but this test has not been updated!");
- }
} catch (ObjectExpiredException e) {
- /* FIXME: Remove the if test and false section when the caching
- * patch to Turbine has been applied
- */
- if (turbineCachePatchApplied == true) {
- assertTrue( "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime) + " millis)", false);
- } else {
- System.out.println( "*** ");
- System.out.println( "* Their is a Turbine patch to resolve the following error");
- System.out.println( "*** ");
- System.out.println( "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime) + " millis)");
-// getLogger().warn("Refreshable object did NOT refresh. Their is a Turbine patch to fix this problem.");
- }
+ assertTrue( "Received unexpected ObjectExpiredException exception "
+ + "when retrieving refreshable object after ( "
+ + (System.currentTimeMillis() - addTime) + " millis)", false);
} catch (Exception e) {
throw e;
}
// See if object will expires (testing every second for 100 seconds. It sould not!
- /* FIXME: Remove the "&& (turbineCachePatchApplied == true)" test when the
- * caching patch to turbine is applied
- */
- for (int i=0; ((i<100) && (turbineCachePatchApplied == true)); i++) {
+ for (int i=0; (i<100); i++) {
Thread.sleep(1000); // Sleep 0.5 seconds
// Try to get expired object
@@ -520,15 +464,7 @@
assertNotNull( "Did not retrieved a cached object", retrievedObject);
assertEquals( "Did not retrieved correct cached object", cacheObject, retrievedObject);
} catch (ObjectExpiredException e) {
- if (turbineCachePatchApplied == true) {
- assertTrue( "Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
- } else {
- System.out.println( "*** ");
- System.out.println( "* Their is a Turbine patch to resolve the following error");
- System.out.println( "*** ");
- System.out.println( "Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)");
-// getLogger().warn( "Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)" );
- }
+ assertTrue( "Object expired early ( " + (System.currentTimeMillis() - addTime) + " millis)", false);
} catch (Exception e) {
throw e;
}
@@ -544,21 +480,9 @@
assertNotNull( "Cached object has no contents, after sleep.", ((RefreshableCachedObject)retrievedObject).getContents());
assertTrue( "Object did not refresh.", ( ((RefreshableObject)((RefreshableCachedObject)retrievedObject).getContents()).getRefreshCount() > 0));
} catch (ObjectExpiredException e) {
- if (turbineCachePatchApplied == true) {
- assertTrue( "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime) + " millis)", false);
- } else {
- System.out.println( "*** ");
- System.out.println( "* Their is a Turbine patch to resolve the following error");
- System.out.println( "*** ");
- System.out.println( "Received unexpected ObjectExpiredException exception "
- + "when retrieving refreshable object after ( "
- + (System.currentTimeMillis() - addTime) + " millis)");
-// getLogger().warn( "Received unexpected ObjectExpiredException exception "
-// + "when retrieving refreshable object after ( "
-// + (System.currentTimeMillis() - addTime) + " millis)");
- }
+ assertTrue( "Received unexpected ObjectExpiredException exception "
+ + "when retrieving refreshable object after ( "
+ + (System.currentTimeMillis() - addTime) + " millis)", false);
} catch (Exception e) {
throw e;
}
@@ -572,15 +496,7 @@
retrievedObject = globalCache.getObject(cacheKey);
assertNull( "Retrieved a cached object, after exceeding TimeToLive", retrievedObject);
} catch (ObjectExpiredException e) {
- if (turbineCachePatchApplied == true) {
- assertNull( "Retrieved the expired cached object, but caught expected ObjectExpiredException exception", retrievedObject);
- } else {
- System.out.println( "*** ");
- System.out.println( "* Their is a Turbine patch to resolve the following error");
- System.out.println( "*** ");
- System.out.println( "Retrieved the expired cached object, but caught expected ObjectExpiredException exception");
-// getLogger().warn( "Retrieved the expired cached object, but caught expected ObjectExpiredException exception");
- }
+ assertNull( "Retrieved the expired cached object, but caught expected ObjectExpiredException exception", retrievedObject);
} catch (Exception e) {
throw e;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>