Package com.google.walkaround.util.server.appengine.CheckedDatastore

Examples of com.google.walkaround.util.server.appengine.CheckedDatastore.CheckedTransaction


      throws PermanentFailure, RetryableFailure, WaveletLockedException {
    log.info("Indexing conversation for participant with udwId " + udwId);
    StateAndVersion raw;
    SlobId convId;
    StableUserId udwOwner;
    CheckedTransaction tx = datastore.beginTransaction();
    try {
      MutationLog l = udwStore.create(tx, udwId);
      ObsoleteWaveletMetadataGsonImpl metadata;
      String metadataString = l.getMetadata();
      try {
        metadata = GsonProto.fromGson(new ObsoleteWaveletMetadataGsonImpl(), metadataString);
      } catch (MessageException e) {
        throw new RuntimeException("Failed to parse obsolete metadata: " + metadataString);
      }
      Assert.check(metadata.hasUdwMetadata(), "Metadata not udw: %s, %s", udwId, metadataString);
      convId = new SlobId(metadata.getUdwMetadata().getAssociatedConvId());
      udwOwner = new StableUserId(metadata.getUdwMetadata().getOwner());
      raw = l.reconstruct(null);
    } finally {
      tx.rollback();
    }
    WaveletName waveletName = IdHack.udwWaveletNameFromConvObjectIdAndUdwObjectId(convId, udwId);
    // TODO(ohler): avoid serialization/deserialization here
    WaveletDataImpl waveletData = deserializeWavelet(waveletName, raw.getState().snapshot());
    Assert.check(raw.getVersion() == waveletData.getVersion(),
View Full Code Here


  }

  private WaveletDataImpl loadConv(SlobId id)
      throws PermanentFailure, RetryableFailure, WaveletLockedException {
    StateAndVersion raw;
    CheckedTransaction tx = datastore.beginTransaction();
    try {
      ConvMetadata metadata = convMetadataStore.get(tx, id);
      if (metadata.hasImportMetadata()
          && !metadata.getImportMetadata().getImportFinished()) {
        throw new WaveletLockedException("Conv " + id + " locked: " + metadata);
      }
      MutationLog l = convStore.create(tx, id);
      raw = l.reconstruct(null);
    } finally {
      tx.rollback();
    }
    WaveletName waveletName = IdHack.convWaveletNameFromConvObjectId(id);
    // TODO(ohler): avoid serialization/deserialization here
    WaveletDataImpl waveletData = deserializeWavelet(waveletName,
        raw.getState().snapshot());
View Full Code Here

  }

  private WaveletDataImpl loadUdw(SlobId convId, SlobId udwId)
      throws PermanentFailure, RetryableFailure {
    StateAndVersion raw;
    CheckedTransaction tx = datastore.beginTransaction();
    try {
      MutationLog l = udwStore.create(tx, udwId);
      raw = l.reconstruct(null);
    } finally {
      tx.rollback();
    }
    WaveletName waveletName = IdHack.udwWaveletNameFromConvObjectIdAndUdwObjectId(convId, udwId);
    // TODO(ohler): avoid serialization/deserialization here
    WaveletDataImpl waveletData = deserializeWavelet(waveletName,
        raw.getState().snapshot());
View Full Code Here

    try {
      pair = new RetryHelper().run(
          new RetryHelper.Body<Pair<List<String>, List<ImportWaveletDisplayRecord>>>() {
            @Override public Pair<List<String>, List<ImportWaveletDisplayRecord>> run()
                throws RetryableFailure, PermanentFailure {
              CheckedTransaction tx = datastore.get().beginTransaction();
              try {
                List<ImportTask> tasksInProgress = perUserTable.get().getAllTasks(tx, userId);
                return Pair.of(describeTasks(tasksInProgress),
                    getWaves(tx, taskDispatcher.waveletImportsInProgress(tasksInProgress)));
              } finally {
                tx.rollback();
              }
            }
          });
    } catch (PermanentFailure e) {
      throw new IOException("PermanentFailure retrieving import records", e);
View Full Code Here

    } else if ("canceltasks".equals(action)) {
      log.info("Cancelling all tasks for " + userId);
      try {
        new RetryHelper().run(new RetryHelper.VoidBody() {
          @Override public void run() throws RetryableFailure, PermanentFailure {
            CheckedTransaction tx = datastore.get().beginTransaction();
            try {
              if (perUserTable.get().deleteAllTasks(tx, userId)) {
                tx.commit();
              }
            } finally {
              tx.close();
            }
          }
        });
      } catch (PermanentFailure e) {
        throw new IOException("Failed to delete tasks", e);
      }
    } else if ("forgetwaves".equals(action)) {
      log.info("Forgetting all waves for " + userId);
      try {
        new RetryHelper().run(new RetryHelper.VoidBody() {
          @Override public void run() throws RetryableFailure, PermanentFailure {
            CheckedTransaction tx = datastore.get().beginTransaction();
            try {
              if (perUserTable.get().deleteAllWaves(tx, userId)) {
                tx.commit();
              }
            } finally {
              tx.close();
            }
          }
        });
      } catch (PermanentFailure e) {
        throw new IOException("Failed to delete tasks", e);
View Full Code Here

  private void enqueueTasks(final List<ImportTaskPayload> payloads) throws IOException {
    try {
      new RetryHelper().run(new RetryHelper.VoidBody() {
        @Override public void run() throws RetryableFailure, PermanentFailure {
          CheckedTransaction tx = datastore.get().beginTransaction();
          try {
            for (ImportTaskPayload payload : payloads) {
              perUserTable.get().addTask(tx, userId, payload);
            }
            tx.commit();
          } finally {
            tx.close();
          }
        }
      });
    } catch (PermanentFailure e) {
      throw new IOException("Failed to enqueue import task", e);
View Full Code Here

    DatastoreUtil.setOrRemoveUnindexedProperty(entity, REFRESH_TOKEN_PROPERTY, refreshToken);
    DatastoreUtil.setOrRemoveUnindexedProperty(entity, ACCESS_TOKEN_PROPERTY, accessToken);

    new RetryHelper().run(new RetryHelper.VoidBody() {
        @Override public void run() throws RetryableFailure, PermanentFailure {
          CheckedTransaction tx = datastore.beginTransaction();
          log.info("About to put " + entity);
          tx.put(entity);
          memcache.enqueuePutNull(tx, userId);
          tx.commit();
          log.info("Committed " + tx);
        }
      });
    memcache.delete(userId);
  }
View Full Code Here

    Preconditions.checkNotNull(userId, "Null userId");
    log.info("Deleting record for user " + userId);
    final Key key = makeKey(userId);
    new RetryHelper().run(new RetryHelper.VoidBody() {
        @Override public void run() throws RetryableFailure, PermanentFailure {
          CheckedTransaction tx = datastore.beginTransaction();
          log.info("About to delete " + key);
          tx.delete(key);
          memcache.enqueuePutNull(tx, userId);
          tx.commit();
          log.info("Committed " + tx);
        }
      });
    memcache.delete(userId);
  }
View Full Code Here

    }
    log.info("Fetching user credentials for user " + userId);
    Entity e = new RetryHelper().run(
        new RetryHelper.Body<Entity>() {
          @Override public Entity run() throws RetryableFailure, PermanentFailure {
            CheckedTransaction tx = datastore.beginTransaction();
            try {
              Entity entity = tx.get(makeKey(userId));
              log.info("Got " + (entity == null ? null : entity.getKey()));
              return entity;
            } finally {
              tx.rollback();
            }
          }
        });
    Record read = convertEntity(e);
    memcache.putIfUntouched(userId, cached, read);
View Full Code Here

    helper.tearDown();
    super.tearDown();
  }

  public void testSizeEstimates() throws Exception {
    CheckedTransaction tx = new CheckedTransaction() {
        @Override
        public Entity get(Key key) throws PermanentFailure, RetryableFailure {
          return null;
        }
View Full Code Here

TOP

Related Classes of com.google.walkaround.util.server.appengine.CheckedDatastore.CheckedTransaction

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.