/** Constructor. */ public WaveletContainerImpl(WaveletName waveletName) { this.waveletName = waveletName; waveletData = new WaveletDataImpl(waveletName.waveId, waveletName.waveletId); currentVersion = HASHED_HISTORY_VERSION_FACTORY.createVersionZero(waveletName); lastCommittedVersion = null; appliedDeltas = Sets.newTreeSet(appliedDeltaComparator); transformedDeltas = Sets.newTreeSet(transformedDeltaComparator); deserializedTransformedDeltas = Sets.newTreeSet(deserializedDeltaComparator); // Configure the locks used by this Wavelet. final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); readLock = readWriteLock.readLock(); writeLock = readWriteLock.writeLock(); state = State.OK; }
/** * Commit an applied delta to this wavelet container. * * @param appliedDelta to commit * @param transformedDelta of the applied delta * @return result of the application */ protected DeltaApplicationResult commitAppliedDelta( ByteStringMessage<ProtocolAppliedWaveletDelta> appliedDelta, WaveletDelta transformedDelta) { ProtocolWaveletDelta transformedProtocolDelta = WaveletOperationSerializer.serialize(transformedDelta, currentVersion); transformedDeltas.add(transformedProtocolDelta); deserializedTransformedDeltas.add(new VersionedWaveletDelta(transformedDelta, currentVersion)); appliedDeltas.add(appliedDelta); HashedVersion newVersion = HASHED_HISTORY_VERSION_FACTORY.create( appliedDelta.getByteArray(), currentVersion, transformedDelta.getOperations().size()); currentVersion = newVersion; return new DeltaApplicationResult( appliedDelta, transformedProtocolDelta, WaveletOperationSerializer.serialize(newVersion)); }