Package org.waveprotocol.wave.model.version

Examples of org.waveprotocol.wave.model.version.HashedVersion


   * Reads all deltas from persistent storage.
   */
  private static ImmutableList<WaveletDeltaRecord> readAll(WaveletDeltaRecordReader reader,
      ConcurrentNavigableMap<HashedVersion, WaveletDeltaRecord> cachedDeltas)
      throws IOException {
    HashedVersion startVersion = HASH_FACTORY.createVersionZero(reader.getWaveletName());
    HashedVersion endVersion = reader.getEndVersion();
    ListReceiver<WaveletDeltaRecord> receiver = new ListReceiver<WaveletDeltaRecord>();
    readDeltasInRange(reader, cachedDeltas, startVersion, endVersion, receiver);
    return ImmutableList.copyOf(receiver);
  }
View Full Code Here


    return (snapshot == null) ? versionZero : snapshot.getHashedVersion();
  }

  @Override
  public HashedVersion getLastPersistedVersion() {
    HashedVersion version = lastPersistedVersion.get();
    return (version == null) ? versionZero : version;
  }
View Full Code Here

  }

  @Override
  public void appendDelta(WaveletDeltaRecord deltaRecord)
      throws OperationException {
    HashedVersion currentVersion = getCurrentVersion();
    Preconditions.checkArgument(currentVersion.equals(deltaRecord.getAppliedAtVersion()),
        "Applied version %s doesn't match current version %s", deltaRecord.getAppliedAtVersion(),
        currentVersion);

    if (deltaRecord.getAppliedAtVersion().getVersion() == 0) {
      Preconditions.checkState(lastPersistedVersion.get() == null);
View Full Code Here

    }
  }

  /** Reports a submit success with resulting version 0 application timestamp 0 */
  public void doSubmitSuccess(WaveletName waveletName) {
    HashedVersion fakeHashedVersion = HashedVersion.of(0, new byte[0]);
    doSubmitSuccess(waveletName, fakeHashedVersion, 0);
  }
View Full Code Here

          HashedVersion.unsigned(0), dummyCreationTime);
      wavelets.put(waveletName.waveletId, wavelet);
    }

    // Add the delta to the history and update the wavelet's version.
    HashedVersion resultingVersion = updateAndGetVersion(waveletName, delta.getOperationCount());
    TransformedWaveletDelta versionedDelta = CoreWaveletOperationSerializer.deserialize(delta,
        resultingVersion, APP_TIMESTAMP);
    deltas.put(waveletName, versionedDelta);

    // Confirm submit success.
View Full Code Here

   * @param operationsCount applied to the wavelet.
   * @return the new hashed version of the wavelet.
   */
  private HashedVersion updateAndGetVersion(WaveletName waveletName, int operationsCount) {
    // Get the current version.
    HashedVersion version = versions.get(waveletName);

    // Calculate the new version.
    if (version != null) {
      version = HashedVersion.unsigned(version.getVersion() + operationsCount);
    } else {
      version = HashedVersion.unsigned(operationsCount);
    }

    // Store and return the new version.
View Full Code Here

   * TODO (alown): Possible race condition here with update? (Though I don't think it would result in
   * anything more serious than repeated history fetches.)
   */
  private void createAndCommitRemoteWavelet(WaveletName waveletName, ProtocolHashedVersion committedVersion) {
    RemoteWaveletContainer wavelet = getOrCreateRemoteWavelet(waveletName);
    HashedVersion v = CoreWaveletOperationSerializer.deserialize(committedVersion);
    wavelet.commit(v);
    LOG.info("Passed commit message for version " + v.getVersion() + " to RemoteWavelet");
  }
View Full Code Here

  public void getDeltaSignerInfo(ByteString signerId,
      WaveletName waveletName, ProtocolHashedVersion deltaEndVersion,
      DeltaSignerInfoResponseListener listener) {
    LocalWaveletContainer wavelet = loadLocalWavelet(waveletName, listener);
    if (wavelet != null) {
      HashedVersion endVersion = CoreWaveletOperationSerializer.deserialize(deltaEndVersion);
      if (wavelet.isDeltaSigner(endVersion, signerId)) {
        ProtocolSignerInfo signerInfo = certificateManager.retrieveSignerInfo(signerId);
        if (signerInfo == null) {
          // Oh no!  We are supposed to store it, and we already know they did sign this delta.
          LOG.severe("No stored signer info for valid getDeltaSignerInfo on " + waveletName);
View Full Code Here

  }

  @Override
  public OpBasedWavelet create(WaveId waveId, WaveletId waveletId, ParticipantId creator) {
    long now = System.currentTimeMillis();
    HashedVersion v0 = HashedVersion.unsigned(0);
    ObservableWaveletData waveData = holderFactory
        .create(new EmptyWaveletSnapshot(waveId, waveletId, creator, v0, now));
    lastContextFactory = new MockWaveletOperationContextFactory().setParticipantId(author);
    lastAuthoriser = new MockParticipationHelper();
    SilentOperationSink<WaveletOperation> executor =
View Full Code Here

    final AsyncCallContext callContext = AsyncCallContext.start("SubmitRequest");
    mux.submit(submitRequest, new SubmitResponseCallback() {
      @Override
      public void run(ProtocolSubmitResponse response) {
        callContext.stop();
        HashedVersion resultVersion = HashedVersion.unsigned(0);
        if (response.hasHashedVersionAfterApplication()) {
          resultVersion =
              WaveletOperationSerializer.deserialize(response.getHashedVersionAfterApplication());
          versions.updateHistory(wavelet, response.getHashedVersionAfterApplication());
        }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.version.HashedVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.