You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2014/02/17 10:04:31 UTC

svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Author: angela
Date: Mon Feb 17 09:04:31 2014
New Revision: 1568910

URL: http://svn.apache.org/r1568910
Log:
OAK-168 : Basic JCR VersionManager support (enable tck tests)

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1568910&r1=1568909&r2=1568910&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Mon Feb 17 09:04:31 2014
@@ -68,9 +68,6 @@
       org.apache.jackrabbit.test.api.lock.SessionScopedLockTest#testImplicitUnlock
       org.apache.jackrabbit.test.api.lock.SessionScopedLockTest#testImplicitUnlock2
 
-      <!-- Lifecycle Mgt : not implemented -->
-      org.apache.jackrabbit.test.api.LifecycleTest
-
       <!-- Observation -->
       org.apache.jackrabbit.test.api.observation.GetIdentifierTest#testNodeMoved  <!-- Move in 2nd session not reflected in nodes of 1st session -->
       org.apache.jackrabbit.test.api.observation.NodeReorderTest#testNodeReorderAddRemove          <!-- Uses SNS -->
@@ -82,26 +79,10 @@
       org.apache.jackrabbit.oak.jcr.observation.ObservationRefreshTest <!-- [tripod] currently too slow...will fix soon -->
 
       <!-- Versioning -->
-      org.apache.jackrabbit.test.api.version.CheckinTest#testCheckinCreatesNewVersion <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.CheckinTest#testCheckinCreatesNewVersionJcr2 <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.VersionTest#testUpdate
-      org.apache.jackrabbit.test.api.version.VersionTest#testGetCorrespondingNodePath
-      org.apache.jackrabbit.test.api.version.VersionTest#testGetLock
-      org.apache.jackrabbit.test.api.version.VersionTest#testGetLockJcr2
       org.apache.jackrabbit.test.api.version.VersionTest#testMerge
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testUpdate
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testGetCorrespondingNodePath
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testGetLock
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testGetLockJcr2
       org.apache.jackrabbit.test.api.version.VersionHistoryTest#testMerge
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testInitialNumberOfLinearVersions <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testInitialNumberOfVersions <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testGetAllVersions <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.VersionHistoryTest#testGetAllVersionsJcr2 <!-- OAK-1335 -->
       org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreLabel
       org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreLabelJcr2
-      org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreName <!-- OAK-1335 -->
-      org.apache.jackrabbit.test.api.version.RestoreTest#testRestoreNameJcr2 <!-- OAK-1335 -->
       org.apache.jackrabbit.test.api.version.WorkspaceRestoreTest
       org.apache.jackrabbit.test.api.version.MergeCancelMergeTest
       org.apache.jackrabbit.test.api.version.MergeCheckedoutSubNodeTest

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java?rev=1568910&r1=1568909&r2=1568910&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java Mon Feb 17 09:04:31 2014
@@ -16,24 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr.session;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterators.transform;
-import static com.google.common.collect.Sets.newLinkedHashSet;
-import static java.util.Arrays.asList;
-import static java.util.Collections.singleton;
-import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
-import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
-import static org.apache.jackrabbit.oak.api.Type.NAME;
-import static org.apache.jackrabbit.oak.api.Type.NAMES;
-import static org.apache.jackrabbit.oak.util.TreeUtil.getNames;
-
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Binary;
@@ -81,6 +69,7 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.delegate.VersionManagerDelegate;
 import org.apache.jackrabbit.oak.jcr.lock.LockImpl;
 import org.apache.jackrabbit.oak.jcr.lock.LockOperation;
+import org.apache.jackrabbit.oak.jcr.session.operation.ItemOperation;
 import org.apache.jackrabbit.oak.jcr.session.operation.NodeOperation;
 import org.apache.jackrabbit.oak.jcr.version.VersionHistoryImpl;
 import org.apache.jackrabbit.oak.jcr.version.VersionImpl;
