Package org.waveprotocol.box.server.waveserver

Examples of org.waveprotocol.box.server.waveserver.WaveletDeltaRecord


  // Test the delta store strips partially written data.
  public void testRecoverFromTruncatedDeltas() throws Exception {
    // Create an entry with one record. Shrink the file byte by byte and ensure
    // we can read it without crashing.
    DeltaStore store = newDeltaStore();
    WaveletDeltaRecord written = createRecord();
    File deltaFile = FileDeltaCollection.deltasFile(path.getAbsolutePath(), WAVE1_WAVELET1);


    long toRemove = 1;
    while (true) {
      // This generates the full file.
      DeltasAccess wavelet = store.open(WAVE1_WAVELET1);
      wavelet.append(ImmutableList.of(written));
      wavelet.close();

      RandomAccessFile file = new RandomAccessFile(deltaFile, "rw");
      if (toRemove > file.length()) {
        file.close();
        break;
      }
      // eat the planned number of bytes
      LOG.info("trying to remove " + toRemove + " bytes");
      file.setLength(file.length() - toRemove);
      file.close();

      wavelet = store.open(WAVE1_WAVELET1);
      WaveletDeltaRecord read = wavelet.getDelta(0);
      assertNull("got an unexpected record " + read, read);
      wavelet.close();
      toRemove++;
    }
  }
View Full Code Here


    DBObject query = createWaveletDBQuery();
    query.put(MongoDbDeltaStoreUtil.FIELD_TRANSFORMED_APPLIEDATVERSION, version);

    DBObject result = deltaDbCollection.findOne(query);

    WaveletDeltaRecord waveletDelta = null;

    if (result != null) try {
      waveletDelta = MongoDbDeltaStoreUtil.deserializeWaveletDeltaRecord(result);
    } catch (PersistenceException e) {
      throw new IOException(e);
View Full Code Here

    DBObject query = createWaveletDBQuery();
    query.put(MongoDbDeltaStoreUtil.FIELD_TRANSFORMED_RESULTINGVERSION_VERSION, version);

    DBObject result = deltaDbCollection.findOne(query);

    WaveletDeltaRecord waveletDelta = null;

    if (result != null)
    try {
      MongoDbDeltaStoreUtil.deserializeWaveletDeltaRecord(result);
    } catch (PersistenceException e) {
View Full Code Here

  @Override
  public ByteStringMessage<ProtocolAppliedWaveletDelta> getAppliedDelta(long version)
      throws IOException {

    WaveletDeltaRecord delta = getDelta(version);
    return (delta != null) ? delta.getAppliedDelta() : null;
  }
View Full Code Here

  }

  @Override
  public TransformedWaveletDelta getTransformedDelta(long version) throws IOException {

    WaveletDeltaRecord delta = getDelta(version);
    return (delta != null) ? delta.getTransformedDelta() : null;
  }
View Full Code Here

  }

  public void testWriteToNewWavelet() throws Exception {
    Pair<DeltaStore,WaveletDeltaRecord> pair = newDeltaStoreWithRecord(WAVE1_WAVELET1);
    DeltaStore store = pair.first;
    WaveletDeltaRecord record = pair.second;

    DeltasAccess wavelet = store.open(WAVE1_WAVELET1);

    assertFalse(wavelet.isEmpty());
    assertEquals(WAVE1_WAVELET1, wavelet.getWaveletName());
    assertEquals(record.getResultingVersion(), wavelet.getEndVersion());
    assertEquals(record, wavelet.getDelta(0));
    assertEquals(record, wavelet.getDeltaByEndVersion(record.getResultingVersion().getVersion()));
    assertEquals(record.getAppliedAtVersion(), wavelet.getAppliedAtVersion(0));
    assertEquals(record.getAppliedDelta(), wavelet.getAppliedDelta(0));
    assertEquals(record.getTransformedDelta(), wavelet.getTransformedDelta(0));

    wavelet.close();
  }
View Full Code Here

    Pair<DeltaStore,WaveletDeltaRecord> pair = newDeltaStoreWithRecord(WAVE1_WAVELET1);
    DeltaStore store = pair.first;

    DeltasAccess wavelet = store.open(WAVE2_WAVELET1);

    WaveletDeltaRecord record = createRecord();
    wavelet.append(ImmutableList.of(record));
    wavelet.close();

    ExceptionalIterator<WaveId, PersistenceException> iterator = store.getWaveIdIterator();
    assertTrue(iterator.hasNext());
View Full Code Here

    ProtocolAppliedWaveletDelta delta =
        ProtocolAppliedWaveletDelta.newBuilder().setApplicationTimestamp(1234567890)
            .setHashedVersionAppliedAt(CoreWaveletOperationSerializer.serialize(targetVersion))
            .setSignedOriginalDelta(signedDelta).setOperationsApplied(2).build();

    return new WaveletDeltaRecord(targetVersion, ByteStringMessage.serializeMessage(delta),
        transformed);
  }
View Full Code Here

  private Pair<DeltaStore, WaveletDeltaRecord> newDeltaStoreWithRecord(WaveletName waveletName)
      throws Exception {
    DeltaStore store = newDeltaStore();
    DeltasAccess wavelet = store.open(waveletName);

    WaveletDeltaRecord record = createRecord();
    wavelet.append(ImmutableList.of(record));
    wavelet.close();

    return new Pair<DeltaStore, WaveletDeltaRecord>(store, record);
  }
View Full Code Here

    return endDeltas.get(version);
  }

  @Override
  public HashedVersion getAppliedAtVersion(long version) throws InvalidProtocolBufferException {
    WaveletDeltaRecord delta = getDelta(version);
    return (delta != null) ? delta.getAppliedAtVersion() : null;
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.waveserver.WaveletDeltaRecord

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.