ozeigermann 2004/03/30 05:47:33
Modified: src/doc Tag: SLIDE_2_0_RELEASE_BRANCH changelog.xml
src/share/org/apache/slide/store Tag:
SLIDE_2_0_RELEASE_BRANCH ExtendedStore.java
src/webdav/server/org/apache/slide/webdav/util Tag:
SLIDE_2_0_RELEASE_BRANCH UriHandler.java
Log:
Fix for bug #26913
Revision Changes Path
No revision
No revision
1.84.2.11 +1 -0 jakarta-slide/src/doc/changelog.xml
Index: changelog.xml
===================================================================
RCS file: /home/cvs/jakarta-slide/src/doc/changelog.xml,v
retrieving revision 1.84.2.10
retrieving revision 1.84.2.11
diff -u -r1.84.2.10 -r1.84.2.11
--- changelog.xml 16 Mar 2004 13:50:14 -0000 1.84.2.10
+++ changelog.xml 30 Mar 2004 13:47:33 -0000 1.84.2.11
@@ -15,6 +15,7 @@
release.
<changelog>
+ <fix date="March 30, 2004" author="ozeigermann" bugzilla-id="26913">Massive
concurrent writes no longer cause lots of conflicts.</fix>
<fix date="March 16, 2004" author="mholz">Fix authentication and name
problem in WebdavResource</fix>
<fix date="March 13, 2004" author="mholz">Fix wrong URL returned by WebDAV
reports (Bugzilla entry 27340)</fix>
<fix date="February 02, 2004" author="mholz">Handle unknown actions in
SecurityImpl.</fix>
No revision
No revision
1.2.2.3 +16 -8
jakarta-slide/src/share/org/apache/slide/store/ExtendedStore.java
Index: ExtendedStore.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/ExtendedStore.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- ExtendedStore.java 5 Feb 2004 16:05:12 -0000 1.2.2.2
+++ ExtendedStore.java 30 Mar 2004 13:47:33 -0000 1.2.2.3
@@ -295,7 +295,7 @@
public NodeRevisionContent retrieveRevisionContent(Uri uri,
NodeRevisionDescriptor revisionDescriptor)
throws ServiceAccessException, RevisionNotFoundException {
- if (contentStore.cacheResults() && contentCache != null) {
+ if (contentStore.cacheResults() && contentCache != null &&
!omitCachingBecauseOfEvilHistoryHack(uri)) {
if (isForceStoreEnlistment(uri)) {
enlist(this);
}
@@ -396,7 +396,7 @@
//
public ObjectNode retrieveObject(Uri uri) throws ServiceAccessException,
ObjectNotFoundException {
- if (nodeStore.cacheResults()) {
+ if (nodeStore.cacheResults() && !omitCachingBecauseOfEvilHistoryHack(uri)) {
if (isForceStoreEnlistment(uri)) {
enlist(this);
}
@@ -684,7 +684,7 @@
public NodeRevisionDescriptors retrieveRevisionDescriptors(Uri uri)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
- if (revisionDescriptorsStore.cacheResults()) {
+ if (revisionDescriptorsStore.cacheResults() &&
!omitCachingBecauseOfEvilHistoryHack(uri)) {
if (isForceStoreEnlistment(uri)) {
enlist(this);
}
@@ -749,7 +749,7 @@
public NodeRevisionDescriptor retrieveRevisionDescriptor(Uri uri,
NodeRevisionNumber revisionNumber)
throws ServiceAccessException, RevisionDescriptorNotFoundException {
- if (revisionDescriptorStore.cacheResults()) {
+ if (revisionDescriptorStore.cacheResults() &&
!omitCachingBecauseOfEvilHistoryHack(uri)) {
if (isForceStoreEnlistment(uri)) {
enlist(this);
}
@@ -947,6 +947,14 @@
getLogger().log(re, LOG_CHANNEL, Logger.CRITICAL);
setRollbackOnly();
throw re;
+ }
+
+ // XXX HACK checks if the requested uri is the history folder. In this
+ // case caching must be disabled to pass any lock operations to the physical
store.
+ // This is needed as part of the fix to the problem described in
+ // bug #26913
+ protected boolean omitCachingBecauseOfEvilHistoryHack(Uri uri) {
+ return ("/history".equals(uri.toString()));
}
protected class TxCacheWrapper implements ObjectCache {
No revision
No revision
1.24.2.3 +80 -107
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java
Index: UriHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v
retrieving revision 1.24.2.2
retrieving revision 1.24.2.3
diff -u -r1.24.2.2 -r1.24.2.3
--- UriHandler.java 14 Mar 2004 18:14:56 -0000 1.24.2.2
+++ UriHandler.java 30 Mar 2004 13:47:33 -0000 1.24.2.3
@@ -39,10 +39,6 @@
import org.apache.slide.content.NodeRevisionNumber;
import org.apache.slide.content.RevisionNotFoundException;
import org.apache.slide.content.RevisionDescriptorNotFoundException;
-import org.apache.slide.content.RevisionAlreadyExistException;
-import org.apache.slide.structure.Structure;
-import org.apache.slide.structure.SubjectNode;
-import org.apache.slide.structure.ObjectAlreadyExistsException;
import org.apache.slide.lock.ObjectLockedException;
import org.apache.slide.security.AccessDeniedException;
@@ -52,6 +48,8 @@
*/
public class UriHandler implements DeltavConstants, AclConstants, DaslConstants {
+ private final static Object HISTORY_LOCK = new Object();
+
/**
* Factory method.
*/
@@ -108,70 +106,54 @@
Content content = nsaToken.getContentHelper();
String hpath = hpathHandler.toString();
- NodeRevisionDescriptors hpathNrds =
- content.retrieve( sToken, hpath );
-
- NodeRevisionDescriptor hpathNrd =
- content.retrieve( sToken, hpathNrds );
-
- NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME,
- NamespaceCache.SLIDE_URI);
-
- if( nextHnProp == null || nextHnProp.getValue() == null ) {
- nextHnProp =
- new NodeProperty(I_NEXT_HISTORY_NAME,
- I_INITIAL_HISTORY_NAME,
- NamespaceCache.SLIDE_URI);
- nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
+ // XXX guarantees that reading and writing of history counting property
+ // is atomic. This is necessary as part of the fix to the problem described
in
+ // bug #26913. While the history counter is incremented no other tx can be
allowed
+ // to access the counter, that's why a write lock that is valid until
commit is needed.
+ // As this requires locking going through to the store and must thus tunnel
caching
+ // the other part of the fix is a HACK in ExtendedStore
+ synchronized (HISTORY_LOCK) {
+ NodeRevisionDescriptors hpathNrds =
+ content.retrieve( sToken, hpath );
+
+ NodeRevisionDescriptor hpathNrd =
+ content.retrieve( sToken, hpathNrds );
+
+ NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME,
+
NamespaceCache.SLIDE_URI);
+ if (nextHnProp == null) {
+ // convert to slide namespace if this property is still
+ // in DAV: namespace
+ nextHnProp = hpathNrd.getProperty( I_NEXT_HISTORY_NAME );
+ if (nextHnProp != null) {
+ hpathNrd.removeProperty(nextHnProp);
+ nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
+ nextHnProp.getValue(),
+ NamespaceCache.SLIDE_URI);
+ nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
+ hpathNrd.setProperty( nextHnProp );
+ }
+ }
+ if( nextHnProp == null || nextHnProp.getValue() == null ) {
+ nextHnProp =
+ new NodeProperty(I_NEXT_HISTORY_NAME,
+ I_INITIAL_HISTORY_NAME,
+ NamespaceCache.SLIDE_URI);
+ nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
+ hpathNrd.setProperty( nextHnProp );
+ }
+
+ String nextHnStr = (String)nextHnProp.getValue();
+ result = new UriHandler( hpath+"/"+nextHnStr );
+
+ long nextHnLong = Long.parseLong( nextHnStr );
+ nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
+ String.valueOf(nextHnLong + 1),
+ NamespaceCache.SLIDE_URI );
hpathNrd.setProperty( nextHnProp );
+
+ content.store( sToken, hpath, hpathNrd, null ); //revisionContent = null
}
-
- String nextHnStr = (String)nextHnProp.getValue();
- long nextHnLong = Long.parseLong( nextHnStr );
-
- if (nextHnLong %10 == 0) {
- // create parent collection
- long dirNum = nextHnLong / 10;
- char dirChar [] = Long.toString(dirNum).toCharArray();
- StringBuffer buf = new StringBuffer();
- for (int i=0;i<dirChar.length-1;i++) {
- buf.append(dirChar[i]);
- buf.append('/');
- }
- buf.append(dirChar[dirChar.length-1]);
- String dirPath = hpath+"/"+ buf.toString();
- Structure structure = nsaToken.getStructureHelper();
-
- try {
- structure.create(sToken,new SubjectNode(),dirPath);
- //content.create(sToken,dirPath,true);
- //NodeRevisionDescriptors dnrds = structure.retrieve(stoken,dirPath);
- content.create(sToken,dirPath,new NodeRevisionDescriptor(0),null);
-
- } catch (ObjectAlreadyExistsException oae) {
- Domain.warn("Object " + dirPath + " already exists.");
- } catch (RevisionAlreadyExistException rae) {
- Domain.warn("Revision " + dirPath + " already exists.");
- }
- }
-
- StringBuffer buf = new StringBuffer();
- char nextHnChar[] = nextHnStr.toCharArray();
- for (int i=0;i<nextHnChar.length-1;i++) {
- buf.append(nextHnChar[i]);
- buf.append('/');
- }
- buf.append('h');
- buf.append(nextHnChar[nextHnChar.length -1]);
-
- result = new UriHandler( hpath+"/"+ buf.toString());
-
- nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
- String.valueOf(nextHnLong + 1),
- NamespaceCache.SLIDE_URI );
- hpathNrd.setProperty( nextHnProp );
-
- content.store( sToken, hpath, hpathNrd, null ); //revisionContent = null
return result;
}
@@ -193,6 +175,7 @@
UriHandler wrpathHandler =
WorkingresourcePathHandler.getResolvedWorkingresourcePathHandler(
nsName, uh );
Content content = nsaToken.getContentHelper();
+
String wrpath = wrpathHandler.toString();
NodeRevisionDescriptors wrpathNrds =
@@ -394,37 +377,32 @@
*/
public boolean isHistoryUri() {
HistoryPathHandler hpathHandler =
HistoryPathHandler.getHistoryPathHandler();
- if (hpathHandler.isAncestorOf(this)) {
- String[] hpathTokens = hpathHandler.getUriTokens();
- if (uriTokens.length < hpathTokens.length + 1) {
- return false;
- }
- String h = uriTokens[uriTokens.length -1];
- return (h.charAt(0) == 'h');
- } else {
- return false;
- }
+ String[] hpathTokens = hpathHandler.getUriTokens();
+
+ if( (hpathTokens.length + 1) == uriTokens.length ) {
+ if( hpathHandler.isHistoryPathUri(getParentUriHandler()) ) {
+ try {
+ Integer.parseInt( uriTokens[uriTokens.length - 1] );
+ return true;
+ }
+ catch( NumberFormatException x ) {};
+ }
+ }
+ return false;
}
/**
* Return true, if this is a version URI
*/
public boolean isVersionUri() {
- /* Version Uris look like
- /my/history/path/1/2/3/h9/1.0
- */
-
- HistoryPathHandler hpathHandler = HistoryPathHandler.getHistoryPathHandler();
- if (hpathHandler.isAncestorOf(this)) {
- String[] hpathTokens = hpathHandler.getUriTokens();
- if (uriTokens.length < hpathTokens.length + 2) {
- return false;
- }
- String h = uriTokens[uriTokens.length -2];
- return (h.charAt(0) == 'h');
- } else {
- return false;
- }
+ HistoryPathHandler hpathHandler =
HistoryPathHandler.getHistoryPathHandler();
+ String[] hpathTokens = hpathHandler.getUriTokens();
+
+ if( (hpathTokens.length + 2) == uriTokens.length ) {
+ if( getParentUriHandler().isHistoryUri() )
+ return true;
+ }
+ return false;
}
/**
@@ -515,14 +493,11 @@
UriHandler hpathHandler = HistoryPathHandler.getHistoryPathHandler();
String[] hpathTokens = hpathHandler.getUriTokens();
- if( isHistoryUri()) {
- return getName();
- } else if (isVersionUri()) {
- return uriTokens[uriTokens.length - 2];
- } else {
+ if( !isHistoryUri() && !isVersionUri() )
throw new IllegalStateException(
- "URI "+ toString()+" is neither history nor version URI" );
- }
+ "URI "+uri+" is neither history nor version URI" );
+
+ return uriTokens[hpathTokens.length];
}
/**
@@ -530,16 +505,14 @@
* @pre isVersionUri()
*/
public String getVersionName() {
- //UriHandler hpathHandler = HistoryPathHandler.getHistoryPathHandler();
- //String[] hpathTokens = hpathHandler.getUriTokens();
+ UriHandler hpathHandler = HistoryPathHandler.getHistoryPathHandler();
+ String[] hpathTokens = hpathHandler.getUriTokens();
if( !isVersionUri() )
throw new IllegalStateException(
"URI "+uri+" is not a version URI" );
- //return uriTokens[hpathTokens.length + 1];
- //String lastToken = uriTokens[uriTokens.length -1];
- return getName();
+ return uriTokens[hpathTokens.length + 1];
}
/**
@@ -552,7 +525,7 @@
"URI "+uri+" is not a version URI" );
StringBuffer b = new StringBuffer();
- for( int i = 0; i < (uriTokens.length-1); i++ ) {
+ for( int i = 0; i < (uriTokens.length - 1); i++ ) {
b.append( "/" );
b.append( uriTokens[i] );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]