diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SyncRepositoryRequest.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SyncRepositoryRequest.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SyncRepositoryRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SyncRepositoryRequest.java new file mode 100644 index 0000000000..e03188175e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SyncRepositoryRequest.java @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.io.CDODataInput; +import org.eclipse.emf.cdo.common.io.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.CDOReplicationContext; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class SyncRepositoryRequest extends CDOClientRequest<Boolean> +{ + private CDOReplicationContext context; + + public SyncRepositoryRequest(CDOClientProtocol protocol, CDOReplicationContext context) + { + super(protocol, CDOProtocolConstants.SIGNAL_SYNC_REPOSITORY); + this.context = context; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(context.getLastReplicatedBranchID()); + out.writeLong(context.getLastReplicatedCommitTime()); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + for (;;) + { + byte opcode = in.readByte(); + switch (opcode) + { + case CDOProtocolConstants.SYNC_FINISHED: + return true; + + case CDOProtocolConstants.SYNC_BRANCH: + context.handleBranch(in.readCDOBranch()); + break; + + case CDOProtocolConstants.SYNC_COMMIT: + context.handleCommitInfo(in.readCDOCommitInfo()); + break; + + default: + throw new IOException("Invalid sync opcode: " + opcode); + } + } + } +} |