Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-04-14 08:33:37 +0000
committerEike Stepper2010-04-14 08:33:37 +0000
commit3fc5cf50f19e2c1471b0c58e0a824f561cdd1603 (patch)
tree021cac2f369b72cbdc2f64c9e56ee23481165064 /plugins
parenta49494b35820ecbf4605a21deb2b3f1fa66ae9a4 (diff)
downloadcdo-3fc5cf50f19e2c1471b0c58e0a824f561cdd1603.tar.gz
cdo-3fc5cf50f19e2c1471b0c58e0a824f561cdd1603.tar.xz
cdo-3fc5cf50f19e2c1471b0c58e0a824f561cdd1603.zip
[256936] Support for Offline Mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256936
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/CloneRepository.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/ReplicatorCommitContext.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineTest.java12
5 files changed, 36 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 3a5ed2dc95..697fd2aab4 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -983,7 +983,7 @@ public class Repository extends Container<Object> implements InternalRepository
branchManager.getBranches(startID, 0, context);
long startTime = context.getLastReplicatedCommitTime();
- if (context.isSqueezeCommitInfos())
+ if (context.isSqueezeCommitInfos() && startTime != CDOBranchPoint.UNSPECIFIED_DATE)
{
replicateSqueezed(startTime, context);
}
@@ -1012,7 +1012,7 @@ public class Repository extends Container<Object> implements InternalRepository
CDOCommitData data = new CDOCommitDataImpl(newPackages, newObjects, changedObjects, detachedObjects);
CDOBranch branch = segment.getBranch();
- long timeStamp = segment.getTimeStamp();
+ long timeStamp = segment.getEndTime();
String comment = "<replicate squeezed commits>"; //$NON-NLS-1$
CDOCommitInfo commitInfo = manager.createCommitInfo(branch, timeStamp, SYSTEM_USER_ID, comment, data);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/CloneRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/CloneRepository.java
index 3b75efe3c7..eb500077ec 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/CloneRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/CloneRepository.java
@@ -158,7 +158,8 @@ public class CloneRepository extends Repository.Default implements CDOReplicatio
CDOBranchPoint head = branch.getHead();
InternalTransaction transaction = replicatorSession.openTransaction(++lastTransactionID, head);
- ReplicatorCommitContext commitContext = new ReplicatorCommitContext(transaction, commitInfo);
+ boolean squeezed = isSqueezeCommitInfos() && lastReplicatedCommitTime != CDOBranchPoint.UNSPECIFIED_DATE;
+ ReplicatorCommitContext commitContext = new ReplicatorCommitContext(transaction, commitInfo, squeezed);
commitContext.preWrite();
boolean success = false;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/ReplicatorCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/ReplicatorCommitContext.java
index 4a4081b1ab..61a279f7e7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/ReplicatorCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/clone/ReplicatorCommitContext.java
@@ -28,10 +28,25 @@ public final class ReplicatorCommitContext extends TransactionCommitContext
{
private final CDOCommitInfo commitInfo;
- public ReplicatorCommitContext(InternalTransaction transaction, CDOCommitInfo commitInfo)
+ private final boolean squeezed;
+
+ private long commitTimeStamp;
+
+ private CDOBranchPoint oldBranchPoint;
+
+ public ReplicatorCommitContext(InternalTransaction transaction, CDOCommitInfo commitInfo, boolean squeezed)
{
super(transaction);
this.commitInfo = commitInfo;
+ this.squeezed = squeezed;
+
+ commitTimeStamp = commitInfo.getTimeStamp();
+ if (commitTimeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ commitTimeStamp = transaction.getSession().getManager().getRepository().getTimeStamp();
+ }
+
+ oldBranchPoint = transaction.getBranch().getPoint(commitTimeStamp - 1L);
setCommitComment(commitInfo.getComment());
InternalCDOPackageUnit[] newPackageUnits = getNewPackageUnits(commitInfo, getPackageRegistry());
@@ -56,7 +71,7 @@ public final class ReplicatorCommitContext extends TransactionCommitContext
@Override
protected long createTimeStamp()
{
- return commitInfo.getTimeStamp();
+ return commitTimeStamp;
}
@Override
@@ -87,9 +102,13 @@ public final class ReplicatorCommitContext extends TransactionCommitContext
protected InternalCDORevision getOldRevision(InternalCDORevisionManager revisionManager,
InternalCDORevisionDelta delta)
{
- // xxx();
- CDOBranchPoint branchPoint = getBranchPoint();
- return revisionManager.getRevision(delta.getID(), branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true);
+ if (squeezed)
+ {
+ return revisionManager.getRevision(delta.getID(), oldBranchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE,
+ true);
+ }
+
+ return super.getOldRevision(revisionManager, delta);
}
private static InternalCDOPackageUnit[] getNewPackageUnits(CDOCommitInfo commitInfo,
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 13eba2ab84..e6f20a07ab 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
@@ -32,7 +32,7 @@ public class AllTestsMEMOffline extends AllTestsAllConfigs
{
// super.initTestClasses(testClasses);
- testClasses.add(OfflineTest.class);
+ testClasses.add(OfflineTest.class);
testClasses.add(OfflineSqueezedTest.class);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineTest.java
index f906e7e212..e73d33e717 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineTest.java
@@ -47,6 +47,8 @@ import java.util.Map;
*/
public class OfflineTest extends AbstractCDOTest
{
+ protected static final int SLEEP_MILLIS = 1000;
+
public OfflineConfig getOfflineConfig()
{
return (OfflineConfig)getRepositoryConfig();
@@ -464,7 +466,7 @@ public class OfflineTest extends AbstractCDOTest
for (int k = 0; k < 10; k++)
{
- sleep(100);
+ sleep(SLEEP_MILLIS);
for (int i = 0; i < 10; i++)
{
Company company = (Company)resource.getContents().get(i);
@@ -511,7 +513,7 @@ public class OfflineTest extends AbstractCDOTest
while (repository.getState() != CDOCommonRepository.State.ONLINE)
{
System.out.println("Waiting for ONLINE...");
- sleep(100);
+ sleep(SLEEP_MILLIS);
}
}
@@ -520,7 +522,7 @@ public class OfflineTest extends AbstractCDOTest
while (repository.getState() == CDOCommonRepository.State.ONLINE)
{
System.out.println("Waiting for OFFLINE...");
- sleep(100);
+ sleep(SLEEP_MILLIS);
}
}
@@ -531,7 +533,7 @@ public class OfflineTest extends AbstractCDOTest
while (receiver.getLastUpdateTime() < timeStamp)
{
System.out.println("Waiting for arrival of commit " + CDOCommonUtil.formatTimeStamp(timeStamp));
- sleep(100);
+ sleep(SLEEP_MILLIS);
}
return commitInfo;
@@ -544,7 +546,7 @@ public class OfflineTest extends AbstractCDOTest
while (receiver.getLastCommitTimeStamp() < timeStamp)
{
System.out.println("Waiting for arrival of commit " + CDOCommonUtil.formatTimeStamp(timeStamp));
- sleep(100);
+ sleep(SLEEP_MILLIS);
}
return commitInfo;

Back to the top