Author: mcardle
Date: Thu Aug 3 07:16:55 2006
New Revision: 14834
URL: https://svndev.jahia.net/websvn/listing.php?sc=1&rev=14834&repname=jahia
Log:
* reduced redundancy in alwaysinvalidate inv messages
Modified:
trunk/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.java
Modified:
trunk/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.java&rev=14834&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.java
(original)
+++
trunk/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.java
Thu Aug 3 07:16:55 2006
@@ -351,7 +351,10 @@
str.append(stagingInvalidationString);
str.append("</ADVANCEDSELECTOR> \n");
str.append("<ACTION REMOVALTTL=\"").append(removalTTL).append("\"
/> \n");
- str.append("<INFO
VALUE=\"remove-Fragment-on-PID-").append(pid).append("-FID-").append(fragID).append("\"/>
\n");
+ if (!absolute)
+ str.append("<INFO
VALUE=\"remove-Fragment-on-PID-").append(pid).append("-FID-").append(fragID).append("\"/>
\n");
+ else
+ str.append("<INFO
VALUE=\"remove-Absolute-Fragment-").append(absoluteKey).append("\"/> \n");
str.append("</OBJECT> \n");
}
return str.toString();
@@ -749,7 +752,8 @@
(sitesToInvalidate != null && sitesToInvalidate.size() > 0)
) {
- HashMap pidsToInvalidateViaAlwayInvalidate = new HashMap();
+ HashSet pidsToInvalidateViaAlwayInvalidate = new HashSet();
+ HashSet absoluteFragsToInvalidate = new HashSet();
str = new StringBuffer();
//Generate invalidation string for Templates
@@ -767,8 +771,7 @@
);
//make sure all AlwaysInvalidate attributed Fragments
are also invalidated on this page
Integer pageidInt = new Integer(tpl.getPageID());
- if
(!pidsToInvalidateViaAlwayInvalidate.containsKey(pageidInt))
-
pidsToInvalidateViaAlwayInvalidate.put(pageidInt,pageidInt);
+ pidsToInvalidateViaAlwayInvalidate.add(pageidInt);
}
else {
logger.debug("[esi]: Template has already been deleted
from TreeCache : " + tpl);
@@ -785,6 +788,13 @@
logger.debug("[esi]: Fragment URL to Invalidate : " +
frg.URL);
if (frg.isAlive()) {
+
+ //for absolute frags, check if it's been processed
already
+ boolean isAbsoluteFrag = frg.isAbsoluteFragment();
+ String absoluteKeyHeader = frg.getAbsoluteKeyHeader();
+ if (isAbsoluteFrag &&
!absoluteFragsToInvalidate.add(absoluteKeyHeader) )
+ continue; //no need to bother adding this
fragment since it's already been added
+
str.append(
getHeaderBasedFragmentInvalidationString(pc,
frg.prefix,
@@ -794,26 +804,26 @@
Integer.toString(frg.getFragID()),
"0",
!frg.isRequiresLiveInvalidation(),
- frg.isAbsoluteFragment(),
- frg.getAbsoluteKeyHeader())
+ isAbsoluteFrag,
+ absoluteKeyHeader)
);
//make sure all AlwaysInvalidate attributed Fragments
are also invalidated on the page containing this fragment
Integer pageidInt;
- if (!frg.isAbsoluteFragment()) {
- //since absolute fragments are not associated with a
particular pid (defaulted to -1)
+ if (!isAbsoluteFrag) {
pageidInt = new Integer(frg.getPageID());
}
else {
- //TODO: this might be a problem when we update an
absolute fragment since a pages's Mode tabs
- //TODO: might not be updated on the templates sharing
this absolute fragment...
- //TODO: so currently resorting to invalidating the
current user's page.
- //TODO: A solution would be to find all templates that
display this fragment, and have their
- //TODO: Mode tabs invalidated (e.g. using
AlwaysInvalidate headers). Rather costly operation though.
+ //TODO: this might be a problem when we update an
absolute fragment since a pages's Mode tabs
+ //TODO: might not be updated on the templates
sharing this absolute fragment...
+ //TODO: so currently resorting to invalidating the
current user's page.
+ //TODO: A solution would be to find all templates
that display this fragment, and have their
+ //TODO: Mode tabs invalidated (e.g. using
AlwaysInvalidate headers). Rather costly operation though.
+
+ //since absolute fragments are not associated with
a particular pid (defaulted to -1)
pageidInt = new Integer(pc.getPageID());
}
- if
(!pidsToInvalidateViaAlwayInvalidate.containsKey(pageidInt))
-
pidsToInvalidateViaAlwayInvalidate.put(pageidInt,pageidInt);
+ pidsToInvalidateViaAlwayInvalidate.add(pageidInt);
}
else {
logger.debug("[esi]: Fragment has already been deleted
from TreeCache : " + frg);
@@ -836,7 +846,7 @@
}
//generate invalidation string for all AlwaysInvalidate
fragments in all the pages being invalidated above
- Iterator pidsIter =
pidsToInvalidateViaAlwayInvalidate.keySet().iterator() ;
+ Iterator pidsIter =
pidsToInvalidateViaAlwayInvalidate.iterator() ;
while (pidsIter.hasNext()) {
Integer pidInt = (Integer) pidsIter.next();
str.append(