Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java
index 1b0315f99a..d39b40a9ee 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.server.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
@@ -20,6 +21,8 @@ import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
import org.eclipse.net4j.util.WrappedException;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Eike Stepper
@@ -30,6 +33,8 @@ public class ReplicateRepositoryIndication extends CDOServerReadIndication
private long lastReplicatedCommitTime;
+ private String[] lockAreaIDs;
+
public ReplicateRepositoryIndication(CDOServerProtocol protocol)
{
super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY);
@@ -40,11 +45,32 @@ public class ReplicateRepositoryIndication extends CDOServerReadIndication
{
lastReplicatedBranchID = in.readInt();
lastReplicatedCommitTime = in.readLong();
+ lockAreaIDs = new String[in.readInt()];
+ for (int i = 0; i < lockAreaIDs.length; i++)
+ {
+ lockAreaIDs[i] = in.readString();
+ }
+ }
+
+ private Set<String> createLockAreaIDSet()
+ {
+ Set<String> idSet = new HashSet<String>(lockAreaIDs.length);
+ for (String id : lockAreaIDs)
+ {
+ idSet.add(id);
+ }
+ return idSet;
}
@Override
protected void responding(final CDODataOutput out) throws IOException
{
+ // We will remove IDs from this set as we process lockAreas one by one;
+ // what remains in this set at the end are the lockAreas that the client
+ // has, but we don't have, which means that they were removed.
+ //
+ final Set<String> lockAreaIDSet = createLockAreaIDSet();
+
getRepository().replicate(new CDOReplicationContext()
{
public int getLastReplicatedBranchID()
@@ -57,6 +83,11 @@ public class ReplicateRepositoryIndication extends CDOServerReadIndication
return lastReplicatedCommitTime;
}
+ public String[] getLockAreaIDs()
+ {
+ return lockAreaIDs;
+ }
+
public void handleBranch(CDOBranch branch)
{
try
@@ -82,8 +113,33 @@ public class ReplicateRepositoryIndication extends CDOServerReadIndication
throw WrappedException.wrap(ex);
}
}
+
+ public boolean handleLockArea(LockArea lockArea)
+ {
+ try
+ {
+ out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA);
+ out.writeBoolean(true);
+ out.writeCDOLockArea(lockArea);
+ lockAreaIDSet.remove(lockArea.getDurableLockingID());
+ return true;
+ }
+ catch (IOException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
});
+ // The IDs that are still in the lockAreaIDSet, must be the IDs of lockAreas that have
+ // been removed.
+ for (String deletedLockAreaID : lockAreaIDSet)
+ {
+ out.writeByte(CDOProtocolConstants.REPLICATE_LOCKAREA);
+ out.writeBoolean(false);
+ out.writeString(deletedLockAreaID);
+ }
+
out.writeByte(CDOProtocolConstants.REPLICATE_FINISHED);
}
}

Back to the top