protected void notifyOfDeltas(ImmutableList<WaveletDeltaRecord> deltas, ImmutableSet<String> domainsToNotify) { Preconditions.checkState(writeLock.isHeldByCurrentThread(), "must hold write lock"); Preconditions.checkArgument(!deltas.isEmpty(), "empty deltas"); HashedVersion endVersion = deltas.get(deltas.size() - 1).getResultingVersion(); HashedVersion currentVersion = getCurrentVersion(); Preconditions.checkArgument(endVersion.equals(currentVersion), "cannot notify of deltas ending in %s != current version %s", endVersion, currentVersion); notifiee.waveletUpdate(waveletState.getSnapshot(), deltas, domainsToNotify); }
private static WaveletDelta doubleRemoveParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), doubleRemoveParticipantOps); }
private static WaveletDelta removeParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), removeParticipantOps); }
private static WaveletDelta removeParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), removeParticipantOps); }
private static WaveletDelta doubleRemoveParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), doubleRemoveParticipantOps); }
private static WaveletDelta addParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), addParticipantOps); }
private static WaveletDelta addParticipantDelta(WaveletContainerImpl target) { return new WaveletDelta(author, target.getCurrentVersion(), addParticipantOps); }
throws OperationException, InvalidHashException { HashedVersion targetVersion = submittedDelta.getTargetVersion(); HashedVersion currentVersion = getCurrentVersion(); Preconditions.checkArgument(!targetVersion.equals(currentVersion)); ListReceiver<TransformedWaveletDelta> receiver = new ListReceiver<TransformedWaveletDelta>();
/** * Transform a wavelet delta if it has been submitted against a different head (currentVersion). * Must be called with write lock held. * * @param delta to possibly transform * @return the transformed delta and the version it was applied at * (the version is the current version of the wavelet, unless the delta is * a duplicate in which case it is the version at which it was originally * applied) * @throws InvalidHashException if submitting against same version but different hash * @throws OperationException if transformation fails */ protected WaveletDelta maybeTransformSubmittedDelta(WaveletDelta delta) throws InvalidHashException, OperationException { HashedVersion targetVersion = delta.getTargetVersion(); HashedVersion currentVersion = getCurrentVersion(); if (targetVersion.equals(currentVersion)) { // Applied version is the same, we're submitting against head, don't need to do OT return delta; } else { // Not submitting against head, we need to do OT, but check the versions really are different if (targetVersion.getVersion() == currentVersion.getVersion()) { LOG.warning("Mismatched hash, expected " + currentVersion + ") but delta targets (" + targetVersion + ")"); throw new InvalidHashException(currentVersion, targetVersion); } else { return transformSubmittedDelta(delta); } } }