@@ -92,6 +81,17 @@ import org.apache.jackrabbit.value.Value
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterators.transform;
+import static com.google.common.collect.Sets.newLinkedHashSet;
+import static java.util.Arrays.asList;
+import static java.util.Collections.singleton;
+import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+import static org.apache.jackrabbit.oak.api.Type.NAMES;
+import static org.apache.jackrabbit.oak.util.TreeUtil.getNames;
+
 /**
  * TODO document
  *
@@ -1003,26 +1003,41 @@ public class NodeImpl<T extends NodeDele
 
     @Override
     @Nonnull
-    public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
-        // TODO: use perform()
-        checkValidWorkspace(workspaceName);
-        throw new UnsupportedRepositoryOperationException("TODO: Node.getCorrespondingNodePath");
+    public String getCorrespondingNodePath(final String workspaceName) throws RepositoryException {
+        return toJcrPath(perform(new ItemOperation<String>(dlg) {
+            @Override
+            public String perform() throws RepositoryException {
+                checkValidWorkspace(workspaceName);
+                if (workspaceName.equals(sessionDelegate.getWorkspaceName())) {
+                    return item.getPath();
+                } else {
+                    throw new UnsupportedRepositoryOperationException("OAK-118: Node.getCorrespondingNodePath");
+                }
+            }
+        }));
     }
 
 
     @Override
-    public void update(String srcWorkspace) throws RepositoryException {
-        // TODO: use perform()
-        checkValidWorkspace(srcWorkspace);
+    public void update(final String srcWorkspace) throws RepositoryException {
+        perform(new ItemWriteOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                checkValidWorkspace(srcWorkspace);
 
-        // check for pending changes
-        if (sessionDelegate.hasPendingChanges()) {
-            String msg = "Unable to perform operation. Session has pending changes.";
-            log.debug(msg);
-            throw new InvalidItemStateException(msg);
-        }
+                // check for pending changes
+                if (sessionDelegate.hasPendingChanges()) {
+                    String msg = "Unable to perform operation. Session has pending changes.";
+                    log.debug(msg);
+                    throw new InvalidItemStateException(msg);
+                }
 
-        // TODO
+                if (!srcWorkspace.equals(sessionDelegate.getWorkspaceName())) {
+                    throw new UnsupportedRepositoryOperationException("OAK-118: Node.update");
+                }
+                return null;
+            }
+        });
     }
 
     /**



Re: System time resolution

Posted by Felix Meschberger <fm...@adobe.com>.
Hi

Right. If you want to get a historic sequence of events, the time stamp is not the way to do that — have been burnt before and now using counters.

Regards
Felix

Am 19.02.2014 um 09:38 schrieb Julian Reschke <ju...@gmx.de>:

> On 2014-02-19 09:37, Julian Reschke wrote:
>> ...
>> A general question is whether we should try to improve the precision of
>> the JCR time stamps. I believe that calculating them based on naoTime
>> might help.
>> ...
> 
> (I just checked and nanoTime is recommended only for calculating time differences...)
> 
> BR, Julian


Re: System time resolution

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Feb 19, 2014 at 9:38 AM, Julian Reschke <ju...@gmx.de>
wrote:
> ...(I just checked and nanoTime is recommended only for calculating time
> differences...)

Yes, quoting [1] "This method provides nanosecond precision, but not
necessarily nanosecond resolution (that is, how frequently the value
changes) - no guarantees are made except that the resolution is at least as
good as that of currentTimeMillis()" - so nanoTime is not better
than currentTimeMillis for generating unique values.

-Bertrand

[1]
http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()

Re: System time resolution

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-02-19 09:37, Julian Reschke wrote:
> ...
> A general question is whether we should try to improve the precision of
> the JCR time stamps. I believe that calculating them based on naoTime
> might help.
> ...

(I just checked and nanoTime is recommended only for calculating time 
differences...)

BR, Julian

Re: System time resolution

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-02-19 09:37, Julian Reschke wrote:
> On 2014-02-17 16:49, Michael Dürig wrote:
>>
>>
>> On 17.2.14 4:41 , Julian Reschke wrote:
>>> On 2014-02-17 16:33, Angela Schreiber wrote:
>>>> hm... doesn't fail for me.
>>>> as usual: it would be good if you could provide some details if
>>>> the problem consistently shows up.
>>>> ...
>>>
>>> What kind of details do you need?
>>>
>>
>> There might be more helpful information in target/unit-tests.log.
>>
>> Michael
>
> So this problem (or one part of this problem) is caused by the attempt
> to use the creation time of the version as key in a sorted map (trying
> to sort the history, probably for linear version histories).
>
> This can fail on machines that are sufficiently fast and at the same
> time have a > 1ms resolution for systemCurrentTimeMillis (and Date).
>
> In this particular case, the right fix is probably not to attempt to
> sort here at all. If it's needed for linear version histories it can be
> done somewhere higher by following the successor relation.
> ...

Turns out that simple versioning already uses a different code path...

System time resolution

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-02-17 16:49, Michael Dürig wrote:
>
>
> On 17.2.14 4:41 , Julian Reschke wrote:
>> On 2014-02-17 16:33, Angela Schreiber wrote:
>>> hm... doesn't fail for me.
>>> as usual: it would be good if you could provide some details if
>>> the problem consistently shows up.
>>> ...
>>
>> What kind of details do you need?
>>
>
> There might be more helpful information in target/unit-tests.log.
>
> Michael

So this problem (or one part of this problem) is caused by the attempt 
to use the creation time of the version as key in a sorted map (trying 
to sort the history, probably for linear version histories).

This can fail on machines that are sufficiently fast and at the same 
time have a > 1ms resolution for systemCurrentTimeMillis (and Date).

In this particular case, the right fix is probably not to attempt to 
sort here at all. If it's needed for linear version histories it can be 
done somewhere higher by following the successor relation.

A general question is whether we should try to improve the precision of 
the JCR time stamps. I believe that calculating them based on naoTime 
might help.

Best regards, Julian

Re: svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Posted by Michael Dürig <md...@apache.org>.

On 17.2.14 4:41 , Julian Reschke wrote:
> On 2014-02-17 16:33, Angela Schreiber wrote:
>> hm... doesn't fail for me.
>> as usual: it would be good if you could provide some details if
>> the problem consistently shows up.
>> ...
>
> What kind of details do you need?
>

There might be more helpful information in target/unit-tests.log.

Michael

Re: svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-02-17 16:33, Angela Schreiber wrote:
> hm... doesn't fail for me.
> as usual: it would be good if you could provide some details if
> the problem consistently shows up.
> ...

What kind of details do you need?

(Test machine in this case was Win7 64bit core i 7).

Best regards, Julian

Re: svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Posted by Angela Schreiber <an...@adobe.com>.
btw... the failures seem to be the same than reported in OAK-1335.
i resolved that issue fixed as i removed those issues from the
known-issues list. just reopen it if the problem persists.

On 17/02/14 16:33, "Angela Schreiber" <an...@adobe.com> wrote:

>hm... doesn't fail for me.
>as usual: it would be good if you could provide some details if
>the problem consistently shows up.
>
>regards
>angela
>
>On 17/02/14 15:46, "Julian Reschke" <ju...@gmx.de> wrote:
>
>>On 2014-02-17 10:04, angela@apache.org wrote:
>>> Author: angela
>>> Date: Mon Feb 17 09:04:31 2014
>>> New Revision: 1568910
>>> ...
>>
>>Some of the versioning tests are failing over here:
>>
>>> Results :
>>>
>>> Failed tests:  
>>>testGetAllVersions(org.apache.jackrabbit.test.api.version.VersionHistory
>>>T
>>>est): VersionHistory.getAllVersions() must contain the root version and
>>>all versions that have been created with a Node.checkin() call.
>>>   
>>>testGetAllVersionsJcr2(org.apache.jackrabbit.test.api.version.VersionHis
>>>t
>>>oryTest): VersionHistory.getAllVersions() must contain the root version
>>>and all versions that have been created with a Node.checkin() call.
>>>   
>>>testRestoreNameJcr2(org.apache.jackrabbit.test.api.version.RestoreTest):
>>>restore must restore child node version 1.0. expected:<1.[0]> but
>>>was:<1.[1]>
>>
>>Do others see this as well?
>>
>>Best regards, Julian
>


Re: svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Posted by Angela Schreiber <an...@adobe.com>.
hm... doesn't fail for me.
as usual: it would be good if you could provide some details if
the problem consistently shows up.

regards
angela

On 17/02/14 15:46, "Julian Reschke" <ju...@gmx.de> wrote:

>On 2014-02-17 10:04, angela@apache.org wrote:
>> Author: angela
>> Date: Mon Feb 17 09:04:31 2014
>> New Revision: 1568910
>> ...
>
>Some of the versioning tests are failing over here:
>
>> Results :
>>
>> Failed tests:   
>>testGetAllVersions(org.apache.jackrabbit.test.api.version.VersionHistoryT
>>est): VersionHistory.getAllVersions() must contain the root version and
>>all versions that have been created with a Node.checkin() call.
>>   
>>testGetAllVersionsJcr2(org.apache.jackrabbit.test.api.version.VersionHist
>>oryTest): VersionHistory.getAllVersions() must contain the root version
>>and all versions that have been created with a Node.checkin() call.
>>   
>>testRestoreNameJcr2(org.apache.jackrabbit.test.api.version.RestoreTest):
>>restore must restore child node version 1.0. expected:<1.[0]> but
>>was:<1.[1]>
>
>Do others see this as well?
>
>Best regards, Julian


Re: svn commit: r1568910 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java

Posted by Julian Reschke <ju...@gmx.de>.
On 2014-02-17 10:04, angela@apache.org wrote:
> Author: angela
> Date: Mon Feb 17 09:04:31 2014
> New Revision: 1568910
> ...

Some of the versioning tests are failing over here:

> Results :
>
> Failed tests:   testGetAllVersions(org.apache.jackrabbit.test.api.version.VersionHistoryTest): VersionHistory.getAllVersions() must contain the root version and all versions that have been created with a Node.checkin() call.
>   testGetAllVersionsJcr2(org.apache.jackrabbit.test.api.version.VersionHistoryTest): VersionHistory.getAllVersions() must contain the root version and all versions that have been created with a Node.checkin() call.
>   testRestoreNameJcr2(org.apache.jackrabbit.test.api.version.RestoreTest): restore must restore child node version 1.0. expected:<1.[0]> but was:<1.[1]>

Do others see this as well?

Best regards, Julian