mcardle 2006/01/06 02:21:46 CET
Modified files:
core/src/java/org/jahia/operations/valves
EsiInvalidateValve.java
core/src/java/org/jahia/services/esi
EsiInvalidationEventListener.java
EsiService.java
Log:
* optimized invalidations when a cache clear is requested
Revision Changes Path
1.6 +13 -6
jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java.diff?r1=1.5&r2=1.6&f=h
1.15 +7 -24
jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java.diff?r1=1.14&r2=1.15&f=h
1.16 +10 -1
jahia/core/src/java/org/jahia/services/esi/EsiService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/EsiService.java.diff?r1=1.15&r2=1.16&f=h
Index: EsiInvalidateValve.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EsiInvalidateValve.java 28 Nov 2005 14:20:11 -0000 1.5
+++ EsiInvalidateValve.java 6 Jan 2006 01:21:46 -0000 1.6
@@ -88,7 +88,7 @@
ParamBean paramBean = (ParamBean) context; //using parambean since
we need the getrealresponse() method, not present in porcessingContext
- if
(paramBean.settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED)
+ if
(paramBean.settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED)
&& ServicesRegistry.getInstance().getEsiService().
checkForAnyContentToInvalidate()) {
@@ -103,10 +103,17 @@
//since we don't want to add ESI commands to pics which will be
ignored by ESI server
if (invMessage != null) {
- if (paramBean.settings().getEsiUsePiggyBackInvalidation())
- piggyBackInvalidation(invMessage, paramBean);
- else
- EsiSOAPInvalidation.SOAPInvalidation(invMessage,
paramBean);
+ if
(ServicesRegistry.getInstance().getEsiService().isEmptyEsiCacheRequested()) {
+ logger.warn("Clearing the whole ESI server cache
(temporary fix).");
+
EsiSOAPInvalidation.emptyEsiServerCache(paramBean.settings());
+
ServicesRegistry.getInstance().getEsiService().setEmptyEsiCacheRequested(false);
+ }
+ else {
+ if
(paramBean.settings().getEsiUsePiggyBackInvalidation())
+ piggyBackInvalidation(invMessage, paramBean);
+ else
+ EsiSOAPInvalidation.SOAPInvalidation(invMessage,
paramBean);
+ }
//TODO: Really should get confirmation from SOAP that
objects have actually been invalidated
//TODO: before doing any of the operations below:
@@ -153,7 +160,7 @@
, 0, strFinal.length());
if (logger.isDebugEnabled())
logger.debug("[esi]: ESI Invalidation Piggy-back Message:
\n" +
- strFinal);
+ strFinal);
//out.print(strFinal.toString());
streamWriter.flush();
} catch (java.io.IOException ioe) {
Index: EsiInvalidationEventListener.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- EsiInvalidationEventListener.java 4 Jan 2006 16:48:23 -0000 1.14
+++ EsiInvalidationEventListener.java 6 Jan 2006 01:21:46 -0000 1.15
@@ -506,32 +506,15 @@
}
private void clearEntireCache(JahiaEvent je, String eventFct) {
- if (je==null) return;
- //TODO: make this more selective !
- //Clear the ESI server cache
- try {
- JahiaData jd = je.getJahiaData();
- ProcessingContext pc = null;
- if (jd==null) {
- if (je.getProcessingContext() != null) {
- pc = je.getProcessingContext();
- }
- } else {
- pc = jd.getProcessingContext();
- }
- if (pc==null) {
- logger.error("No ProcessingContext could be found in event :
"+je.getObject());
- return;
- }
- SettingsBean sb = pc.settings();
- EsiSOAPInvalidation.emptyEsiServerCache(sb);
- logger.warn(eventFct+" event detected so Clearing the whole ESI
server cache (temporary fix). For JahiaEvent"+je.getObject());
- }
- catch (Exception ex) {
- logger.error("couldn't complete cache clearing operation due to
"+ex);
- }
+
+ if
(ServicesRegistry.getInstance().getEsiService().isEmptyEsiCacheRequested())
+ return;
+
+
ServicesRegistry.getInstance().getEsiService().setEmptyEsiCacheRequested(true);
+ logger.warn(eventFct+" event detected so Clearing the whole ESI
server cache (temporary fix). For JahiaEvent"+je.getObject());
}
+
}
/* -------------------------------- TODO EVENTS
------------------------------------------------ */
Index: EsiService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiService.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- EsiService.java 28 Nov 2005 18:53:03 -0000 1.15
+++ EsiService.java 6 Jan 2006 01:21:46 -0000 1.16
@@ -60,6 +60,7 @@
private HashMap ctnListsToInvalidate = new HashMap();
private HashMap ctnListsID0ToInvalidate = new HashMap();
private HashMap pagesToInvalidate = new HashMap();
+ private boolean emptyEsiCacheRequested = false;
//keeps track of which templates, containing aclGroup attributed
fragments and
// which have had a new username added with addAclUserNames(), need to
be invalidated
@@ -67,7 +68,8 @@
public EsiService () {
-
+ EsiSOAPInvalidation.init(); //TODO: make EsiSOAPInvalidation an
instance classe instead of static
+
}
/**
@@ -945,7 +947,14 @@
public void ctnListID0RequiresInvalidation (String ctnListName, int
ctnListPageID) {
ctnListsID0ToInvalidate.put( ctnListPageID+"_"+ctnListName, new
Boolean(false) ); //Boolean is toggled once entry has been invalidated
+ }
+
+ public boolean isEmptyEsiCacheRequested() {
+ return emptyEsiCacheRequested;
+ }
+ public void setEmptyEsiCacheRequested(boolean emptyEsiCacheRequested) {
+ this.emptyEsiCacheRequested = emptyEsiCacheRequested;
}