Package org.waveprotocol.box.server.waveserver.DeltaStore

Examples of org.waveprotocol.box.server.waveserver.DeltaStore.DeltasAccess



    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


  /** Create and return a new delta store instance of the type being tested. */
  protected abstract DeltaStore newDeltaStore() throws Exception;

  public void testOpenNonexistantWavelet() throws Exception {
    DeltaStore store = newDeltaStore();
    DeltasAccess wavelet = store.open(WAVE1_WAVELET1);

    // Sanity check a bunch of values in the wavelet.
    assertTrue(wavelet.isEmpty());
    assertEquals(WAVE1_WAVELET1, wavelet.getWaveletName());
    assertNull(wavelet.getEndVersion());
    assertNull(wavelet.getDelta(0));
    assertNull(wavelet.getDeltaByEndVersion(0));
    assertNull(wavelet.getAppliedAtVersion(0));
    assertNull(wavelet.getResultingVersion(0));
    assertNull(wavelet.getAppliedDelta(0));
    assertNull(wavelet.getTransformedDelta(0));

    wavelet.close();
  }
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

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

    store.delete(WAVE1_WAVELET1);
    DeltasAccess wavelet = store.open(WAVE1_WAVELET1);
    assertTrue(wavelet.isEmpty());
    wavelet.close();
  }
View Full Code Here

    assertEquals(ImmutableSet.of(WAVE1_WAVELET1.waveletId), store.lookup(WAVE1_WAVELET1.waveId));
  }

  public void testLookupDoesNotReturnEmptyWavelets() throws Exception {
    DeltaStore store = newDeltaStore();
    DeltasAccess wavelet = store.open(WAVE1_WAVELET1);
    wavelet.close();

    assertTrue(store.lookup(WAVE1_WAVELET1.waveId).isEmpty());
  }
View Full Code Here

    assertEquals(ImmutableSet.of(WAVE1_WAVELET1.waveId), waveIds);
  }

  public void testWaveIdIteratorDoesNotReturnEmptyWavelets() throws Exception {
    DeltaStore store = newDeltaStore();
    DeltasAccess wavelet = store.open(WAVE1_WAVELET1);
    wavelet.close();

    assertFalse(store.getWaveIdIterator().hasNext());
  }
View Full Code Here

  public void testWaveIdIteratorLimits() throws Exception {
    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());

    WaveId waveId1 = iterator.next();
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

          waveletsCount++;

          LOG.info("Migrating wavelet " + waveletsCount + "/" + waveletsTotal + " : "
              + waveletId.toString());

          DeltasAccess sourceDeltas = sourceStore.open(WaveletName.of(waveId, waveletId));
          DeltasAccess targetDeltas = targetStore.open(WaveletName.of(waveId, waveletId));

          // Get all deltas from last version to initial version (0): reverse
          // order
          int deltasCount = 0;

          ArrayList<WaveletDeltaRecord> deltas = new ArrayList<WaveletDeltaRecord>();
          HashedVersion deltaResultingVersion = sourceDeltas.getEndVersion();

          // Deltas
          while (deltaResultingVersion != null && deltaResultingVersion.getVersion() != 0) {
            deltasCount++;
            WaveletDeltaRecord deltaRecord =
                sourceDeltas.getDeltaByEndVersion(deltaResultingVersion.getVersion());
            deltas.add(deltaRecord);
            // get the previous delta, this is the appliedAt
            deltaResultingVersion = deltaRecord.getAppliedAtVersion();
          }
          LOG.info("Appending " + deltasCount + "deltas to target");
          targetDeltas.append(deltas);
        }
      } // While Waves

      long endTime = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.waveserver.DeltaStore.DeltasAccess

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.