summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-07-04 01:57:33 (EDT)
committerCaspar De Groot2011-07-04 01:57:33 (EDT)
commit1b8822cdb83e6d503a06ab44599d36ac1740151a (patch)
treeeffb2070f48a5d907146f539709267b8e9eed7bd
parenta434dcc32b4f4ff86818a334dbe04b3878b8604f (diff)
downloadcdo-1b8822cdb83e6d503a06ab44599d36ac1740151a.zip
cdo-1b8822cdb83e6d503a06ab44599d36ac1740151a.tar.gz
cdo-1b8822cdb83e6d503a06ab44599d36ac1740151a.tar.bz2
[Bug 350649] Offline test and example failures
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350649
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TimeStampAuthority.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java2
11 files changed, 66 insertions, 35 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TimeStampAuthority.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TimeStampAuthority.java
index 68c692e..eebbbfb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TimeStampAuthority.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TimeStampAuthority.java
@@ -100,11 +100,10 @@ class TimeStampAuthority
now = timeStampOverride;
}
- long previousIssuedTimeStamp = lastIssuedTimeStamp;
lastIssuedTimeStamp = now;
runningTransactions.add(lastIssuedTimeStamp);
- return new long[] { lastIssuedTimeStamp, previousIssuedTimeStamp };
+ return new long[] { lastIssuedTimeStamp, getLastFinishedTimeStamp() };
}
finally
{
@@ -125,10 +124,20 @@ class TimeStampAuthority
// of the runningTransactions. Since both sets are sorted, we only need to compare the heads.
long oldestRunning = runningTransactions.isEmpty() ? Long.MAX_VALUE : runningTransactions.get(0);
long oldestFinished;
- while (!finishedTransactions.isEmpty() && (oldestFinished = finishedTransactions.first()) < oldestRunning)
+ synchronized (lastCommitTimeStampLock)
{
- finishedTransactions.remove(oldestFinished);
- lastFinishedTimeStamp = oldestFinished;
+ long oldValue = lastFinishedTimeStamp;
+ while (!finishedTransactions.isEmpty() && (oldestFinished = finishedTransactions.first()) < oldestRunning)
+ {
+ finishedTransactions.remove(oldestFinished);
+ lastFinishedTimeStamp = oldestFinished;
+ }
+
+ // If we actually changed the lastFinishedTimeStamp, we need to notify waiting threads
+ if (lastFinishedTimeStamp != oldValue)
+ {
+ lastCommitTimeStampLock.notifyAll();
+ }
}
if (strictOrdering)
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index 81ecb3f..a751d4a 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test;
import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test;
import org.eclipse.emf.cdo.tests.offline.Bugzilla_328352_Test;
import org.eclipse.emf.cdo.tests.offline.Bugzilla_329014_Test;
+import org.eclipse.emf.cdo.tests.offline.FailoverTest;
import org.eclipse.emf.cdo.tests.offline.OfflineDelayedTest;
import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
import org.eclipse.emf.cdo.tests.offline.OfflineTest;
@@ -80,16 +81,17 @@ public class AllTestsDBH2Offline extends DBConfigs
{
// super.initTestClasses(testClasses);
+ testClasses.add(OfflineTest.class);
+ testClasses.add(OfflineRawTest.class);
+ testClasses.add(OfflineDelayedTest.class);
+
testClasses.add(Bugzilla_329014_Test.class);
testClasses.add(Bugzilla_328352_Test.class);
testClasses.add(Bugzilla_326047_Test.class);
testClasses.add(Bugzilla_325097_Test.class);
testClasses.add(Bugzilla_319552_Test.class);
- testClasses.add(OfflineRawTest.class);
- testClasses.add(OfflineDelayedTest.class);
- testClasses.add(OfflineTest.class);
- // testClasses.add(FailoverTest.class);
+ testClasses.add(FailoverTest.class);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
index 04945cc..c9c94bf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
@@ -100,19 +100,20 @@ public abstract class AbstractSyncingTest extends AbstractCDOTest
return 0L;
}
- protected static void checkEvent(TestListener listener, int newPackageUnits, int newObjects, int changedObjects,
- int detachedObjects) throws InterruptedException
+ protected static void checkEvent(final TestListener listener, int newPackageUnits, int newObjects,
+ int changedObjects, int detachedObjects) throws InterruptedException
{
- final IEvent[] events = listener.getEvents();
new PollingTimeOuter()
{
@Override
protected boolean successful()
{
- return events.length == 1;
+ IEvent[] events = listener.getEvents();
+ return events.length >= 1;
}
}.assertNoTimeOut();
+ IEvent[] events = listener.getEvents();
IEvent event = events[0];
if (event instanceof CDOSessionInvalidationEvent)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
index 8f14183..abbfc25 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.offline.FailoverTest;
+import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test;
+import org.eclipse.emf.cdo.tests.offline.OfflineTest;
import java.util.List;
@@ -33,9 +35,11 @@ public class AllTestsMEMOffline extends AllConfigs
{
// super.initTestClasses(testClasses);
+ // MEM does not support raw replication
// testClasses.add(OfflineRawTest.class);
- // testClasses.add(OfflineTest.class);
- // testClasses.add(OfflineDelayed2Test.class);
+
+ testClasses.add(OfflineTest.class);
+ testClasses.add(OfflineDelayed2Test.class);
testClasses.add(FailoverTest.class);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index 65febee..ad6e08f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -279,7 +279,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
public void tearDown() throws Exception
{
deactivateServerBrowser();
- if (!isOptimizing() || leavesCleanRepos())
+ if (!isOptimizing() || mustLeaveCleanRepos())
{
deactivateRepositories();
}
@@ -464,7 +464,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
return hasAnnotation(CleanRepositoriesBefore.class);
}
- protected boolean leavesCleanRepos()
+ protected boolean mustLeaveCleanRepos()
{
return hasAnnotation(CleanRepositoriesAfter.class);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
index a7e5692..a705a10 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/Bugzilla_329014_Test.java
@@ -215,6 +215,7 @@ public class Bugzilla_329014_Test extends AbstractSyncingTest
masterTransaction.commit();
masterCompany.setName("Company3");
masterTransaction.commit();
+ msg(CDOUtil.getCDOObject(masterCompany).cdoRevision().getVersion());
// go online.
getOfflineConfig().startMasterTransport();
@@ -222,6 +223,9 @@ public class Bugzilla_329014_Test extends AbstractSyncingTest
cloneTransaction.waitForUpdate(masterTransaction.getLastCommitTime(), 1000);
+ cloneCompany.getName();
+ msg(CDOUtil.getCDOObject(cloneCompany).cdoRevision().getVersion());
+
cloneCompany.setName("Company4");
cloneTransaction.commit();
cloneCompany.setName("Company5");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
index b1a3668..88c5087 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
@@ -114,7 +114,7 @@ public class FailoverTest extends AbstractSyncingTest
{
CDOSession masterSession = openSession(getRepository().getName() + "_master");
CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
TestListener listener = new TestListener();
CDOSession backupSession = openSession();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
index 585d7f0..a23a1aa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineRawTest.java
@@ -53,7 +53,7 @@ public class OfflineRawTest extends OfflineTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(getModel1Factory().createCompany());
transaction.setCommitComment("resource with one company created on clone");
@@ -71,7 +71,7 @@ public class OfflineRawTest extends OfflineTest
{
CDOSession masterSession = openSession(clone.getName() + "_master");
CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource(getResourcePath("/my/resource"));
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
masterResource.getContents().add(getModel1Factory().createCompany());
masterTransaction.setCommitComment("one company added on master");
@@ -120,7 +120,7 @@ public class OfflineRawTest extends OfflineTest
CDOSession session = openSession();
session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(getModel1Factory().createCompany());
transaction.setCommitComment("resource with one company created on clone");
@@ -138,7 +138,7 @@ public class OfflineRawTest extends OfflineTest
{
CDOSession masterSession = openSession(clone.getName() + "_master");
CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource(getResourcePath("/my/resource"));
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
masterResource.getContents().add(getModel1Factory().createCompany());
masterTransaction.setCommitComment("one company added on master");
@@ -188,7 +188,7 @@ public class OfflineRawTest extends OfflineTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(getModel1Factory().createCompany());
transaction.setCommitComment("resource with one company created on clone");
@@ -200,7 +200,7 @@ public class OfflineRawTest extends OfflineTest
{
CDOSession masterSession = openSession(clone.getName() + "_master");
CDOTransaction masterTransaction = masterSession.openTransaction();
- CDOResource masterResource = masterTransaction.getResource(getResourcePath("/my/resource"));
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
for (int i = 0; i < 100; i++)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
index 01c62a2..11380d8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
@@ -41,7 +41,7 @@ public class OfflineTest extends AbstractSyncingTest
{
CDOSession session = openSession(getRepository().getName() + "_master");
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
Company company = getModel1Factory().createCompany();
company.setName("Test");
@@ -84,7 +84,7 @@ public class OfflineTest extends AbstractSyncingTest
{
CDOSession masterSession = openSession(getRepository().getName() + "_master");
CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
TestListener listener = new TestListener();
CDOSession cloneSession = openSession();
@@ -142,7 +142,7 @@ public class OfflineTest extends AbstractSyncingTest
waitForOnline(cloneSession.getRepositoryInfo());
CDOTransaction transaction = cloneSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(company);
transaction.commit();
@@ -186,7 +186,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(company);
transaction.commit();
@@ -222,7 +222,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/master/resource"));
+ CDOResource resource = transaction.getResource("/master/resource");
Company company = (Company)resource.getContents().get(0);
assertEquals("MODIFICATION", company.getName());
@@ -255,7 +255,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("/master/resource"));
+ CDOResource resource = transaction.getResource("/master/resource");
assertEquals(0, resource.getContents().size());
}
@@ -273,7 +273,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(company);
CDOCommitInfo commitInfo = transaction.commit();
@@ -288,7 +288,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(getModel1Factory().createCompany());
transaction.commit();
@@ -330,7 +330,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
resource.getContents().add(company);
CDOCommitInfo commitInfo = transaction.commit();
@@ -354,7 +354,7 @@ public class OfflineTest extends AbstractSyncingTest
CDOSession masterSession = openSession(clone.getName() + "_master");
CDOTransaction transaction = masterSession.openTransaction();
- CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
+ CDOResource resource = transaction.createResource("/my/resource");
for (int i = 0; i < 10; i++)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index e336e1c..31779a7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -1155,7 +1156,15 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
{
InternalCDORevision newRevision = oldRevision.copy();
newRevision.adjustForCommit(commitInfo.getBranch(), commitInfo.getTimeStamp());
+
+ CDORevisable target = delta.getTarget();
+ if (target != null)
+ {
+ newRevision.setVersion(target.getVersion());
+ }
+
delta.apply(newRevision);
+ newRevision.freeze();
return new Pair<InternalCDORevision, InternalCDORevision>(oldRevision, newRevision);
}
}
@@ -1187,6 +1196,8 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
Pair<CDOCommitInfo, InternalCDOTransaction> currentPair = outOfSequenceInvalidations
.remove(nextPreviousTimeStamp);
+ // If we don't have the invalidation that follows the last one we processed,
+ // then there is nothing we can do right now
if (currentPair == null)
{
break;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
index ef1fe74..09261dd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
@@ -383,7 +383,7 @@ public final class CDOStoreImpl implements CDOStore
value = convertToCDO(cdoObject, feature, value);
- InternalCDORevision oldRevision = getRevision(cdoObject);
+ InternalCDORevision oldRevision = getRevisionForReading(cdoObject);
Object oldValue = oldRevision.get(feature, index);
oldValue = convertToEMF(eObject, oldRevision, feature, index, oldValue);