Пример #1
0
  @Override
  @Test
  public void testGetVersions() throws Exception {
    List<ByteArray> keys = getKeys(2);
    ByteArray key = keys.get(0);
    byte[] value = getValue();
    VectorClock vc = getClock(0, 0);
    Store<ByteArray, byte[], byte[]> store = getStore();
    store.put(key, Versioned.value(value, vc), null);
    List<Versioned<byte[]>> versioneds = store.get(key, null);
    List<Version> versions = store.getVersions(key);
    assertEquals(1, versioneds.size());
    assertTrue(versions.size() > 0);
    for (int i = 0; i < versions.size(); i++)
      assertEquals(versioneds.get(0).getVersion(), versions.get(i));

    assertEquals(0, store.getVersions(keys.get(1)).size());
  }
Пример #2
0
 private Message handleGetVersion(GetRequest request, Store<ByteArray, byte[]> store) {
   VProto.GetVersionResponse.Builder response = VProto.GetVersionResponse.newBuilder();
   try {
     List<Version> versions = store.getVersions(ProtoUtils.decodeBytes(request.getKey()));
     for (Version version : versions) response.addVersions(ProtoUtils.encodeClock(version));
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }